From 3ea78f5a20fe80bd819fb643053a190ce42ff58a Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 25 Jun 2002 12:10:27 +0000 Subject: [PATCH] 2002-06-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_export): Only export the keys listed in RECP. * export.c (gpgme_op_export): If no data was returned, return GPGME_No_Recipients. --- gpgme/ChangeLog | 7 +++++++ gpgme/engine-gpgsm.c | 44 +++++++++++++++++++++++++++++++++++++++++--- gpgme/export.c | 8 +++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index cd73a3e2..7ac84e60 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2002-06-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_export): Only export the keys + listed in RECP. + * export.c (gpgme_op_export): If no data was returned, return + GPGME_No_Recipients. + 2002-06-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_export): Implement. diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 6115b25b..166d97bd 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -759,14 +759,52 @@ GpgmeError _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp, GpgmeData keydata, int use_armor) { - GpgmeError err; + GpgmeError err = 0; + char *cmd = NULL; + int cmdi; + int cmdlen = 32; if (!gpgsm) return mk_error (Invalid_Value); - gpgsm->command = xtrystrdup ("EXPORT"); - if (!gpgsm->command) + cmd = malloc (cmdlen); + if (!cmd) return mk_error (Out_Of_Core); + strcpy (cmd, "EXPORT"); + cmdi = 6; + + if (recp) + { + void *ec; + const char *s; + + err = gpgme_recipients_enum_open (recp, &ec); + while (!err && (s = gpgme_recipients_enum_read (recp, &ec))) + { + int slen = strlen (s); + /* New string is old string + ' ' + s + '\0'. */ + if (cmdlen < cmdi + 1 + slen + 1) + { + char *newcmd = xtryrealloc (cmd, cmdlen * 2); + if (!newcmd) + { + xfree (cmd); + return mk_error (Out_Of_Core); + } + cmd = newcmd; + cmdlen *= 2; + } + cmd[cmdi++] = ' '; + strcpy (cmd + cmdi, s); + cmdi += slen; + } + if (!err) + err = gpgme_recipients_enum_close (recp, &ec); + if (err) + return err; + } + + gpgsm->command = cmd; gpgsm->output_cb.data = keydata; err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, diff --git a/gpgme/export.c b/gpgme/export.c index c222861e..968de2e1 100644 --- a/gpgme/export.c +++ b/gpgme/export.c @@ -99,6 +99,12 @@ gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recipients, GpgmeData keydata) { GpgmeError err = _gpgme_op_export_start (ctx, 1, recipients, keydata); if (!err) - err = _gpgme_wait_one (ctx); + { + err = _gpgme_wait_one (ctx); + /* XXX We don't get status information. */ + if (!ctx->error && gpgme_data_get_type (keydata) == GPGME_DATA_TYPE_NONE) + ctx->error = mk_error (No_Recipients); + err = ctx->error; + } return err; }