]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Give a try to splint and apply a few of the recommandations
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 17 Mar 2010 08:54:14 +0000 (08:54 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 17 Mar 2010 08:54:14 +0000 (08:54 +0000)
43 files changed:
CMakeLists.txt
auth.c
authfail.c
btree_cache.c
configure.in
convlog.c
dansguardian_log.c
dansguardian_report.c
datafile.c
decomp.c
denied.c
documentation/util.txt
download.c
email.c
exclude.c
getconf.c
grepday.c
html.c
include/conf.h
include/config.h.in
include/defs.h
index.c
ip2name.c
lastlog.c
log.c
realtime.c
repday.c
report.c
siteuser.c
smartfilter.c
sort.c
splintrc [new file with mode: 0644]
splitlog.c
squidguard_log.c
squidguard_report.c
topsites.c
topuser.c
totday.c
totger.c
useragent.c
userinfo.c
usertab.c
util.c

index cf8a39ea8bf3ea75965410104c8f473adeca394e..e7c988ddae00055d72f3abe2e15dc05a56b8cbb7 100755 (executable)
@@ -113,6 +113,7 @@ CHECK_INCLUDE_FILE(locale.h HAVE_LOCALE_H)
 CHECK_INCLUDE_FILE(execinfo.h HAVE_EXECINFO_H)
 CHECK_INCLUDE_FILE(libintl.h HAVE_LIBINTL_H)
 CHECK_INCLUDE_FILE(libgen.h HAVE_LIBGEN_H)
+CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
 
 CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
 CHECK_FUNCTION_EXISTS(backtrace HAVE_BACKTRACE)
diff --git a/auth.c b/auth.c
index 341eea86b8089a4b361aaca9cf08fdbd075ec77c..5a5481415ff159caf1efafb24961e385a63e16c4 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -33,23 +33,23 @@ void htaccess(const struct userinfostruct *uinfo)
    char line[MAXLEN];
    FILE *fp_in;
    FILE *fp_auth;
-   int i, nread;
+   size_t i,nread;
 
    if(!UserAuthentication)
       return;
 
    if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",outdirname,uinfo->filename)>=sizeof(htname)) {
       debuga(_("File name too long: %s/%s/.htaccess\n"),outdirname,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_auth=fopen(htname,"w"))==NULL) {
       debuga(_("(auth) Cannot open file: %s - %s\n"),htname,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if ((fp_in=fopen(AuthUserTemplateFile,"r"))==NULL) {
       debuga(_("(auth) Cannot open template file: %s - %s\n"),AuthUserTemplateFile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((nread=fread(line,1,sizeof(line),fp_in))!=0) {
index b6e1c51774270fbb439232151d120a95b10b97ad..e8b3deec81fe0bf2b493f12683e2dba62a1b4db3 100644 (file)
@@ -50,7 +50,7 @@ void authfail_report(void)
    int  z=0;
    int  count=0;
    int  cstatus;
-   int new_user;
+   bool new_user;
    struct getwordstruct gwarea;
    struct longlinestruct line;
    struct userinfostruct *uinfo;
@@ -59,45 +59,46 @@ void authfail_report(void)
 
    ouser[0]='\0';
    ouser2[0]='\0';
+   oip[0]='\0';
 
-   sprintf(tmp4,"%s/sarg/authfail.log.unsort",TempDir);
+   snprintf(tmp4,sizeof(tmp4),"%s/sarg/authfail.log.unsort",TempDir);
 
-   if(!authfail_count) {
+   if(authfail_count == 0) {
       unlink(tmp4);
       return;
    }
 
-   sprintf(authfail_in,"%s/authfail.log",TempDir);
-   sprintf(per,"%s/sarg-period",outdirname);
-   sprintf(report,"%s/authfail.html",outdirname);
+   snprintf(authfail_in,sizeof(authfail_in),"%s/authfail.log",TempDir);
+   snprintf(per,sizeof(per),"%s/sarg-period",outdirname);
+   snprintf(report,sizeof(report),"%s/authfail.html",outdirname);
 
-   if ((fp_in = fopen(per, "r")) == 0) {
-      fprintf(stderr, "SARG: (authfail) %s: %s\n",_("Cannot open file"),per);
-      exit(1);
+   if ((fp_in = fopen(per, "r")) == NULL) {
+      debuga(_("(authfail) Cannot open file %s\n"),per);
+      exit(EXIT_FAILURE);
    }
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(authfail) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
-   sprintf(csort,"sort -b -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", TempDir, authfail_in, tmp4);
+   snprintf(csort,sizeof(csort),"sort -b -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", TempDir, authfail_in, tmp4);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=MY_FOPEN(authfail_in,"r"))==NULL) {
-      debuga(_("(authfail) Cannot open file: %s\n"),authfail_in);
+      debuga(_("(authfail) Cannot open file %s\n"),authfail_in);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlink(tmp4);
 
    if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
-     debuga(_("(authfail) Cannot open file: %s\n"),report);
-     exit(1);
+     debuga(_("(authfail) Cannot open file %s\n"),report);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures"));
@@ -113,45 +114,56 @@ void authfail_report(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read file %s\n"),authfail_in);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
       getword_start(&gwarea,buf);
-      if (getword(data,sizeof(data),&gwarea,'\t')<0 || getword(hora,sizeof(hora),&gwarea,'\t')<0 ||
-          getword(user,sizeof(user),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
-         debuga(_("There is a broken record or garbage in file %s\n"),authfail_in);
-         exit(1);
+      if (getword(data,sizeof(data),&gwarea,'\t')<0) {
+         debuga(_("There is a broken date in file %s\n"),authfail_in);
+         exit(EXIT_FAILURE);
+      }
+      if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
+         debuga(_("There is a broken time in file %s\n"),authfail_in);
+         exit(EXIT_FAILURE);
+      }
+      if (getword(user,sizeof(user),&gwarea,'\t')<0) {
+         debuga(_("There is a broken user ID in file %s\n"),authfail_in);
+         exit(EXIT_FAILURE);
+      }
+      if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
+         debuga(_("There is a broken IP address in file %s\n"),authfail_in);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("There is a broken url in file %s\n"),authfail_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       uinfo=userinfo_find_from_id(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),user,authfail_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
-      new_user=0;
-      if(!z) {
+      new_user=false;
+      if(z == 0) {
          strcpy(ouser,user);
          strcpy(oip,ip);
          z++;
-         new_user=1;
+         new_user=true;
       } else {
          if(strcmp(ouser,user) != 0) {
             strcpy(ouser,user);
-            new_user=1;
+            new_user=true;
          }
          if(strcmp(oip,ip) != 0) {
             strcpy(oip,ip);
-            new_user=1;
+            new_user=true;
          }
       }
 
-     if(AuthfailReportLimit) {
+     if(AuthfailReportLimit>0) {
         if(strcmp(ouser2,uinfo->label) == 0) {
             count++;
          } else {
index 03cfd41fd4ba0d400618913a2f8dff89c64b39c4..6eb11f794e720f25400867dbb469d45d76df1be8 100644 (file)
@@ -259,7 +259,7 @@ void balance_node(struct bt *node)
                        rotate_left(node);
                        break;
                default:
-                       exit(1);
+   exit(EXIT_FAILURE);
                        break;
 
        }
index 6418f93ca5e1fcf8533030fda0414e69460928ca..6a0c239e9edd0db9b2b948be55f01cccac5cf337 100644 (file)
@@ -75,7 +75,7 @@ AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h
                dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \
                ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
                errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \
-               execinfo.h ldap.h math.h libintl.h libgen.h)
+               execinfo.h ldap.h math.h libintl.h libgen.h stdbool.h)
 
 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD="yes", HAVE_GD="")
 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
index b750ef82a35d4dab4829b63135980cef3c613485..70dc6754775e649283245f5d7a8ecec1d11d14f7 100644 (file)
--- a/convlog.c
+++ b/convlog.c
@@ -45,14 +45,14 @@ void convlog(const char *arq, char *df, int dfrom, int duntil)
 
    if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
       fprintf(stderr, "SARG: (convlog) %s: %s\n",_("Cannot open log file"),arq);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       getword_start(&gwarea,buf);
       if (getword(data,sizeof(data),&gwarea,' ')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       tt=atoi(data);
       t=localtime(&tt);
index f32d32e0529cde82eacbb7c33a0239c5a9d19fc9..95b907a1e655328c2885bc29335cbb2941fc5ae5 100644 (file)
@@ -31,6 +31,7 @@ void dansguardian_log(void)
 {
 
    FILE *fp_in = NULL, *fp_ou = NULL, *fp_guard = NULL;
+   char buf[MAXLEN];
    char guard_in[MAXLEN];
    char guard_ou[MAXLEN];
    char loglocation[MAXLEN] = "/var/log/dansguardian/access.log";
@@ -77,22 +78,22 @@ void dansguardian_log(void)
       duntil=atoi(warea);
    }
 
-   sprintf(guard_in,"%s/dansguardian.unsort",tmp);
-   sprintf(guard_ou,"%s/dansguardian.log",tmp);
+   snprintf(guard_in,sizeof(guard_in),"%s/dansguardian.unsort",tmp);
+   snprintf(guard_ou,sizeof(guard_ou),"%s/dansguardian.log",tmp);
 
    if(access(DansGuardianConf, R_OK) != 0) {
       debuga(_("Cannot open DansGuardian config file: %s\n"),DansGuardianConf);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_guard=fopen(DansGuardianConf,"r"))==NULL) {
       debuga(_("(dansguardian) Cannot open log file: %s\n"),DansGuardianConf);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(guard_in,"a"))==NULL) {
       debuga(_("(dansguardian) Cannot open log file: %s\n"),guard_in);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_guard)!=NULL) {
@@ -103,7 +104,7 @@ void dansguardian_log(void)
          getword_start(&gwarea,buf);
          if (getword_skip(MAXLEN,&gwarea,'\'')<0 || getword(loglocation,sizeof(loglocation),&gwarea,'\'')<0) {
             debuga(_("Maybe you have a broken record or garbage in your %s file\n"),DansGuardianConf);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          break;
       }
@@ -114,7 +115,7 @@ void dansguardian_log(void)
 
    if((fp_in=MY_FOPEN(loglocation,"r"))==NULL) {
       debuga(_("(dansguardian) Cannot open log file: %s\n"),loglocation);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_in) != NULL) {
@@ -126,16 +127,16 @@ void dansguardian_log(void)
           getword(user,sizeof(user),&gwarea,' ')<0 || getword(ip,sizeof(ip),&gwarea,' ')<0 ||
           getword_skip(MAXLEN,&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,'/')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),loglocation);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,' ')<0) {
          debuga(_("Maybe you have a broken url in your %s file\n"),loglocation);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_skip(255,&gwarea,' ')<0 ||
           getword(code1,sizeof(code1),&gwarea,' ')<0 || getword(code2,sizeof(code2),&gwarea,' ')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),loglocation);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       sprintf(wdata,"%s%02d%s",year,atoi(mon),day);
       idata = atoi(wdata);
@@ -160,12 +161,12 @@ void dansguardian_log(void)
    if(debug)
       debuga(_("Sorting file: %s\n"),guard_ou);
 
-   sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
+   snprintf(tmp6,sizeof(tmp6),"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
    cstatus=system(tmp6);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),tmp6);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlink(guard_in);
 }
index 37a54df3b847412dfbf741b75577a925b773c331..cf8efa08dcd10028953c5479ad46b3ed45daf05f 100644 (file)
@@ -32,6 +32,7 @@ void dansguardian_report(void)
 
    FILE *fp_in = NULL, *fp_ou = NULL;
 
+   char buf[MAXLEN];
    char *url;
    char dansguardian_in[MAXLEN];
    char per[MAXLEN];
@@ -45,13 +46,14 @@ void dansguardian_report(void)
    char date[15];
    char date2[15];
    char hour[15];
+   char ouser2[255];
    int  z=0;
    int  count=0;
    struct getwordstruct gwarea;
 
    ouser[0]='\0';
 
