GPGME_DEBUG on Android, which makes env vars hard

Hans-Christoph Steiner hans at guardianproject.info
Tue Oct 16 23:51:24 CEST 2012



On 09/25/2012 10:13 AM, Werner Koch wrote:
> On Tue,  4 Sep 2012 19:58, hans at guardianproject.info said:
> 
>> Another idea would be for setting this from a conf file somewhere, but
>> I'm not sure if there is a gpgme conf file.
> 
> I just pushed a new function to set debugging.
> 
>  -- Function: int gpgme_set_global_flag (const char *NAME,
>           const char *VALUE)
>      On some systems it is not easy to set environment variables and
>      thus hard to use GPGME's internal trace facility for debugging.
>      This function has been introduced as an alternative way to enable
>      debugging.  It is important to assure that only one thread accesses
>      GPGME functions between a call to this function and after the
>      return from the call to `gpgme_check_version'.
> 
>      To enable debugging, you need to call this function as early as
>      possible -- even before `gpgme_check_version' -- with the string
>      "debug" for NAME and VALUE identical to the value used with the
>      environment variable `GPGME_DEBUG'.
> 
>      This function returns `0' on success.  In contrast to other
>      functions the non-zero return value on failure does not convey any
>      error code.  For setting "debug" the only possible error cause is
>      an out of memory condition; which would exhibit itself later
>      anyway.  Thus the return value may be ignored.
> 
> Thus your init code may look like this:
> 
>      void
>      init_gpgme (void)
>      {
>        /* Initialize the locale environment.  */
>        setlocale (LC_ALL, "");
>        if (debug_gpgme)
>           gpgme_set_global_flag ("debug", "9:/tmp/gpgme.log");
>        gpgme_check_version (NULL);
>        gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
>      #ifdef LC_MESSAGES
>        gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
>      #endif
>      }
> 
> 
> Does this make sense?

OMG, thank you!  Its working for me. This makes life soooo much easier,
rather than flying blind.  Here's how I used it:

...
setlocale(LC_ALL, "");
gpgme_set_global_flag("debug",

"9:/data/data/info.guardianproject.gpg/app_log/gpgme.log");
const char* version = gpgme_check_version(NULL);
...

.hc



More information about the Gnupg-devel mailing list