chiark / gitweb /
key.c: Split before storing a subkey.
[catacomb-python] / key.c
diff --git a/key.c b/key.c
index f9acd3c8a07c038846c916f7be3160f6b50244f0..19a57923403ed7f272dc7a0885fb527f4bf080b6 100644 (file)
--- a/key.c
+++ b/key.c
@@ -7,7 +7,7 @@
  * (c) 2005 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the Python interface to Catacomb.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Catacomb/Python is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Catacomb/Python; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -336,7 +336,7 @@ static void keydata_pydealloc(PyObject *me)
 static PyObject *kdmeth_matchp(PyObject *me, PyObject *arg)
 {
   key_filter f;
-  
+
   if (!PyArg_ParseTuple(arg, "O&:matchp", convfilter, &f))
     return (0);
   return (getbool(KEY_MATCH(KEYDATA_KD(me), &f)));
@@ -388,7 +388,7 @@ static PyObject *kdmeth_plock(PyObject *me, PyObject *arg)
   int err;
   PyObject *rc = 0;
   key_data *kd;
-  
+
   if (!PyArg_ParseTuple(arg, "s:plock", &tag))
     goto end;
   if ((err = key_plock(&kd, KEYDATA_KD(me), tag)) != 0)
@@ -404,7 +404,7 @@ static PyObject *kdmeth_lock(PyObject *me, PyObject *arg)
   int n;
   PyObject *rc = 0;
   key_data *kd;
-  
+
   if (!PyArg_ParseTuple(arg, "s#:lock", &p, &n))
     goto end;
   key_lock(&kd, KEYDATA_KD(me), p, n);
@@ -440,7 +440,7 @@ static PyObject *meth__KeyData_decode(PyObject *me, PyObject *arg)
     goto end;
   if ((kd = key_decode(p, n)) == 0)
     KEYERR(KERR_MALFORMED);
-  rc =  keydata_pywrap(kd);
+  rc = keydata_pywrap(kd);
 end:
   return (rc);
 }
@@ -635,7 +635,7 @@ static PyObject *kdemeth_punlock(PyObject *me, PyObject *arg)
   int err;
   PyObject *rc = 0;
   key_data *kd;
-  
+
   if (!PyArg_ParseTuple(arg, "s:punlock", &tag))
     goto end;
   if ((err = key_punlock(&kd, KEYDATA_KD(me), tag)) != 0)
@@ -652,7 +652,7 @@ static PyObject *kdemeth_unlock(PyObject *me, PyObject *arg)
   int err;
   PyObject *rc = 0;
   key_data *kd;
-  
+
   if (!PyArg_ParseTuple(arg, "s#:unlock", &p, &n))
     goto end;
   if ((err = key_unlock(&kd, KEYDATA_KD(me), p, n)) != 0)
@@ -1097,6 +1097,7 @@ static int keydatastruct_pystore(PyObject *me,
 
   if ((tag = PyString_AsString(key)) == 0)
     goto end;
+  key_split(&KEYDATA_KD(me));
   if (value) {
     if (!KEYDATA_PYCHECK(value))
       TYERR("expected KeyData value");
@@ -1395,7 +1396,7 @@ static void key_pydealloc(PyObject *me)
 static PyObject *kmeth_delete(PyObject *me, PyObject *arg)
 {
   int err;
-  
+
   if (!PyArg_ParseTuple(arg, ":delete")) goto end;
   if ((err = key_delete(KEY_KF(me), KEY_K(me))) != 0) KEYERR(err);
   RETURN_ME;
@@ -1406,7 +1407,7 @@ end:
 static PyObject *kmeth_expire(PyObject *me, PyObject *arg)
 {
   int err;
-  
+
   if (!PyArg_ParseTuple(arg, ":expire")) goto end;
   if ((err = key_expire(KEY_KF(me), KEY_K(me))) != 0) KEYERR(err);
   RETURN_ME;
@@ -1418,7 +1419,7 @@ static PyObject *kmeth_used(PyObject *me, PyObject *arg)
 {
   long t;
   int err;
-  
+
   if (!PyArg_ParseTuple(arg, "l:used", &t)) goto end;
   if ((err = key_used(KEY_KF(me), KEY_K(me), t)) != 0) KEYERR(err);
   RETURN_ME;
@@ -1909,7 +1910,7 @@ static PyObject *keyfile_pylookup(PyObject *me, PyObject *key)
   }
 end:
   return (rc);
-}  
+}
 
 static PyObject *kfmeth_newkey(PyObject *me, PyObject *arg, PyObject *kw)
 {