diff options
author | Werner Koch <[email protected]> | 2016-11-15 08:24:17 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-11-15 08:24:17 +0000 |
commit | 3234b1bf1d6939772677d64f6c1e1820ec98e3cd (patch) | |
tree | e3c6a0b6666bed4ef10f78b73a2e5a985de99d65 /src/gpgme.c | |
parent | core: Enable extraction of session keys. (diff) | |
download | gpgme-3234b1bf1d6939772677d64f6c1e1820ec98e3cd.tar.gz gpgme-3234b1bf1d6939772677d64f6c1e1820ec98e3cd.zip |
core: Add public function gpgme_get_ctx_flag.
* src/gpgme.h.in (gpgme_get_ctx_flag): New.
* src/gpgme.c (gpgme_set_ctx_flag): Move down the file and add a trace
statement.
(gpgme_get_ctx_flag): New.
* src/gpgme.def, src/libgpgme.vers: Add new interface.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/gpgme.c')
-rw-r--r-- | src/gpgme.c | 93 |
1 files changed, 60 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) |