diff options
author | Werner Koch <[email protected]> | 2013-02-22 09:56:13 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-02-22 09:56:13 +0000 |
commit | 585d5c62eece23911a768d97d11f159be138b13d (patch) | |
tree | 32ac4792efcdd419d1f725b13671a540770943d6 /agent | |
parent | Remove some unused variables. (diff) | |
download | gnupg-585d5c62eece23911a768d97d11f159be138b13d.tar.gz gnupg-585d5c62eece23911a768d97d11f159be138b13d.zip |
Use has_leading_keyword in the assuan callbacks.
* agent/call-pinentry.c (inq_quality): Use has_leading_keyword.
* agent/call-scd.c (inq_needpin, inq_writekey_parms): Ditto.
* g10/call-agent.c (inq_writecert_parms, keyinfo_status_cb): Ditto.
(inq_genkey_parms, inq_ciphertext_cb, inq_import_key_parms): Ditto.
* g10/call-dirmngr.c (ks_put_inq_cb): Ditto.
* sm/call-agent.c (default_inq_cb, inq_ciphertext_cb): Ditto.
(inq_genkey_parms, istrusted_status_cb, learn_status_cb): Ditto.
(keyinfo_status_cb, inq_import_key_parms): Ditto.
* sm/call-dirmngr.c (inq_certificate, isvalid_status_cb): Ditto.
(lookup_status_cb, run_command_inq_cb, run_command_status_cb): Ditto.
Diffstat (limited to '')
-rw-r--r-- | agent/call-pinentry.c | 9 | ||||
-rw-r--r-- | agent/call-scd.c | 22 |
2 files changed, 10 insertions, 21 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index c6b6b5282..78e1c1106 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -596,18 +596,15 @@ static gpg_error_t inq_quality (void *opaque, const char *line) { assuan_context_t ctx = opaque; + const char *s; char *pin; int rc; int percent; char numbuf[20]; - if (!strncmp (line, "QUALITY", 7) && (line[7] == ' ' || !line[7])) + if ((s = has_leading_keyword (line, "QUALITY"))) { - line += 7; - while (*line == ' ') - line++; - - pin = unescape_passphrase_string (line); + pin = unescape_passphrase_string (s); if (!pin) rc = gpg_error_from_syserror (); else diff --git a/agent/call-scd.c b/agent/call-scd.c index cbe4d1c34..f4ea20bd3 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -701,17 +701,15 @@ static gpg_error_t inq_needpin (void *opaque, const char *line) { struct inq_needpin_s *parm = opaque; + const char *s; char *pin; size_t pinlen; int rc; parm->any_inq_seen = 1; - if (!strncmp (line, "NEEDPIN", 7) && (line[7] == ' ' || !line[7])) + if ((s = has_leading_keyword (line, "NEEDPIN"))) { - line += 7; - while (*line == ' ') - line++; - + line = s; pinlen = 90; pin = gcry_malloc_secure (pinlen); if (!pin) @@ -722,17 +720,11 @@ inq_needpin (void *opaque, const char *line) rc = assuan_send_data (parm->ctx, pin, pinlen); xfree (pin); } - else if (!strncmp (line, "POPUPPINPADPROMPT", 17) - && (line[17] == ' ' || !line[17])) + else if ((s = has_leading_keyword (line, "POPUPPINPADPROMPT"))) { - line += 17; - while (*line == ' ') - line++; - - rc = parm->getpin_cb (parm->getpin_cb_arg, line, NULL, 1); + rc = parm->getpin_cb (parm->getpin_cb_arg, s, NULL, 1); } - else if (!strncmp (line, "DISMISSPINPADPROMPT", 19) - && (line[19] == ' ' || !line[19])) + else if ((s = has_leading_keyword (line, "DISMISSPINPADPROMPT"))) { rc = parm->getpin_cb (parm->getpin_cb_arg, "", NULL, 0); } @@ -1069,7 +1061,7 @@ inq_writekey_parms (void *opaque, const char *line) { struct writekey_parm_s *parm = opaque; - if (!strncmp (line, "KEYDATA", 7) && (line[7]==' '||!line[7])) + if (has_leading_keyword (line, "KEYDATA")) return assuan_send_data (parm->ctx, parm->keydata, parm->keydatalen); else return inq_needpin (opaque, line); |