Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 27 Feb 2012 21:52:09 +0000 (22:52 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 27 Feb 2012 21:52:09 +0000 (22:52 +0100)
citadel/config.c
citadel/modules/rwho/serv_rwho.c
webcit/.gitignore
webcit/gettext.c
webcit/mk_module_init.sh
webcit/sieve.c

index 78a01d074c6358fefe1911450aa06cbad551894f..5328e30369149a50d2c04939d0c6469b1557a17f 100644 (file)
@@ -42,9 +42,7 @@ void brand_new_installation_set_defaults(void) {
        uname(&my_utsname);
 
        /* set some sample/default values in place of blanks... */
-       char c_nodename[256];
-       safestrncpy(c_nodename, my_utsname.nodename, sizeof c_nodename);
-       strtok(config.c_nodename, ".");
+       extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename);
        if (IsEmptyStr(config.c_fqdn) ) {
                if ((he = gethostbyname(my_utsname.nodename)) != NULL) {
                        safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
index 0aed437ceb96b991b0a1af7e60fd5801f98a65c7..09e256f8657466f32ada03c65e875b785975cd55 100644 (file)
@@ -4,19 +4,14 @@
  *
  * Copyright (c) 1987-2012 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  
- *  
- *  
  */
 
 #include "sysdep.h"
@@ -76,8 +71,6 @@ void cmd_rwho(char *argbuf) {
        /* So that we don't keep the context list locked for a long time
         * we create a copy of it first
         */
-       
-
        nptr = CtdlGetContextArray(&nContexts) ;
        if (!nptr)
        {
@@ -87,7 +80,7 @@ void cmd_rwho(char *argbuf) {
                return;
        }
        
-       aide = (CC->user.axlevel >= AxAideU) ;
+       aide = ( (CC->user.axlevel >= AxAideU) || (CC->internal_pgm) ) ;
        cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );
        
        for (i=0; i<nContexts; i++) 
index 042f838f2b67e6a88b083b95c8d7fe28f76430a5..2be77a2f282fe9c78f6dda262b9cb7abe2415447 100644 (file)
@@ -13,7 +13,6 @@ ical_maps.c
 locale/
 modules_init.c
 modules_init.h
-language_list.c
 po/Makefile
 setup
 sysdep.h
index d8b48f1b123ec68ead662c7c7d6544a2f7f024de..5e5d0909bb2e1bc55d37e4b71e656adbd8b7c2a4 100644 (file)
 #define SEARCH_LANG 20         /* how many langs should we parse? */
 
 #ifdef ENABLE_NLS
-#include "language_list.h"
+/* actual supported locales */
+const char *AvailLang[] = {
+       "C",
+       "bg_BG",
+       "cs_CZ",
+       "en_US",
+       "da_DK",
+       "de_DE",
+       "el_GR",
+       "en_GB",
+       "es_ES",
+       "et_EE",
+       "fi_FI",
+       "fr_FR",
+       "hu_HU",
+       "it_IT",
+       "nl_NL",
+       "pt_BR",
+       "ru_RU",
+       "zh_CN",
+       "he_IL",
+       "kk_KK",
+       "ro_RO",
+       "sl_SL",
+       "tr_TR",
+       ""
+};
 
 const char **AvailLangLoaded;
 long nLocalesLoaded = 0;
@@ -25,7 +51,7 @@ locale_t *wc_locales; /* here we keep the parsed stuff */
 #endif
 
 /* Keep information about one locale */
-typedef struct _lang_pref{
+typedef struct _lang_pref {
        char lang[16];          /* the language locale string */
        char region[16];        /* the region locale string */
        long priority;          /* which priority does it have */
@@ -183,12 +209,25 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
  */
 void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
 {
-#ifdef HAVE_USELOCALE
        int i;
+#ifndef HAVE_USELOCALE
+       char *Lang = getenv("LANG");
+       
+       if (Lang == NULL)
+               Lang = "C";
+#endif
+
+       if (nLocalesLoaded == 1) {
+               wc_printf("<p>%s</p>", AvailLangLoaded[0]);
+               return;
+       }
 
        wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"switch_to_lang($('lname').value);\">\n");
 
        for (i=0; i < nLocalesLoaded; ++i) {
+#ifndef HAVE_USELOCALE
+               if (strcmp(AvailLangLoaded[i], Lang) == 0)
+#endif
                wc_printf("<option %s value=%s>%s</option>\n",
                        ((WC->selected_language == i) ? "selected" : ""),
                        AvailLangLoaded[i],
@@ -197,9 +236,6 @@ void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
        }
 
        wc_printf("</select>\n");
-#else
-       wc_printf("%s", (getenv("LANG") ? getenv("LANG") : "C"));
-#endif
 }
 
 /*
@@ -244,6 +280,9 @@ void stop_selected_language(void) {
 #endif
 }
 
+#ifdef HAVE_USELOCALE
+       locale_t Empty_Locale;
+#endif
 
 /*
  * Create a locale_t for each available language
@@ -251,15 +290,9 @@ void stop_selected_language(void) {
 void initialize_locales(void) {
        int nLocales;
        int i;
+       char buf[32];
        char *language = NULL;
 
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       syslog(9, "Text domain: %s", textdomain("webcit"));
-       syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
-       syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
-#endif
-
        nLocales = 0; 
        while (!IsEmptyStr(AvailLang[nLocales]))
                nLocales++;
@@ -275,33 +308,42 @@ void initialize_locales(void) {
 #ifdef HAVE_USELOCALE
        wc_locales = malloc (sizeof(locale_t) * nLocales);
        memset(wc_locales,0, sizeof(locale_t) * nLocales);
-       wc_locales[0] = newlocale(LC_ALL_MASK, NULL, NULL);
+       /* create default locale */
+       Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
 #endif
 
-       for (i = 1; i < nLocales; ++i) {
+       for (i = 0; i < nLocales; ++i) {
+               if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
+                       continue;
+               if (i == 0) {
+                       sprintf(buf, "%s", AvailLang[i]);       /* locale 0 (C) is ascii, not utf-8 */
+               }
+               else {
+                       sprintf(buf, "%s.UTF8", AvailLang[i]);
+               }
 #ifdef HAVE_USELOCALE
                wc_locales[nLocalesLoaded] = newlocale(
                        (LC_MESSAGES_MASK|LC_TIME_MASK),
-                       AvailLang[i],
-                       NULL
+                       buf,
+                       (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
                );
                if (wc_locales[nLocalesLoaded] == NULL) {
-                       syslog(1, "locale for %s disabled: %s", AvailLang[i], strerror(errno));
+                       syslog(1, "locale for %s disabled: %s", buf, strerror(errno));
                }
                else {
-                       syslog(3, "Found locale: %s", AvailLang[i]);
+                       syslog(3, "Found locale: %s", buf);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        nLocalesLoaded++;
                }
 #else
                if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
-                       setenv("LANG", AvailLang[i], 1);
+                       setenv("LANG", buf, 1);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        setlocale(LC_MESSAGES, AvailLang[i]);
                        nLocalesLoaded++;
                }
                else if (nLocalesLoaded == 0) {
-                       setenv("LANG", AvailLang[i], 1);
+                       setenv("LANG", buf, 1);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        nLocalesLoaded++;
                }
@@ -309,13 +351,26 @@ void initialize_locales(void) {
        }
        if ((language != NULL) && (nLocalesLoaded == 0)) {
                syslog(1, "Your selected locale [%s] isn't available on your system. falling back to C", language);
-#ifndef HAVE_USELOCALE
+#ifdef HAVE_USELOCALE
+               wc_locales[0] = newlocale(
+                       (LC_MESSAGES_MASK|LC_TIME_MASK),
+                       AvailLang[0],
+                       Empty_Locale
+               );
+#else
                setlocale(LC_MESSAGES, AvailLang[0]);
                setenv("LANG", AvailLang[0], 1);
 #endif
                AvailLangLoaded[0] = AvailLang[0];
                nLocalesLoaded = 1;
        }
+
+#ifdef ENABLE_NLS
+       setlocale(LC_ALL, "");
+       syslog(9, "Text domain: %s", textdomain("webcit"));
+       syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit", "UTF8"));
+       syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
+#endif
 }
 
 
@@ -326,7 +381,9 @@ ServerShutdownModule_GETTEXT
 #ifdef HAVE_USELOCALE
        int i;
        for (i = 0; i < nLocalesLoaded; ++i) {
-               freelocale(wc_locales[i]);
+               if (Empty_Locale != wc_locales[i]) {
+                       freelocale(wc_locales[i]);
+               }
        }
        free(wc_locales);
 #endif
@@ -340,6 +397,13 @@ const char *AvailLang[] = {
 };
 
 /* dummy for non NLS enabled systems */
+void 
+ServerShutdownModule_GETTEXT
+(void)
+{
+}
+
+
 void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
 {
        wc_printf("English (US)");
index 6f6871bf20d147cf90d2461659b463677cb735fd..ae1cd375133a4c594c57fc073610fed36459eab6 100755 (executable)
@@ -26,7 +26,6 @@ H_FILE="$CUR_DIR/modules_init.h"
 MOD_FILE="$CUR_DIR/Make_modules"
 SRC_FILE="$CUR_DIR/Make_sources"
 U_FILE="$CUR_DIR/modules_upgrade.c"
-L_FILE="$CUR_DIR/language_list.h"
 
 /usr/bin/printf "Scanning extension modules for entry points.\n"
 
@@ -502,25 +501,3 @@ cat <<EOF  >> $H_FILE
 #endif /* MODULES_INIT_H */
 
 EOF
-
-
-### Now see what language modules we have installed ###
-/usr/bin/printf "Scanning language modules.\n"
-
-cat >$L_FILE <<EOF
-/* This file is generated automatically by mk_module_init.sh
- * Editing it by hand would be an exercise in futility.
- */
-const char *AvailLang[] = {
-        "C",
-EOF
-
-for x in po/webcit/*.po
-do
-       echo \  \"`basename $x | sed s/\.po\$//g`\",
-done >>$L_FILE
-
-cat >>$L_FILE <<EOF
-        ""
-};
-EOF
index 1d55abbdd795c8302cd06c502f159e2af3f1da15..dd049cf82a81ea894a682a1da77ae0c428a74cc6 100644 (file)
@@ -374,7 +374,7 @@ void save_sieve(void) {
        int bigaction;
        char script_names[MAX_SCRIPTS][64];
        int num_scripts = 0;
-       int active_script = (-1);
+       int active_script = (-1);       /* this throws a 'set but not used' warning , check this ! */
        int i;
        char this_name[64];
        char buf[256];
@@ -1522,13 +1522,13 @@ void FreeSieveRule(void *vRule)
 #define WC_RULE_HEADER "# WEBCIT_RULE|"
 HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
 {
-       StrBuf *Line;
-       StrBuf *EncodedRule;
-       int n;
-       const char *pch;
+       StrBuf *Line = NULL;
+       StrBuf *EncodedRule = NULL;
+       int n = 0;
+       const char *pch = NULL;
        HashList *SieveRules = NULL;
        int Done = 0;
-       SieveRule *Rule;
+       SieveRule *Rule = NULL;
 
        SieveRules = NewHash(1, Flathash);
        serv_printf("MSIV getscript|"RULES_SCRIPT);