From 1ffa0534eabcbb70891221967b514be598a499cb Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 25 Jul 2002 18:44:57 +0000 Subject: [PATCH] 2002-07-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_delete): Implement this. --- gpgme/ChangeLog | 4 +++ gpgme/engine-gpgsm.c | 59 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) 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; } -- 2.26.2