]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Display locale information for debugging purpose
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 11 Dec 2014 14:01:23 +0000 (15:01 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 11 Dec 2014 14:01:23 +0000 (15:01 +0100)
Running sarg -x -v display the version number but also the directory where
the message file is looked for, the package name and the currently
selected locale.

log.c
util.c

diff --git a/log.c b/log.c
index de08ac880bafaef41976c71ccfae0275a852542c..c5d51971f2a6282281d8594d3981b89365e1604d 100644 (file)
--- a/log.c
+++ b/log.c
@@ -46,6 +46,9 @@ struct userfilestruct
 numlist weekdays = { { 0, 1, 2, 3, 4, 5, 6 }, 7 };
 numlist hours = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, 24 };
 
+//! Selected locale set through the environment variable.
+char *CurrentLocale=NULL;
+
 static void getusers(const char *pwdfile, int debug);
 
 int main(int argc,char *argv[])
@@ -190,7 +193,8 @@ int main(int argc,char *argv[])
 #endif
 
 #if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
-       if (!setlocale (LC_ALL, "")) {
+       CurrentLocale=setlocale (LC_ALL, "");
+       if (!CurrentLocale) {
                fprintf(stderr,"SARG: Cannot set the locale LC_ALL to the environment variable\n");
                exit(EXIT_FAILURE);
        }
diff --git a/util.c b/util.c
index 318472ec65de9c1c17a1b0f7a1c367379b5e02fe..794e61ce10e472e360235c2b5e3c2cc3d414a6ac 100644 (file)
--- a/util.c
+++ b/util.c
@@ -41,6 +41,8 @@ static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
 //! The list of the HTTP codes to exclude from the report.
 static char *excludecode=NULL;
 
+extern char *CurrentLocale;
+
 #if USE_GETWORD_BACKTRACE
 static void getword_backtrace(void)
 {
@@ -1784,6 +1786,12 @@ void url_to_file(const char *url,char *file,int filesize)
 void version(void)
 {
        printf(_("SARG Version: %s\n"),VERSION);
+#if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
+       if (debug) {
+               printf(_("Translation file should be somewhere under \"%s\" and be named \"%s.mo\"\n"),LOCALEDIR,PACKAGE_NAME);
+               if (CurrentLocale) printf(_("The currently selected locale is \"%s\"\n"),CurrentLocale);
+       }
+#endif
        exit(EXIT_SUCCESS);
 }