From 23b812e1ddade925dd78f3d150e2e25456114391 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 28 Feb 2002 09:53:56 +0000 Subject: [PATCH] * key.h (subkey_s): New member expires_at. * keylist.c (keylist_colon_handler): Set it here * key.c (gpgme_key_get_as_xml,gpgme_key_get_ulong_attr): Return it. --- trunk/gpgme/ChangeLog | 6 +++++ trunk/gpgme/key.c | 9 ++++++- trunk/gpgme/key.h | 61 ++++++++++++++++++++++--------------------- trunk/gpgme/keylist.c | 5 ++-- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 58f09c6..9979a33 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2002-02-28 Werner Koch + + * key.h (subkey_s): New member expires_at. + * keylist.c (keylist_colon_handler): Set it here + * key.c (gpgme_key_get_as_xml,gpgme_key_get_ulong_attr): Return it. + 2002-02-27 Marcus Brinkmann * rungpg.h (_gpgme_gpg_op_keylist_ext): New prototype. diff --git a/trunk/gpgme/key.c b/trunk/gpgme/key.c index 3bd3b56..25d6a5d 100644 --- a/trunk/gpgme/key.c +++ b/trunk/gpgme/key.c @@ -683,7 +683,7 @@ gpgme_key_get_as_xml ( GpgmeKey key ) add_tag_and_uint (d, "algo", key->keys.key_algo ); add_tag_and_uint (d, "len", key->keys.key_len ); add_tag_and_time (d, "created", key->keys.timestamp ); - /*add_tag_and_time (d, "expires", key->expires );*/ + add_tag_and_time (d, "expire", key->keys.expires_at ); _gpgme_data_append_string (d, " \n"); /* Now the user IDs. */ @@ -709,6 +709,7 @@ gpgme_key_get_as_xml ( GpgmeKey key ) add_tag_and_uint (d, "algo", k->key_algo ); add_tag_and_uint (d, "len", k->key_len ); add_tag_and_time (d, "created", k->timestamp ); + add_tag_and_time (d, "expire", k->expires_at ); _gpgme_data_append_string (d, " \n"); } _gpgme_data_append_string ( d, "\n" ); @@ -904,6 +905,12 @@ gpgme_key_get_ulong_attr ( GpgmeKey key, GpgmeAttr what, if (k) val = k->timestamp < 0? 0L:(unsigned long)k->timestamp; break; + case GPGME_ATTR_EXPIRE: + for (k=&key->keys; k && idx; k=k->next, idx-- ) + ; + if (k) + val = k->expires_at < 0? 0L:(unsigned long)k->expires_at; + break; case GPGME_ATTR_VALIDITY: for (u=key->uids; u && idx; u=u->next, idx-- ) ; diff --git a/trunk/gpgme/key.h b/trunk/gpgme/key.h index 597dd0c..9503d55 100644 --- a/trunk/gpgme/key.h +++ b/trunk/gpgme/key.h @@ -27,39 +27,40 @@ #include "context.h" struct subkey_s { - struct subkey_s *next; - unsigned int secret:1; - struct { - unsigned int revoked:1 ; - unsigned int expired:1 ; - unsigned int disabled:1 ; - unsigned int invalid:1 ; - unsigned int can_encrypt:1; - unsigned int can_sign:1; - unsigned int can_certify:1; - } flags; - unsigned int key_algo; - unsigned int key_len; - char keyid[16+1]; - char *fingerprint; /* malloced hex digits */ - time_t timestamp; /* -1 for invalid, 0 for not available */ + struct subkey_s *next; + unsigned int secret:1; + struct { + unsigned int revoked:1 ; + unsigned int expired:1 ; + unsigned int disabled:1 ; + unsigned int invalid:1 ; + unsigned int can_encrypt:1; + unsigned int can_sign:1; + unsigned int can_certify:1; + } flags; + unsigned int key_algo; + unsigned int key_len; + char keyid[16+1]; + char *fingerprint; /* malloced hex digits */ + time_t timestamp; /* -1 for invalid, 0 for not available */ + time_t expires_at; /* 0 for does not expires */ }; struct gpgme_key_s { - struct { - unsigned int revoked:1 ; - unsigned int expired:1 ; - unsigned int disabled:1 ; - unsigned int invalid:1 ; - unsigned int can_encrypt:1; - unsigned int can_sign:1; - unsigned int can_certify:1; - } gloflags; - unsigned int ref_count; - unsigned int secret:1; - unsigned int x509:1; - struct subkey_s keys; - struct user_id_s *uids; + struct { + unsigned int revoked:1 ; + unsigned int expired:1 ; + unsigned int disabled:1 ; + unsigned int invalid:1 ; + unsigned int can_encrypt:1; + unsigned int can_sign:1; + unsigned int can_certify:1; + } gloflags; + unsigned int ref_count; + unsigned int secret:1; + unsigned int x509:1; + struct subkey_s keys; + struct user_id_s *uids; }; void _gpgme_key_cache_init (void); diff --git a/trunk/gpgme/keylist.c b/trunk/gpgme/keylist.c index 55d427d..1bcda34 100644 --- a/trunk/gpgme/keylist.c +++ b/trunk/gpgme/keylist.c @@ -300,7 +300,8 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) case 6: /* timestamp (seconds) */ key->keys.timestamp = parse_timestamp (p); break; - case 7: /* valid for n days */ + case 7: /* expiration time (seconds) */ + key->keys.expires_at = parse_timestamp (p); break; case 8: /* X.509 serial number */ /* fixme: store it */ @@ -345,7 +346,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) case 6: /* timestamp (seconds) */ sk->timestamp = parse_timestamp (p); break; - case 7: /* valid for n days */ + case 7: /* expiration time (seconds) */ break; case 8: /* reserved (LID) */ break; -- 2.26.2