]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Write getword errors on stderr
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 9 Jul 2012 07:30:24 +0000 (09:30 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 9 Jul 2012 07:30:24 +0000 (09:30 +0200)
Errors detected by any getword function is written using debuga (on stderr)
instead of stdout. It makes the redirection easier.

util.c

diff --git a/util.c b/util.c
index 419c3e68529c2b367e5847c119ac9375d8e3eb45..27c85460e35138a8b9801d6c8b07a2c844d1907c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -83,11 +83,11 @@ int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
 
        for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) {
                if(x>=limit) {
-                       printf("SARG: getword loop detected after %d bytes.\n",x);
-                       printf("SARG: Line=\"%s\"\n",gwarea->beginning);
-                       printf("SARG: Record=\"%s\"\n",gwarea->current);
-                       printf("SARG: searching for \'x%x\'\n",stop);
-                       //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n");
+                       debuga(_("getword loop detected after %d bytes.\n"),x);
+                       debuga(_("Line=\"%s\"\n"),gwarea->beginning);
+                       debuga(_("Record=\"%s\"\n"),gwarea->current);
+                       debuga(_("searching for \'x%x\'\n"),stop);
+                       //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n"));
                        word[(limit>0) ? limit-1 : 0]='\0';
 #if USE_GETWORD_BACKTRACE
                        getword_backtrace();
@@ -124,11 +124,11 @@ int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, char s
 
        for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) {
                if(x>=limit) {
-                       printf("SARG: getword_multisep loop detected.\n");
-                       printf("SARG: Line=\"%s\"\n",gwarea->beginning);
-                       printf("SARG: Record=\"%s\"\n",gwarea->current);
-                       printf("SARG: searching for \'x%x\'\n",stop);
-                       //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n");
+                       debuga(_("getword_multisep loop detected.\n"));
+                       debuga(_("Line=\"%s\"\n"),gwarea->beginning);
+                       debuga(_("Record=\"%s\"\n"),gwarea->current);
+                       debuga(_("searching for \'x%x\'\n"),stop);
+                       //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n"));
                        if (limit>0) word[limit-1]='\0';
 #if USE_GETWORD_BACKTRACE
                        getword_backtrace();
@@ -151,11 +151,11 @@ int getword_skip(int limit, struct getwordstruct *gwarea, char stop)
 
        for(x=0;(gwarea->current[x] && (gwarea->current[x] != stop ));x++) {
                if(x>=limit) {
-                       printf("SARG: getword_skip loop detected after %d bytes.\n",x);
-                       printf("SARG: Line=\"%s\"\n",gwarea->beginning);
-                       printf("SARG: Record=\"%s\"\n",gwarea->current);
-                       printf("SARG: searching for \'x%x\'\n",stop);
-                       //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n");
+                       debuga(_("getword_skip loop detected after %d bytes.\n"),x);
+                       debuga(_("Line=\"%s\"\n"),gwarea->beginning);
+                       debuga(_("Record=\"%s\"\n"),gwarea->current);
+                       debuga(_("searching for \'x%x\'\n"),stop);
+                       //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n"));
 #if USE_GETWORD_BACKTRACE
                        getword_backtrace();
 #endif
@@ -190,11 +190,11 @@ int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop
                *number=(*number * 10) + digit;
        }
        if(gwarea->current[x] && gwarea->current[x]!=stop) {
-               printf("SARG: getword_atoll loop detected after %d bytes.\n",x);
-               printf("SARG: Line=\"%s\"\n",gwarea->beginning);
-               printf("SARG: Record=\"%s\"\n",gwarea->current);
-               printf("SARG: searching for \'x%x\'\n",stop);
-               //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n");
+               debuga(_("getword_atoll loop detected after %d bytes.\n"),x);
+               debuga(_("Line=\"%s\"\n"),gwarea->beginning);
+               debuga(_("Record=\"%s\"\n"),gwarea->current);
+               debuga(_("searching for \'x%x\'\n"),stop);
+               //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n"));
 #if USE_GETWORD_BACKTRACE
                getword_backtrace();
 #endif
@@ -229,11 +229,11 @@ int getword_atoi(int *number, struct getwordstruct *gwarea, char stop)
                *number=(*number * 10) + digit;
        }
        if(gwarea->current[x] && gwarea->current[x]!=stop) {
-               printf("SARG: getword_atoi loop detected after %d bytes.\n",x);
-               printf("SARG: Line=\"%s\"\n",gwarea->beginning);
-               printf("SARG: Record=\"%s\"\n",gwarea->current);
-               printf("SARG: searching for \'x%x\'\n",stop);
-               //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n");
+               debuga(_("getword_atoi loop detected after %d bytes.\n"),x);
+               debuga(_("Line=\"%s\"\n"),gwarea->beginning);
+               debuga(_("Record=\"%s\"\n"),gwarea->current);
+               debuga(_("searching for \'x%x\'\n"),stop);
+               //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n"));
 #if USE_GETWORD_BACKTRACE
                getword_backtrace();
 #endif
@@ -438,11 +438,11 @@ void name_month(char *month,int month_len)
 
        for(x=0; x<z; x++)
                if (getword_multisep(w,sizeof(w),&gwarea,',')<0) {
-                       printf("SARG: Maybe you have a broken record or garbage in the names of the months.\n");
+                       debuga(_("SARG: Maybe you have a broken record or garbage in the names of the months.\n"));
                        exit(EXIT_FAILURE);
                }
        if (getword_multisep(month,month_len,&gwarea,',')<0) {
-               printf("SARG: Maybe you have a broken record or garbage in the name of the months.\n");
+               debuga(_("Maybe you have a broken record or garbage in the name of the months.\n"));
                exit(EXIT_FAILURE);
        }
 }