2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* export.c: Do not include <stdlib.h>, "debug.h" and "util.h", but "gpgme.h". (export_status_handler): Change type of first argument to void *. (_gpgme_op_export_start): Rename to ... (export_start): ... this. Rework error handling. (gpgme_op_export_start): Rewritten to use export_start instead _gpgme_op_export_start. (gpgme_op_export): Likewise.
This commit is contained in:
parent
a6c92323b6
commit
359c251b4d
@ -1,5 +1,14 @@
|
|||||||
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
|
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* export.c: Do not include <stdlib.h>, "debug.h" and "util.h", but
|
||||||
|
"gpgme.h".
|
||||||
|
(export_status_handler): Change type of first argument to void *.
|
||||||
|
(_gpgme_op_export_start): Rename to ...
|
||||||
|
(export_start): ... this. Rework error handling.
|
||||||
|
(gpgme_op_export_start): Rewritten to use export_start instead
|
||||||
|
_gpgme_op_export_start.
|
||||||
|
(gpgme_op_export): Likewise.
|
||||||
|
|
||||||
* gpgme.h (GpgmeError): Add GPGME_Busy, GPGME_No_Request.
|
* gpgme.h (GpgmeError): Add GPGME_Busy, GPGME_No_Request.
|
||||||
(GPGME_No_Recipients, GPGME_Invalid_Recipient,
|
(GPGME_No_Recipients, GPGME_Invalid_Recipient,
|
||||||
GPGME_No_Passphrase): New macros.
|
GPGME_No_Passphrase): New macros.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* export.c - Encrypt functions.
|
/* export.c - Export a key.
|
||||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
|
|
||||||
@ -21,76 +21,52 @@
|
|||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "util.h"
|
#include "gpgme.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "ops.h"
|
#include "ops.h"
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
|
|
||||||
static GpgmeError
|
static GpgmeError
|
||||||
export_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
|
export_status_handler (void *priv, GpgmeStatusCode code, char *args)
|
||||||
{
|
{
|
||||||
DEBUG2 ("export_status: code=%d args=`%s'\n", code, args);
|
|
||||||
/* FIXME: Need to do more */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GpgmeError
|
static GpgmeError
|
||||||
_gpgme_op_export_start (GpgmeCtx ctx, int synchronous,
|
export_start (GpgmeCtx ctx, int synchronous,
|
||||||
GpgmeRecipients recp, GpgmeData keydata)
|
GpgmeRecipients recp, GpgmeData keydata)
|
||||||
{
|
{
|
||||||
GpgmeError err = 0;
|
GpgmeError err;
|
||||||
|
|
||||||
|
if (!keydata || !recp)
|
||||||
|
return GPGME_Invalid_Value;
|
||||||
|
|
||||||
err = _gpgme_op_reset (ctx, synchronous);
|
err = _gpgme_op_reset (ctx, synchronous);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
return err;
|
||||||
|
|
||||||
if (!keydata)
|
|
||||||
{
|
|
||||||
err = GPGME_Invalid_Value;
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
|
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
|
||||||
|
|
||||||
err = _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor);
|
return _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor);
|
||||||
|
|
||||||
leave:
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
_gpgme_engine_release (ctx->engine);
|
|
||||||
ctx->engine = NULL;
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Export the keys listed in RECP into KEYDATA. */
|
||||||
GpgmeError
|
GpgmeError
|
||||||
gpgme_op_export_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData keydata)
|
gpgme_op_export_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData keydata)
|
||||||
{
|
{
|
||||||
return _gpgme_op_export_start (ctx, 0, recp, keydata);
|
return export_start (ctx, 0, recp, keydata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gpgme_op_export:
|
/* Export the keys listed in RECP into KEYDATA. */
|
||||||
* @c: the context
|
|
||||||
* @recp: a list of recipients or NULL
|
|
||||||
* @keydata: Returns the keys
|
|
||||||
*
|
|
||||||
* This function can be used to extract public keys from the GnuPG key
|
|
||||||
* database either in armored (by using gpgme_set_armor()) or in plain
|
|
||||||
* binary form. The function expects a list of user IDs in @recp for
|
|
||||||
* whom the public keys are to be exported.
|
|
||||||
*
|
|
||||||
* Return value: 0 for success or an error code
|
|
||||||
**/
|
|
||||||
GpgmeError
|
GpgmeError
|
||||||
gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recipients, GpgmeData keydata)
|
gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recipients, GpgmeData keydata)
|
||||||
{
|
{
|
||||||
GpgmeError err = _gpgme_op_export_start (ctx, 1, recipients, keydata);
|
GpgmeError err = 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 enough status information. */
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user