* key.h (gpgme_key_s): Add OTRUST.

* keylist.c (set_ownertrust): New.
(keylist_colon_handler): Get the ownertrust value
* key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr):
Return that value.
This commit is contained in:
Werner Koch 2002-05-10 10:42:45 +00:00
parent 0ab2c2918a
commit fe2e3af237
4 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2002-05-10 Werner Koch <wk@gnupg.org>
* key.h (gpgme_key_s): Add OTRUST.
* keylist.c (set_ownertrust): New.
(keylist_colon_handler): Get the ownertrust value
* key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr):
Return that value.
2002-05-08 Marcus Brinkmann <marcus@g10code.de> 2002-05-08 Marcus Brinkmann <marcus@g10code.de>
* w32-util.c: New static variable GET_PATH_LOCK. * w32-util.c: New static variable GET_PATH_LOCK.

View File

@ -888,7 +888,14 @@ gpgme_key_get_string_attr (GpgmeKey key, GpgmeAttr what,
/* Use another get function. */ /* Use another get function. */
break; break;
case GPGME_ATTR_OTRUST: case GPGME_ATTR_OTRUST:
val = "[fixme]"; switch (key->otrust)
{
case GPGME_VALIDITY_NEVER: val = "n"; break;
case GPGME_VALIDITY_MARGINAL: val = "m"; break;
case GPGME_VALIDITY_FULL: val = "f"; break;
case GPGME_VALIDITY_ULTIMATE: val = "u"; break;
default: val = "?"; break;
}
break; break;
case GPGME_ATTR_USERID: case GPGME_ATTR_USERID:
for (u = key->uids; u && idx; u = u->next, idx--) for (u = key->uids; u && idx; u = u->next, idx--)
@ -1041,6 +1048,9 @@ gpgme_key_get_ulong_attr (GpgmeKey key, GpgmeAttr what,
if (u) if (u)
val = u->validity; val = u->validity;
break; break;
case GPGME_ATTR_OTRUST:
val = key->otrust;
break;
case GPGME_ATTR_IS_SECRET: case GPGME_ATTR_IS_SECRET:
val = !!key->secret; val = !!key->secret;
break; break;

View File

@ -62,6 +62,7 @@ struct gpgme_key_s {
char *issuer_serial; /* malloced string used only with X.509 */ char *issuer_serial; /* malloced string used only with X.509 */
char *issuer_name; /* ditto */ char *issuer_name; /* ditto */
char *chain_id; /* ditto */ char *chain_id; /* ditto */
GpgmeValidity otrust; /* only used with OpenPGP */
struct subkey_s keys; struct subkey_s keys;
struct user_id_s *uids; struct user_id_s *uids;
}; };

View File

@ -151,6 +151,23 @@ set_subkey_capability ( struct subkey_s *k, const char *s)
} }
} }
static void
set_ownertrust (GpgmeKey key, const char *s)
{
/* Look at letters and stop at the first digit. */
for (; *s && !my_isdigit (*s); s++)
{
switch (*s)
{
case 'n': key->otrust = GPGME_VALIDITY_NEVER; break;
case 'm': key->otrust = GPGME_VALIDITY_MARGINAL; break;
case 'f': key->otrust = GPGME_VALIDITY_FULL; break;
case 'u': key->otrust = GPGME_VALIDITY_ULTIMATE; break;
default : key->otrust = GPGME_VALIDITY_UNKNOWN; break;
}
}
}
/* Note: We are allowed to modify LINE. */ /* Note: We are allowed to modify LINE. */
static void static void
@ -312,6 +329,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
} }
break; break;
case 9: /* ownertrust */ case 9: /* ownertrust */
set_ownertrust (key, p);
break; break;
case 10: /* not used for gpg due to --fixed-list-mode option case 10: /* not used for gpg due to --fixed-list-mode option
but gpgsm stores the issuer name */ but gpgsm stores the issuer name */