diff options
author | Werner Koch <[email protected]> | 2010-01-08 19:15:06 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-01-08 19:15:06 +0000 |
commit | 1b2fb1b737d1a0928cc9f7a210c9dbc5f374adff (patch) | |
tree | 07993ac73bb60ffaf4c6e4faef9eb35b7c768899 /src/passwd.c | |
parent | 2010-01-07 Marcus Brinkmann <[email protected]> (diff) | |
download | gpgme-1b2fb1b737d1a0928cc9f7a210c9dbc5f374adff.tar.gz gpgme-1b2fb1b737d1a0928cc9f7a210c9dbc5f374adff.zip |
Support gpgme_op_apsswd for GPG.
Diffstat (limited to 'src/passwd.c')
-rw-r--r-- | src/passwd.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/passwd.c b/src/passwd.c index d189814d..67668770 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -20,6 +20,7 @@ #if HAVE_CONFIG_H #include <config.h> #endif +#include <stdlib.h> #include "gpgme.h" #include "debug.h" @@ -27,17 +28,60 @@ #include "ops.h" +/* Parse an error status line and return the error code. */ static gpgme_error_t -passwd_status_handler (void *priv, gpgme_status_code_t code, char *args) +parse_error (char *args) { - (void)priv; - (void)code; - (void)args; + gpgme_error_t err; + char *where = strchr (args, ' '); + char *which; + + if (where) + { + *where = '\0'; + which = where + 1; + + where = strchr (which, ' '); + if (where) + *where = '\0'; + + where = args; + } + else + return gpg_error (GPG_ERR_INV_ENGINE); + + err = atoi (which); + + if (!strcmp (where, "keyedit.passwd")) + return err; + return 0; } static gpgme_error_t +passwd_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err = 0; + + (void)ctx; + + switch (code) + { + case GPGME_STATUS_ERROR: + err = parse_error (args); + break; + + default: + break; + } + + return err; +} + + +static gpgme_error_t passwd_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key, unsigned int flags) { |