* migrate to _GNU_SOURCE and uselocale() to be threadsafe.
authorWilfried Göesgens <willi@citadel.org>
Mon, 28 Nov 2005 22:00:34 +0000 (22:00 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 28 Nov 2005 22:00:34 +0000 (22:00 +0000)
webcit/ChangeLog
webcit/gettext.c

index 7d18df5a36475817a2658b1c12c64ed1746a3021..4eb2e775470f23de0453844a272f261ab45a961c 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Mon Nov 27 21:28:03 CET 2005 dothebart
+* migrate to _GNU_SOURCE and uselocale() to be threadsafe.
+       
 Sun Nov 27 21:28:03 EST 2005 ajc
 * Eliminated the use of tmpnam() to shut up compiler warnings.
 
index fb31756a9c58889a73d092c0033cff54337466a3..6fd2a96e5d982e1c71ddf537e3d8e4567f19decf 100644 (file)
@@ -1,10 +1,11 @@
+#define _GNU_SOURCE
 #include "webcit.h"
 #include "webserver.h"
 
 static const char* AvailLang[]=
        {
                "de_DE"
-
 
        };
 
@@ -21,9 +22,10 @@ void httplang_to_locale(const char* LocaleString)
        int nAvail=1;
        char *search=(char*)malloc(len);
        int done=0;
-       char *mo;
-       char *webcitdir = WEBCITDIR;
-
+       //      char *mo;
+       //      char *webcitdir = WEBCITDIR;
+       locale_t my_Locale;
+       locale_t my_Empty_Locale;
        memcpy(search,LocaleString,len);
        search[len+1]='\0';
        len=strlen(search);
@@ -58,7 +60,7 @@ void httplang_to_locale(const char* LocaleString)
                                                                                strlen(wanted_locales[i]));
                                        if (!ret)
                                                {
-                                                       locale=AvailLang[j];//wanted_locales[i];
+                                                       locale=(char*)AvailLang[j];//wanted_locales[i];
                                                        i=nFound+1;
                                                        j=nAvail+1;
                                                        continue;
@@ -66,37 +68,20 @@ void httplang_to_locale(const char* LocaleString)
 
                                }
                }
-       setlocale(LC_ALL,"C");
+       
        len=strlen(locale);
        memcpy(search,locale,len);
        memcpy(&search[len],".UTF8",5);
        search[len+5]='\0';
-       /*
-       len=strlen(search);
-       mo=malloc(len+1);
-       memcpy(mo,search,len+1);
-       */
-       /*
-       mo = malloc(strlen(webcitdir) + 20);
-       sprintf(mo, "%s/locale", webcitdir);
+       my_Empty_Locale=newlocale(LC_ALL_MASK, NULL, NULL); /* create default locale */
+       my_Locale=newlocale(LC_MESSAGES_MASK/*|LC_TIME_MASK TODO */,
+                                          search,
+                                          my_Empty_Locale);
 
-       lprintf(9, "Message catalog directory: %s\n",
-               bindtextdomain("webcit", mo)
-               );
-       free(mo);
-       
-       lprintf(9, "Text domain: %s\n",
-               textdomain("webcit")
-               );
-       
-       lprintf(9, "Text domain Charset: %s\n",
-                       bind_textdomain_codeset("webcit","UTF8")
-                       );
-       
-       */
-       //setlocale(LC_MESSAGES,mo);//search);
-       setlocale(LC_MESSAGES,search);
-       //      free(mo);
+       uselocale(my_Locale);
+       //freelocale(my_Locale);
+       //      freelocale(my_Empty_Locale);
        free(search);
 
 }
+