From 5844be8acb0853eb5160a9111d96c3010724cfe7 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 25 Apr 2003 13:18:13 +0000 Subject: [PATCH] 2003-04-25 Marcus Brinkmann * export.c: Do not include , "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. --- trunk/gpgme/ChangeLog | 9 +++++++ trunk/gpgme/export.c | 60 +++++++++++++------------------------------ 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index d03971a..ba6e296 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,5 +1,14 @@ 2003-04-25 Marcus Brinkmann + * export.c: Do not include , "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. diff --git a/trunk/gpgme/export.c b/trunk/gpgme/export.c index 3fda602..3657ddd 100644 --- a/trunk/gpgme/export.c +++ b/trunk/gpgme/export.c @@ -1,4 +1,4 @@ -/* export.c - Encrypt functions. +/* export.c - Export a key. Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003 g10 Code GmbH @@ -21,76 +21,52 @@ #if HAVE_CONFIG_H #include #endif -#include -#include "util.h" +#include "gpgme.h" #include "context.h" #include "ops.h" -#include "debug.h" + 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; } -- 2.26.2