2002-11-19 16:41:17 +00:00
|
|
|
|
/* genkey.c - Key generation.
|
2016-09-13 16:57:38 +00:00
|
|
|
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
|
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2016 g10 Code GmbH
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GPGME.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2002-11-19 16:41:17 +00:00
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
2000-12-18 20:54:43 +00:00
|
|
|
|
#include <config.h>
|
2002-11-19 16:41:17 +00:00
|
|
|
|
#endif
|
2000-12-18 20:54:43 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2003-06-05 23:20:29 +00:00
|
|
|
|
#include <errno.h>
|
2000-12-18 20:54:43 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
#include "gpgme.h"
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
#include "debug.h"
|
2000-12-18 20:54:43 +00:00
|
|
|
|
#include "context.h"
|
|
|
|
|
#include "ops.h"
|
2010-11-15 15:30:04 +00:00
|
|
|
|
#include "util.h"
|
2000-12-18 20:54:43 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
|
|
|
|
typedef struct
|
2002-01-31 00:31:44 +00:00
|
|
|
|
{
|
2003-04-24 17:16:28 +00:00
|
|
|
|
struct _gpgme_op_genkey_result result;
|
|
|
|
|
|
2015-08-25 11:22:43 +00:00
|
|
|
|
/* The error code from a FAILURE status line or 0. */
|
|
|
|
|
gpg_error_t failure_code;
|
|
|
|
|
|
2016-09-13 16:57:38 +00:00
|
|
|
|
/* The error code from certain ERROR status lines or 0. */
|
|
|
|
|
gpg_error_t error_code;
|
|
|
|
|
|
2016-09-14 09:40:34 +00:00
|
|
|
|
/* Flag to indicate that a UID is to be added. */
|
|
|
|
|
gpg_error_t uidmode;
|
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
/* The key parameters passed to the crypto engine. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_data_t key_parameter;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
} *op_data_t;
|
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
|
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (status_handler): Do not close status fd at end
of function.
* ops.h (_gpgme_op_data_lookup): Add prototype.
* op-support.c: Include <stdlib.h>.
(_gpgme_op_data_lookup): New function.
* decrypt.c (_gpgme_release_decrypt_result): Function removed.
(struct decrypt_result_s): Rename to ...
(struct decrypt_resul): ... this.
(DecryptResult): New type.
(_gpgme_decrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* sign.c (_gpgme_release_sign_result): Function removed.
(release_sign_result): New function.
(struct sign_result_s): Rename to ...
(struct sign_result): ... this.
(SignResult): New type.
(_gpgme_sign_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* encrypt.c (struct encrypt_result_s): Rename to ...
(struct encrypt_result): ... this.
(_gpgme_release_encrypt_result): Function removed.
(release_encrypt_result): New function.
(_gpgme_encrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* verify.c (struct verify_result_s): Rename to ...
(struct verify_result): ... this. Remove member next.
(VerifyResult): New type.
(_gpgme_release_verify_result): Function removed.
(release_verify_result): New function.
(finish_sig): Change first argument to type VerifyResult. Diddle
the type of the op_data structure.
(add_notation): Change first argument to type VerifyResult.
(_gpgme_verify_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* passphrase.c (struct passphrase_result_s): Rename to ...
(struct passphrase_result): ... this. Remove member next.
(PassphraseResult): New type.
(_gpgme_release_passphrase_result): Function removed.
(release_passphrase_result): New function.
(_gpgme_passphrase_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(_gpgme_passphrase_command_handler): Likewise.
* keylist.c (struct keylist_result_s): Rename to ...
(struct keylist_result): ... this. Remove member next.
(KeylistResult): New type.
(_gpgme_release_keylist_result): Function removed.
(release_keylist_result): New function.
(keylist_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* edit.c (struct edit_result_s): Rename to ...
(struct edit_result): ... this. Remove member next.
(EditResult): New type.
(_gpgme_release_edit_result): Function removed.
(release_edit_result): New function.
(edit_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(command_handler): Likewise.
* types.h (DecryptResult, SignResult, EncryptResult,
PassphraseResult, ImportResult, DeleteResult, GenKeyResult,
KeylistResult, EditResult): Types removed.
* ops.h: Don't include "types.h", but "gpgme.h" and "context.h".
(test_and_allocate_result): Remove macro.
(_gpgme_release_decrypt_result): Remove prototype.
(_gpgme_decrypt_result): Remove prototype.
(_gpgme_release_sign_result): Remove prototype.
(_gpgme_release_encrypt_result): Remove prototype.
(_gpgme_release_passphrase_result): Remove prototype.
(_gpgme_release_import_result): Remove prototype.
(_gpgme_release_delete_result): Remove prototype.
(_gpgme_release_genkey_result): Remove prototype.
(_gpgme_release_keylist_result): Remove prototype.
(_gpgme_release_edit_result): Remove prototype.
(_gpgme_release_verify_result): Remove prototype.
* gpgme.c (_gpgme_release_result): Rewritten.
* context.h (enum ctx_op_data_type): New enum.
(struct ctx_op_data): New structure.
(struct gpgme_context_s): Replace the member result with a member
op_data.
(fail_on_pending_request): Remove macro.
* op-support.c (_gpgme_op_reset): Expand macro
fail_on_pending_request.
* util.h: Don't include "types.h" or "debug.h", but include "gpgme.h".
2003-01-30 22:40:05 +00:00
|
|
|
|
static void
|
2003-04-24 17:16:28 +00:00
|
|
|
|
release_op_data (void *hook)
|
2002-01-31 00:31:44 +00:00
|
|
|
|
{
|
2003-04-24 17:16:28 +00:00
|
|
|
|
op_data_t opd = (op_data_t) hook;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
if (opd->result.fpr)
|
|
|
|
|
free (opd->result.fpr);
|
|
|
|
|
if (opd->key_parameter)
|
|
|
|
|
gpgme_data_release (opd->key_parameter);
|
2002-01-31 00:31:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-19 16:41:17 +00:00
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_genkey_result_t
|
|
|
|
|
gpgme_op_genkey_result (gpgme_ctx_t ctx)
|
2003-04-24 17:16:28 +00:00
|
|
|
|
{
|
2003-05-27 02:54:36 +00:00
|
|
|
|
void *hook;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
op_data_t opd;
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t err;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
TRACE_BEG (DEBUG_CTX, "gpgme_op_genkey_result", ctx);
|
|
|
|
|
|
2003-05-27 02:54:36 +00:00
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL);
|
|
|
|
|
opd = hook;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
if (err || !opd)
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE_SUC0 ("result=(null)");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
TRACE_LOG3 ("fpr = %s, %s, %s", opd->result.fpr,
|
|
|
|
|
opd->result.primary ? "primary" : "no primary",
|
|
|
|
|
opd->result.sub ? "sub" : "no sub");
|
|
|
|
|
|
|
|
|
|
TRACE_SUC1 ("result=%p", &opd->result);
|
2003-04-24 17:16:28 +00:00
|
|
|
|
return &opd->result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
2016-09-13 16:57:38 +00:00
|
|
|
|
/* Parse an error status line. Return the error location and the
|
|
|
|
|
error code. The function may modify ARGS. */
|
|
|
|
|
static char *
|
|
|
|
|
parse_error (char *args, gpg_error_t *r_err)
|
|
|
|
|
{
|
|
|
|
|
char *where = strchr (args, ' ');
|
|
|
|
|
char *which;
|
|
|
|
|
|
|
|
|
|
if (where)
|
|
|
|
|
{
|
|
|
|
|
*where = '\0';
|
|
|
|
|
which = where + 1;
|
|
|
|
|
|
|
|
|
|
where = strchr (which, ' ');
|
|
|
|
|
if (where)
|
|
|
|
|
*where = '\0';
|
|
|
|
|
|
|
|
|
|
where = args;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*r_err = trace_gpg_error (GPG_ERR_INV_ENGINE);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*r_err = atoi (which);
|
|
|
|
|
|
|
|
|
|
return where;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
static gpgme_error_t
|
|
|
|
|
genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
2000-12-18 20:54:43 +00:00
|
|
|
|
{
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_ctx_t ctx = (gpgme_ctx_t) priv;
|
|
|
|
|
gpgme_error_t err;
|
2003-05-27 02:54:36 +00:00
|
|
|
|
void *hook;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
op_data_t opd;
|
2016-09-13 16:57:38 +00:00
|
|
|
|
char *loc;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
|
|
|
|
/* Pipe the status code through the progress status handler. */
|
|
|
|
|
err = _gpgme_progress_status_handler (ctx, code, args);
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
2002-01-31 00:31:44 +00:00
|
|
|
|
|
2003-05-27 02:54:36 +00:00
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL);
|
|
|
|
|
opd = hook;
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (status_handler): Do not close status fd at end
of function.
* ops.h (_gpgme_op_data_lookup): Add prototype.
* op-support.c: Include <stdlib.h>.
(_gpgme_op_data_lookup): New function.
* decrypt.c (_gpgme_release_decrypt_result): Function removed.
(struct decrypt_result_s): Rename to ...
(struct decrypt_resul): ... this.
(DecryptResult): New type.
(_gpgme_decrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* sign.c (_gpgme_release_sign_result): Function removed.
(release_sign_result): New function.
(struct sign_result_s): Rename to ...
(struct sign_result): ... this.
(SignResult): New type.
(_gpgme_sign_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* encrypt.c (struct encrypt_result_s): Rename to ...
(struct encrypt_result): ... this.
(_gpgme_release_encrypt_result): Function removed.
(release_encrypt_result): New function.
(_gpgme_encrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* verify.c (struct verify_result_s): Rename to ...
(struct verify_result): ... this. Remove member next.
(VerifyResult): New type.
(_gpgme_release_verify_result): Function removed.
(release_verify_result): New function.
(finish_sig): Change first argument to type VerifyResult. Diddle
the type of the op_data structure.
(add_notation): Change first argument to type VerifyResult.
(_gpgme_verify_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* passphrase.c (struct passphrase_result_s): Rename to ...
(struct passphrase_result): ... this. Remove member next.
(PassphraseResult): New type.
(_gpgme_release_passphrase_result): Function removed.
(release_passphrase_result): New function.
(_gpgme_passphrase_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(_gpgme_passphrase_command_handler): Likewise.
* keylist.c (struct keylist_result_s): Rename to ...
(struct keylist_result): ... this. Remove member next.
(KeylistResult): New type.
(_gpgme_release_keylist_result): Function removed.
(release_keylist_result): New function.
(keylist_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* edit.c (struct edit_result_s): Rename to ...
(struct edit_result): ... this. Remove member next.
(EditResult): New type.
(_gpgme_release_edit_result): Function removed.
(release_edit_result): New function.
(edit_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(command_handler): Likewise.
* types.h (DecryptResult, SignResult, EncryptResult,
PassphraseResult, ImportResult, DeleteResult, GenKeyResult,
KeylistResult, EditResult): Types removed.
* ops.h: Don't include "types.h", but "gpgme.h" and "context.h".
(test_and_allocate_result): Remove macro.
(_gpgme_release_decrypt_result): Remove prototype.
(_gpgme_decrypt_result): Remove prototype.
(_gpgme_release_sign_result): Remove prototype.
(_gpgme_release_encrypt_result): Remove prototype.
(_gpgme_release_passphrase_result): Remove prototype.
(_gpgme_release_import_result): Remove prototype.
(_gpgme_release_delete_result): Remove prototype.
(_gpgme_release_genkey_result): Remove prototype.
(_gpgme_release_keylist_result): Remove prototype.
(_gpgme_release_edit_result): Remove prototype.
(_gpgme_release_verify_result): Remove prototype.
* gpgme.c (_gpgme_release_result): Rewritten.
* context.h (enum ctx_op_data_type): New enum.
(struct ctx_op_data): New structure.
(struct gpgme_context_s): Replace the member result with a member
op_data.
(fail_on_pending_request): Remove macro.
* op-support.c (_gpgme_op_reset): Expand macro
fail_on_pending_request.
* util.h: Don't include "types.h" or "debug.h", but include "gpgme.h".
2003-01-30 22:40:05 +00:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
2000-12-18 20:54:43 +00:00
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
|
switch (code)
|
|
|
|
|
{
|
2002-07-28 Marcus Brinkmann <marcus@g10code.de>
* data.c (gpgme_data_read): For GPGME_DATA_TYPE_NONE, return EOF
instead an error.
The following changes make it possible to flush an inbound data
pipe before invoking a command handler:
* posix-io.c (_gpgme_io_select): Accept new argument NONBLOCK to
_gpgme_io_select. Set timeout of 0 if this is set.
* w32-io.c (_gpgme_io_select): Likewise.
* io.h: Add new argument NONBLOCK to _gpgme_io_select prototype.
* wait.c (do_select): Add new argument to _gpgme_io_select
invocation.
* rungpg.h (_gpgme_gpg_set_command_handler): Add new argument
linked_data to prototype.
* engine.h (_gpgme_engine_set_command_handler): Likewise.
* engine.c (_gpgme_engine_set_command_handler): Likewise.
* passphrase.c (_gpgme_passphrase_start): Pass NULL as linked_data
argument to _gpgme_engine_set_command_handler.
* rungpg.c (struct gpg_object_s): New members linked_data and
linked_idx in CMD.
(_gpgme_gpg_new): Initialize those new members.
(_gpgme_gpg_set_command_handler): Accept new argument linked_data.
(build_argv): Handle linked_data in the same hack as cb_data.
(read_status): If linked_data is in use, flush the pipe before
activating the command handler.
* gpgme.h: Add prototypes for gpgme_op_edit_start and
gpgme_op_edit.
The next changes export the status codes to the user:
* decrypt.c (_gpgme_decrypt_status_handler): Likewise, also prefix
all STATUS_ with GPGME_.
* delete.c (delete_status_handler): Likewise.
* decrypt-verify.c (decrypt_verify_status_handler): Likewise.
* encrypt.c (_gpgme_encrypt_status_handler): Likewise.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (parse_status): Likewise.
(gpgsm_status_handler): Likewise.
(gpgsm_set_recipients): Likewise.
* export.c (export_status_handler): Likewise.
* genkey.c (genkey_status_handler): Likewise.
* import.c (append_xml_impinfo): Likewise.
(import_status_handler): Likewise.
* keylist.c (keylist_status_handler): Likewise.
* passphrase.c (_gpgme_passphrase_status_handler): Likewise.
(command_handler): Likewise.
* progress.c (_gpgme_progress_status_handler): Likewise.
* sign.c (_gpgme_sign_status_handler): Likewise.
* trustlist.c (trustlist_status_handler): Likewise.
* verify.c (_gpgme_verify_status_handler): Likewise.
* gpgme.h (GpgmeEditCb): New type.
* rungpg.h (GpgStatusCode): Rename and move to ...
* gpgme.h (GpgmeStatusCode): ... this and here.
* Makefile.am (status-table.h): Run mkstatus on gpgme.h, not rungpg.h.
* mkstatus: Prefix STATUS with GPGME_.
* rungpg.h (GpgStatusHandler, GpgCommandHandler): Change type
accordingly.
* ops.h (_gpgme_verify_status_handler,
_gpgme_decrypt_status_handler, _gpgme_sign_status_handler,
_gpgme_encrypt_status_handler, _gpgme_passphrase_status_handler,
_gpgme_progress_status_handler): Likewise.
* rungpg.c (struct gpg_object_s): Likewise for CMD.code.
These changes add an edit operation to GPGME:
* context.h (struct gpgme_context_s): New member RESULT.edit. *
ops.h: Add prototype for _gpgme_release_edit_result and
_gpgme_passphrase_command_handler.
* passphrase.c (command_handler): Make non-static and rename to ...
(_gpgme_passphrase_command_handler): ... this.
(_gpgme_passphrase_start): Use new name for command handler.
* types.h: Add EditResult type.
* gpgme.c (_gpgme_release_result): Release EDIT result.
* edit.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add edit.c.
(libgpgme_la_LDADD): Rename to libgpgme_la_LIBADD, and include
assuan_libobjs.
(assuan_libobjs): New variable, set this instead
libgpgme_la_LIBADD.
* engine.h (_gpgme_engine_op_edit): New prototype.
* engine.c (_gpgme_engine_op_edit): New function.
* rungpg.h (_gpgme_gpg_op_edit): New prototype.
* rungpg.c (_gpgme_gpg_op_edit): New function.
2002-07-28 18:41:02 +00:00
|
|
|
|
case GPGME_STATUS_KEY_CREATED:
|
2002-01-31 00:31:44 +00:00
|
|
|
|
if (args && *args)
|
|
|
|
|
{
|
|
|
|
|
if (*args == 'B' || *args == 'P')
|
2016-09-14 09:40:34 +00:00
|
|
|
|
{
|
|
|
|
|
opd->result.primary = 1;
|
|
|
|
|
opd->result.uid = 1;
|
|
|
|
|
}
|
2002-01-31 00:31:44 +00:00
|
|
|
|
if (*args == 'B' || *args == 'S')
|
2003-04-24 17:16:28 +00:00
|
|
|
|
opd->result.sub = 1;
|
2002-11-19 16:41:17 +00:00
|
|
|
|
if (args[1] == ' ')
|
|
|
|
|
{
|
2003-04-24 17:16:28 +00:00
|
|
|
|
if (opd->result.fpr)
|
|
|
|
|
free (opd->result.fpr);
|
|
|
|
|
opd->result.fpr = strdup (&args[2]);
|
|
|
|
|
if (!opd->result.fpr)
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return gpg_error_from_syserror ();
|
2002-11-19 16:41:17 +00:00
|
|
|
|
}
|
2002-01-31 00:31:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-09-13 16:57:38 +00:00
|
|
|
|
case GPGME_STATUS_ERROR:
|
|
|
|
|
loc = parse_error (args, &err);
|
|
|
|
|
if (!loc)
|
|
|
|
|
return err;
|
|
|
|
|
if (!opd->error_code)
|
|
|
|
|
opd->error_code = err;
|
|
|
|
|
break;
|
|
|
|
|
|
2015-08-25 11:22:43 +00:00
|
|
|
|
case GPGME_STATUS_FAILURE:
|
|
|
|
|
opd->failure_code = _gpgme_parse_failure (args);
|
|
|
|
|
break;
|
|
|
|
|
|
2002-07-28 Marcus Brinkmann <marcus@g10code.de>
* data.c (gpgme_data_read): For GPGME_DATA_TYPE_NONE, return EOF
instead an error.
The following changes make it possible to flush an inbound data
pipe before invoking a command handler:
* posix-io.c (_gpgme_io_select): Accept new argument NONBLOCK to
_gpgme_io_select. Set timeout of 0 if this is set.
* w32-io.c (_gpgme_io_select): Likewise.
* io.h: Add new argument NONBLOCK to _gpgme_io_select prototype.
* wait.c (do_select): Add new argument to _gpgme_io_select
invocation.
* rungpg.h (_gpgme_gpg_set_command_handler): Add new argument
linked_data to prototype.
* engine.h (_gpgme_engine_set_command_handler): Likewise.
* engine.c (_gpgme_engine_set_command_handler): Likewise.
* passphrase.c (_gpgme_passphrase_start): Pass NULL as linked_data
argument to _gpgme_engine_set_command_handler.
* rungpg.c (struct gpg_object_s): New members linked_data and
linked_idx in CMD.
(_gpgme_gpg_new): Initialize those new members.
(_gpgme_gpg_set_command_handler): Accept new argument linked_data.
(build_argv): Handle linked_data in the same hack as cb_data.
(read_status): If linked_data is in use, flush the pipe before
activating the command handler.
* gpgme.h: Add prototypes for gpgme_op_edit_start and
gpgme_op_edit.
The next changes export the status codes to the user:
* decrypt.c (_gpgme_decrypt_status_handler): Likewise, also prefix
all STATUS_ with GPGME_.
* delete.c (delete_status_handler): Likewise.
* decrypt-verify.c (decrypt_verify_status_handler): Likewise.
* encrypt.c (_gpgme_encrypt_status_handler): Likewise.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (parse_status): Likewise.
(gpgsm_status_handler): Likewise.
(gpgsm_set_recipients): Likewise.
* export.c (export_status_handler): Likewise.
* genkey.c (genkey_status_handler): Likewise.
* import.c (append_xml_impinfo): Likewise.
(import_status_handler): Likewise.
* keylist.c (keylist_status_handler): Likewise.
* passphrase.c (_gpgme_passphrase_status_handler): Likewise.
(command_handler): Likewise.
* progress.c (_gpgme_progress_status_handler): Likewise.
* sign.c (_gpgme_sign_status_handler): Likewise.
* trustlist.c (trustlist_status_handler): Likewise.
* verify.c (_gpgme_verify_status_handler): Likewise.
* gpgme.h (GpgmeEditCb): New type.
* rungpg.h (GpgStatusCode): Rename and move to ...
* gpgme.h (GpgmeStatusCode): ... this and here.
* Makefile.am (status-table.h): Run mkstatus on gpgme.h, not rungpg.h.
* mkstatus: Prefix STATUS with GPGME_.
* rungpg.h (GpgStatusHandler, GpgCommandHandler): Change type
accordingly.
* ops.h (_gpgme_verify_status_handler,
_gpgme_decrypt_status_handler, _gpgme_sign_status_handler,
_gpgme_encrypt_status_handler, _gpgme_passphrase_status_handler,
_gpgme_progress_status_handler): Likewise.
* rungpg.c (struct gpg_object_s): Likewise for CMD.code.
These changes add an edit operation to GPGME:
* context.h (struct gpgme_context_s): New member RESULT.edit. *
ops.h: Add prototype for _gpgme_release_edit_result and
_gpgme_passphrase_command_handler.
* passphrase.c (command_handler): Make non-static and rename to ...
(_gpgme_passphrase_command_handler): ... this.
(_gpgme_passphrase_start): Use new name for command handler.
* types.h: Add EditResult type.
* gpgme.c (_gpgme_release_result): Release EDIT result.
* edit.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add edit.c.
(libgpgme_la_LDADD): Rename to libgpgme_la_LIBADD, and include
assuan_libobjs.
(assuan_libobjs): New variable, set this instead
libgpgme_la_LIBADD.
* engine.h (_gpgme_engine_op_edit): New prototype.
* engine.c (_gpgme_engine_op_edit): New function.
* rungpg.h (_gpgme_gpg_op_edit): New prototype.
* rungpg.c (_gpgme_gpg_op_edit): New function.
2002-07-28 18:41:02 +00:00
|
|
|
|
case GPGME_STATUS_EOF:
|
2016-09-13 16:57:38 +00:00
|
|
|
|
if (opd->error_code)
|
|
|
|
|
return opd->error_code;
|
2016-09-14 09:40:34 +00:00
|
|
|
|
else if (!opd->uidmode && !opd->result.primary && !opd->result.sub)
|
2003-06-05 23:20:29 +00:00
|
|
|
|
return gpg_error (GPG_ERR_GENERAL);
|
2015-08-25 11:22:43 +00:00
|
|
|
|
else if (opd->failure_code)
|
|
|
|
|
return opd->failure_code;
|
2016-09-14 10:41:16 +00:00
|
|
|
|
else if (opd->uidmode == 1)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
opd->result.uid = 1; /* We have no status line, thus this hack. */
|
2002-02-02 Marcus Brinkmann <marcus@g10code.de>
This patch has gotten a bit large... mmh. The main thing that
happens here is that error values are now not determined in the
operation function after gpgme_wait completed, but in the status
handler when EOF is received. It should always be the case that
either an error is flagged or EOF is received, so that after a
gpgme_wait you should never have the situation that no error is
flagged and EOF is not received. One problem is that the engine
status handlers don't have access to the context, a horrible
kludge works around this for now. All errors that happen during a
pending operation should be catched and reported in ctx->error,
including out-of-core and cancellation. This rounds up neatly a
couple of loose ends, and makes it possible to pass up any errors
in the communication with the backend as well. As a bonus, there
will be a function to access gpgme->wait, so that the operations
can truly be implemented with their _start function.
* engine-gpgsm.c (gpgsm_status_handler): Horrible kludge to report
error back to the context.
* rungpg.c (gpg_status_handler): Same horrible kludge applied here.
* engine-gpgsm.c (gpgsm_assuan_simple_command): Add error checking.
* wait.c (_gpgme_wait_on_condition): If canceled, set CTX->error
to a value indication that.
* verify.c (add_notation): Set error, not out_of_core.
(finish_sig): Likewise.
(gpgme_op_verify_start): Don't clear out_of_core.
(_gpgme_verify_status_handler): At EOF, clean up the notation data.
(gpgme_op_verify): And don't do it here.
* trustlist.c (trustlist_status_handler): Check error, not out_of_core.
(gpgme_op_trustlist_start): Don't clear out_of_core.
(gpgme_op_trustlist_next): Check error, not out_of_core.
(gpgme_op_trustlist_end): Likewise.
* ops.h (test_and_allocate_result): New macro.
(_gpgme_passphrase_result): Remove prototype.
* delete.c (gpgme_op_delete): Return error from context.
(delete_status_handler): Use macro test_and_allocate_result.
Perform error checking at EOF.
(gpgme_op_delete_start): Release result.
* passphrase.c (_gpgme_passphrase_status_handler): Use macro
test_and_allocate_result, and perform error checking here.
(_gpgme_passphrase_result): Function removed.
* sign.c (gpgme_op_sign_start): Do not set out_of_core to zero.
(gpgme_op_sign): Just return the error value from the context.
(sign_status_handler): Only progress if no error is set yet. If
we process an EOF, set the resulting error value (if any).
* decrypt.c (_gpgme_decrypt_result): Function removed.
(create_result_struct): Function removed.
(_gpgme_decrypt_status_handler): Use macro test_and_allocate_result,
caclulate error on EOF, do not progress with errors.
(_gpgme_decrypt_start): Do not set out_of_core to zero.
(gpgme_op_decrypt): Just return the error value from the context.
* encrypt.c (encrypt_status_handler): Perform the error checking
here.
(gpgme_op_encrypt_start): Do not clear out_of_core.
* export.c (export_status_handler): Return if error is set in context.
(gpgme_op_export_start): Release result.
(gpgme_op_export): Return error from context.
* decrypt-verify.c (gpgme_op_decrypt_verify): Return the error in
the context.
* genkey.c (genkey_status_handler): Use macro
test_and_allocate_result. Perform error checking at EOF.
(gpgme_op_genkey): Just return the error from context.
* import.c (gpgme_op_import): Return the error from context.
(import_status_handler): Use macro test_and_allocate_result.
* keylist.c (gpgme_op_keylist_start): Do not clear out_of_core.
(gpgme_op_keylist_next): Return error of context.
(keylist_colon_handler): Set error instead out_of_code.
(finish_key): Likewise.
* context.h: Remove member out_of_core, add member error.
* gpgme.c (_gpgme_release_result): Clear error flag.
* engine.h (_gpgme_engine_get_error): New prototype.
* engine.c (_gpgme_engine_get_error): New function.
* engine-gpgsm.c (_gpgme_gpgsm_get_error): New function.
* engine-gpgsm.c (map_assuan_error): New function.
(gpgsm_assuan_simple_command): Change return type to GpgmeError,
use the new function to map error values.
(gpgsm_set_fd): Change return type tp GpgmeError.
(_gpgme_gpgsm_op_decrypt): Change type of ERR to GpgmeError.
(gpgsm_set_recipients): Likewise. Change type of return value
equivalently. Adjust error values.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(struct gpgsm_object_s): New member error.
(gpgsm_status_handler): Set error if error occurs. Determine
error number from ERR line received. If assuan_read_line fails,
terminate the connection.
2002-02-02 03:52:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2015-04-17 01:05:01 +00:00
|
|
|
|
case GPGME_STATUS_INQUIRE_MAXLEN:
|
2016-05-19 15:01:07 +00:00
|
|
|
|
if (ctx->status_cb && !ctx->full_status)
|
2015-04-17 01:05:01 +00:00
|
|
|
|
{
|
|
|
|
|
err = ctx->status_cb (ctx->status_cb_value, "INQUIRE_MAXLEN", args);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
|
return 0;
|
2000-12-18 20:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-19 16:41:17 +00:00
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
static gpgme_error_t
|
|
|
|
|
get_key_parameter (const char *parms, gpgme_data_t *key_parameter)
|
2000-12-18 20:54:43 +00:00
|
|
|
|
{
|
2003-04-24 17:16:28 +00:00
|
|
|
|
const char *content;
|
|
|
|
|
const char *attrib;
|
|
|
|
|
const char *endtag;
|
|
|
|
|
|
|
|
|
|
/* Extract the key parameter from the XML structure. */
|
|
|
|
|
parms = strstr (parms, "<GnupgKeyParms ");
|
|
|
|
|
if (!parms)
|
2003-06-05 23:20:29 +00:00
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
|
|
|
|
content = strchr (parms, '>');
|
|
|
|
|
if (!content)
|
2003-06-05 23:20:29 +00:00
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
2003-04-24 17:16:28 +00:00
|
|
|
|
content++;
|
|
|
|
|
|
|
|
|
|
attrib = strstr (parms, "format=\"internal\"");
|
|
|
|
|
if (!attrib || attrib >= content)
|
2003-06-05 23:20:29 +00:00
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
|
|
|
|
endtag = strstr (content, "</GnupgKeyParms>");
|
|
|
|
|
/* FIXME: Check that there are no control statements inside. */
|
2006-07-16 13:27:08 +00:00
|
|
|
|
while (content[0] == '\n'
|
|
|
|
|
|| (content[0] == '\r' && content[1] == '\n'))
|
2003-04-24 17:16:28 +00:00
|
|
|
|
content++;
|
|
|
|
|
|
|
|
|
|
return gpgme_data_new_from_mem (key_parameter, content,
|
2003-10-10 09:08:23 +00:00
|
|
|
|
endtag - content, 1);
|
2003-04-24 17:16:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-21 03:40:17 +00:00
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
static gpgme_error_t
|
|
|
|
|
genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
|
|
|
|
|
gpgme_data_t pubkey, gpgme_data_t seckey)
|
2003-04-24 17:16:28 +00:00
|
|
|
|
{
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t err;
|
2003-05-27 02:54:36 +00:00
|
|
|
|
void *hook;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
op_data_t opd;
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
err = _gpgme_op_reset (ctx, synchronous);
|
|
|
|
|
if (err)
|
2003-04-24 17:16:28 +00:00
|
|
|
|
return err;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-05-27 02:54:36 +00:00
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook,
|
2003-04-24 17:16:28 +00:00
|
|
|
|
sizeof (*opd), release_op_data);
|
2003-05-27 02:54:36 +00:00
|
|
|
|
opd = hook;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
2000-12-18 20:54:43 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
err = get_key_parameter (parms, &opd->key_parameter);
|
2001-11-21 03:40:17 +00:00
|
|
|
|
if (err)
|
2003-04-24 17:16:28 +00:00
|
|
|
|
return err;
|
2001-11-21 03:40:17 +00:00
|
|
|
|
|
|
|
|
|
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
|
|
|
|
|
2015-04-14 22:39:26 +00:00
|
|
|
|
if (ctx->passphrase_cb)
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_set_command_handler
|
|
|
|
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-13 16:57:38 +00:00
|
|
|
|
return _gpgme_engine_op_genkey (ctx->engine,
|
|
|
|
|
NULL, NULL, 0, 0, NULL, 0,
|
|
|
|
|
opd->key_parameter,
|
2016-09-14 10:15:35 +00:00
|
|
|
|
ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
|
|
|
|
|
pubkey, seckey);
|
2000-12-18 20:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
/* Generate a new keypair and add it to the keyring. PUBKEY and
|
|
|
|
|
SECKEY should be null for now. PARMS specifies what keys should be
|
|
|
|
|
generated. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
|
|
|
|
|
gpgme_data_t pubkey, gpgme_data_t seckey)
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
{
|
2009-11-05 02:17:07 +00:00
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey_start", ctx,
|
|
|
|
|
"pubkey=%p, seckey=%p", pubkey, seckey);
|
|
|
|
|
TRACE_LOGBUF (parms, strlen (parms));
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
2009-11-05 02:17:07 +00:00
|
|
|
|
err = genkey_start (ctx, 0, parms, pubkey, seckey);
|
|
|
|
|
return TRACE_ERR (err);
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
/* Generate a new keypair and add it to the keyring. PUBKEY and
|
|
|
|
|
SECKEY should be null for now. PARMS specifies what keys should be
|
|
|
|
|
generated. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey,
|
|
|
|
|
gpgme_data_t seckey)
|
2000-12-18 20:54:43 +00:00
|
|
|
|
{
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t err;
|
2003-04-24 17:16:28 +00:00
|
|
|
|
|
2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
* encrypt-sign.c (gpgme_op_encrypt_sign_start)
(gpgme_op_encrypt_sign): Likewise.
* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
(gpgme_op_encrypt_result): Likewise.
* export.c (gpgme_op_export_start, gpgme_op_export)
(gpgme_op_export_ext_start, gpgme_op_export_ext)
(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
(gpgme_op_genkey_result): Likewise.
* getauditlog.c (gpgme_op_getauditlog_start)
(gpgme_op_getauditlog): Likewise.
* import.c (gpgme_op_import_result, gpgme_op_import_start)
(gpgme_op_import): Likewise.
* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
* opassuan.c (gpgme_op_assuan_transact_start)
(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
(gpgme_op_assuan_transact): Likewise.
* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
* trustlist.c (gpgme_op_trustlist_start)
(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
* verify.c (gpgme_op_verify_start, gpgme_op_verify)
(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey", ctx,
|
|
|
|
|
"pubkey=%p, seckey=%p", pubkey, seckey);
|
|
|
|
|
TRACE_LOGBUF (parms, strlen (parms));
|
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
|
err = genkey_start (ctx, 1, parms, pubkey, seckey);
|
2002-01-22 15:11:53 +00:00
|
|
|
|
if (!err)
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
err = _gpgme_wait_one (ctx);
|
2010-06-09 13:14:44 +00:00
|
|
|
|
return TRACE_ERR (err);
|
2000-12-18 20:54:43 +00:00
|
|
|
|
}
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpgme_error_t
|
|
|
|
|
createkey_start (gpgme_ctx_t ctx, int synchronous,
|
|
|
|
|
const char *userid, const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
gpgme_key_t anchorkey, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
void *hook;
|
|
|
|
|
op_data_t opd;
|
|
|
|
|
|
|
|
|
|
err = _gpgme_op_reset (ctx, synchronous);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
if (reserved || anchorkey || !userid)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return gpg_error (GPG_ERR_INV_ARG);
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook,
|
|
|
|
|
sizeof (*opd), release_op_data);
|
|
|
|
|
opd = hook;
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx->passphrase_cb)
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_set_command_handler
|
|
|
|
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _gpgme_engine_op_genkey (ctx->engine,
|
|
|
|
|
userid, algo, reserved, expires,
|
|
|
|
|
anchorkey, flags,
|
2016-09-14 10:15:35 +00:00
|
|
|
|
NULL,
|
|
|
|
|
ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
|
|
|
|
|
NULL, NULL);
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_createkey_start (gpgme_ctx_t ctx, const char *userid, const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
gpgme_key_t anchorkey, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_createkey_start", ctx,
|
|
|
|
|
"userid='%s', algo='%s' flags=0x%x", userid, algo, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
|
|
|
|
err = createkey_start (ctx, 0,
|
|
|
|
|
userid, algo, reserved, expires, anchorkey, flags);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_createkey (gpgme_ctx_t ctx, const char *userid, const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
gpgme_key_t anchorkey, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_createkey", ctx,
|
|
|
|
|
"userid='%s', algo='%s' flags=0x%x", userid, algo, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2016-09-13 16:57:38 +00:00
|
|
|
|
|
|
|
|
|
err = createkey_start (ctx, 1,
|
|
|
|
|
userid, algo, reserved, expires, anchorkey, flags);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = _gpgme_wait_one (ctx);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
2016-09-14 07:51:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpgme_error_t
|
|
|
|
|
createsubkey_start (gpgme_ctx_t ctx, int synchronous,
|
|
|
|
|
gpgme_key_t key,
|
|
|
|
|
const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
void *hook;
|
|
|
|
|
op_data_t opd;
|
|
|
|
|
|
|
|
|
|
if (ctx->protocol != GPGME_PROTOCOL_OPENPGP)
|
|
|
|
|
return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
|
|
|
|
|
|
|
|
|
|
err = _gpgme_op_reset (ctx, synchronous);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
if (reserved || !key)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return gpg_error (GPG_ERR_INV_ARG);
|
2016-09-14 07:51:16 +00:00
|
|
|
|
|
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook,
|
|
|
|
|
sizeof (*opd), release_op_data);
|
|
|
|
|
opd = hook;
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx->passphrase_cb)
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_set_command_handler
|
|
|
|
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _gpgme_engine_op_genkey (ctx->engine,
|
|
|
|
|
NULL, algo, reserved, expires,
|
|
|
|
|
key, flags,
|
2016-09-14 10:15:35 +00:00
|
|
|
|
NULL,
|
|
|
|
|
ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
|
|
|
|
|
NULL, NULL);
|
2016-09-14 07:51:16 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Add a subkey to an existing KEY. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_createsubkey_start (gpgme_ctx_t ctx, gpgme_key_t key, const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_createsubkey_start", ctx,
|
|
|
|
|
"key=%p, algo='%s' flags=0x%x", key, algo, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2016-09-14 07:51:16 +00:00
|
|
|
|
|
|
|
|
|
err = createsubkey_start (ctx, 0, key, algo, reserved, expires, flags);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_createsubkey (gpgme_ctx_t ctx, gpgme_key_t key, const char *algo,
|
|
|
|
|
unsigned long reserved, unsigned long expires,
|
|
|
|
|
unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_createsubkey", ctx,
|
|
|
|
|
"key=%p, algo='%s' flags=0x%x", key, algo, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
2016-09-14 07:51:16 +00:00
|
|
|
|
|
|
|
|
|
err = createsubkey_start (ctx, 1, key, algo, reserved, expires, flags);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = _gpgme_wait_one (ctx);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
2016-09-14 09:40:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpgme_error_t
|
2016-09-14 10:41:16 +00:00
|
|
|
|
addrevuid_start (gpgme_ctx_t ctx, int synchronous, int revoke,
|
|
|
|
|
gpgme_key_t key, const char *userid, unsigned int flags)
|
2016-09-14 09:40:34 +00:00
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
void *hook;
|
|
|
|
|
op_data_t opd;
|
|
|
|
|
|
|
|
|
|
if (ctx->protocol != GPGME_PROTOCOL_OPENPGP)
|
|
|
|
|
return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
|
|
|
|
|
|
|
|
|
|
if (!key || !userid)
|
|
|
|
|
return gpg_error (GPG_ERR_INV_ARG);
|
|
|
|
|
|
|
|
|
|
err = _gpgme_op_reset (ctx, synchronous);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook,
|
|
|
|
|
sizeof (*opd), release_op_data);
|
|
|
|
|
opd = hook;
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
2016-09-14 10:41:16 +00:00
|
|
|
|
opd->uidmode = revoke? 2 : 1;
|
2016-09-14 09:40:34 +00:00
|
|
|
|
|
|
|
|
|
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx->passphrase_cb)
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_set_command_handler
|
|
|
|
|
(ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _gpgme_engine_op_genkey (ctx->engine,
|
|
|
|
|
userid, NULL, 0, 0,
|
|
|
|
|
key, flags,
|
2016-09-14 10:15:35 +00:00
|
|
|
|
NULL,
|
2016-09-14 10:41:16 +00:00
|
|
|
|
revoke? GENKEY_EXTRAFLAG_REVOKE : 0,
|
2016-09-14 10:15:35 +00:00
|
|
|
|
NULL, NULL);
|
2016-09-14 09:40:34 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Add USERID to an existing KEY. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_adduid_start (gpgme_ctx_t ctx,
|
|
|
|
|
gpgme_key_t key, const char *userid, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_adduid_start", ctx,
|
|
|
|
|
"uid='%s' flags=0x%x", userid, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
|
|
|
|
|
2016-09-14 10:41:16 +00:00
|
|
|
|
err = addrevuid_start (ctx, 0, 0, key, userid, flags);
|
2016-09-14 09:40:34 +00:00
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_adduid (gpgme_ctx_t ctx,
|
|
|
|
|
gpgme_key_t key, const char *userid, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_adduid", ctx,
|
|
|
|
|
"uid='%s' flags=0x%x", userid, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
|
|
|
|
|
2016-09-14 10:41:16 +00:00
|
|
|
|
err = addrevuid_start (ctx, 1, 0, key, userid, flags);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = _gpgme_wait_one (ctx);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Revoke USERID from KEY. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_revuid_start (gpgme_ctx_t ctx,
|
|
|
|
|
gpgme_key_t key, const char *userid, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_revuid_start", ctx,
|
|
|
|
|
"uid='%s' flags=0x%x", userid, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
|
|
|
|
|
|
|
|
|
err = addrevuid_start (ctx, 0, 1, key, userid, flags);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_op_revuid (gpgme_ctx_t ctx,
|
|
|
|
|
gpgme_key_t key, const char *userid, unsigned int flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_revuid", ctx,
|
|
|
|
|
"uid='%s' flags=0x%x", userid, flags);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
|
|
|
|
|
|
|
|
|
|
err = addrevuid_start (ctx, 1, 1, key, userid, flags);
|
2016-09-14 09:40:34 +00:00
|
|
|
|
if (!err)
|
|
|
|
|
err = _gpgme_wait_one (ctx);
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|