From 350fdc93b048b83bf33ced2beccfbf93562953f1 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 25 Apr 2003 13:42:02 +0000 Subject: [PATCH] 2003-04-25 Marcus Brinkmann * context.h (struct gpgme_context_s): Remove member initialized, use_cms and help_data_1. Add member protocol. Make use_armor and use_textmode bit flags. Make keylist_mode, include_certs, signers_len and signers_size unsigned. * gpgme.c (gpgme_new): Initialize CTX->protocol. (gpgme_set_protocol): Do not check CTX. Use CTX->protocol. (gpgme_get_protocol): Likewise. (gpgme_release): Do not release CTX->help_data_1. * op-support.c (_gpgme_op_reset): Use CTX->protocol. --- trunk/gpgme/ChangeLog | 10 ++++++++++ trunk/gpgme/context.h | 29 ++++++++++++++++++----------- trunk/gpgme/gpgme.c | 35 +++++++---------------------------- trunk/gpgme/op-support.c | 3 +-- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 6796531..f0a4010 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,5 +1,15 @@ 2003-04-25 Marcus Brinkmann + * context.h (struct gpgme_context_s): Remove member initialized, + use_cms and help_data_1. Add member protocol. Make use_armor and + use_textmode bit flags. Make keylist_mode, include_certs, + signers_len and signers_size unsigned. + * gpgme.c (gpgme_new): Initialize CTX->protocol. + (gpgme_set_protocol): Do not check CTX. Use CTX->protocol. + (gpgme_get_protocol): Likewise. + (gpgme_release): Do not release CTX->help_data_1. + * op-support.c (_gpgme_op_reset): Use CTX->protocol. + * wait-private.c (_gpgme_wait_private_event_cb): Remove variable CTX. * data.c: Do not include , but "gpgme.h". diff --git a/trunk/gpgme/context.h b/trunk/gpgme/context.h index 748dd2e..2b77e27 100644 --- a/trunk/gpgme/context.h +++ b/trunk/gpgme/context.h @@ -74,22 +74,29 @@ struct trust_queue_item_s into this header file. */ struct gpgme_context_s { - int initialized; - - int use_cms; + /* The protocol used by this context. */ + GpgmeProtocol protocol; /* The running engine process. */ EngineObject engine; - int use_armor; - int use_textmode; - int keylist_mode; - int include_certs; + /* True if armor mode should be used. */ + unsigned int use_armor : 1; + + /* True if text mode should be used. */ + unsigned int use_textmode : 1; + + /* Flags for keylist mode. */ + unsigned int keylist_mode; + + /* Number of certs to be included. */ + unsigned int include_certs; /* The number of keys in signers. */ - int signers_len; + unsigned int signers_len; + /* Size of the following array. */ - int signers_size; + unsigned int signers_size; GpgmeKey *signers; /* The operation data hooked into the context. */ @@ -108,9 +115,11 @@ struct gpgme_context_s struct key_queue_item_s *key_queue; struct trust_queue_item_s *trust_queue; + /* The user provided passphrase callback and its hook value. */ GpgmePassphraseCb passphrase_cb; void *passphrase_cb_value; + /* The user provided progress callback and its hook value. */ GpgmeProgressCb progress_cb; void *progress_cb_value; @@ -118,8 +127,6 @@ struct gpgme_context_s operation. */ struct fd_table fdt; struct GpgmeIOCbs io_cbs; - - GpgmeData help_data_1; }; /* Forward declaration of a structure to store certification diff --git a/trunk/gpgme/gpgme.c b/trunk/gpgme/gpgme.c index 5f62b59..41b3b09 100644 --- a/trunk/gpgme/gpgme.c +++ b/trunk/gpgme/gpgme.c @@ -31,15 +31,8 @@ #include "ops.h" #include "wait.h" -/** - * gpgme_new: - * @r_ctx: Returns the new context - * - * Create a new context to be used with most of the other GPGME - * functions. Use gpgme_release_context() to release all resources - * - * Return value: An error code - **/ +/* Create a new context as an environment for GPGME crypto + operations. */ GpgmeError gpgme_new (GpgmeCtx *r_ctx) { @@ -53,6 +46,7 @@ gpgme_new (GpgmeCtx *r_ctx) return GPGME_Out_Of_Core; ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->include_certs = 1; + ctx->protocol = GPGME_PROTOCOL_OpenPGP; _gpgme_fd_table_init (&ctx->fdt); *r_ctx = ctx; return 0; @@ -74,7 +68,6 @@ gpgme_release (GpgmeCtx ctx) _gpgme_fd_table_deinit (&ctx->fdt); _gpgme_release_result (ctx); gpgme_key_release (ctx->tmp_key); - gpgme_data_release (ctx->help_data_1); gpgme_data_release (ctx->notation); gpgme_signers_clear (ctx); if (ctx->signers) @@ -181,32 +174,18 @@ _gpgme_set_op_info (GpgmeCtx ctx, GpgmeData info) GpgmeError gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol) { - if (!ctx) + if (protocol != GPGME_PROTOCOL_OpenPGP && protocol != GPGME_PROTOCOL_CMS) return GPGME_Invalid_Value; - switch (protocol) - { - case GPGME_PROTOCOL_OpenPGP: - ctx->use_cms = 0; - break; - case GPGME_PROTOCOL_CMS: - ctx->use_cms = 1; - break; - default: - return GPGME_Invalid_Value; - } - + ctx->protocol = protocol; return 0; } + GpgmeProtocol gpgme_get_protocol (GpgmeCtx ctx) { - if (!ctx) - return 0; /* well, this is OpenPGP */ - if (ctx->use_cms) - return GPGME_PROTOCOL_CMS; - return GPGME_PROTOCOL_OpenPGP; + return ctx->protocol; } diff --git a/trunk/gpgme/op-support.c b/trunk/gpgme/op-support.c index 4bf5bb5..1d55e38 100644 --- a/trunk/gpgme/op-support.c +++ b/trunk/gpgme/op-support.c @@ -71,8 +71,7 @@ _gpgme_op_reset (GpgmeCtx ctx, int type) /* Create an engine object. */ _gpgme_engine_release (ctx->engine); ctx->engine = NULL; - err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS - : GPGME_PROTOCOL_OpenPGP, &ctx->engine); + err = _gpgme_engine_new (ctx->protocol, &ctx->engine); if (err) return err; -- 2.26.2