Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: devel

gpgme_set_locale on global context fails ?

 

 

GnuPG devel RSS feed   Index | Next | Previous | View Threaded


ekleog at gmail

Jul 27, 2012, 11:53 AM

Post #1 of 4 (169 views)
Permalink
gpgme_set_locale on global context fails ?

Hello !

I'm learning GPGME, and just tried to use gpgme_set_locale. However, it looks
like it doesn't work on the global context, only on a normal one.

Here is what I mean :
#include <gpgme.h>
#include <locale.h>
#include <stdio.h>

int main() {
setlocale(LC_ALL, "");
gpgme_ctx_t ctx;
gpgme_new(&ctx);
printf("%d\n", gpgme_set_locale(ctx, LC_ALL, setlocale(LC_ALL, NULL)));
return 0;
}
It outputs 0, as expected.

Now, the issue :
#include <gpgme.h>
#include <locale.h>
#include <stdio.h>

int main() {
setlocale(LC_ALL, "");
printf("%d\n", gpgme_set_locale(NULL, LC_ALL, setlocale(LC_ALL, NULL)));
return 0;
}
It outputs 117440567 ; that is "source: GPGME ; error: Invalid value".

Do you have any idea of what it may have come from ?

I have GPGME version 1.3.1, and GnuPG version 2.0.19, as distributed by archlinux.

Thanks in advance,

Ekleog

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-devel


wking at tremily

Jul 27, 2012, 1:40 PM

Post #2 of 4 (173 views)
Permalink
Re: [GnuPG] gpgme_set_locale on global context fails ? [In reply to]

On Fri, Jul 27, 2012 at 08:53:18PM +0200, Leo Gaspard wrote:
> I'm learning GPGME, and just tried to use gpgme_set_locale. However,
> it looks like it doesn't work on the global context, only on a
> normal one.

That would be because the definition is currently:

gpgme_error_t
gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
{
…
if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));

It looks like Marcus just got into the zone with:

commit b34add3fe438a693e236a835135bd11b4e177daa
Author: Marcus Brinkmann <marcus.brinkmann [at] ruhr-uni-bochum>
Date: Thu May 26 16:01:26 2011 +0200

Check context pointers for null pointer on entry points.

But it looks like gpgme_set_locale actually does handle the !ctx case
well.

Cheers,
Trevor

--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
Attachments: signature.asc (0.82 KB)


ekleog at gmail

Jul 27, 2012, 2:43 PM

Post #3 of 4 (164 views)
Permalink
Re: [GnuPG] gpgme_set_locale on global context fails ? [In reply to]

On 27/07/2012 22:40, W. Trevor King wrote:
> On Fri, Jul 27, 2012 at 08:53:18PM +0200, Leo Gaspard wrote:
>> I'm learning GPGME, and just tried to use gpgme_set_locale. However,
>> it looks like it doesn't work on the global context, only on a
>> normal one.
>
> That would be because the definition is currently:
>
> [...]
>
> But it looks like gpgme_set_locale actually does handle the !ctx case
> well.

Oh.
Just tried, and it looks like global context's locale is set only through setlocale.
Then, why does the documentation
(http://www.gnupg.org/documentation/manuals/gpgme/Locale.html#Locale) states
that "The function gpgme_set_locale sets the locale of the context ctx, /or the
default locale if ctx is a null pointer/." ?

Should I still call gpgme_set_locale(NULL, ...) and ignore its result for
upwards compatibility ?

Thanks !

Leo Gaspard

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-devel


marcus.brinkmann at ruhr-uni-bochum

Jul 27, 2012, 4:18 PM

Post #4 of 4 (165 views)
Permalink
Re: [GnuPG] gpgme_set_locale on global context fails ? [In reply to]

Hi,

thanks, it turns out my checking-spree went over the line with that one.

;)

Reverted in 434735f71e6969248651ac01c6bd6f6789a6305d.

Marcus

On 07/27/2012 10:40 PM, W. Trevor King wrote:
> On Fri, Jul 27, 2012 at 08:53:18PM +0200, Leo Gaspard wrote:
>> I'm learning GPGME, and just tried to use gpgme_set_locale. However,
>> it looks like it doesn't work on the global context, only on a
>> normal one.
>
> That would be because the definition is currently:
>
> gpgme_error_t
> gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
> {
> …
> if (!ctx)
> return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
>
> It looks like Marcus just got into the zone with:
>
> commit b34add3fe438a693e236a835135bd11b4e177daa
> Author: Marcus Brinkmann <marcus.brinkmann [at] ruhr-uni-bochum>
> Date: Thu May 26 16:01:26 2011 +0200
>
> Check context pointers for null pointer on entry points.
>
> But it looks like gpgme_set_locale actually does handle the !ctx case
> well.
>
> Cheers,
> Trevor
>
>
>
> _______________________________________________
> Gnupg-devel mailing list
> Gnupg-devel [at] gnupg
> http://lists.gnupg.org/mailman/listinfo/gnupg-devel
>



_______________________________________________
Gnupg-devel mailing list
Gnupg-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-devel

GnuPG devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.