From 631a7e5c2edbcf458479874b9ae676ca8a26ac5c 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. --- trunk/gpgme/ChangeLog | 7 ++++++ trunk/gpgme/engine-gpgsm.c | 44 +++++++++++++++++++++++++++++++++++--- trunk/gpgme/export.c | 8 ++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index cd73a3e..7ac84e6 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/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/trunk/gpgme/engine-gpgsm.c b/trunk/gpgme/engine-gpgsm.c index 6115b25..166d97b 100644 --- a/trunk/gpgme/engine-gpgsm.c +++ b/trunk/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/trunk/gpgme/export.c b/trunk/gpgme/export.c index c222861..968de2e 100644 --- a/trunk/gpgme/export.c +++ b/trunk/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; } -- 2.26.2