diff options
author | Werner Koch <[email protected]> | 2013-02-06 11:49:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-02-06 11:56:19 +0000 |
commit | 8b2b8dfe5c4cd346bbea2c228e75737bbeeca4c4 (patch) | |
tree | f87e3eeb29b7322fbbf8ced57e70e5b066f9d36c /agent/command.c | |
parent | agent: Return a better error code if no passphrase was given. (diff) | |
download | gnupg-8b2b8dfe5c4cd346bbea2c228e75737bbeeca4c4.tar.gz gnupg-8b2b8dfe5c4cd346bbea2c228e75737bbeeca4c4.zip |
agent: Move a typedef to common and provide parse_pinentry_mode.
* common/agent-opt.c: New.
* common/shareddefs.h: New.
* common/Makefile.am: Add new files.
* agent/agent.h: Include shareddefs.h.
(pinentry_mode_t): Factor out to shareddefs.h.
* agent/command.c (option_handler): Use parse_pinentry_mode.
Diffstat (limited to 'agent/command.c')
-rw-r--r-- | agent/command.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/agent/command.c b/agent/command.c index 3ba921be4..715e70a94 100644 --- a/agent/command.c +++ b/agent/command.c @@ -2548,21 +2548,13 @@ option_handler (assuan_context_t ctx, const char *key, const char *value) ctrl->server_local->allow_pinentry_notify = 1; else if (!strcmp (key, "pinentry-mode")) { - if (!strcmp (value, "ask") || !strcmp (value, "default")) - ctrl->pinentry_mode = PINENTRY_MODE_ASK; - else if (!strcmp (value, "cancel")) - ctrl->pinentry_mode = PINENTRY_MODE_CANCEL; - else if (!strcmp (value, "error")) - ctrl->pinentry_mode = PINENTRY_MODE_ERROR; - else if (!strcmp (value, "loopback")) - { - if (opt.allow_loopback_pinentry) - ctrl->pinentry_mode = PINENTRY_MODE_LOOPBACK; - else - err = gpg_error (GPG_ERR_NOT_SUPPORTED); - } - else + int tmp = parse_pinentry_mode (value); + if (tmp == -1) err = gpg_error (GPG_ERR_INV_VALUE); + else if (tmp == PINENTRY_MODE_LOOPBACK && !opt.allow_loopback_pinentry) + err = gpg_error (GPG_ERR_NOT_SUPPORTED); + else + ctrl->pinentry_mode = tmp; } else if (!strcmp (key, "cache-ttl-opt-preset")) { |