2002-06-25 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2002-06-25 12:10:27 +00:00
parent ea042a1fa9
commit 3ea78f5a20
3 changed files with 55 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2002-06-25 Marcus Brinkmann <marcus@g10code.de>
* 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 <marcus@g10code.de> 2002-06-25 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_op_export): Implement. * engine-gpgsm.c (_gpgme_gpgsm_op_export): Implement.

View File

@ -759,14 +759,52 @@ GpgmeError
_gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp, _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp,
GpgmeData keydata, int use_armor) GpgmeData keydata, int use_armor)
{ {
GpgmeError err; GpgmeError err = 0;
char *cmd = NULL;
int cmdi;
int cmdlen = 32;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return mk_error (Invalid_Value);
gpgsm->command = xtrystrdup ("EXPORT"); cmd = malloc (cmdlen);
if (!gpgsm->command) if (!cmd)
return mk_error (Out_Of_Core); 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; gpgsm->output_cb.data = keydata;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,

View File

@ -99,6 +99,12 @@ gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recipients, GpgmeData keydata)
{ {
GpgmeError err = _gpgme_op_export_start (ctx, 1, recipients, keydata); GpgmeError err = _gpgme_op_export_start (ctx, 1, recipients, keydata);
if (!err) 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; return err;
} }