From: Marcus Brinkmann Date: Thu, 25 Jul 2002 18:44:57 +0000 (+0000) Subject: 2002-07-25 Marcus Brinkmann X-Git-Tag: gpgme-0-3-9~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1ffa0534eabcbb70891221967b514be598a499cb;p=gpgme.git 2002-07-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_delete): Implement this. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 1a92046..f6f2d93 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,7 @@ +2002-07-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_delete): Implement this. + 2002-07-25 Marcus Brinkmann * Makefile.am (libgpgme_la_LDADD): Add @LIBOBJS@ for vasprintf and diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 5dd28f9..07692d4 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -669,8 +669,63 @@ _gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain) GpgmeError _gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key, int allow_secret) { - /* FIXME */ - return mk_error (Not_Implemented); + char *fpr = (char *) gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0); + char *linep = fpr; + char *line; + int length = 8; /* "DELKEYS " */ + + if (!fpr) + return mk_error (Invalid_Key); + + while (*linep) + { + length++; + if (*linep == '%' || *linep == ' ' || *linep == '+') + length += 2; + linep++; + } + length++; + + line = xtrymalloc (length); + if (!line) + return mk_error (Out_Of_Core); + + strcpy (line, "DELKEYS "); + linep = &line[8]; + + while (*fpr) + { + switch (*fpr) + { + case '%': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '5'; + break; + case ' ': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '0'; + break; + case '+': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = 'B'; + break; + default: + *(linep++) = *fpr; + break; + } + fpr++; + } + *linep = '\0'; + + gpgsm->command = line; + _gpgme_io_close (gpgsm->output_cb.fd); + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + return 0; }