From: Marcus Brinkmann Date: Fri, 25 Apr 2003 13:42:02 +0000 (+0000) Subject: 2003-04-25 Marcus Brinkmann X-Git-Tag: gpgme-0-4-1~78 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9dbd9c6dffb5cab9a60733bc800b47702184835c;p=gpgme.git 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. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 6796531..f0a4010 100644 --- a/gpgme/ChangeLog +++ b/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/gpgme/context.h b/gpgme/context.h index 748dd2e..2b77e27 100644 --- a/gpgme/context.h +++ b/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/gpgme/gpgme.c b/gpgme/gpgme.c index 5f62b59..41b3b09 100644 --- a/gpgme/gpgme.c +++ b/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/gpgme/op-support.c b/gpgme/op-support.c index 4bf5bb5..1d55e38 100644 --- a/gpgme/op-support.c +++ b/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;