diff options
author | David Shaw <[email protected]> | 2003-02-12 18:43:44 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2003-02-12 18:43:44 +0000 |
commit | d691cf8d107a3940fed78a799ccb50db114d0651 (patch) | |
tree | 0670b14ba2bf27a839ed28a90db3ed21feb24b1f /g10/getkey.c | |
parent | * exec.c (set_exec_path): Add debugging line. (diff) | |
download | gnupg-d691cf8d107a3940fed78a799ccb50db114d0651.tar.gz gnupg-d691cf8d107a3940fed78a799ccb50db114d0651.zip |
* keydb.h, getkey.c (classify_user_id, classify_user_id2): Make 'exact' a
per-desc item. Merge into one function since 'force_exact' is no longer
needed. (key_byname): Use new classify_user_id function, and new exact
flag in KEYDB_SEARCH_DESC.
* keyring.h, keyring.c (keyring_search): Return an optional index to show
which KEYDB_SEARCH_DESC was the matching one.
* keydb.h, keydb.c (keydb_search): Rename to keydb_search2, and pass the
optional index to keyring_search. Add a macro version of keydb_search
that calls this new function.
* export.c (do_export_stream): If the keyid! syntax is used, export only
that specified key. If the key in question is a subkey, export the
primary plus that subkey only.
Diffstat (limited to 'g10/getkey.c')
-rw-r--r-- | g10/getkey.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index e729b97c2..9040d386c 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -552,20 +552,22 @@ seckey_available( u32 *keyid ) * is not case sensitive. */ -static int -classify_user_id2( const char *name, - KEYDB_SEARCH_DESC *desc, - int *force_exact ) +int +classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc ) { const char *s; int hexprefix = 0; int hexlength; int mode = 0; - + KEYDB_SEARCH_DESC dummy_desc; + + if (!desc) + desc = &dummy_desc; + /* clear the structure so that the mode field is set to zero unless * we set it to the correct value right at the end of this function */ memset (desc, 0, sizeof *desc); - *force_exact = 0; + /* skip leading spaces. Fixme: what is with trailing spaces? */ for(s = name; *s && isspace(*s); s++ ) ; @@ -643,7 +645,7 @@ classify_user_id2( const char *name, hexlength = strspn(s, "0123456789abcdefABCDEF"); if (hexlength >= 8 && s[hexlength] =='!') { - *force_exact = 1; + desc->exact = 1; hexlength++; /* just for the following check */ } @@ -655,7 +657,7 @@ classify_user_id2( const char *name, hexlength = 0; /* a hex number, but really were not. */ } - if (*force_exact) + if (desc->exact) hexlength--; if (hexlength == 8 @@ -711,7 +713,7 @@ classify_user_id2( const char *name, if (hexprefix) /* This was a hex number with a prefix */ return 0; /* and a wrong length */ - *force_exact = 0; + desc->exact = 0; desc->u.name = s; mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */ } @@ -721,16 +723,6 @@ classify_user_id2( const char *name, return mode; } -int -classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) -{ - int dummy; - KEYDB_SEARCH_DESC dummy_desc; - - if (!desc) - desc = &dummy_desc; - return classify_user_id2 (name, desc, &dummy); -} /**************** * Try to get the pubkey by the userid. This function looks for the @@ -752,7 +744,6 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist, STRLIST r; GETKEY_CTX ctx; KBNODE help_kb = NULL; - int exact; if( retctx ) {/* reset the returned context in case of error */ assert (!ret_kdbhd); /* not allowed because the handle is @@ -769,9 +760,9 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist, ctx->nitems = n; for(n=0, r=namelist; r; r = r->next, n++ ) { - classify_user_id2 (r->d, &ctx->items[n], &exact); + classify_user_id (r->d, &ctx->items[n]); - if (exact) + if (ctx->items[n].exact) ctx->exact = 1; if (!ctx->items[n].mode) { m_free (ctx); |