aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpgme/ChangeLog10
-rw-r--r--gpgme/context.h29
-rw-r--r--gpgme/gpgme.c35
-rw-r--r--gpgme/op-support.c3
4 files changed, 36 insertions, 41 deletions
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index 6796531f..f0a40101 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,5 +1,15 @@
2003-04-25 Marcus Brinkmann <[email protected]>
+ * 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 <assert.h>, but "gpgme.h".
diff --git a/gpgme/context.h b/gpgme/context.h
index 748dd2e1..2b77e276 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 5f62b59e..41b3b095 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 4bf5bb5d..1d55e387 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;