From 1b2fb1b737d1a0928cc9f7a210c9dbc5f374adff Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 8 Jan 2010 19:15:06 +0000 Subject: Support gpgme_op_apsswd for GPG. --- src/passwd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'src/passwd.c') 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 #endif +#include #include "gpgme.h" #include "debug.h" @@ -27,16 +28,59 @@ #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) -- cgit v1.2.3