diff options
author | Werner Koch <wk@gnupg.org> | 2014-04-15 16:40:48 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-04-17 21:44:09 +0200 |
commit | e184a11f94e2d41cd9266484542631bec23628b5 (patch) | |
tree | 3be1b428fd499e94afa9fda630fb06fdb7c941e1 | |
parent | common: Add z-base-32 encoder. (diff) | |
download | gnupg2-e184a11f94e2d41cd9266484542631bec23628b5.tar.xz gnupg2-e184a11f94e2d41cd9266484542631bec23628b5.zip |
gpg: New %U expando for the photo viewer.
* g10/photoid.c (show_photos): Set namehash.
* g10/misc.c (pct_expando): Add "%U" expando.
--
This makes is possible to extract all photos ids from a key to
different files.
-rw-r--r-- | doc/gpg.texi | 2 | ||||
-rw-r--r-- | g10/main.h | 1 | ||||
-rw-r--r-- | g10/misc.c | 17 | ||||
-rw-r--r-- | g10/photoid.c | 2 |
4 files changed, 21 insertions, 1 deletions
diff --git a/doc/gpg.texi b/doc/gpg.texi index 607a61122..f72775e39 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -1195,7 +1195,7 @@ for the key fingerprint, "%t" for the extension of the image type (e.g. "jpg"), "%T" for the MIME type of the image (e.g. "image/jpeg"), "%v" for the single-character calculated validity of the image being viewed (e.g. "f"), "%V" for the calculated validity as a string (e.g. -"full"), +"full"), "%U" for a base32 encoded hash of the user ID, and "%%" for an actual percent sign. If neither %i or %I are present, then the photo will be supplied to the viewer on standard input. diff --git a/g10/main.h b/g10/main.h index 04abb4fa2..d8b9a4db5 100644 --- a/g10/main.h +++ b/g10/main.h @@ -119,6 +119,7 @@ struct expando_args byte imagetype; int validity_info; const char *validity_string; + const byte *namehash; }; char *pct_expando(const char *string,struct expando_args *args); diff --git a/g10/misc.c b/g10/misc.c index ba83b1910..77928aa6c 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -822,6 +822,23 @@ pct_expando(const char *string,struct expando_args *args) } break; + case 'U': /* z-base-32 encoded user id hash. */ + if (args->namehash) + { + char *tmp = zb32_encode (args->namehash, 8*20); + if (tmp) + { + if (idx + strlen (tmp) < maxlen) + { + strcpy (ret+idx, tmp); + idx += strlen (tmp); + } + xfree (tmp); + done = 1; + } + } + break; + case 'c': /* signature count from card, if any. */ if(idx+10<maxlen) { diff --git a/g10/photoid.c b/g10/photoid.c index 829d36c9e..f6e625a00 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -305,6 +305,8 @@ show_photos(const struct user_attribute *attrs, int count, args.pk = pk; args.validity_info = get_validity_info (pk, uid); args.validity_string = get_validity_string (pk, uid); + namehash_from_uid (uid); + args.namehash = uid->namehash; if (pk) keyid_from_pk (pk, kid); |