-   sprintf(dansguardian_in,"%s/dansguardian.log",tmp);
+   snprintf(dansguardian_in,sizeof(dansguardian_in),"%s/dansguardian.log",tmp);
    if(!dansguardian_count) {
       unlink(dansguardian_in);
       return;
@@ -62,23 +64,23 @@ void dansguardian_report(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       fprintf(stderr, "SARG: (dansguardian_report) %s: %s\n",_("Cannot open file"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(dansguardian_report) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if((fp_in=MY_FOPEN(dansguardian_in,"r"))==NULL) {
      fprintf(stderr, "SARG: (dansguardian_report) %s: %s\n",_("Cannot open log file"),dansguardian_in);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
      fprintf(stderr, "SARG: (dansguardian_report) %s: %s\n",_("Cannot open log file"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DansGuardian"));
@@ -95,15 +97,15 @@ void dansguardian_report(void)
       if (getword(user,sizeof(user),&gwarea,'\t')<0 || getword(date2,sizeof(date2),&gwarea,'\t')<0 ||
           getword(hour,sizeof(hour),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),dansguardian_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken url in your %s file\n"),dansguardian_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(rule,sizeof(rule),&gwarea,'\n')<0) {
          debuga(_("Maybe you have a broken rule in your %s file\n"),dansguardian_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(UserIp)
index d0f6815edf6be27cdf745018d1917a2fee526650..082a4007c2948a0569099ff9f068cb251356728e 100644 (file)
@@ -104,17 +104,17 @@ void data_file(char *tmp)
 
       if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) {
          debuga(_("(datafile) directory path too long: %s/%s\n"),tmp,direntp->d_name);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
          debuga(_("(datafile) Cannot open file %s\n"),tmp3);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if (longline_prepare(&line)<0) {
          debuga(_("Not enough memory to read the downloaded files.\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       ttopen=0;
@@ -126,11 +126,11 @@ void data_file(char *tmp)
              getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
              getword(acccode,sizeof(acccode),&gwarea,'\t')<0 || getword_atoll(&accelap,&gwarea,'\t')<0) {
             debuga(_("There is a broken record or garbage in file %s\n"),tmp3);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
             debuga(_("There is an invalid smart info in file %s\n"),tmp3);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
 
          if(Ip2Name) {
@@ -149,7 +149,7 @@ void data_file(char *tmp)
                oldurl=realloc(oldurl,ourl_size);
                if (!oldurl) {
                   debuga(_("Not enough memory to store the url\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             strcpy(oldurl,accurl);
@@ -169,7 +169,7 @@ void data_file(char *tmp)
                strcpy(oldmsg,"OK");
             if(!fp_ou && (fp_ou=MY_FOPEN(DataFile,"w"))==NULL){
                debuga(_("(datafile) Cannot open file %s\n"),DataFile);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             saverecs(fp_ou,uinfo,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
             nacc=0;
@@ -198,7 +198,7 @@ void data_file(char *tmp)
                oldurl=realloc(oldurl,ourl_size);
                if (!oldurl) {
                   debuga(_("Not enough memory to store the url\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             strcpy(oldurl,accurl);
index 43cee57bcc27be51561ef6f72b6ee7e1e795e0b8..c28cca5f495f3dc63de2beae98439021594eb198 100644 (file)
--- a/decomp.c
+++ b/decomp.c
@@ -35,7 +35,7 @@ void decomp(char *arq, char *zip, const char *tmp)
 
    if(access(arq, R_OK) != 0) {
       debuga(_("File not found: %s\n"),arq);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    arqlen=strlen(arq);
@@ -43,13 +43,13 @@ void decomp(char *arq, char *zip, const char *tmp)
       debuga(_("Decompressing log file: %s > %s/sarg/sarg-file.in (zcat)\n"),arq,tmp);
       if (snprintf(cmd,sizeof(cmd),"zcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq,tmp)>=sizeof(cmd)) {
          debuga(_("decompression command too long for log file %s\n"),arq);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("command: %s\n"),cmd);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcpy(zip,"zcat");
       sprintf(arq,"%s/sarg/sarg-file.in",tmp);
@@ -60,13 +60,13 @@ void decomp(char *arq, char *zip, const char *tmp)
       debuga(_("Decompressing log file: %s > %s/sarg/sarg-file.in (bzcat)\n"),arq,tmp);
       if (snprintf(cmd,sizeof(cmd),"bzcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq,tmp)>=sizeof(cmd)) {
          debuga(_("decompression command too long for log file %s\n"),arq);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("command: %s\n"),cmd);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcpy(zip,"zcat");
       sprintf(arq,"%s/sarg/sarg-file.in",tmp);
@@ -77,13 +77,13 @@ void decomp(char *arq, char *zip, const char *tmp)
       debuga(_("Decompressing log file: %s (uncompress)\n"),arq);
       if (snprintf(cmd,sizeof(cmd),"zcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq,tmp)>=sizeof(cmd)) {
          debuga(_("decompression command too long for log file %s\n"),arq);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("command: %s\n"),cmd);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcpy(zip,"zcat");
       sprintf(arq,"%s/sarg/sarg-file.in",tmp);
@@ -101,7 +101,7 @@ void recomp(const char *arq, const char *zip)
 
    if(access(arq, R_OK) != 0) {
       debuga(_("File not found: %s\n"),arq);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((strcmp(zip,"gzip") != 0) &&
@@ -112,13 +112,13 @@ void recomp(const char *arq, const char *zip)
 
    if (snprintf(cmd,sizeof(cmd),"%s \"%s\"",zip,arq)>=sizeof(cmd)) {
       debuga(_("compression command too long for log file %s\n"),arq);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    cstatus=system(cmd);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("command: %s\n"),cmd);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    return;
 
index 0964ec36410d4a1283e8288a7695ab056d488f5d..aac0c062f5de7ffb84b979d4ea2d855fcdc71197 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -66,23 +66,23 @@ void gen_denied_report(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       debuga(_("(denied) Cannot open file %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(denied) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if((fp_in=MY_FOPEN(denied_in,"r"))==NULL) {
      debuga(_("(denied) Cannot open log file %s\n"),denied_in);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
      debuga(_("(denied) Cannot open log file %s\n"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DENIED"));
@@ -96,7 +96,7 @@ void gen_denied_report(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the denied accesses\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -104,17 +104,17 @@ void gen_denied_report(void)
       if (getword(data,sizeof(data),&gwarea,'\t')<0 || getword(hora,sizeof(hora),&gwarea,'\t')<0 ||
           getword(user,sizeof(user),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("There is a broken record or garbage in file %s\n"),denied_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("There is a broken url in file %s\n"),denied_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       uinfo=userinfo_find_from_id(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),user,denied_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       new_user=0;
index a1774a5b12093c16eaf510618858572d9948a325..5a4ed044a33bf4e9fd80a1f55607a4e1720572ee 100644 (file)
@@ -41,7 +41,7 @@ Restart the getword buffer from the beginning.
 
 
 
-/*! \fn int getword(char *word, int limit, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
 
 Extract one "word" from the text line and remove it from the text line. The word's boundary is defined
 by the \a stop character. If multiple stop characters are found after the word, only the first one is
@@ -63,7 +63,7 @@ the function displays an error message and returns an error code.
 
 
 
-/*! \fn int getword_limit(char *word, int limit, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword_limit(char *word, int limit, struct getwordstruct *gwarea, char stop)
 Extract one word with a maximum size and skip any supernumerary bytes until the stop bytes is
 found.
 
@@ -79,7 +79,7 @@ found.
 
 
 
-/*! \fn int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, char stop)
 
 Extract one "word" from the text line and remove it from the text line. The word's boundary is defined
 by the \a stop character. All the stop characters following the word are removed too. Therefore, passing
@@ -100,7 +100,7 @@ the function displays an error message and returns an error code.
 
 
 
-/*! \fn int getword_skip(int limit, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword_skip(int limit, struct getwordstruct *gwarea, char stop)
 Skip one "word" from the text line and remove it from the text line. The word's boundary is defined
 by the \a stop character.
 
@@ -117,7 +117,7 @@ the function displays an error message and returns an error code.
 
 
 
-/*! \fn int getword_atoll(long long int *number, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop)
 Extract one number from the text line.
 
 \param number Where the store the extracted number.
@@ -131,7 +131,7 @@ Extract one number from the text line.
 
 
 
-/*! \fn int getword_ptr(char *orig_line,char **word, struct getwordstruct *gwarea, int stop)
+/*! \fn int getword_ptr(char *orig_line,char **word, struct getwordstruct *gwarea, char stop)
 Return a pointer to a null terminated string starting at the current position and ending
 and the stop character.
 
index b2c61662ae68cd184291b7c687003f7145bcb28a..6f550b50a26e553e65fa979d2d528fc75c14aa60 100644 (file)
@@ -71,23 +71,23 @@ void download_report(void)
 
    if ((fp_in = fopen(wdirname, "r")) == 0) {
       debuga(_("(download) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(download) read error in %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if((fp_in=MY_FOPEN(report_in,"r"))==NULL) {
       debuga(_("(download) Cannot open log file %s\n"),report_in);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
       debuga(_("(download) Cannot open log file %s\n"),report);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Downloads"));
@@ -101,7 +101,7 @@ void download_report(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the downloaded files\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -109,17 +109,17 @@ void download_report(void)
       if (getword(data,sizeof(data),&gwarea,'\t')<0 || getword(hora,sizeof(hora),&gwarea,'\t')<0 ||
           getword(user,sizeof(user),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("There is a broken record or garbage in file %s\n"),report_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("There is a broken url in file %s\n"),report_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       uinfo=userinfo_find_from_id(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),user,report_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       new_user=0;
       if(!z) {
@@ -204,7 +204,7 @@ void set_download_suffix(const char *list)
    DownloadSuffix=strdup(list);
    if (!DownloadSuffix) {
       debuga(_("Download suffix list too long\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    j = 1;
    for (i=0 ; list[i] ; i++)
@@ -212,7 +212,7 @@ void set_download_suffix(const char *list)
    DownloadSuffixIndex=malloc(j*sizeof(char *));
    if (!DownloadSuffixIndex) {
       debuga(_("Too many download suffixes\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    str = DownloadSuffix;
diff --git a/email.c b/email.c
index 7f376b110c391d16fbcdb87a8d64e74992a211b1..c9c37d8c72ae21695912addbb04a0d524ae6d602 100644 (file)
--- a/email.c
+++ b/email.c
@@ -40,6 +40,7 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
    char olduser[MAX_USER_LEN], csort[MAXLEN], period[MAXLEN], arqper[MAXLEN];
    char wger[MAXLEN], top1[MAXLEN], top2[MAXLEN], top3[MAXLEN], user[MAX_USER_LEN], tusr[MAXLEN];
    char strip1[MAXLEN], strip2[MAXLEN], strip3[MAXLEN], strip4[MAXLEN], strip5[MAXLEN], strip6[MAXLEN], strip7[MAXLEN];
+   char buf[MAXLEN];
    int totuser=0;
    time_t t;
    struct tm *local;
@@ -61,17 +62,17 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
 
    if((fp_in=fopen(wger,"r"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),wger);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_top1=fopen(top1,"w"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_top2=fopen(top2,"w"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top2);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    olduser[0]='\0';
@@ -128,14 +129,14 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(top2);
 
    if((fp_top1=fopen(top1,"a"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 #if defined(__FreeBSD__)
    fprintf(fp_top1,"TOTAL\t%qu\t%qu\t%qu\n",ttnbytes,ttnacc,ttnelap);
@@ -155,23 +156,23 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
 
    if ((fp_in = fopen(arqper, "r")) == 0){
       debuga(_("(email) Cannot open file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(email) read error in %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if((fp_top1=fopen(top1,"r"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_top3=fopen(top3,"w"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top3);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    strcpy(strip1,_("Squid User Access Report"));
@@ -208,19 +209,19 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
       getword_start(&gwarea,warea);
       if (getword(user,sizeof(user),&gwarea,'\t')<0) {
          debuga(_("There is an invalid user ID in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
          debuga(_("There is an invalid number of bytes in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&nacc,&gwarea,'\t')<0) {
          debuga(_("There is an invalid number of access in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&elap,&gwarea,'\t')<0) {
          debuga(_("There is an invalid elapsed time in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       perc=(ttnbytes) ? nbytes * 100. / ttnbytes : 0;
@@ -272,24 +273,24 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
    if(strcmp(email,"stdout") == 0) {
       if((fp_top3=fopen(top3,"r"))==NULL) {
          debuga(_("(email) Cannot open file %s\n"),top3);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       while(fgets(buf,sizeof(buf),fp_top3)!=NULL)
          fputs(buf,stdout);
     } else {
-      sprintf(buf,"\"%s\" -s \"SARG %s, %s\" \"%s\" <\"%s\"",MailUtility,_("Report"),asctime(local),email,top3);
+      snprintf(buf,sizeof(buf),"\"%s\" -s \"SARG %s, %s\" \"%s\" <\"%s\"",MailUtility,_("Report"),asctime(local),email,top3);
       cstatus=system(buf);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("command: %s\n"),buf);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
     }
 
    if (snprintf(warea,sizeof(warea),"%s/sarg",TempDir)>=sizeof(warea)) {
       debuga(_("Temporary directory name too long: %s\n"),warea);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlinkdir(warea,0);
 
index f9da18a3d95988e2e4d15d12f74b9f0f8841b4b2..2b3602e90eff3f8890c795d9605d7547999a629a 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -63,7 +63,7 @@ static void store_exclude_ip4(unsigned short int *addr,int mask)
       temp=realloc(exclude_ip4,ip4allocated*sizeof(*temp));
       if (temp==NULL) {
          debuga(_("Not enough memory to store the exlcluded IP addresses\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       exclude_ip4=temp;
    }
@@ -108,7 +108,7 @@ static void store_exclude_url(char *url,int length)
       temp=realloc(exclude_name,nameallocated*sizeof(*temp));
       if (temp==NULL) {
          debuga(_("Not enough memory to store the excluded URLs\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       exclude_name=temp;
    }
@@ -118,7 +118,7 @@ static void store_exclude_url(char *url,int length)
    item->url=malloc(length+1);
    if (!item->url) {
       debuga(_("Not enough memory to store the excluded URLs\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    strncpy(item->url,url,length);
    item->url[length]='\0';
@@ -140,14 +140,14 @@ void gethexclude(const char *hexfile, int debug)
 
    if(access(hexfile, R_OK) != 0) {
       debuga(_("Cannot open exclude_hosts file: %s - %s\n"),hexfile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if(debug)
       debuga(_("Loading exclude file from: %s\n"),hexfile);
 
    if ((fp_ex = fopen(hexfile, "r")) == NULL) {
       debuga(_("(gethexclude) Cannot open file %s - %s\n"),hexfile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_ex)!=NULL){
@@ -209,7 +209,7 @@ void gethexclude(const char *hexfile, int debug)
             store_exclude_ip4(addr,mask);
          else {
             debuga(_("IPv6 addresses are not supported (found in %s)\n"),hexfile);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       } else {
          store_exclude_url(buf,i);
@@ -324,21 +324,21 @@ void getuexclude(const char *uexfile, int debug)
 
    if ((fp_ex = fopen(uexfile, "r")) == NULL) {
       debuga(_("(gethexclude) Cannot open file %s - %s\n"),uexfile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fseek(fp_ex, 0, SEEK_END);
    nreg = ftell(fp_ex);
    if (nreg<0) {
       debuga(_("Cannot get the size of file %s\n"),uexfile);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    nreg += 11;
    fseek(fp_ex, 0, SEEK_SET);
 
    if((excludeuser=(char *) malloc(nreg))==NULL){
       debuga(_("malloc error (%ld bytes required)\n"),nreg);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    bzero(excludeuser,nreg);
index 960fe13cee2f47333b216aaa1d0004d9d29ed195..06783667504566d8ccefb2099184126c707502d8 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -153,7 +153,7 @@ static int getparam_string(const char *param,char *buf,char *value,int value_siz
 
    if (strlen(buf)>=value_size) {
       debuga(_("The string value of parameter \"%s\" is too long\n"),param);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    strcpy(value,buf);
    fixnone(value);
@@ -173,7 +173,7 @@ static int getparam_quoted(const char *param,char *buf,char *value,int value_siz
 
    if (*buf != '\"') {
       debuga(_("Missing double quote after parameter \"%s\"\n"),param);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    buf++;
 
@@ -185,7 +185,7 @@ static int getparam_quoted(const char *param,char *buf,char *value,int value_siz
 
    if (*buf != '\"') {
       debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fixnone(value);
    return(1);
@@ -206,11 +206,11 @@ static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz
       word1[i]=*buf++;
    if (i>=word1_size) {
       debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (*buf!=' ') {
       debuga(_("Missing second word for parameter \"%s\"\n"),param);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    word1[i]=0;
 
@@ -220,7 +220,7 @@ static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz
       word2[i]=*buf++;
    if (i>=word2_size) {
       debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    word2[i]=0;
 
@@ -243,12 +243,12 @@ static int getparam_int(const char *param,char *buf,int *value)
    next=0;
    if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
       debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    return(1);
 }
 
-static int getparam_bool(const char *param,char *buf,int *value)
+static int getparam_bool(const char *param,char *buf,bool *value)
 {
    int plen;
    int i;
@@ -260,11 +260,11 @@ static int getparam_bool(const char *param,char *buf,int *value)
    if ((unsigned char)*buf>' ') return(0);
    while (*buf && (unsigned char)*buf<=' ') buf++;
 
-   *value=0;
+   *value=false;
    for ( ; *bool_str ; bool_str+=i) {
       for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
       if (strncasecmp(bool_str,buf,i)==0) {
-         *value=1;
+         *value=true;
          break;
       }
       if (bool_str[i]==',') i++;
@@ -295,11 +295,11 @@ static int getparam_list(const char *param,struct param_list *options,int noptio
       for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
       if (i>=noptions) {
          debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if ((*value & options[i].exclude)!=0) {
          debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *value|=options[i].value;
       buf=str;
@@ -366,7 +366,7 @@ static void parmtest(char *buf)
       getword_start(&gwarea,buf);
       if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
          debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strncpy(DateFormat,gwarea.current,1);
       fixnone(DateFormat);
@@ -395,7 +395,7 @@ static void parmtest(char *buf)
       if (AccessLogFromCmdLine==0) {
          if (NAccessLog>=MAXLOGS) {
             debuga(_("Too many log files in configuration file\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          getparam_string("access_log",buf,AccessLog[NAccessLog],MAXLEN);
          NAccessLog++;
@@ -535,14 +535,14 @@ static void parmtest(char *buf)
       if (is_absolute(wbuf)) {
          if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
             debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          strcpy(AuthUserTemplateFile,wbuf);
       } else {
          strcpy(dir,ConfigFile);
          if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
             debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
       return;
@@ -605,12 +605,12 @@ static void parmtest(char *buf)
       getword_start(&gwarea,buf);
       if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
          debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       cost=atol(gwarea.current);
       if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
          debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       nocost=my_atoll(gwarea.current);
       return;
@@ -630,7 +630,7 @@ void getconf(void)
 
    if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
       debuga(_("(getconf) Cannot open file %s\n"),ConfigFile);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while (fgets(buf, sizeof(buf), fp_in) != NULL) {
index 6212292cd334a2228341b562fa39fe579a6c8961..ede95390c82b2994191285c1c074c1655746c333 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -56,7 +56,7 @@ static char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontl
    sstring = (char *)malloc(sslen);
    if (!sstring) {
       debuga(_("malloc error (%zu bytes required)\n"),sslen);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    str = (char *) string;
@@ -267,7 +267,7 @@ void greport_day(const struct userinfostruct *uinfo)
    }
    if(access(GraphFont, R_OK) != 0) {
       debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    im = gdImageCreate(720, 480);
@@ -389,15 +389,15 @@ void greport_day(const struct userinfostruct *uinfo)
 
    if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",outdirname,uinfo->filename)>=sizeof(graph)) {
       debuga(_("user name too long for %s/%s/graph_day.png\n"),outdirname,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename)>=sizeof(wdirname)) {
       debuga(_("user name too long for %s/%s.day\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (snprintf(tmp5,sizeof(tmp5),"%s/%s.graph",tmp,uinfo->filename)>=sizeof(tmp5)) {
       debuga(_("user name too long for %s/%s.graph\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if(access(wdirname, R_OK) != 0) {
@@ -414,17 +414,17 @@ void greport_day(const struct userinfostruct *uinfo)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_in=fopen(tmp5,"r"))==NULL) {
       debuga(_("(grepday) Cannot open log file %s\n"),tmp5);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((pngout=fopen(graph,"wb"))==NULL) {
       debuga(_("(grepday) Cannot open log file %s\n"),graph);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
@@ -432,17 +432,17 @@ void greport_day(const struct userinfostruct *uinfo)
       getword_start(&gwarea,buf);
       if (getword(data,sizeof(data),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       getword_start(&gwarea1,data);
       if (getword_atoll(&llday,&gwarea1,'/')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strcmp(DateFormat,"u") == 0) {
          if (getword_atoll(&llday,&gwarea1,'/')<0) {
             debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
       day=(int)llday;
@@ -452,7 +452,7 @@ void greport_day(const struct userinfostruct *uinfo)
       }
       if (getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(oday!=day) {
diff --git a/html.c b/html.c
index 5e06987ff9f9958c254d4e119c284c7192257278..5ab1ab4a6673a4df3e3e708d8e6a5182651d1106 100644 (file)
--- a/html.c
+++ b/html.c
@@ -75,22 +75,22 @@ void htmlrel(void)
    snprintf(arqper,sizeof(arqper),"%s/sarg-period",outdirname);
    if ((fp_in = fopen(arqper, "r")) == 0){
       debuga(_("(html1) Cannot open file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(html1) read error in %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    snprintf(arqper,sizeof(arqper),"%s/sarg-general",outdirname);
    if ((fp_in = fopen(arqper, "r")) == 0){
       debuga(_("(html2) Cannot open file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    ttnacc=0;
    totbytes=0;
@@ -109,11 +109,11 @@ void htmlrel(void)
    snprintf(arqper,sizeof(arqper),"%s/sarg-users",outdirname);
    if ((fp_in = fopen(arqper, "r")) == 0){
       debuga(_("(html11) Cannot open file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (!fgets(totuser,sizeof(totuser),fp_in)) {
       debuga(_("(html11) read error in %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
    ntotuser=my_atoll(totuser);
@@ -138,7 +138,7 @@ void htmlrel(void)
       uinfo=userinfo_find_from_file(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in directory %s\n"),user,tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       str=strrchr(user,'.');
       if (str)
@@ -148,7 +148,7 @@ void htmlrel(void)
 
       if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,user)>=sizeof(warea)) {
          debuga(_("Destination directory too long: %s/%s\n"),outdirname,user);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       mkdir(warea,0755);
 
@@ -157,27 +157,27 @@ void htmlrel(void)
 
       if (snprintf(arqin,sizeof(arqin),"%s/%s",tmp,direntp->d_name)>=sizeof(arqin)) {
          debuga(_("Input file name too long: %s/%s\n"),tmp,direntp->d_name);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (snprintf(arqou,sizeof(arqou),"%s/%s/%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqou)) {
          debuga(_("Output file name too long: %s/%s/%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (snprintf(duser,sizeof(duser),"%s/%s/denied_%s.html",tmp,direntp->d_name,denied_report)>=sizeof(duser)) {
          debuga(_("File name too long: %s/%s/denied_%s.html\n"),tmp,direntp->d_name,denied_report);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(access(duser, R_OK) != 0)
          denied_report[0]='\0';
 
       if ((fp_in = fopen(arqin, "r")) == 0){
          debuga(_("(html3) Cannot open file %s\n"),arqin);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if (longline_prepare(&line)<0) {
          debuga(_("Not enough memory to read file %s\n"),arqin);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       tnacc=0;
@@ -189,35 +189,35 @@ void htmlrel(void)
          getword_start(&gwarea,buf);
          if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
             debuga(_("There is a broken number of access in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          tnacc+=ltemp;
          if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
             debuga(_("There is a broken downloaded size in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          tnbytes+=ltemp;
          if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
             debuga(_("There is a broken url in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_skip(MAXLEN,&gwarea,'\t')<0) {
             debuga(_("There is a broken access code in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
             debuga(_("There is a broken elapsed time in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          tnelap+=ltemp;
          if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
             debuga(_("There is a broken in-cache volume in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          tnincache+=ltemp;
          if (getword_atoll(&ltemp,&gwarea,'\n')<0) {
             debuga(_("There is a broken out-cache volume in file %s\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          tnoucache+=ltemp;
       }
@@ -226,7 +226,7 @@ void htmlrel(void)
 
       if ((fp_ou = fopen(arqou, "w")) == 0){
          debuga(_("(html5) Cannot open file %s\n"),arqou);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("User report"));
@@ -270,31 +270,31 @@ void htmlrel(void)
          getword_start(&gwarea,buf);
          if (getword_atoll(&twork,&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken number of access in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_atoll(&nnbytes,&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken number of bytes in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken url in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword(tmsg,sizeof(tmsg),&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken status in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_atoll(&nnelap,&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken elapsed time in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_atoll(&incache,&gwarea,'\t')<0) {
             debuga(_("Maybe you have a broken in cache column in your %s file\n"),arqin);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_atoll(&oucache,&gwarea,'\n')<0) {
             debuga(_("Maybe you have a broken not in cache column in your %s file (%d)\n"),arqin,__LINE__);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
 
          if(UserReportLimit<=0 || count<=UserReportLimit) {
@@ -364,22 +364,22 @@ void htmlrel(void)
          if(iprel) {
             if (snprintf(arqip,sizeof(arqip),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(arqip)) {
                debuga(_("File name too long: %s/%s.ip\n"),tmp,uinfo->filename);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             if ((fp_ip = fopen(arqip, "r")) == 0){
                debuga(_("(html6) Cannot open file %s\n"),arqip);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             if ((fp_ip2 = MY_FOPEN(tmp2, "a")) == 0){
                debuga(_("(html7) Cannot open file %s\n"),tmp2);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             if (longline_prepare(&line1)<0) {
                debuga(_("Not enough memory to read file %s\n"),arqip);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             while((buf=longline_read(fp_ip,&line1))!=NULL) {
                if(strstr(buf,url) != 0)
@@ -395,45 +395,45 @@ void htmlrel(void)
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
                debuga(_("sort command: %s\n"),csort);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             if ((fp_ip = MY_FOPEN(tmp3, "r")) == 0) {
                debuga(_("(html8) Cannot open file %s\n"),tmp3);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             olduserip[0]='\0';
 
             if (longline_prepare(&line1)<0) {
                debuga(_("Not enough memory to read file %s\n"),arqip);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             while((buf=longline_read(fp_ip,&line1))!=NULL) {
                getword_start(&gwarea,buf);
                if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken url in your %s file\n"),tmp3);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(userdia,sizeof(userdia),&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken day in your %s file\n"),tmp3);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(userhora,sizeof(userhora),&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword_atoll(&userelap,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken elapsed time in your %s file (%d)\n"),tmp3,__LINE__);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if(strcmp(user_ip,olduserip) != 0) {
                   sprintf(wwork1,"%s",fixnum(unbytes,1));
@@ -503,7 +503,7 @@ void htmlrel(void)
             if(access(PerUserLimitFile, R_OK) == 0) {
                if((fp_usr = fopen(PerUserLimitFile, "r")) == 0) {
                   fprintf(stderr, "SARG: (html9) %s: %s\n",_("Cannot open file"),PerUserLimitFile);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                while(fgets(tmp6,sizeof(tmp6),fp_usr)!=NULL) {
                   fixendofline(tmp6);
@@ -518,7 +518,7 @@ void htmlrel(void)
             if(!limit_flag) {
                if((fp_usr = fopen(PerUserLimitFile, "a")) == 0) {
                   debuga(_("(html10) Cannot open file %s\n"),PerUserLimitFile);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                fprintf(fp_usr,"%s\n",uinfo->label);
                fclose(fp_usr);
index 2fb7a958385392e78a289b2cb28b4f3920cd8aed..df6a91215831b18cb049bad80a9c7d7f5ccf0b08 100755 (executable)
@@ -64,7 +64,6 @@
 #endif
 #ifdef HAVE_GD_H
 #include <gd.h>
-#define HAVE_GD
 gdImagePtr im;
 gdPoint points[4];
 #endif
@@ -107,6 +106,13 @@ gdPoint points[4];
 #ifdef HAVE_LIBGEN_H
 #include <libgen.h>
 #endif
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else
+typedef int bool;
+#define true 1
+#define false 0
+#endif
 
 #if defined(HAVE_FOPEN64)
 #define _FILE_OFFSET_BITS 64
@@ -135,6 +141,7 @@ int mkstemps(char *template, int suffixlen);
 #else /* No NLS */
 #define _(String) (String)
 #define N_(String) (String)
+#define ngettext(String,Strings,num) (Strings)
 #define textdomain(String)
 #define bindtextdomain(Domain,Directory)
 #endif //NLS
@@ -223,7 +230,6 @@ int mkstemps(char *template, int suffixlen);
 
 char outdir[MAXLEN];
 char outdirname[MAXLEN];
-char buf[MAXLEN];
 char period[MAXLEN];
 char code[MAXLEN];
 char code2[MAXLEN];
@@ -236,12 +242,12 @@ char df[20];
 char cdfrom[30];
 char cduntil[30];
 int LastLog;
-int RemoveTempFiles;
+bool RemoveTempFiles;
 char ReplaceIndex[256];
 unsigned long int Index;
-int OverwriteReport;
+bool OverwriteReport;
 unsigned long int RecordsWithoutUser;
-int UseComma;
+bool UseComma;
 char MailUtility[PATH_MAX];
 int TopSitesNum;
 int TopUsersNum;
@@ -252,8 +258,8 @@ unsigned long int ReportType;
 char UserTabFile[255];
 char warea[MAXLEN];
 char name[MAXLEN];
-int LongUrl;
-int Ip2Name;
+bool LongUrl;
+bool Ip2Name;
 int NAccessLog;
 char AccessLog[MAXLOGS][MAXLEN];
 int AccessLogFromCmdLine;
@@ -287,37 +293,37 @@ char ExcludeUsers[255];
 char DateFormat[2];
 char PerUserLimitFile[255];
 int PerUserLimit;
-int UserIp;
+bool UserIp;
 char MaxElapsed[255];
 char datetimeby[10];
 char CharSet[255];
 char UserInvalidChar[255];
-int Graphs;
+bool Graphs;
 char GraphDaysBytesBarColor[255];
-int Privacy;
+bool Privacy;
 char PrivacyString[255];
 char PrivacyStringColor[30];
 char IncludeUsers[MAXLEN];
 char ExcludeString[MAXLEN];
-int SuccessfulMsg;
+bool SuccessfulMsg;
 unsigned long int TopUserFields;
 unsigned long int UserReportFields;
 char DataFile[MAXLEN];
 char DataFileDelimiter[3];
 unsigned long int DataFileFields;
 unsigned long int DataFileUrl;
-int ShowReadStatistics;
+bool ShowReadStatistics;
 char IndexSortOrder[5];
 char DansGuardianConf[MAXLEN];
-int DansguardianIgnoreDate;
+bool DansguardianIgnoreDate;
 char SquidGuardConf[MAXLEN];
 char SquidGuarddbHome[255];
 char SquidGuardLogFormat[MAXLEN];
 char SquidGuardLogAlternate[MAXLEN];
-int SquidguardIgnoreDate;
-int ShowSargInfo;
-int BytesInSitesUsersReport;
-int ShowSargLogo;
+bool SquidguardIgnoreDate;
+bool ShowSargInfo;
+bool BytesInSitesUsersReport;
+bool ShowSargLogo;
 char ParsedOutputLog[MAXLEN];
 char ParsedOutputLogCompress[512];
 char DisplayedValues[20];
@@ -328,7 +334,7 @@ char ExternalCSSFile[MAXLEN];
 char BlockIt[255];
 unsigned long int NtlmUserFormat;
 unsigned long int IndexTree;
-int UserAuthentication;
+bool UserAuthentication;
 char AuthUserTemplateFile[1024];
 char *str;
 char *str2;
@@ -351,7 +357,6 @@ char site[MAXLEN];
 char us[50];
 char email[MAXLEN];
 char test[1];
-char ouser2[255];
 char user2[MAXLEN];
 char wentp[512];
 char addr[MAXLEN];
@@ -360,7 +365,6 @@ char RealtimeTypes[1024];
 char cmd[255];
 char ImageFile[255];
 char tbuf[128];
-char ip[25];
 char RealtimeUnauthRec[15];
 char LDAPHost[255];
 char LDAPBindDN[512];
index 91fbbd59cfbe400bff52d3ff09acca02e3f8648b..d8b132d0bcb1e1d873bd52f35410529a5354c847 100644 (file)
@@ -46,6 +46,7 @@
 #cmakedefine HAVE_EXECINFO_H
 #cmakedefine HAVE_LIBINTL_H
 #cmakedefine HAVE_LIBGEN_H
+#cmakedefine HAVE_STDBOOL_H
 
 #cmakedefine IBERTY_LIB
 
index 10226e9b4f04e63f1360950e71265358d33fec81..b725c371e16c35bcfab8d09f1376cd9f0d335b17 100755 (executable)
@@ -192,14 +192,14 @@ void user_find(char *mappedname, int namelen, const char *userlogin);
 void close_usertab(void);
 
 // util.c
-void getword_start(struct getwordstruct *gwarea, const char *line);
+void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line);
 void getword_restart(struct getwordstruct *gwarea);
-int getword(char *word, int limit, struct getwordstruct *gwarea, int stop);
-int getword_limit(char *word, int limit, struct getwordstruct *gwarea, int stop);
-int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, int stop);
-int getword_skip(int limit, struct getwordstruct *gwarea, int stop);
-int getword_atoll(long long int *number, struct getwordstruct *gwarea, int stop);
-int getword_ptr(char *orig_line,char **word, struct getwordstruct *gwarea, int stop);
+int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
+int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
+int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
+int getword_skip(int limit, struct getwordstruct *gwarea, char stop);
+int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop);
+int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop);
 long long int my_atoll (const char *nptr);
 int is_absolute(const char *path);
 int getnumlist(char *, numlist *, const int, const int);
@@ -253,6 +253,6 @@ void baddata(void);
 char *get_param_value(const char *param,char *line);
 int compar( const void *, const void * );
 void unlinkdir(const char *dir,int contentonly);
-int longline_prepare(struct longlinestruct *line);
+int longline_prepare(/*@out@*/struct longlinestruct *line);
 char *longline_read(FILE *fp_in,struct longlinestruct *line);
 void longline_free(struct longlinestruct *line);
diff --git a/index.c b/index.c
index 887bdfc60cae5e331c877ee18a500b6c2b6c5854..092a7c6b3e7eb7e72521c1a41bc0d4a5df6f9e73 100644 (file)
--- a/index.c
+++ b/index.c
@@ -124,13 +124,13 @@ static void make_date_index(void)
          nyears++;
       }
    }
-   (void)closedir( dirp );
+   closedir( dirp );
 
    order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1;
 
    if((fp_ou=fopen(yearindex,"w"))==NULL) {
       debuga(_("(index) Cannot open file %s - %s\n"),yearindex,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nyears));
    close_html_header(fp_ou);
@@ -169,11 +169,11 @@ static void make_date_index(void)
          monthsort[i]=month;
          nmonths++;
       }
-      (void)closedir(dirp2);
+      closedir(dirp2);
       sprintf(monthindex,"%s/index.html",yeardir);
       if((fp_ou2=fopen(monthindex,"w"))==NULL) {
          debuga(_("(index) Cannot open file %s - %s\n"),monthindex,strerror(errno));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       snprintf(title,sizeof(title),ngettext("SARG: report for %04d","SARG: reports for %04d",nmonths),year);
       write_html_header(fp_ou2,1,title);
@@ -227,11 +227,11 @@ static void make_date_index(void)
             daysort[i]=day;
             ndays++;
          }
-         (void)closedir(dirp3);
+         closedir(dirp3);
          sprintf(dayindex,"%s/index.html",monthdir);
          if((fp_ou3=fopen(dayindex,"w"))==NULL) {
             debuga(_("(index) Cannot open file %s - %s\n"),dayindex,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          snprintf(title,sizeof(title),ngettext("SARG: report for %04d/%02d","SARG: reports for %04d/%02d",ndays),year,month);
          write_html_header(fp_ou3,2,title);
@@ -311,7 +311,7 @@ static void make_file_index(void)
       item=malloc(sizeof(*item));
       if (!item) {
          debuga(_("not enough memory to sort the index\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strcmp(df,"u") == 0) {
          strncpy(item->sortname,direntp->d_name,4);
@@ -337,29 +337,29 @@ static void make_file_index(void)
          getword_start(&gwarea,data);
          if (getword_skip(16,&gwarea,' ')<0) {
             debuga(_("Maybe you have a broken week day in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_multisep(mon,sizeof(mon),&gwarea,' ')<0) {
             debuga(_("Maybe you have a broken month in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_multisep(day,sizeof(day),&gwarea,' ')<0) {
             debuga(_("Maybe you have a broken day in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_multisep(hour,sizeof(hour),&gwarea,' ')<0) {
             debuga(_("Maybe you have a broken time in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          do {
             if (getword_multisep(year,sizeof(year),&gwarea,' ')<0) {
                debuga(_("Maybe you have a broken year in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          } while (year[0] && !isdigit(year[0])); //skip time zone information with spaces until the year is found
          if (sscanf(hour,"%d:%d:%d",&ihour,&iminute,&isecond)!=3) {
             debuga(_("Maybe you have a broken time in your %s%s/sarg-date file\n"),outdir,direntp->d_name);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          buildymd(day,mon,year,ftime);
          snprintf(item->creationdate,sizeof(item->creationdate),"%s%02d%02d%02d",ftime, ihour, iminute, isecond);
@@ -371,7 +371,7 @@ static void make_file_index(void)
          tempsort=realloc(sortlist,nallocated*sizeof(*item));
          if (!tempsort) {
             debuga(_("not enough memory to sort the index\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          sortlist=tempsort;
       }
@@ -387,11 +387,11 @@ static void make_file_index(void)
       nsort++;
    }
 
-   (void)closedir( dirp );
+   closedir( dirp );
 
    if((fp_ou=fopen(wdir,"w"))==NULL) {
       debuga(_("(index) Cannot open file %s\n"),wdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nsort));
    close_html_header(fp_ou);
@@ -500,7 +500,7 @@ static void file_index_to_date_index(const char *entry)
    sprintf(olddir,"%s%s",outdir,entry);
    if (rename(olddir,newdir)) {
       debuga(_("(index) rename error from \"%s\" to \"%s\" - %s\n"),olddir,newdir,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    strcpy(newdir+monthlen,"/images");
@@ -511,7 +511,7 @@ static void file_index_to_date_index(const char *entry)
       sprintf(linkdir,"%simages",outdir);
       if (symlink(linkdir,newdir)) {
          debuga(_("failed to create link \"%s\" to \"%s\" - %s\n"),linkdir,newdir,strerror(errno));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 #else
       char cmd[MAXLEN];
@@ -522,7 +522,7 @@ static void file_index_to_date_index(const char *entry)
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("command: %s\n"),cmd);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 #endif
    }
@@ -601,12 +601,12 @@ static void date_index_to_file_index(const char *entry)
          sprintf(olddir,"%s%04d/%s/%s",outdir,y1,direntp2->d_name,direntp3->d_name);
          if(rename(olddir,newdir)) {
             debuga(_("(index) rename error from \"%s\" to \"%s\" - %s\n"),olddir,newdir,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
-      (void)closedir( dirp3 );
+      closedir( dirp3 );
    }
-   (void)closedir( dirp2 );
+   closedir( dirp2 );
 
    /*!
    \bug The links to the images in the reports are broken after moving the directories
index 92be758de2db685acc40637dceded90ba2e19864..ffeaa63cc13b0a076417f5c50cfc230e45de21f9 100644 (file)
--- a/ip2name.c
+++ b/ip2name.c
@@ -99,7 +99,7 @@ void name2ip(char *name)
    if (getword(n4,sizeof(n4),&gwarea,'.')<0 || getword(n3,sizeof(n3),&gwarea,'.')<0 ||
          getword(n2,sizeof(n2),&gwarea,'.')<0 || getword(n1,sizeof(n1),&gwarea,0)<0) {
       printf("SARG: Maybe you have a broken record or garbage in your %s ip address.\n",gwarea.beginning);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    sprintf(name,"%s.%s.%s.%s",n1,n2,n3,n4);
 
index 730c5274f36523659a645ae452e0524ad1eb5abf..87dcedd834127605cc9bcd23ed43826e60f082e4 100644 (file)
--- a/lastlog.c
+++ b/lastlog.c
@@ -33,6 +33,7 @@ void mklastlog(const char *outdir)
    FILE *fp_in, *fp_ou;
    DIR *dirp;
    struct dirent *direntp;
+   char buf[MAXLEN];
    char temp[MAXLEN];
    char warea[MAXLEN];
    char ftime[128];
@@ -49,7 +50,7 @@ void mklastlog(const char *outdir)
    sprintf(temp,"%slastlog1",outdir);
    if((fp_ou=fopen(temp,"w"))==NULL) {
      debuga(_("(lastlog) Cannot open temporary file %s\n"),temp);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    dirp = opendir(outdir);
@@ -66,15 +67,15 @@ void mklastlog(const char *outdir)
       ftot++;
    }
 
-   (void)closedir( dirp );
+   closedir( dirp );
    fclose(fp_ou);
 
-   sprintf(buf,"sort -n -k 1,1 -o \"%slastlog\" \"%s\"",outdir,temp);
+   snprintf(buf,sizeof(buf),"sort -n -k 1,1 -o \"%slastlog\" \"%s\"",outdir,temp);
    cstatus=system(buf);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),buf);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(temp);
@@ -91,7 +92,7 @@ void mklastlog(const char *outdir)
    sprintf(temp,"%slastlog",outdir);
    if((fp_in=fopen(temp,"r"))==NULL) {
      debuga(_("(lastlog) Cannot open temporary file %s\n"),temp);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    while(ftot>0 && fgets(buf,sizeof(buf),fp_in)!=NULL) {
@@ -99,14 +100,14 @@ void mklastlog(const char *outdir)
       getword_start(&gwarea,buf);
       if (getword(warea,sizeof(warea),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),temp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(debug)
          debuga(_("Removing old report file %s\n"),gwarea.current);
       if (snprintf(temp,sizeof(temp),"%s%s",outdir,gwarea.current)>=sizeof(temp)) {
          debuga(_("Directory name too long: %s%s\n"),outdir,gwarea.current);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       unlinkdir(temp,0);
       ftot--;
diff --git a/log.c b/log.c
index 59dca9e01ec07d9aa3168ff796d40920b82a79f7..9b06f4276c7886ee4fb31ee951b5527a6e74fc72 100644 (file)
--- a/log.c
+++ b/log.c
@@ -354,7 +354,7 @@ int main(int argc,char *argv[])
             getword_start(&gwarea,optarg);
             if (getword(cdfrom,sizeof(cdfrom),&gwarea,'-')<0 || getword(cduntil,sizeof(cduntil),&gwarea,0)<0) {
                printf(_("SARG: The date range requested on the command line by option -d is invalid.\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             date_from(date, cdfrom, cduntil);
             dfrom=atoi(cdfrom);
@@ -379,7 +379,7 @@ int main(int argc,char *argv[])
          case 'l':
             if (NAccessLog>=MAXLOGS) {
                printf(_("SARG: Too many log files passed on command line with option -l.\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             strcpy(AccessLog[NAccessLog],optarg);
             NAccessLog++;
@@ -417,17 +417,17 @@ int main(int argc,char *argv[])
                getword_start(&gwarea,optarg);
                if (getword(hm,sizeof(hm),&gwarea,'-')<0 || getword(hmf,sizeof(hmf),&gwarea,0)<0) {
                   debuga(_("The time range passed on the command line with option -t is invalid\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             if(sscanf(hm,"%d:%d",&h,&m)!=2) {
                debuga(_("Time period must be MM or MM:SS. Exit\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             sprintf(hm,"%02d%02d",h,m);
             if(sscanf(hmf,"%d:%d",&h,&m)!=2) {
                debuga(_("Time period must be MM or MM:SS. Exit\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             sprintf(hmf,"%02d%02d",h,m);
             break;
@@ -456,7 +456,7 @@ int main(int argc,char *argv[])
             break;
          case '?':
             usage(argv[0]);
-            exit(1);
+            exit(EXIT_FAILURE);
             break;
       }
 
@@ -472,7 +472,7 @@ int main(int argc,char *argv[])
    if(ConfigFile[0] == '\0') sprintf(ConfigFile,"%s/sarg.conf",SYSCONFDIR);
    if(access(ConfigFile, R_OK) != 0) {
       debuga(_("Cannot open config file: %s - %s\n"),ConfigFile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if(access(ConfigFile, R_OK) == 0)
@@ -688,7 +688,7 @@ int main(int argc,char *argv[])
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read a log file\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    sprintf ( sz_Download_Unsort , "%s/sarg/download.unsort", tmp);
@@ -697,14 +697,14 @@ int main(int argc,char *argv[])
       if((ReportType & REPORT_TYPE_DENIED) != 0) {
          if((fp_denied=MY_FOPEN(denied_unsort,"w"))==NULL) {
             debuga(_("(log) Cannot open file: %s - %s\n"),denied_unsort,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
 
       if((ReportType & REPORT_TYPE_DENIED) != 0 || (ReportType & REPORT_TYPE_AUTH_FAILURES) != 0) {
          if((fp_authfail=MY_FOPEN(authfail_unsort,"w"))==NULL) {
             debuga(_("(log) Cannot open file: %s - %s\n"),authfail_unsort,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
    }
@@ -725,7 +725,7 @@ int main(int argc,char *argv[])
             debuga(_("Reading access log file: %s\n"),arq);
          if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
             debuga(_("(log) Cannot open log file: %s - %s\n"),arq,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          from_stdin=0;
       }
@@ -780,7 +780,7 @@ int main(int argc,char *argv[])
                if (getword_skip(2000,&gwarea,'-')<0 || getword(val2,sizeof(val2),&gwarea,'_')<0 ||
                    getword_skip(10,&gwarea,'-')<0 || getword(val3,sizeof(val3),&gwarea,'_')<0) {
                   debuga(_("The name of the file is invalid: %s\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                sprintf(period,"%s-%s",val2,val3);
                ilf=ILF_Sarg;
@@ -796,7 +796,7 @@ int main(int argc,char *argv[])
             sprintf(arq_log,"%s/sarg_temp.log",ParsedOutputLog);
             if((fp_log=MY_FOPEN(arq_log,"w"))==NULL) {
                debuga(_("(log) Cannot open log file: %s - %s\n"),arq_log,strerror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             fputs("*** SARG Log ***\n",fp_log);
          }
@@ -822,7 +822,7 @@ int main(int argc,char *argv[])
             while(strchr(gwarea.current,':') != 0) {
                if (getword_multisep(val1,sizeof(val1),&gwarea,':')<0) {
                   debuga(_("Maybe you have a broken record or garbage in your exclusion string\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if((str=(char *) strstr(linebuf,val1)) != (char *) NULL )
                   exstring++;
@@ -840,7 +840,7 @@ int main(int argc,char *argv[])
             getword_start(&gwarea,linebuf);
             if (getword(data,sizeof(data),&gwarea,' ')<0) {
                debuga(_("Maybe you have a broken time in your access.log file\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if((str=(char *) strchr(data, '.')) != (char *) NULL ) {
                if((str=(char *) strchr(str+1, '.')) != (char *) NULL ) {
@@ -849,37 +849,37 @@ int main(int argc,char *argv[])
                   if(squid24) {
                      if (getword(user,sizeof(user),&gwarea,' ')<0 || getword_skip(255,&gwarea,' ')<0) {
                         debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                      }
                   } else {
                      if (getword_skip(255,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,' ')<0) {
                         debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                      }
                   }
                   if (getword(data,sizeof(data),&gwarea,']')<0 || getword_skip(MAXLEN,&gwarea,'"')<0 ||
                       getword(fun,sizeof(fun),&gwarea,' ')<0) {
                      debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   if (getword_ptr(linebuf,&url,&gwarea,' ')<0) {
                      debuga(_("Maybe you have a broken url in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(code2,sizeof(code2),&gwarea,' ')<0 ||
                       getword(tam,sizeof(tam),&gwarea,' ')<0) {
                      debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   if((str=(char *) strchr(gwarea.current, ' ')) != (char *) NULL ) {
                      if (getword(code,sizeof(code),&gwarea,' ')<0) {
                         debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                      }
                   } else {
                      if (getword(code,sizeof(code),&gwarea,'\0')<0) {
                         debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                      }
                   }
 
@@ -897,37 +897,37 @@ int main(int argc,char *argv[])
             if(ilf==ILF_Unknown || ilf==ILF_Squid) {
                if (getword(elap,sizeof(elap),&gwarea,' ')<0) {
                   debuga(_("Maybe you have a broken elapsed time in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                while(strcmp(elap,"") == 0 && gwarea.current[0] != '\0')
                   if (getword(elap,sizeof(elap),&gwarea,' ')<0) {
                      debuga(_("Maybe you have a broken elapsed time in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                if(strlen(elap) < 1) continue;
                if (getword(ip,sizeof(ip),&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken client IP address in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(code,sizeof(code),&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken result code in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(tam,sizeof(tam),&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken amount of data in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(fun,sizeof(fun),&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken request method in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword_ptr(linebuf,&url,&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken url in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(user,sizeof(user),&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken user ID in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                ilf=ILF_Squid;
                ilf_count[ilf]++;
@@ -937,39 +937,39 @@ int main(int argc,char *argv[])
             getword_start(&gwarea,linebuf);
             if (getword(data,sizeof(data),&gwarea,'\t')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(user,sizeof(user),&gwarea,'\t')<0) {
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword_ptr(linebuf,&url,&gwarea,'\t')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(tam,sizeof(tam),&gwarea,'\t')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(code,sizeof(code),&gwarea,'\t')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(elap,sizeof(elap),&gwarea,'\t')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(smartfilter,sizeof(smartfilter),&gwarea,'\0')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
          if (ilf==ILF_Isa) {
@@ -981,14 +981,14 @@ int main(int argc,char *argv[])
                // remove the #Fields: column at the beginning of the line
                if (getword_skip(1000,&gwarea,' ')<0){
                   debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                for (ncols=0 ; ncols<ISACOL_Last ; ncols++) cols[ncols]=-1;
                ncols=0;
                while(gwarea.current[0] != '\0') {
                   if (getword(val1,sizeof(val1),&gwarea,'\t')<0){
                      debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   if(strcmp(val1,"c-ip") == 0) cols[ISACOL_Ip]=ncols;
                   if(strcmp(val1,"cs-username") == 0) cols[ISACOL_UserName]=ncols;
@@ -1012,42 +1012,42 @@ int main(int argc,char *argv[])
             for (x=0 ; x<isa_ncols ; x++) {
                if (getword_ptr(linebuf,&str,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (x==isa_cols[ISACOL_Ip]) {
                   if (strlen(str)>=sizeof(ip)) {
                      debuga(_("Maybe you have a broken IP in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(ip,str);
                } else if (x==isa_cols[ISACOL_UserName]) {
                   if (strlen(str)>=sizeof(user)) {
                      debuga(_("Maybe you have a broken user ID in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(user,str);
                } else if (x==isa_cols[ISACOL_Date]) {
                   if (strlen(str)>=sizeof(data)) {
                      debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(data,str);
                } else if (x==isa_cols[ISACOL_Time]) {
                   if (strlen(str)>=sizeof(hora)) {
                      debuga(_("Maybe you have a broken time in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(hora,str);
                } else if (x==isa_cols[ISACOL_TimeTaken]) {
                   if (strlen(str)>=sizeof(elap)) {
                      debuga(_("Maybe you have a broken download duration in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(elap,str);
                } else if (x==isa_cols[ISACOL_Bytes]) {
                   if (strlen(str)>=sizeof(tam)) {
                      debuga(_("Maybe you have a broken download size in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(tam,str);
                } else if (x==isa_cols[ISACOL_Uri]) {
@@ -1055,7 +1055,7 @@ int main(int argc,char *argv[])
                } else if (x==isa_cols[ISACOL_Status]) {
                   if (strlen(str)>=sizeof(code)) {
                      debuga(_("Maybe you have a broken access code in your %s file\n"),arq);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(code,str);
                }
@@ -1068,15 +1068,15 @@ int main(int argc,char *argv[])
             getword_start(&gwarea,data);
             if (getword(ano,sizeof(ano),&gwarea,'-')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(mes,sizeof(mes),&gwarea,'-')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(dia,sizeof(dia),&gwarea,'\0')<0){
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             conv_month_name(mes);
             sprintf(data," %s/%s/%s:%s",dia,mes,ano,hora);
@@ -1110,24 +1110,24 @@ int main(int argc,char *argv[])
             getword_start(&gwarea,data+1);
             if (getword_multisep(data,sizeof(data),&gwarea,':')<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword_multisep(hora,sizeof(hora),&gwarea,' ')<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             getword_start(&gwarea,data);
             if (getword(dia,sizeof(dia),&gwarea,'/')<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(mes,sizeof(mes),&gwarea,'/')<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if (getword(ano,sizeof(ano),&gwarea,'/')<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
 
             if(strcmp(df,"u") == 0)
@@ -1143,25 +1143,25 @@ int main(int argc,char *argv[])
             if(strcmp(df,"u") == 0) {
                if (getword(mes,sizeof(mes),&gwarea,'/')<0){
                   debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(dia,sizeof(dia),&gwarea,'/')<0){
                   debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             } else {
                if (getword(dia,sizeof(dia),&gwarea,'/')<0){
                   debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if (getword(mes,sizeof(mes),&gwarea,'/')<0){
                   debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             if (getword(ano,sizeof(ano),&gwarea,0)<0){
                debuga(_("Maybe you have a broken date in your %s file\n"),arq);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             snprintf(wdata,9,"%s%s%s",ano,mes,dia);
             idata=atoi(wdata);
@@ -1288,7 +1288,7 @@ int main(int argc,char *argv[])
             while(chm) {
                if (getword_multisep(warea,sizeof(warea),&gwarea,':')<0){
                   debuga(_("Maybe you have a broken time in your %s file\n"),arq);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                strncat(hmr,warea,2);
                chm--;
@@ -1374,7 +1374,7 @@ int main(int argc,char *argv[])
             ufile=malloc(sizeof(*ufile));
             if (!ufile) {
                debuga(_("Not enough memory to store the user %s\n"),user);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             memset(ufile,0,sizeof(*ufile));
             ufile->next=first_user_file;
@@ -1405,7 +1405,7 @@ int main(int argc,char *argv[])
             }
             if (snprintf (tmp3, sizeof(tmp3), "%s/sarg/%s.unsort", tmp, ufile->user->filename)>=sizeof(tmp3)) {
                debuga(_("Temporary user file name too long: %s/sarg/%s.unsort\n"), tmp, ufile->user->filename);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if ((ufile->file = MY_FOPEN (tmp3, "a")) == NULL) {
                debuga(_("(log) Cannot open temporary file: %s - %s\n"), tmp3, strerror(errno));
@@ -1579,11 +1579,11 @@ int main(int argc,char *argv[])
       getword_start(&gwarea,period);
       if (getword(val2,sizeof(val2),&gwarea,'-')<0){
          debuga(_("Maybe you have a broken date range definition.\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(val1,sizeof(val1),&gwarea,'\0')<0){
          debuga(_("Maybe you have a broken date range definition.\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       sprintf(val4,"%s/sarg-%s_%s-%s_%s.log",ParsedOutputLog,val2,start_hour,val1,end_hour);
       if (rename(arq_log,val4)) {
@@ -1601,7 +1601,7 @@ int main(int argc,char *argv[])
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
                debuga(_("command: %s\n"),val1);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
       }
@@ -1615,7 +1615,7 @@ int main(int argc,char *argv[])
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("sort command: %s\n"),csort);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       unlink(denied_unsort);
    }
@@ -1666,21 +1666,21 @@ static void getusers(const char *pwdfile, int debug)
 
    if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
       debuga(_("(getusers) Cannot open file %s - %s\n"),pwdfile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fseek(fp_usr, 0, SEEK_END);
    nreg = ftell(fp_usr);
    if (nreg<0) {
       debuga(_("Cannot get the size of file %s\n"),pwdfile);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    nreg = nreg+5000;
    fseek(fp_usr, 0, SEEK_SET);
 
    if((userfile=(char *) malloc(nreg))==NULL){
       debuga(_("malloc error (%ld)\n"),nreg);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    bzero(userfile,nreg);
@@ -1690,7 +1690,7 @@ static void getusers(const char *pwdfile, int debug)
       str=strchr(buf,':');
       if (!str) {
          debuga(_("You have an invalid user in your %s file\n"),pwdfile);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       str[1]=0;
       strcat(userfile,buf);
index f303731312c5c1a8876477b2658bdc13547bcefb..81ee8dffbd5adad899d432fb3a74b785654f5e84 100755 (executable)
@@ -57,12 +57,12 @@ static void getlog(void)
 
    if((fd1 == -1 ) || ((tmp = fdopen (fd1, "w+" )) == NULL)  ) {    /* failure, bail out */
        debuga(_("(realtime) mkstemp error - %s\n"),strerror(errno));
-       exit(1);
+       exit(EXIT_FAILURE);
    }
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the log file\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    sprintf(cmd,"tail -%d %s",realtime_access_log_lines,AccessLog[0]);
@@ -70,7 +70,7 @@ static void getlog(void)
    while((buf=longline_read(fp,&line)) != NULL )
       if (getdata(buf,tmp)<0) {
          debuga(_("Maybe a broken record or garbage was returned by %s\n"),cmd);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
    pclose(fp);
    fclose(tmp);
@@ -81,7 +81,7 @@ static void getlog(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),cmd);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlink(template1);
    datashow(template2);
@@ -96,6 +96,7 @@ static int getdata(char *rec, FILE *ftmp)
    char typ[128];
    char warea[MAXLEN];
    char user[MAX_USER_LEN];
+   char ip[25];
    char *url;
    struct getwordstruct gwarea;
 
@@ -186,6 +187,7 @@ static void datashow(const char *tmp)
    char typ[128];
    char user[MAX_USER_LEN];
    char u2[MAX_USER_LEN];
+   char ip[25];
    int url_len;
    int ourl_size=0;
    struct getwordstruct gwarea;
@@ -193,14 +195,14 @@ static void datashow(const char *tmp)
 
    if((fin=fopen(tmp,"r"))==NULL) {
       debuga(_("(realtime) open error %s - %s\n"),tmp,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    header();
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the log file\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fin,&line))!=NULL) {
@@ -208,28 +210,28 @@ static void datashow(const char *tmp)
       getword_start(&gwarea,buf);
       if (getword(dat,sizeof(dat),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(tim,sizeof(tim),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(user,sizeof(user),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strlen(dat) < 3 || strlen(user) < 1) continue;
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken url in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(typ,sizeof(typ),&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strstr(RealtimeTypes,typ) == 0)
          continue;
@@ -253,7 +255,7 @@ static void datashow(const char *tmp)
          ourl=realloc(ourl,ourl_size);
          if (!ourl) {
             debuga(_("Not enough memory to store the url\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
       strcpy(ourl,url);
index 0e44237138c33dded56093e0ba0278d89da51b04..199282246d73f4369c6642f95a2c28756e27e4aa 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -34,6 +34,7 @@ void report_day(const struct userinfostruct *uinfo)
 
    FILE *fp_in, *fp_ou;
 
+   char buf[MAXLEN];
    char data[20];
    char odata[20];
    char hour[20];
@@ -54,7 +55,7 @@ void report_day(const struct userinfostruct *uinfo)
 
    if (snprintf(arqout,sizeof(arqout),"%s/%s/d%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqout)) {
       debuga(_("Output file name too long: %s/%s/d%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename);
 
@@ -62,13 +63,13 @@ void report_day(const struct userinfostruct *uinfo)
       return;
 
    if((fp_in=fopen(wdirname,"r"))==NULL) {
-     fprintf(stderr, "SARG: (repday) %s: %s\n",_("Cannot open log file"),wdirname);
-     exit(1);
+     debuga(_("(repday) Cannot open log file %s\n"),wdirname);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(arqout,"w"))==NULL) {
-     fprintf(stderr, "SARG: (repday) %s: %s\n",_("Cannot open log file"),arqout);
-     exit(1);
+     debuga(_("(repday) Cannot open log file %s\n"),arqout);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Day report"));
@@ -101,7 +102,7 @@ void report_day(const struct userinfostruct *uinfo)
       getword_start(&gwarea,buf);
       if (getword(data,sizeof(data),&gwarea,'\t')<0) {
          debuga(_("There is a broken date in file %s\n"),wdirname);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(!count) {
          strcpy(odata,data);
@@ -110,11 +111,11 @@ void report_day(const struct userinfostruct *uinfo)
 
       if (getword(hour,sizeof(hour),&gwarea,'\t')<0) {
          debuga(_("There is a broken time in file %s\n"),wdirname);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&elap,&gwarea,'\t')<0) {
          debuga(_("There is a broken quantity in file %s\n"),wdirname);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(strcmp(data,odata) != 0) {
index 5ecca350db6905af4abc63de108abc3e79fd81a7..e17911b737735bc6f254f8aee43625c98429dace 100644 (file)
--- a/report.c
+++ b/report.c
@@ -97,7 +97,7 @@ void gerarel(void)
    snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname);
    if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    puinfo=NULL;
@@ -115,11 +115,11 @@ void gerarel(void)
          continue;
       if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) {
          fprintf(stderr, "SARG: (report) directory entry too long: %s/%s\n",tmp,direntp->d_name);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
          fprintf(stderr, "SARG: (report) %s: %s\n",_("Cannot open file"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if (dlen>0) {
@@ -155,7 +155,7 @@ void gerarel(void)
 
       if (longline_prepare(&line)<0) {
          debuga(_("Not enough memory to read the downloaded files\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -165,16 +165,16 @@ void gerarel(void)
              getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
              getword(acccode,sizeof(acccode),&gwarea,'\t')<0) {
             debuga(_("There is a broken record or garbage in file %s\n"),tmp3);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
          if (getword_atoll(&accelap,&gwarea,'\t')<0) {
             debuga(_("There is a broken elapsed time in file %s\n"),tmp3);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
             debuga(_("There is a broken smart info in file %s\n"),tmp3);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
 
          if(accsmart[0] != '\0') {
@@ -203,7 +203,7 @@ void gerarel(void)
                oldurl=realloc(oldurl,ourl_size);
                if (!oldurl) {
                   debuga(_("Not enough memory to store the url\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             strcpy(oldurl,accurl);
@@ -260,7 +260,7 @@ void gerarel(void)
                snprintf(arqtt,sizeof(arqtt),"%s/%s/tt%s-%s.html",outdirname,uinfo->filename,uinfo->filename,siteind);
                if ((fp_tt = fopen(arqtt, "w")) == 0) {
                   fprintf(stderr, "SARG: (report) %s: %s\n",_("Cannot open file"),arqtt);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                ttopen=1;
 
@@ -296,7 +296,7 @@ void gerarel(void)
                oldurltt=realloc(oldurltt,ourltt_size);
                if (!oldurltt) {
                   debuga(_("Not enough memory to store the url\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             strcpy(oldurltt,accurl);
@@ -326,7 +326,7 @@ void gerarel(void)
                oldurl=realloc(oldurl,ourl_size);
                if (!oldurl) {
                   debuga(_("Not enough memory to store the url\n"));
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
             }
             strcpy(oldurl,accurl);
@@ -420,12 +420,12 @@ static void maketmp(const char *user, const char *dirname, int debug, int indexo
    if(debug) debuga(_("Making file: %s/%s\n"),tmp,user);
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,user)>=sizeof(wdirname)) {
       debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp,user);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(wdirname,"w"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fclose(fp_ou);
@@ -445,12 +445,12 @@ static void maketmp_hour(const char *user, const char *dirname, int indexonly)
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.htmp",tmp,user)>=sizeof(wdirname)) {
       debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp,user);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(wdirname,"w"))==NULL){
       debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fclose(fp_ou);
@@ -468,12 +468,12 @@ void gravatmp(const struct userinfostruct *uinfo, const char *oldurl, long long
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(wdirname)) {
       debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
@@ -500,12 +500,12 @@ static void gravatmpf(const struct userinfostruct *uinfo,const char *oldurl, lon
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(wdirname)) {
       debuga(_("Path too long %s/%s.utmp\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
@@ -534,12 +534,12 @@ static void gravatmp_hora(const char *dirname, const struct userinfostruct *uinf
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.htmp",tmp,uinfo->filename)>=sizeof(wdirname)) {
       debuga(_("Path too long %s/%s.htmp\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
       debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if(strcmp(datetimeby,"bytes") == 0) fprintf(fp_ou,"%s\t%s\t%lld\n",data,hora,bytes);
@@ -561,12 +561,12 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
 
    if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(wdirname)) {
       debuga(_("Path too long %s/%s.ip\n"),tmp,uinfo->filename);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou,"%s\t%s\t%s\t%s\t%lld\t%lld\n",ip,url,data,hora,tam,elap);
@@ -606,7 +606,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid total number of accesses in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nacc=number*sign;
@@ -623,7 +623,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid total size in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nbytes=number*sign;
@@ -640,7 +640,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid total elapsed time in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nelap=number*sign;
@@ -657,7 +657,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid total cache hit in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->incache=number*sign;
@@ -674,7 +674,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\0') {
          debuga(_("Invalid total cache miss in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       item->oucache=number*sign;
    } else {
@@ -684,7 +684,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
       for (i=0 ; i<MAX_USER_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
       if (*buffer!='\t') {
          debuga(_("User name too long or invalid in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *buffer++='\0';
 
@@ -700,7 +700,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid number of accesses in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nacc=number*sign;
@@ -717,7 +717,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid number of bytes in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nbytes=number*sign;
@@ -726,7 +726,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
       while ((unsigned char)*buffer>=' ') buffer++;
       if (*buffer!='\t') {
          debuga(_("URL too long or invalid in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *buffer++='\0';
 
@@ -734,7 +734,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
       for (i=0 ; i<MAX_IP_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
       if (*buffer!='\t') {
          debuga(_("IP address too long or invalid in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *buffer++='\0';
 
@@ -742,7 +742,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
       for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
       if (*buffer!='\t') {
          debuga(_("Time too long or invalid in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *buffer++='\0';
 
@@ -750,7 +750,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
       for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
       if (*buffer!='\t') {
          debuga(_("Date too long or invalid in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       *buffer++='\0';
 
@@ -766,7 +766,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid elapsed time in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->nelap=number*sign;
@@ -783,7 +783,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\t') {
          debuga(_("Invalid cache hit size in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buffer++;
       item->incache=number*sign;
@@ -800,7 +800,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
          number=(number * 10) + (*buffer++)-'0';
       if (*buffer!='\0') {
          debuga(_("Invalid cache miss size in %s\n"),filename);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       item->oucache=number*sign;
    }
@@ -817,7 +817,7 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char
 
    if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
       debuga(_("(report) Cannot open file %s\n"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou,"%s\t%s\t%s\t%s\t%s\t%s\n",user,data,hora,ip,url,smart);
index 1cffde803ca256f89ae3faaa2c99e85804bb89eb..13a57b75891ed8ef68cbb3b9fd60e89dcd4a6a0a 100644 (file)
@@ -65,12 +65,12 @@ void siteuser(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       fprintf(stderr, "SARG: (siteuser) %s: %s\n",_("Cannot open file"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(siteuser) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
@@ -79,18 +79,18 @@ void siteuser(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_in=fopen(general2,"r"))==NULL) {
      debuga(_("(siteuser) Cannot open log file %s\n"),general2);
      debuga(_("sort command: %s\n"),csort);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(report,"w"))==NULL) {
      debuga(_("(siteuser) Cannot open log file %s\n"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Sites & Users"));
@@ -111,13 +111,13 @@ void siteuser(void)
 
    if((users=(char *) malloc(204800))==NULL){
       debuga(_("ERROR: Cannot load. Memory fault\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    strcpy(users," ");
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read file %s\n"),general2);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -126,7 +126,7 @@ void siteuser(void)
       uinfo=userinfo_find_from_id(item.user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),item.user,general2);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if (item.nacc > 0) nsitesusers = 1;
@@ -137,7 +137,7 @@ void siteuser(void)
             ourl=realloc(ourl,ourl_size);
             if (!ourl) {
                debuga(_("Not enough memory to store the url\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
          strcpy(ourl,item.url);
@@ -188,7 +188,7 @@ void siteuser(void)
             ourl=realloc(ourl,ourl_size);
             if (!ourl) {
                debuga(_("Not enough memory to store the url\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
          strcpy(ourl,item.url);
index 9b1512cc6079ab0be1b59fd55a109ea6bbff46fd..ba1fcfb4d1c6dc9d310f67b26b0ad25ff64b5a32 100644 (file)
@@ -32,6 +32,7 @@ void smartfilter_report(void)
 
    FILE *fp_in = NULL, *fp_ou = NULL, *fp_user = NULL;
 
+   char buf[MAXLEN];
    char url[MAXLEN];
    char csort[255];
    char smart_in[MAXLEN];
@@ -67,35 +68,35 @@ void smartfilter_report(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       debuga(_("(smartfilter) Cannot open file %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(smartfilter) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if (snprintf(csort,sizeof(csort),"sort -n -k 1,1 -k 2,2 -k 3,3 -o \"%s\" \"%s\"",smart_ou,smart_in)>=sizeof(csort)) {
       debuga(_("cannot build the sort command to sort file %s\n"),smart_in);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(smart_ou,"r"))==NULL) {
       debuga(_("(smartfilter) Cannot open log file %s\n"),smart_ou);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlink(smart_in);
 
    if((fp_ou=fopen(report,"w"))==NULL) {
      debuga(_("(smartfilter) Cannot open log file %s\n"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
@@ -122,13 +123,13 @@ void smartfilter_report(void)
           getword(hora,sizeof(hora),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0 ||
           getword(url,sizeof(url),&gwarea,'\t')<0 || getword(smartcat,sizeof(smartcat),&gwarea,'\n')<0) {
          debuga(_("There is a broken record or garbage in file %s\n"),smart_ou);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       uinfo=userinfo_find_from_id(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),user,smart_ou);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strcmp(ouser,user) != 0) {
          strcpy(ouser,user);
@@ -145,7 +146,7 @@ void smartfilter_report(void)
          }
          if ((fp_user = fopen(smartuser, "a")) == 0) {
             debuga(_("(smartfilter) Cannot open file %s\n"),smartuser);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          fuser=1;
 
diff --git a/sort.c b/sort.c
index 03d9b091e1f3d45f1b3dbbf6ccd0b2bac268e343..04a6dd3370934aaab699e94c6602f4ce92cdbe99 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -35,7 +35,6 @@ void tmpsort(void)
    int cstatus;
    const char tmpext[]=".utmp";
    int dlen;
-
    char csort[MAXLEN];
    char arqou[MAXLEN], arqin[MAXLEN], wnome[MAXLEN];
    const char *field1="2,2";
@@ -96,7 +95,7 @@ void tmpsort(void)
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("sort command: %s\n"),csort);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       unlink(arqin);
 
@@ -150,17 +149,17 @@ void sort_users_log(const char *tmp, int debug)
               tmp, wtmp, user, wtmp, user);
       if (clen>=sizeof(csort)) {
          debuga(_("user name too long to sort %s\n"),csort);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       cstatus=system(csort);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
          debuga(_("sort command: %s\n"),csort);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (snprintf(wdname,sizeof(wdname),"%s/%s.unsort",wtmp,user)>=sizeof(wdname)) {
          debuga(_("user name too long for %s/%s.unsort\n"),wtmp,user);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       unlink(wdname);
    }
diff --git a/splintrc b/splintrc
new file mode 100644 (file)
index 0000000..673aa93
--- /dev/null
+++ b/splintrc
@@ -0,0 +1,57 @@
++posixlib
+-retvalint
++matchanyintegral
+
+-I .
+
+-DPACKAGE_NAME="sarg"
+-DPACKAGE_VERSION="2.3rc1"
+-DSYSCONFDIR="/home/fmarchal/c/sarg/root/etc/sarg"
+-DLANGDIR="/home/fmarchal/c/sarg/root/share/sarg/languages"
+-DFONTDIR="/home/fmarchal/c/sarg/root/share/sarg/fonts"
+-DIMAGEDIR="/home/fmarchal/c/sarg/root/share/sarg/images"
+
+-DHAVE_STDIO_H=1
+-DHAVE_STDLIB_H=1
+-DHAVE_STRING_H=1
+-DHAVE_STRINGS_H=1
+-DHAVE_SYS_TIME_H=1
+-DHAVE_TIME_H=1
+-DHAVE_DIRENT_H=1
+-DHAVE_SYS_SOCKET_H=1
+-DHAVE_NETDB_H=1
+-DHAVE_ARPA_INET_H=1
+-DHAVE_SYS_TYPES_H=1
+-DHAVE_NETINET_H=1
+-DHAVE_SYS_STAT_H=1
+-DHAVE_CTYPE_H=1
+-DHAVE_GD=1
+-DHAVE_GD_H=1
+-DHAVE_GDFONTL_H=1
+-DHAVE_GDFONTT_H=1
+-DHAVE_GDFONTS_H=1
+-DHAVE_GDFONTMB_H=1
+-DHAVE_GDFONTG_H=1
+-DHAVE_ICONV_H=1
+-DHAVE_ERRNO_H=1
+-DHAVE_SYS_RESOURCE_H=1
+-DHAVE_SYS_WAIT_H=1
+-DHAVE_STDARG_H=1
+-DHAVE_INTTYPES_H=1
+-DHAVE_LIMITS_H=1
+-DHAVE_MATH_H=1
+-DHAVE_LOCALE_H=1
+-DHAVE_EXECINFO_H=1
+-DHAVE_LIBINTL_H=1
+-DHAVE_LIBGEN_H=1
+-DHAVE_STDBOOL_H=1
+-DHAVE_BZERO=1
+-DHAVE_MKSTEMP=1
+-DHAVE_FOPEN64=1
+-DHAVE_BACKTRACE=1
+-DHAVE_SYMLINK=1
+-DHAVE_LSTAT=1
+-DHAVE_GETNAMEINFO=1
+-DRLIM_STRING="%d"
+-DICONV_CONST
+-DHAVE_LC_MESSAGES=1
index 59ca7b0177710dd4b1c86b177905d36e63e138cd..34ee43500e6824de2e8206599567b594f3f27b09 100644 (file)
@@ -45,14 +45,14 @@ void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert)
 
    if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
       debuga(_("(splitlog) Cannot open log file %s\n"),arq);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       getword_start(&gwarea,buf);
       if (getword(data,sizeof(data),&gwarea,' ')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),arq);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       tt=atoi(data);
       t=localtime(&tt);
index 2db2bbddb6315a1cea874c1ba32f06839f015da2..0123a8944363a0c58e22d6565f5548dde5645718 100644 (file)
@@ -34,12 +34,14 @@ static int nfiles_done = 0;
 static void read_log(const char *wentp, FILE *fp_ou)
 {
    FILE *fp_in = NULL;
+   char buf[MAXLEN];
    char leks[5], sep[2], res[MAXLEN];
    char mon[20], day[3], year[5], hour[15];
    char list[MAXLEN];
    char wdata[127];
    char url[MAX_URL_LEN];
    char user[MAX_USER_LEN];
+   char ip[25];
    int  idata=0;
    int  i;
    char *str;
@@ -85,7 +87,7 @@ static void read_log(const char *wentp, FILE *fp_ou)
 
    if ((fp_in=fopen(wentp,"r"))==NULL) {
       debuga(_("(squidguard) Cannot open log file %s\n"),wentp);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while (fgets(buf,sizeof(buf),fp_in) != NULL) {
@@ -95,64 +97,64 @@ static void read_log(const char *wentp, FILE *fp_ou)
          leks[0]='\0';
          if (getword(leks,sizeof(leks),&gwarea1,'#')<0) {
             debuga(_("There is a broken record or garbage in your %s file\n"),wentp);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          while(strcmp(leks,"end") != 0) {
             if (getword(leks,sizeof(leks),&gwarea1,'#')<0 || getword(sep,sizeof(sep),&gwarea1,'#')<0) {
                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),wentp);
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             if(strcmp(leks,"end") != 0) {
                if (getword(res,sizeof(res),&gwarea,sep[0])<0) {
                   debuga(_("Maybe you have a broken record or garbage in your %s file\n"),wentp);
-                  exit(1);
+                  exit(EXIT_FAILURE);
                }
                if(strcmp(leks,"year") == 0) {
                   if (strlen(res)>=sizeof(year)) {
                      debuga(_("Year string too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(year,res);
                } else if(strcmp(leks,"mon") == 0) {
                   if (strlen(res)>=sizeof(mon)) {
                      debuga(_("Month string too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(mon,res);
                } else if(strcmp(leks,"day") == 0) {
                   if (strlen(res)>=sizeof(day)) {
                      debuga(_("Day string too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(day,res);
                } else if(strcmp(leks,"hour") == 0) {
                   if (strlen(res)>=sizeof(hour)) {
                      debuga(_("Hour string too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(hour,res);
                } else if(strcmp(leks,"list") == 0) {
                   if (strlen(res)>=sizeof(list)) {
                      debuga(_("Banning list name too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(list,res);
                } else if(strcmp(leks,"ip") == 0) {
                   if (strlen(res)>=sizeof(ip)) {
                      debuga(_("IP address too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(ip,res);
                } else if(strcmp(leks,"user") == 0) {
                   if (strlen(res)>=sizeof(user)) {
                      debuga(_("User ID too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(user,res);
                } else if(strcmp(leks,"url") == 0) {
                   if (strlen(res)>=sizeof(url)) {
                      debuga(_("URL too long in squidGuard log file %s\n"),wentp);
-                     exit(1);
+                     exit(EXIT_FAILURE);
                   }
                   strcpy(url,res);
                }
@@ -166,7 +168,7 @@ static void read_log(const char *wentp, FILE *fp_ou)
              getword(ip,sizeof(ip),&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,' ')<0 ||
              getword(user,sizeof(user),&gwarea,' ')<0) {
             debuga(_("There is a broken record or garbage in your %s file\n"),wentp);
-            exit(1);
+            exit(EXIT_FAILURE);
           }
           /*
           The URL may be "http://url:port/data" if the method is GET or simply "url:port/" if the method is CONNECT.
@@ -210,6 +212,7 @@ static void read_log(const char *wentp, FILE *fp_ou)
 void squidguard_log(void)
 {
    FILE *fp_ou = NULL, *fp_guard = NULL;
+   char buf[MAXLEN];
    char guard_in[MAXLEN];
    char guard_ou[MAXLEN];
    char logdir[MAXLEN];
@@ -233,7 +236,7 @@ void squidguard_log(void)
    sprintf(guard_ou,"%s/squidguard.log",tmp);
    if((fp_ou=fopen(guard_in,"a"))==NULL) {
       debuga(_("(squidguard) Cannot open log file %s\n"),guard_in);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    bzero(day, 3);
@@ -273,12 +276,12 @@ void squidguard_log(void)
    if(SquidGuardConf[0] != 0) {
       if(access(SquidGuardConf, R_OK) != 0) {
          debuga(_("Cannot open squidGuard config file: %s\n"),SquidGuardConf);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if((fp_guard=fopen(SquidGuardConf,"r"))==NULL) {
          debuga(_("(squidguard) Cannot open log file %s\n"),SquidGuardConf);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       logdir[0]=0;
@@ -349,7 +352,7 @@ void squidguard_log(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),tmp6);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(guard_in);
index e62c630034cefd0ac27a4765ba0661c076b45cc5..28de27d09153712c7679c4c0bbbef4f4d490fd73 100644 (file)
@@ -32,6 +32,7 @@ void squidguard_report(void)
 
    FILE *fp_in = NULL, *fp_ou = NULL;
 
+   char buf[MAXLEN];
    char *url;
    char squidguard_in[MAXLEN];
    char per[MAXLEN];
@@ -45,6 +46,7 @@ void squidguard_report(void)
    char data[15];
    char data2[15];
    char hora[15];
+   char ouser2[255];
    int  z=0;
    int  count=0;
    struct getwordstruct gwarea;
@@ -62,23 +64,23 @@ void squidguard_report(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       debuga(_("(squidguard) Cannot open file %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(squidguard) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
    if((fp_in=fopen(squidguard_in,"r"))==NULL) {
      debuga(_("(squidguard) Cannot open log file %s\n"),squidguard_in);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(report,"w"))==NULL) {
      debuga(_("(squidguard) Cannot open log file %s\n"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("SQUIDGUARD"));
@@ -95,15 +97,15 @@ void squidguard_report(void)
       if (getword(user,sizeof(user),&gwarea,'\t')<0 || getword(data2,sizeof(data2),&gwarea,'\t')<0 ||
           getword(hora,sizeof(hora),&gwarea,'\t')<0 || getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("There is a broken record or garbage in file %s\n"),squidguard_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("There is a broken url in file %s\n"),squidguard_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(rule,sizeof(rule),&gwarea,'\n')<0) {
          debuga(_("There is a broken rule in file %s\n"),squidguard_in);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(UserIp)
index 5ea1746682ecb3b2458b7f48c3345fc91e8b48ae..9e424aeeadea98322c20542122408ed4f0e1d12d 100644 (file)
@@ -76,12 +76,12 @@ void topsites(void)
 
    if ((fp_in = fopen(per, "r")) == 0) {
       debuga(_("(topsites) Cannot open file %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(topsites) read error in %s\n"),per);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
@@ -90,23 +90,23 @@ void topsites(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_in=fopen(general2,"r"))==NULL) {
      debuga(_("(topsites) Cannot open log file %s\n"),general2);
      debuga(_("sort command: %s\n"),csort);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(general3,"w"))==NULL) {
      debuga(_("(topsites) Cannot open log file %s\n"),general3);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read file %s\n"),general2);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -120,7 +120,7 @@ void topsites(void)
             ourl=realloc(ourl,ourl_size);
             if (!ourl) {
                debuga(_("Not enough memory to store the url\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
          strcpy(ourl,item.url);
@@ -135,7 +135,7 @@ void topsites(void)
             ourl=realloc(ourl,ourl_size);
             if (!ourl) {
                debuga(_("Not enough memory to store the url\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
          strcpy(ourl,item.url);
@@ -180,12 +180,12 @@ void topsites(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(sites,"r"))==NULL) {
       debuga(_("(topsites) Cannot open log file %s\n"),sites);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(general2);
@@ -193,7 +193,7 @@ void topsites(void)
 
    if((fp_ou=fopen(report,"w"))==NULL) {
      debuga(_("(topsites) Cannot open log file %s\n"),report);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Top sites"));
@@ -214,23 +214,23 @@ void topsites(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read file %s\n"),sites);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while(regs<TopSitesNum && (buf=longline_read(fp_in,&line))!=NULL) {
       getword_start(&gwarea,buf);
       if (getword_atoll(&nacc,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),sites);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (nacc == 0) continue;
       if (getword_atoll(&nbytes,&gwarea,'\t')<0 || getword_atoll(&ntime,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),sites);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
          debuga(_("The url is invalid in file %s\n"),sites);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       twork1=nacc;
index d39b84b89c14bbdbb95b0ce7277631ae1a433d16..73d23391ff236cbf0ca8db0b3b419f54cb9ebd0c 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -69,11 +69,11 @@ void topuser(void)
    snprintf(arqper,sizeof(arqper),"%s/sarg-period",outdirname);
    if ((fp_in = fopen(arqper, "r")) == 0) {
       debuga(_("(topuser) Cannot open file %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (!fgets(period,sizeof(period),fp_in)) {
       debuga(_("(topuser) Read error in %s\n"),arqper);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
 
@@ -91,12 +91,12 @@ void topuser(void)
    ntopuser = 0;
    if((fp_in=fopen(wger,"r"))==NULL) {
       debuga(_("(topuser) Cannot open file %s\n"),wger);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_top2=fopen(top2,"w"))==NULL) {
       debuga(_("(topuser) Cannot open file %s\n"),top2);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    olduser[0]='\0';
@@ -104,7 +104,7 @@ void topuser(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the file %s\n"),wger);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((warea=longline_read(fp_in,&line))!=NULL) {
@@ -170,19 +170,19 @@ void topuser(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_top1=fopen(top1,"r"))==NULL) {
       debuga(_("(topuser) Cannot open file %s\n"),top1);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(top2);
 
    if((fp_top3=fopen(top3,"w"))==NULL) {
       debuga(_("(topuser) Cannot open file %s\n"),top3);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    snprintf(title,sizeof(title),_("SARG report for %s"),period);
@@ -244,34 +244,34 @@ void topuser(void)
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the downloaded files\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((warea=longline_read(fp_top1,&line))!=NULL) {
       getword_start(&gwarea,warea);
       if (getword(user,sizeof(user),&gwarea,'\t')<0) {
          debuga(_("There is a broken user in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
          debuga(_("There is a broken number of bytes in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&nacc,&gwarea,'\t')<0) {
          debuga(_("There is a broken number of access in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&elap,&gwarea,'\t')<0) {
          debuga(_("There is a broken elpased time in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&incac,&gwarea,'\t')<0) {
          debuga(_("There is a broken in-cache size in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&oucac,&gwarea,'\n')<0) {
          debuga(_("There is a broken out-of-cache size in file %s\n"),top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(nacc < 1)
          continue;
@@ -283,7 +283,7 @@ void topuser(void)
       uinfo=userinfo_find_from_id(user);
       if (!uinfo) {
          debuga(_("Unknown user ID %s in file %s\n"),user,top1);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       fputs("<tr>",fp_top3);
@@ -407,7 +407,7 @@ void topuser(void)
 
    if((fp_ou=fopen(tusr,"w"))==NULL) {
       debuga(_("(topuser) Cannot open file %s\n"),tusr);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fprintf(fp_ou,"%d\n",totuser);
    fclose(fp_ou);
index 0a69a6578fbd2feff802f24d694d35f91cd8cf21..faae1867e497726c8f3882739775e81c32c64939 100644 (file)
--- a/totday.c
+++ b/totday.c
@@ -32,6 +32,7 @@ void day_totalize(const char *tmp, const struct userinfostruct *uinfo, int index
 
    FILE *fp_in, *fp_ou;
 
+   char buf[200];
    char data[20];
    char hora[20];
    char min[20];
@@ -60,19 +61,19 @@ void day_totalize(const char *tmp, const struct userinfostruct *uinfo, int index
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(sortout,"r"))==NULL) {
       debuga(_("(totday) Cannot open log file %s\n"),sortout);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(wdirname);
 
    if((fp_ou=fopen(arqout,"w"))==NULL) {
      debuga(_("(totday) Cannot open log file %s\n"),arqout);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
@@ -82,7 +83,7 @@ void day_totalize(const char *tmp, const struct userinfostruct *uinfo, int index
           getword(min,sizeof(min),&gwarea,':')<0 || getword_skip(20,&gwarea,'\t')<0 ||
           getword(elap,sizeof(elap),&gwarea,0)<0) {
          debuga(_("There is a broken record or garbage in file %s\n"),sortout);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(!regs) {
index 8d72240eeb59204ba2ada7cd0fee4edbe8e1c459..74bc110b14705e7f2dddd065b6fee838d0a74255 100644 (file)
--- a/totger.c
+++ b/totger.c
@@ -43,12 +43,12 @@ int totalger(const char *dirname, int debug, const char *outdir)
 
    if((fp_in=fopen(wger,"r"))==NULL) {
       debuga(_("(totger) Cannot open file %s\n"),wger);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the temporary file %s\n"),wger);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((warea=longline_read(fp_in,&line))!=NULL)
@@ -66,7 +66,7 @@ int totalger(const char *dirname, int debug, const char *outdir)
 
    if((fp_ou=fopen(wger,"a"))==NULL) {
      debuga(_("(totger) Cannot open file %s\n"),wger);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    fprintf(fp_ou,"TOTAL\t%lld\t%lld\t%lld\t%lld\t%lld\n",tnacc,tnbytes,telap,tincache,toucache);
index 3da4d341a38c618a7b5a410006c73be0e6a547b6..87bd875ce19d07d94fcc07e88bbca1ace9ef718c 100644 (file)
@@ -31,6 +31,7 @@ void useragent(void)
 {
 
    FILE *fp_in = NULL, *fp_ou = NULL, *fp_ht = NULL;
+   char buf[MAXLEN];
    char ip[MAXLEN], data[MAXLEN], agent[MAXLEN], user[MAXLEN];
    char ipbefore[MAXLEN], namebefore[MAXLEN];
    char tagent[MAXLEN];
@@ -63,12 +64,12 @@ void useragent(void)
 
    if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),UserAgentLog);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if((fp_ou=fopen(tmp3,"w"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),tmp3);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if(debug) {
@@ -81,13 +82,13 @@ void useragent(void)
       if (getword(ip,sizeof(ip),&gwarea,' ')<0 || getword_skip(MAXLEN,&gwarea,'[')<0 ||
           getword(data,sizeof(data),&gwarea,' ')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       getword_start(&gwarea1,data);
       if (getword(day,sizeof(day),&gwarea1,'/')<0 || getword(month,sizeof(month),&gwarea1,'/')<0 ||
           getword(year,sizeof(year),&gwarea1,':')<0) {
          debuga(_("Maybe you have a broken date in your %s file\n"),UserAgentLog);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       buildymd(day,month,year,wdate);
       ndate=atoi(wdate);
@@ -98,7 +99,7 @@ void useragent(void)
       strcpy(fdate,data);
       if (getword_skip(MAXLEN,&gwarea,'"')<0 || getword(agent,sizeof(agent),&gwarea,'"')<0) {
          debuga(_("Maybe you have a broken useragent entry in your %s file\n"),UserAgentLog);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcpy(warea,agent);
       strup(warea);
@@ -108,7 +109,7 @@ void useragent(void)
       if(gwarea.current[0]!='\0') {
          if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,'\n')<0) {
             debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       }
 
@@ -138,12 +139,12 @@ void useragent(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(tmp2,"r"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),tmp2);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(tmp3);
@@ -151,7 +152,7 @@ void useragent(void)
    snprintf(hfile,sizeof(hfile),"%s/useragent.html", outdirname);
    if((fp_ht=fopen(hfile,"w"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),hfile);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    if(debug)
@@ -173,7 +174,7 @@ void useragent(void)
       getword_start(&gwarea,buf);
       if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("There is an invalid IP address in file %s\n"),tmp2);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(Ip2Name) {
@@ -186,11 +187,11 @@ void useragent(void)
 
       if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
          debuga(_("There is an invalid useragent in file %s\n"),tmp2);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(user,sizeof(user),&gwarea,'\t')<0) {
          debuga(_("There is an invalid user ID in file %s\n"),tmp2);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(strcmp(user,user_old) != 0) {
@@ -213,19 +214,19 @@ void useragent(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(tmp3,"r"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),tmp3);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(tmp2);
 
    if((fp_ou=fopen(tmp2,"w"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),tmp2);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    agent_old[0]='\0';
@@ -235,11 +236,11 @@ void useragent(void)
       getword_start(&gwarea,buf);
       if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
          debuga(_("There is an invalid IP address in file %s\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
          debuga(_("There is an invalid useragent in file %s\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 
       if(!cont) {
@@ -270,12 +271,12 @@ void useragent(void)
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(tmp3,"r"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),tmp3);
       debuga(_("sort command: %s\n"),csort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    unlink(tmp2);
@@ -291,7 +292,7 @@ void useragent(void)
       getword_start(&gwarea,buf);
       if (getword(tagent,sizeof(tagent),&gwarea,' ')<0) {
          debuga(_("There is an invalid useragent in file %s\n"),tmp);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       nagent=atoi(tagent);
       perc=(agentot2>0) ? nagent * 100. / agentot2 : 0.;
index f448eb01f5612c7962f4e41972e3f09d78f8d4f4..cbafa295abf204170e345f781fe048fbd99ac399 100644 (file)
@@ -67,7 +67,7 @@ struct userinfostruct *userinfo_create(const char *userid)
       group=malloc(sizeof(*group));
       if (!group) {
          debuga(_("Not enough memory to store the user\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       memset(group,0,sizeof(*group));
       if (last)
index 353623035b558b19a0e29dae18a2b6a8dea0c32a..51e1c4f619a6d8e121f448be9bfa5ba03ae60593 100644 (file)
--- a/usertab.c
+++ b/usertab.c
@@ -63,19 +63,19 @@ static void init_file_usertab(const char *UserTabFile)
 
    if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
       debuga(_("(usertab) Cannot open file %s - %s\n"),UserTabFile,strerror(errno));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fseek(fp_usr, 0, SEEK_END);
    nreg = ftell(fp_usr);
    if (nreg<0) {
       debuga(_("Cannot get the size of file %s"),UserTabFile);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    nreg += 100;
    fseek(fp_usr, 0, SEEK_SET);
    if((userfile=(char *) malloc(nreg))==NULL){
       debuga(_("ERROR: Cannot load. Memory fault"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    userfile[0]='\t';
    z2=1;
@@ -86,7 +86,7 @@ static void init_file_usertab(const char *UserTabFile)
       while(buf[z1] && (unsigned char)buf[z1]>' ') {
          if (z2+3>=nreg) { //need at least 3 additional bytes for the minimum string "\n\t\0"
             debuga(_("The list of the users is too long in your %s file.\n"),UserTabFile);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          userfile[z2++]=buf[z1++];
       }
@@ -95,7 +95,7 @@ static void init_file_usertab(const char *UserTabFile)
       while(buf[z1] && (unsigned char)buf[z1]>' ') {
          if (z2+2>=nreg) { //need at least 2 additional bytes for "\t\0"
             debuga(_("The list of the users is too long in your %s file.\n"),UserTabFile);
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          userfile[z2++]=buf[z1++];
       }
@@ -131,13 +131,13 @@ static void init_ldap_usertab(void) {
    ldap_handle = NULL;
    if ((ldap_handle = ldap_init(LDAPHost, LDAPPort)) == NULL) {
       debuga(_("Unable to connect to LDAP server %s on port %d\n"), LDAPHost, LDAPPort);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    int ldap_protocol_version = LDAPProtocolVersion;
    if (ldap_set_option(ldap_handle, LDAP_OPT_PROTOCOL_VERSION, &ldap_protocol_version) != LDAP_SUCCESS) {
       debuga(_("Could not set LDAP protocol version %d\n"), ldap_protocol_version);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    /* Bind to the LDAP server. */
@@ -145,7 +145,7 @@ static void init_ldap_usertab(void) {
    rc = ldap_simple_bind_s( ldap_handle, LDAPBindDN, LDAPBindPW );
    if ( rc != LDAP_SUCCESS ) {
       debuga(_("Cannot bind to LDAP server: %s\n"), ldap_err2string(rc));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    /* Initializing cache */
@@ -215,7 +215,7 @@ void init_usertab(const char *UserTabFile)
       init_ldap_usertab();
 #else
       debuga(_("LDAP module not compiled in sarg\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
 #endif //HAVE_LDAP_H
    } else if (UserTabFile[0] != '\0') {
       if(debug)
diff --git a/util.c b/util.c
index 020ab133e613aa41c1a0f14740d1600450b1ff9e..96dec5e7f9882e081a2dfa15daa57f11e414e045 100644 (file)
--- a/util.c
+++ b/util.c
@@ -96,12 +96,12 @@ void getword_restart(struct getwordstruct *gwarea)
 {
    if (gwarea->modified) {
       debuga(_("Cannot parse again the line as it was modified\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    gwarea->current=gwarea->beginning;
 }
 
-int getword(char *word, int limit, struct getwordstruct *gwarea, int stop)
+int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
 {
   int x;
 
@@ -127,7 +127,7 @@ int getword(char *word, int limit, struct getwordstruct *gwarea, int stop)
   return(0);
 }
 
-int getword_limit(char *word, int limit, struct getwordstruct *gwarea, int stop)
+int getword_limit(char *word, int limit, struct getwordstruct *gwarea, char stop)
 {
   int x;
 
@@ -142,7 +142,7 @@ int getword_limit(char *word, int limit, struct getwordstruct *gwarea, int stop)
   return(0);
 }
 
-int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, int stop)
+int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, char stop)
 {
   int x;
 
@@ -157,7 +157,7 @@ int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, int st
 #if USE_GETWORD_BACKTRACE
         getword_backtrace();
 #endif
-        //exit(1);
+        //exit(EXIT_FAILURE);
         return(-1);
      }
      word[x] = gwarea->current[x];
@@ -169,7 +169,7 @@ int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, int st
   return(0);
 }
 
-int getword_skip(int limit, struct getwordstruct *gwarea, int stop)
+int getword_skip(int limit, struct getwordstruct *gwarea, char stop)
 {
    int x;
 
@@ -192,7 +192,7 @@ int getword_skip(int limit, struct getwordstruct *gwarea, int stop)
    return(0);
 }
 
-int getword_atoll(long long int *number, struct getwordstruct *gwarea, int stop)
+int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop)
 {
    int x;
    int sign=+1;
@@ -226,7 +226,7 @@ int getword_atoll(long long int *number, struct getwordstruct *gwarea, int stop)
 }
 
 
-int getword_ptr(char *orig_line,char **word, struct getwordstruct *gwarea, int stop)
+int getword_ptr(char *orig_line,char **word, struct getwordstruct *gwarea, char stop)
 {
    /*!
    \note Why pass the original buffer to the function ? Because we must modify it to
@@ -295,14 +295,14 @@ void my_mkdir(const char *name)
    if(!is_absolute(name)) {
       debuga(_("Invalid path (%s). Please, use absolute paths only.\n"),name);
       debuga(_("process aborted.\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    chars=0;
    for (i=0 ; name[i] ; i++) {
       if (i>=sizeof(w0)) {
          debuga(_("directory name too long: %s\n"),name);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (chars>0 && name[i] == '/') {
          w0[i] = '\0';
@@ -310,7 +310,7 @@ void my_mkdir(const char *name)
             if(mkdir(w0,0755)) {
                debuga(_("mkdir %s %s\n"),w0,strerror(errno));
                debuga(_("process aborted.\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
          }
       }
@@ -322,7 +322,7 @@ void my_mkdir(const char *name)
       if(mkdir(name,0755)) {
          debuga(_("mkdir %s %s\n"),name,strerror(errno));
          debuga(_("process aborted.\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
    }
 }
@@ -434,11 +434,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");
-         exit(1);
+         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");
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 }
 
@@ -683,7 +683,7 @@ void obtdate(const char *dirname, const char *name, char *data)
 
    if (!fgets(data,80,fp_in)) {
       debuga(_("Failed to read the date in %s\n"),wdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
    fixendofline(data);
@@ -751,7 +751,7 @@ int obtuser(const char *dirname, const char *name)
 
    if (!fgets(tuser,sizeof(tuser),fp_in)) {
       debuga(_("Failed to read the number of users in %s\n"),wdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fclose(fp_in);
    nuser=atoi(tuser);
@@ -786,7 +786,7 @@ void obttotal(const char *dirname, const char *name, char *tbytes, int nuser, ch
 
    if (longline_prepare(&line)<0) {
       debuga(_("Not enough memory to read the file %s\n"),wdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -799,17 +799,17 @@ void obttotal(const char *dirname, const char *name, char *tbytes, int nuser, ch
       getword_start(&gwarea,buf);
       if (getword(user,sizeof(user),&gwarea,sep)<0) {
          debuga(_("There is a invalid user in file %s\n"),wdir);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if(strcmp(user,"TOTAL") != 0)
          continue;
       if (getword_skip(MAXLEN,&gwarea,sep)<0) {
          debuga(_("There a broken total number of access in file %s\n"),wdir);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (getword_atoll(&twork,&gwarea,sep)<0) {
          debuga(_("There is a broken number of bytes in file %s\n"),wdir);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcpy(tbytes,fixnum(twork,1));
       break;
@@ -840,7 +840,7 @@ void gperiod(const char *dirname, const char *period)
 
    if((fp_ou=fopen(wdirname,"w"))==NULL){
       fprintf(stderr, "SARG: (report) %s: %s\n",_("Cannot open file"),wdirname);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    fputs(period,fp_ou);
@@ -868,7 +868,7 @@ static void copy_images(void)
 
    if (snprintf(images,sizeof(images),"%simages",outdir)>=sizeof(images)) {
       debuga(_("Cannot copy images to target directory %simages\n"),outdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if (access(images,R_OK)!=0) {
       mkdir(images,0755);
@@ -1051,7 +1051,7 @@ void vrfydir(const char *per1, const char *addr, const char *site, const char *u
    if ((fp_ou = fopen(wdir, "wt")) == 0) {
       debuga(_("cannot open %s for writing\n"),wdir);
       perror("SARG:");
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    time(&curtime);
    //strftime(wdir,sizeof(wdir),"%a %b %d %H:%M:%S %Z %Y",localtime(&curtime));
@@ -1152,7 +1152,7 @@ void date_from(char *date, char *dfrom, char *duntil)
    if(strchr(wdate,'-') == NULL) {
       if (strlen(wdate)*2+1>=sizeof(wdate)) {
          debuga(_("Invalid date range passed as argument\n"));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       strcat(wdate,"-");
       strcat(wdate,date);
@@ -1161,7 +1161,7 @@ void date_from(char *date, char *dfrom, char *duntil)
 
    if (sscanf(wdate,"%d/%d/%d-%d/%d/%d",&diaf,&mesf,&anof,&diau,&mesu,&anou)!=6) {
       debuga(_("The date range passed as argument is not formated as dd/mm/yyyy-dd/mm/yyyy\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
 
    sprintf(dfrom,"%04d%02d%02d",anof,mesf,diaf);
@@ -1205,6 +1205,7 @@ void removetmp(const char *outdir)
 
    FILE *fp_in;
    char warea[256];
+   char buf[MAXLEN];
 
    if(!RemoveTempFiles)
       return;
@@ -1214,11 +1215,11 @@ void removetmp(const char *outdir)
    }
    if (snprintf(warea,sizeof(warea),"%s/sarg-general",outdir)>=sizeof(warea)) {
       debuga(_("(removetmp) directory too long to remove %s/sarg-period\n"),outdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    if((fp_in=fopen(warea,"r"))==NULL){
       debuga(_("(removetmp) Cannot open file %s\n"),warea);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       if(strncmp(buf,"TOTAL",5) == 0 && (buf[6]=='\t' || buf[6]==' '))
@@ -1227,13 +1228,13 @@ void removetmp(const char *outdir)
    fclose(fp_in);
    if((fp_in=fopen(warea,"w"))==NULL){
       debuga(_("(removetmp) Cannot open file %s\n"),warea);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fputs(buf,fp_in);
    fclose(fp_in);
    if (snprintf(warea,sizeof(warea),"%s/sarg-period",outdir)>=sizeof(warea)) {
       debuga(_("(removetmp) directory too long to remove %s/sarg-period\n"),outdir);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlink(warea);
 
@@ -1252,13 +1253,13 @@ void load_excludecodes(const char *ExcludeCodes)
 
    if((excludecode=(char *) malloc(1024))==NULL) {
       debuga(_("malloc error (1024)\n"));
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    bzero(excludecode,1024);
 
    if((fp_in=fopen(ExcludeCodes,"r"))==NULL) {
      debuga(_("(util) Cannot open file %s (exclude_codes)\n"),ExcludeCodes);
-     exit(1);
+     exit(EXIT_FAILURE);
    }
 
    while(fgets(data,sizeof(data),fp_in)!=NULL) {
@@ -1414,17 +1415,17 @@ char *get_size(const char *path, const char *file)
 
    if (snprintf(cmd,sizeof(cmd),"du -skh %s%s",path,file)>=sizeof(cmd)) {
       debuga(_("Cannot get disk space because the path %s%s is too long\n"),path,file);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    fp = popen(cmd, "r");
    if (!fgets(response, sizeof(response), fp)) {
       debuga(_("Cannot get disk size with command %s\n"),cmd);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    ptr=strchr(response,'\t');
    if (ptr==NULL) {
       debuga(_("The command %s failed\n"),cmd);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    pclose(fp);
    *ptr='\0';
@@ -1537,12 +1538,12 @@ void baddata(void)
 
    if (snprintf(dir,sizeof(dir),"%s/sarg",tmp)>=sizeof(dir)) {
       debuga(_("temporary directory too long: %s/sarg\n"),tmp);
-      exit(1);
+      exit(EXIT_FAILURE);
    }
    unlinkdir(dir,0);
    unlinkdir(outdirname,0);
 
-   exit(1);
+   exit(EXIT_FAILURE);
 }
 
 void url_hostname(const char *url,char *hostname,int hostsize)
@@ -1631,7 +1632,7 @@ void unlinkdir(const char *dir,int contentonly)
          continue;
       if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) {
          debuga(_("directory name to delete too long: %s/%s\n"),dir,direntp->d_name);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
 #ifdef HAVE_LSTAT
       err=lstat(dname,&st);
@@ -1640,12 +1641,12 @@ void unlinkdir(const char *dir,int contentonly)
 #endif
       if (err) {
          debuga(_("cannot stat %s\n"),dname);
-         exit(1);
+         exit(EXIT_FAILURE);
       }
       if (S_ISREG(st.st_mode)) {
          if (unlink(dname)) {
             debuga(_("cannot delete %s - %s\n"),dname,strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
       } else if (S_ISDIR(st.st_mode)) {
          unlinkdir(dname,0);
@@ -1658,7 +1659,7 @@ void unlinkdir(const char *dir,int contentonly)
    if (!contentonly) {
       if (rmdir(dir)) {
          debuga(_("cannot delete %s - %s\n"),dir,strerror(errno));
-         exit(1);
+         exit(EXIT_FAILURE);
       }
    }
 }
@@ -1712,7 +1713,7 @@ char *longline_read(FILE *fp_in,struct longlinestruct *line)
          newbuf=realloc(line->buffer,line->size);
          if (!newbuf) {
             debuga(_("Not enough memory to read one more line from the input log file\n"));
-            exit(1);
+            exit(EXIT_FAILURE);
          }
          line->buffer=newbuf;
       }
@@ -1725,7 +1726,7 @@ char *longline_read(FILE *fp_in,struct longlinestruct *line)
             newbuf=realloc(line->buffer,line->size);
             if (!newbuf) {
                debuga(_("Not enough memory to read one more line from the input log file\n"));
-               exit(1);
+               exit(EXIT_FAILURE);
             }
             line->buffer=newbuf;
          }