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)
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) {
int z=0;
int count=0;
int cstatus;
- int new_user;
+ bool new_user;
struct getwordstruct gwarea;
struct longlinestruct line;
struct userinfostruct *uinfo;
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"));
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 {
rotate_left(node);
break;
default:
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
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="")
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);
{
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";
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) {
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;
}
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) {
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);
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);
}
FILE *fp_in = NULL, *fp_ou = NULL;
+ char buf[MAXLEN];
char *url;
char dansguardian_in[MAXLEN];
char per[MAXLEN];
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;
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"));
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)
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;
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) {
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(oldurl,accurl);
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;
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(oldurl,accurl);
if(access(arq, R_OK) != 0) {
debuga(_("File not found: %s\n"),arq);
- exit(1);
+ exit(EXIT_FAILURE);
}
arqlen=strlen(arq);
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);
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);
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);
if(access(arq, R_OK) != 0) {
debuga(_("File not found: %s\n"),arq);
- exit(1);
+ exit(EXIT_FAILURE);
}
if((strcmp(zip,"gzip") != 0) &&
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;
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"));
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) {
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;
-/*! \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
-/*! \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.
-/*! \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
-/*! \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.
-/*! \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.
-/*! \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.
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"));
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) {
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) {
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++)
DownloadSuffixIndex=malloc(j*sizeof(char *));
if (!DownloadSuffixIndex) {
debuga(_("Too many download suffixes\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
str = DownloadSuffix;
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;
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';
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);
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"));
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;
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);
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;
}
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;
}
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';
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){
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);
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);
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);
if (*buf != '\"') {
debuga(_("Missing double quote after parameter \"%s\"\n"),param);
- exit(1);
+ exit(EXIT_FAILURE);
}
buf++;
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);
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;
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;
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;
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++;
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;
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);
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++;
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;
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;
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) {
sstring = (char *)malloc(sslen);
if (!sstring) {
debuga(_("malloc error (%zu bytes required)\n"),sslen);
- exit(1);
+ exit(EXIT_FAILURE);
}
str = (char *) string;
}
if(access(GraphFont, R_OK) != 0) {
debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
- exit(1);
+ exit(EXIT_FAILURE);
}
im = gdImageCreate(720, 480);
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) {
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) {
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;
}
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) {
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;
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);
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)
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);
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;
getword_start(&gwarea,buf);
if (getword_atoll(<emp,&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(<emp,&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(<emp,&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(<emp,&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(<emp,&gwarea,'\n')<0) {
debuga(_("There is a broken out-cache volume in file %s\n"),arqin);
- exit(1);
+ exit(EXIT_FAILURE);
}
tnoucache+=ltemp;
}
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"));
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) {
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)
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));
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);
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);
#endif
#ifdef HAVE_GD_H
#include <gd.h>
-#define HAVE_GD
gdImagePtr im;
gdPoint points[4];
#endif
#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
#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
char outdir[MAXLEN];
char outdirname[MAXLEN];
-char buf[MAXLEN];
char period[MAXLEN];
char code[MAXLEN];
char code2[MAXLEN];
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;
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;
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];
char BlockIt[255];
unsigned long int NtlmUserFormat;
unsigned long int IndexTree;
-int UserAuthentication;
+bool UserAuthentication;
char AuthUserTemplateFile[1024];
char *str;
char *str2;
char us[50];
char email[MAXLEN];
char test[1];
-char ouser2[255];
char user2[MAXLEN];
char wentp[512];
char addr[MAXLEN];
char cmd[255];
char ImageFile[255];
char tbuf[128];
-char ip[25];
char RealtimeUnauthRec[15];
char LDAPHost[255];
char LDAPBindDN[512];
#cmakedefine HAVE_EXECINFO_H
#cmakedefine HAVE_LIBINTL_H
#cmakedefine HAVE_LIBGEN_H
+#cmakedefine HAVE_STDBOOL_H
#cmakedefine IBERTY_LIB
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);
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);
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);
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);
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);
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);
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);
tempsort=realloc(sortlist,nallocated*sizeof(*item));
if (!tempsort) {
debuga(_("not enough memory to sort the index\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
sortlist=tempsort;
}
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);
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");
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];
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
debuga(_("command: %s\n"),cmd);
- exit(1);
+ exit(EXIT_FAILURE);
}
#endif
}
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
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);
FILE *fp_in, *fp_ou;
DIR *dirp;
struct dirent *direntp;
+ char buf[MAXLEN];
char temp[MAXLEN];
char warea[MAXLEN];
char ftime[128];
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);
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);
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) {
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--;
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);
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++;
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;
break;
case '?':
usage(argv[0]);
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
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)
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);
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);
}
}
}
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;
}
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;
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);
}
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++;
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 ) {
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);
}
}
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]++;
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) {
// 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;
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]) {
} 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);
}
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);
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)
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);
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--;
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;
}
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));
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)) {
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
debuga(_("command: %s\n"),val1);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
}
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);
}
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);
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);
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]);
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);
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);
char typ[128];
char warea[MAXLEN];
char user[MAX_USER_LEN];
+ char ip[25];
char *url;
struct getwordstruct gwarea;
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;
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) {
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;
ourl=realloc(ourl,ourl_size);
if (!ourl) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(ourl,url);
FILE *fp_in, *fp_ou;
+ char buf[MAXLEN];
char data[20];
char odata[20];
char hour[20];
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);
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"));
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);
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) {
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;
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) {
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) {
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') {
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(oldurl,accurl);
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;
oldurltt=realloc(oldurltt,ourltt_size);
if (!oldurltt) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(oldurltt,accurl);
oldurl=realloc(oldurl,ourl_size);
if (!oldurl) {
debuga(_("Not enough memory to store the url\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
strcpy(oldurl,accurl);
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);
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);
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);
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);
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);
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);
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;
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;
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;
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;
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 {
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';
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;
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;
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';
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';
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';
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';
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;
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;
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;
}
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);
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);
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"));
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) {
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;
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);
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);
FILE *fp_in = NULL, *fp_ou = NULL, *fp_user = NULL;
+ char buf[MAXLEN];
char url[MAXLEN];
char csort[255];
char smart_in[MAXLEN];
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);
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);
}
if ((fp_user = fopen(smartuser, "a")) == 0) {
debuga(_("(smartfilter) Cannot open file %s\n"),smartuser);
- exit(1);
+ exit(EXIT_FAILURE);
}
fuser=1;
int cstatus;
const char tmpext[]=".utmp";
int dlen;
-
char csort[MAXLEN];
char arqou[MAXLEN], arqin[MAXLEN], wnome[MAXLEN];
const char *field1="2,2";
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);
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);
}
--- /dev/null
++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
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);
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;
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) {
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);
}
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.
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];
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);
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;
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);
FILE *fp_in = NULL, *fp_ou = NULL;
+ char buf[MAXLEN];
char *url;
char squidguard_in[MAXLEN];
char per[MAXLEN];
char data[15];
char data2[15];
char hora[15];
+ char ouser2[255];
int z=0;
int count=0;
struct getwordstruct gwarea;
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"));
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)
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);
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) {
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);
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);
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);
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"));
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;
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);
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';
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) {
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);
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;
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);
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);
FILE *fp_in, *fp_ou;
+ char buf[200];
char data[20];
char hora[20];
char min[20];
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) {
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) {
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)
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);
{
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];
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) {
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);
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);
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);
}
}
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);
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)
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) {
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) {
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';
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) {
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);
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.;
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)
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;
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++];
}
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++];
}
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. */
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 */
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)
{
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;
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;
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;
#if USE_GETWORD_BACKTRACE
getword_backtrace();
#endif
- //exit(1);
+ //exit(EXIT_FAILURE);
return(-1);
}
word[x] = gwarea->current[x];
return(0);
}
-int getword_skip(int limit, struct getwordstruct *gwarea, int stop)
+int getword_skip(int limit, struct getwordstruct *gwarea, char stop)
{
int x;
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;
}
-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
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';
if(mkdir(w0,0755)) {
debuga(_("mkdir %s %s\n"),w0,strerror(errno));
debuga(_("process aborted.\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
}
if(mkdir(name,0755)) {
debuga(_("mkdir %s %s\n"),name,strerror(errno));
debuga(_("process aborted.\n"));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
}
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);
}
}
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);
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);
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) {
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;
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);
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);
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));
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);
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);
FILE *fp_in;
char warea[256];
+ char buf[MAXLEN];
if(!RemoveTempFiles)
return;
}
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]==' '))
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);
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) {
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';
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)
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);
#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);
if (!contentonly) {
if (rmdir(dir)) {
debuga(_("cannot delete %s - %s\n"),dir,strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
}
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;
}
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;
}