GPGME_DEBUG on Android, which makes env vars hard

Werner Koch wk at gnupg.org
Tue Sep 25 16:13:16 CEST 2012


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?


Shalom-Salam,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-devel mailing list