2003-04-25 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2003-04-25 13:42:02 +00:00
parent 7869230d18
commit 9dbd9c6dff
4 changed files with 36 additions and 41 deletions

View File

@ -1,5 +1,15 @@
2003-04-25 Marcus Brinkmann <marcus@g10code.de> 2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* 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. * wait-private.c (_gpgme_wait_private_event_cb): Remove variable CTX.
* data.c: Do not include <assert.h>, but "gpgme.h". * data.c: Do not include <assert.h>, but "gpgme.h".

View File

@ -74,22 +74,29 @@ struct trust_queue_item_s
into this header file. */ into this header file. */
struct gpgme_context_s struct gpgme_context_s
{ {
int initialized; /* The protocol used by this context. */
GpgmeProtocol protocol;
int use_cms;
/* The running engine process. */ /* The running engine process. */
EngineObject engine; EngineObject engine;
int use_armor; /* True if armor mode should be used. */
int use_textmode; unsigned int use_armor : 1;
int keylist_mode;
int include_certs; /* 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. */ /* The number of keys in signers. */
int signers_len; unsigned int signers_len;
/* Size of the following array. */ /* Size of the following array. */
int signers_size; unsigned int signers_size;
GpgmeKey *signers; GpgmeKey *signers;
/* The operation data hooked into the context. */ /* The operation data hooked into the context. */
@ -108,9 +115,11 @@ struct gpgme_context_s
struct key_queue_item_s *key_queue; struct key_queue_item_s *key_queue;
struct trust_queue_item_s *trust_queue; struct trust_queue_item_s *trust_queue;
/* The user provided passphrase callback and its hook value. */
GpgmePassphraseCb passphrase_cb; GpgmePassphraseCb passphrase_cb;
void *passphrase_cb_value; void *passphrase_cb_value;
/* The user provided progress callback and its hook value. */
GpgmeProgressCb progress_cb; GpgmeProgressCb progress_cb;
void *progress_cb_value; void *progress_cb_value;
@ -118,8 +127,6 @@ struct gpgme_context_s
operation. */ operation. */
struct fd_table fdt; struct fd_table fdt;
struct GpgmeIOCbs io_cbs; struct GpgmeIOCbs io_cbs;
GpgmeData help_data_1;
}; };
/* Forward declaration of a structure to store certification /* Forward declaration of a structure to store certification

View File

@ -31,15 +31,8 @@
#include "ops.h" #include "ops.h"
#include "wait.h" #include "wait.h"
/** /* Create a new context as an environment for GPGME crypto
* gpgme_new: operations. */
* @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
**/
GpgmeError GpgmeError
gpgme_new (GpgmeCtx *r_ctx) gpgme_new (GpgmeCtx *r_ctx)
{ {
@ -53,6 +46,7 @@ gpgme_new (GpgmeCtx *r_ctx)
return GPGME_Out_Of_Core; return GPGME_Out_Of_Core;
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
ctx->include_certs = 1; ctx->include_certs = 1;
ctx->protocol = GPGME_PROTOCOL_OpenPGP;
_gpgme_fd_table_init (&ctx->fdt); _gpgme_fd_table_init (&ctx->fdt);
*r_ctx = ctx; *r_ctx = ctx;
return 0; return 0;
@ -74,7 +68,6 @@ gpgme_release (GpgmeCtx ctx)
_gpgme_fd_table_deinit (&ctx->fdt); _gpgme_fd_table_deinit (&ctx->fdt);
_gpgme_release_result (ctx); _gpgme_release_result (ctx);
gpgme_key_release (ctx->tmp_key); gpgme_key_release (ctx->tmp_key);
gpgme_data_release (ctx->help_data_1);
gpgme_data_release (ctx->notation); gpgme_data_release (ctx->notation);
gpgme_signers_clear (ctx); gpgme_signers_clear (ctx);
if (ctx->signers) if (ctx->signers)
@ -181,32 +174,18 @@ _gpgme_set_op_info (GpgmeCtx ctx, GpgmeData info)
GpgmeError GpgmeError
gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol) gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol)
{ {
if (!ctx) if (protocol != GPGME_PROTOCOL_OpenPGP && protocol != GPGME_PROTOCOL_CMS)
return GPGME_Invalid_Value; return GPGME_Invalid_Value;
switch (protocol) ctx->protocol = protocol;
{
case GPGME_PROTOCOL_OpenPGP:
ctx->use_cms = 0;
break;
case GPGME_PROTOCOL_CMS:
ctx->use_cms = 1;
break;
default:
return GPGME_Invalid_Value;
}
return 0; return 0;
} }
GpgmeProtocol GpgmeProtocol
gpgme_get_protocol (GpgmeCtx ctx) gpgme_get_protocol (GpgmeCtx ctx)
{ {
if (!ctx) return ctx->protocol;
return 0; /* well, this is OpenPGP */
if (ctx->use_cms)
return GPGME_PROTOCOL_CMS;
return GPGME_PROTOCOL_OpenPGP;
} }

View File

@ -71,8 +71,7 @@ _gpgme_op_reset (GpgmeCtx ctx, int type)
/* Create an engine object. */ /* Create an engine object. */
_gpgme_engine_release (ctx->engine); _gpgme_engine_release (ctx->engine);
ctx->engine = NULL; ctx->engine = NULL;
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS err = _gpgme_engine_new (ctx->protocol, &ctx->engine);
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
if (err) if (err)
return err; return err;