+/* --- @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_incref(kd);
+ key_drop(k->k);
+ k->k = kd;
+ kf->f |= KF_MODIFIED;
+ return (0);
+}
+