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_No_Recipients, GPGME_Invalid_Recipient,
GPGME_No_Passphrase): New macros.
-/* export.c - Encrypt functions.
+/* export.c - Export a key.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
#if HAVE_CONFIG_H
#include <config.h>
#endif
-#include <stdlib.h>
-#include "util.h"
+#include "gpgme.h"
#include "context.h"
#include "ops.h"
-#include "debug.h"
+\f
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;
}
static GpgmeError
-_gpgme_op_export_start (GpgmeCtx ctx, int synchronous,
- GpgmeRecipients recp, GpgmeData keydata)
+export_start (GpgmeCtx ctx, int synchronous,
+ GpgmeRecipients recp, GpgmeData keydata)
{
- GpgmeError err = 0;
+ GpgmeError err;
+
+ if (!keydata || !recp)
+ return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, synchronous);
if (err)
- goto leave;
-
- if (!keydata)
- {
- err = GPGME_Invalid_Value;
- goto leave;
- }
+ return err;
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
- err = _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor);
-
- leave:
- if (err)
- {
- _gpgme_engine_release (ctx->engine);
- ctx->engine = NULL;
- }
- return err;
+ return _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor);
}
+
+/* Export the keys listed in RECP into KEYDATA. */
GpgmeError
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:
- * @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
- **/
+
+/* Export the keys listed in RECP into KEYDATA. */
GpgmeError
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)
err = _gpgme_wait_one (ctx);
- /* XXX We don't get enough status information. */
return err;
}