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 <wk@gnupg.org>
This commit is contained in:
parent
cad1210fb8
commit
3234b1bf1d
1
NEWS
1
NEWS
@ -12,6 +12,7 @@ Noteworthy changes in version 1.7.2 (unreleased)
|
|||||||
gpgme_op_query_swdb NEW.
|
gpgme_op_query_swdb NEW.
|
||||||
gpgme_op_query_swdb_result NEW.
|
gpgme_op_query_swdb_result NEW.
|
||||||
gpgme_query_swdb_result_t NEW.
|
gpgme_query_swdb_result_t NEW.
|
||||||
|
gpgme_get_ctx_flag NEW.
|
||||||
qt: DN NEW.
|
qt: DN NEW.
|
||||||
qt: DN::Attribute NEW.
|
qt: DN::Attribute NEW.
|
||||||
qt: Job::context(Job*) NEW.
|
qt: Job::context(Job*) NEW.
|
||||||
|
@ -2929,6 +2929,19 @@ This function returns @code{0} on success.
|
|||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
|
||||||
|
@deftypefun {const char *} gpgme_get_ctx_flag @
|
||||||
|
(@w{gpgme_ctx_t @var{ctx}}, @
|
||||||
|
@w{const char *@var{name}})
|
||||||
|
|
||||||
|
The value of flags settable by @code{gpgme_set_ctx_flag} can be
|
||||||
|
retrieved by this function. If @var{name} is unknown the function
|
||||||
|
returns @code{NULL}. For boolean flags an empty string is returned
|
||||||
|
for False and the string "1" is returned for True; either atoi(3) or a
|
||||||
|
test for an empty string can be used to get the boolean value.
|
||||||
|
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
|
|
||||||
@node Locale
|
@node Locale
|
||||||
@subsection Locale
|
@subsection Locale
|
||||||
@cindex locale, default
|
@cindex locale, default
|
||||||
|
93
src/gpgme.c
93
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
|
/* Create a new context as an environment for GPGME crypto
|
||||||
operations. */
|
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. */
|
/* Enable or disable the exporting session keys upon decryption. */
|
||||||
void
|
void
|
||||||
gpgme_set_export_session_keys (gpgme_ctx_t ctx, int export_session_keys)
|
gpgme_set_export_session_keys (gpgme_ctx_t ctx, int export_session_keys)
|
||||||
|
@ -254,5 +254,6 @@ EXPORTS
|
|||||||
|
|
||||||
gpgme_set_export_session_keys @191
|
gpgme_set_export_session_keys @191
|
||||||
gpgme_get_export_session_keys @192
|
gpgme_get_export_session_keys @192
|
||||||
|
gpgme_get_ctx_flag @193
|
||||||
; END
|
; END
|
||||||
|
|
||||||
|
@ -999,6 +999,9 @@ void gpgme_release (gpgme_ctx_t ctx);
|
|||||||
gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
|
gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
|
||||||
const char *name, const char *value);
|
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. */
|
/* Set the protocol to be used by CTX to PROTO. */
|
||||||
gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
|
gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ GPGME_1.1 {
|
|||||||
|
|
||||||
gpgme_pubkey_algo_string;
|
gpgme_pubkey_algo_string;
|
||||||
gpgme_set_ctx_flag;
|
gpgme_set_ctx_flag;
|
||||||
|
gpgme_get_ctx_flag;
|
||||||
gpgme_data_set_flag;
|
gpgme_data_set_flag;
|
||||||
|
|
||||||
gpgme_op_createkey_start;
|
gpgme_op_createkey_start;
|
||||||
|
@ -99,6 +99,7 @@ main (int argc, char **argv)
|
|||||||
const char *fpr;
|
const char *fpr;
|
||||||
const char *policystr = NULL;
|
const char *policystr = NULL;
|
||||||
gpgme_tofu_policy_t policy;
|
gpgme_tofu_policy_t policy;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
if (argc)
|
if (argc)
|
||||||
{ argc--; argv++; }
|
{ argc--; argv++; }
|
||||||
@ -145,10 +146,31 @@ main (int argc, char **argv)
|
|||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
gpgme_set_protocol (ctx, protocol);
|
gpgme_set_protocol (ctx, protocol);
|
||||||
gpgme_set_armor (ctx, 1);
|
gpgme_set_armor (ctx, 1);
|
||||||
|
|
||||||
|
|
||||||
|
s = gpgme_get_ctx_flag (ctx, "no_such-flag");
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
fprintf (stderr, PGM ": gpgme_get_ctx_flag failed "
|
||||||
|
"(bad name not detected)\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
s = gpgme_get_ctx_flag (ctx, "full-status");
|
||||||
|
if (!s || *s)
|
||||||
|
{
|
||||||
|
fprintf (stderr, PGM ": gpgme_get_ctx_flag failed (wrong false)\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
if (print_status)
|
if (print_status)
|
||||||
{
|
{
|
||||||
gpgme_set_status_cb (ctx, status_cb, NULL);
|
gpgme_set_status_cb (ctx, status_cb, NULL);
|
||||||
gpgme_set_ctx_flag (ctx, "full-status", "1");
|
gpgme_set_ctx_flag (ctx, "full-status", "1");
|
||||||
|
s = gpgme_get_ctx_flag (ctx, "full-status");
|
||||||
|
if (!s || strcmp (s, "1"))
|
||||||
|
{
|
||||||
|
fprintf (stderr, PGM ": gpgme_get_ctx_flag fauled (wrong true)\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gpgme_get_key (ctx, fpr, &thekey, 0);
|
err = gpgme_get_key (ctx, fpr, &thekey, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user