key_attr *a = sym_next(&i->i);
if (!a)
return (0);
- *n = SYM_NAME(a);
- *v = a->p;
+ if (n) *n = SYM_NAME(a);
+ if (v) *v = a->p;
return (1);
}
return (0);
}
+/* --- @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.
+ */
+
+int key_setkeydata(key_file *kf, key *k, key_data *kd)
+{
+ if (!(kf->f & KF_WRITE))
+ return (KERR_READONLY);
+ key_drop(k->k);
+ key_incref(kd);
+ k->k = kd;
+ kf->f |= KF_MODIFIED;
+ return (0);
+}
+
/* --- @key_setcomment@ --- *
*
* Arguments: @key_file *f@ = pointer to key file block