Major and incompatible overhaul of key_data representation. Fix leaks.
[u/mdw/catacomb] / key.h
diff --git a/key.h b/key.h
index ff3f81d..1986e8c 100644 (file)
--- a/key.h
+++ b/key.h
@@ -97,7 +97,7 @@ typedef struct key {
 
   /* --- The key data itself --- */
 
 
   /* --- The key data itself --- */
 
-  key_data k;                          /* The actual key data */
+  key_data *k;                         /* The actual key data */
 
   /* --- Other attributes and commentary --- */
 
 
   /* --- Other attributes and commentary --- */
 
@@ -302,10 +302,9 @@ extern int key_lockfile(key_file */*f*/, const char */*file*/,
  *             @uint32 id@ = keyid to set
  *             @const char *type@ = the type of this key
  *             @time_t exp@ = when the key expires
  *             @uint32 id@ = keyid to set
  *             @const char *type@ = the type of this key
  *             @time_t exp@ = when the key expires
- *             @int *err@ = where to store the error condition
+ *             @key *kk@ = where to put the key pointer
  *
  *
- * Returns:    Key block containing new data, or null if it couldn't be
- *             done.
+ * Returns:    Error code (one of the @KERR@ constants).
  *
  * Use:                Attaches a new key to a key file.  You must have a writable
  *             key file for this to work.
  *
  * Use:                Attaches a new key to a key file.  You must have a writable
  *             key file for this to work.
@@ -324,8 +323,8 @@ extern int key_lockfile(key_file */*f*/, const char */*file*/,
  *             You have to set the actual key yourself.
  */
 
  *             You have to set the actual key yourself.
  */
 
-extern key *key_new(key_file */*f*/, uint32 /*id*/, const char */*type*/,
-                   time_t /*exp*/, int */*err*/);
+extern int key_new(key_file */*f*/, uint32 /*id*/, const char */*type*/,
+                  time_t /*exp*/, key **/*kk*/);
 
 /* --- @key_delete@ --- *
  *
 
 /* --- @key_delete@ --- *
  *
@@ -451,6 +450,19 @@ extern int key_setcomment(key_file */*f*/, key */*k*/, const char */*c*/);
 
 extern int key_settag(key_file */*f*/, key */*k*/, const char */*tag*/);
 
 
 extern int key_settag(key_file */*f*/, key */*k*/, const char */*tag*/);
 
+/* --- @key_setkeydata@ --- *
+ *
+ * Arguments:  @key_file *kf@ = pointer to key file
+ *             @key *k@ = pointer to key
+ *             @key_data *kd@ = new key data
+ *
+ * Returns:    Zero on success, or a @KERR_@ error code on failure.
+ *
+ * Use:                Sets the key data for a key.
+ */
+
+extern int key_setkeydata(key_file */*kf*/, key */*k*/, key_data */*kd*/);
+
 /* --- @key_fulltag@ --- *
  *
  * Arguments:  @key *k@ = pointer to key
 /* --- @key_fulltag@ --- *
  *
  * Arguments:  @key *k@ = pointer to key
@@ -471,7 +483,7 @@ extern void key_fulltag(key */*k*/, dstr */*d*/);
  *             @const char *tag@ = pointer to tag string
  *             @dstr *d@ = pointer to string for full tag name
  *             @key **k@ = where to store the key pointer
  *             @const char *tag@ = pointer to tag string
  *             @dstr *d@ = pointer to string for full tag name
  *             @key **k@ = where to store the key pointer
- *             @key_data **kd@ = where to store the key data pointer
+ *             @key_data ***kd@ = where to store the key data pointer
  *
  * Returns:    Zero if OK, nonzero if it failed.
  *
  *
  * Returns:    Zero if OK, nonzero if it failed.
  *
@@ -483,7 +495,7 @@ extern void key_fulltag(key */*k*/, dstr */*d*/);
  */
 
 extern int key_qtag(key_file */*f*/, const char */*tag*/,
  */
 
 extern int key_qtag(key_file */*f*/, const char */*tag*/,
-                   dstr */*d*/, key **/*k*/, key_data **/*kd*/);
+                   dstr */*d*/, key **/*k*/, key_data ***/*kd*/);
 
 /* --- @key_getattr@ --- *
  *
 
 /* --- @key_getattr@ --- *
  *