diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpgme.c | 93 | ||||
-rw-r--r-- | src/gpgme.def | 1 | ||||
-rw-r--r-- | src/gpgme.h.in | 3 | ||||
-rw-r--r-- | src/libgpgme.vers | 1 |
4 files changed, 65 insertions, 33 deletions
diff --git a/src/gpgme.c b/src/gpgme.c index 7b14b5e9..32abc282 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -85,39 +85,6 @@ gpgme_set_global_flag (const char *name, const char *value) } -/* Set the flag NAME for CTX to VALUE. The supported flags are: - * - * - full-status :: With a value of "1" the status callback set by - * gpgme_set_status_cb returns all status lines - * except for PROGRESS lines. With the default of - * "0" the status callback is only called in certain - * situations. - */ -gpgme_error_t -gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value) -{ - int abool; - - if (!ctx || !name || !value) - return gpg_error (GPG_ERR_INV_VALUE); - - abool = *value? !!atoi (value) : 0; - - if (!strcmp (name, "full-status")) - { - ctx->full_status = abool; - } - else if (!strcmp (name, "raw-description")) - { - ctx->raw_description = abool; - } - else - return gpg_error (GPG_ERR_UNKNOWN_NAME); - - return 0; -} - - /* Create a new context as an environment for GPGME crypto operations. */ @@ -518,6 +485,66 @@ gpgme_get_armor (gpgme_ctx_t ctx) } +/* Set the flag NAME for CTX to VALUE. The supported flags are: + * + * - full-status :: With a value of "1" the status callback set by + * gpgme_set_status_cb returns all status lines + * except for PROGRESS lines. With the default of + * "0" the status callback is only called in certain + * situations. + */ +gpgme_error_t +gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value) +{ + gpgme_error_t err = 0; + int abool; + + TRACE2 (DEBUG_CTX, "gpgme_set_ctx_flag", ctx, + "name='%s' value='%s'", + name? name:"(null)", value?value:"(null)"); + + abool = (value && *value)? !!atoi (value) : 0; + + if (!ctx || !name || !value) + err = gpg_error (GPG_ERR_INV_VALUE); + else if (!strcmp (name, "full-status")) + { + ctx->full_status = abool; + } + else if (!strcmp (name, "raw-description")) + { + ctx->raw_description = abool; + } + else + err = gpg_error (GPG_ERR_UNKNOWN_NAME); + + return err; +} + + +/* Get the context flag named NAME. See gpgme_set_ctx_flag for a list + * of valid names. If the NAME is unknown NULL is returned. For a + * boolean flag an empty string is returned for False and the string + * "1" for True; thus either atoi or a simple string test can be + * used. */ +const char * +gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name) +{ + if (!ctx || !name) + return NULL; + else if (!strcmp (name, "full-status")) + { + return ctx->full_status? "1":""; + } + else if (!strcmp (name, "raw-description")) + { + return ctx->raw_description? "1":""; + } + else + return NULL; +} + + /* Enable or disable the exporting session keys upon decryption. */ void gpgme_set_export_session_keys (gpgme_ctx_t ctx, int export_session_keys) diff --git a/src/gpgme.def b/src/gpgme.def index 35f43411..cd0d0848 100644 --- a/src/gpgme.def +++ b/src/gpgme.def @@ -254,5 +254,6 @@ EXPORTS gpgme_set_export_session_keys @191 gpgme_get_export_session_keys @192 + gpgme_get_ctx_flag @193 ; END diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 2a0e16e3..43e07b06 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -999,6 +999,9 @@ void gpgme_release (gpgme_ctx_t ctx); gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value); +/* Get the value of the flag NAME from CTX. */ +const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name); + /* Set the protocol to be used by CTX to PROTO. */ gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto); diff --git a/src/libgpgme.vers b/src/libgpgme.vers index 9a3ecb2e..362909ae 100644 --- a/src/libgpgme.vers +++ b/src/libgpgme.vers @@ -101,6 +101,7 @@ GPGME_1.1 { gpgme_pubkey_algo_string; gpgme_set_ctx_flag; + gpgme_get_ctx_flag; gpgme_data_set_flag; gpgme_op_createkey_start; |