X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/e4a509b8174c8b2cfc0a084b78c9c7b7d08b624b..ef13e9a46baaa347014ac236f36a2536f055b108:/key-attr.c diff --git a/key-attr.c b/key-attr.c index 27f4490..2d33b9c 100644 --- a/key-attr.c +++ b/key-attr.c @@ -179,6 +179,28 @@ int key_putattr(key_file *f, key *k, const char *n, const char *v) 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