From c62b79a1d6e576d94e08cb81c2f5dbcb42ecf8cf Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 25 Sep 2012 15:38:26 +0200 Subject: Add gpgme_set_global_flag to help debugging * src/gpgme.c (gpgme_set_global_flag): New. * src/gpgme.h.in (gpgme_set_global_flag): New. * src/gpgme.def, src/libgpgme.vers: Add new public function. * src/debug.c (envvar_override): New.: (_gpgme_debug_set_debug_envvar): New. (debug_init): Take ENVVAR_OVERRIDE in account. -- On Android envvars can't be used, thus we need another way to enable GPGME debugging. The new function allows this and may be used in the future to implement similar things. --- src/gpgme.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/gpgme.c') diff --git a/src/gpgme.c b/src/gpgme.c index 771fcc00..2c6ac875 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -1,6 +1,6 @@ /* gpgme.c - GnuPG Made Easy. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2012 g10 Code GmbH This file is part of GPGME. @@ -51,6 +51,25 @@ gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL; accesses to a result structure are read only. */ DEFINE_STATIC_LOCK (result_ref_lock); + +/* Set the global flag NAME to VALUE. Return 0 on success. Note that + this function does use gpgme_error and thus a non-zero return value + merely means "error". Certain flags may be set before + gpgme_check_version is called. See the manual for a description of + supported flags. The caller must assure that this function is + called only by one thread at a time. */ +int +gpgme_set_global_flag (const char *name, const char *value) +{ + if (!name || !value) + return -1; + else if (!strcmp (name, "debug")) + return _gpgme_debug_set_debug_envvar (value); + else + return -1; +} + + /* Create a new context as an environment for GPGME crypto operations. */ -- cgit v1.2.3