The format of the date written in sarg-date is forced to prevent a failure if the locale is not en_US.
char *str;
int z=0;
int count=0;
+ int cstatus;
if(strlen(DataFile) > 0) return;
sprintf(per,"%s/sarg-period",dirname);
sprintf(report,"%s/authfail.html",dirname);
- sprintf(csort,"sort -b -T %s -k 3,3 -k 5,5 -o '%s' '%s'", TempDir, authfail_in, tmp4);
- system(csort);
- unlink(tmp4);
-
if ((fp_in = fopen(per, "r")) == 0) {
fprintf(stderr, "SARG: (authfail) %s: %s\n",text[45],per);
exit(1);
}
-
fgets(period,sizeof(period),fp_in);
fclose(fp_in);
+ sprintf(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)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
#if defined(HAVE_FOPEN64)
if((fp_in=(long)fopen64(authfail_in,"r"))==NULL) {
#else
if((fp_in=fopen(authfail_in,"r"))==NULL) {
#endif
- fprintf(stderr, "SARG: (authfail) %s: %s\n",text[45],authfail_in);
- exit(1);
+ fprintf(stderr, "SARG: (authfail) %s: %s\n",text[45],authfail_in);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
}
+ unlink(tmp4);
#if defined(HAVE_FOPEN64)
if((fp_ou=(long)fopen64(report,"w"))==NULL) {
char wdata[127];
int idata=0;
int x, y;
+ int cstatus;
bzero(day, 3);
bzero(mon, 4);
}
sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
- system(tmp6);
+ cstatus=system(tmp6);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",tmp6);
+ exit(1);
+ }
unlink(guard_in);
return;
}
void decomp(char *arq, char *zip, char *tmp)
{
-
char cmd[1024];
+ int cstatus;
if(access(arq, R_OK) != 0) {
sprintf(cmd,"%s: %s",text[64],arq);
sprintf(cmd,"%s: %s > %s/sarg-file.in (zcat)",text[62],arq,tmp);
debuga(cmd);
sprintf(cmd,"zcat %s > %s/sarg-file.in",arq,tmp);
- system(cmd);
+ cstatus=system(cmd);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",cmd);
+ exit(1);
+ }
strcpy(zip,"zcat");
sprintf(arq,"%s/sarg-file.in",tmp);
return;
sprintf(cmd,"%s: %s > %s/sarg-file.in (bzcat)",text[62],arq,tmp);
debuga(cmd);
sprintf(cmd,"bzcat %s > %s/sarg-file.in",arq,tmp);
- system(cmd);
+ cstatus=system(cmd);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",cmd);
+ exit(1);
+ }
strcpy(zip,"zcat");
sprintf(arq,"%s/sarg-file.in",tmp);
return;
sprintf(cmd,"%s: %s (uncompress)",text[62],arq);
debuga(cmd);
sprintf(cmd,"uncompress %s",arq);
- system(cmd);
+ cstatus=system(cmd);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",cmd);
+ exit(1);
+ }
arq[strlen(arq)-2]='\0';
strcpy(zip,"compress");
}
void recomp(char *arq, char *zip)
{
-
char cmd[1024];
+ int cstatus;
if(access(arq, R_OK) != 0) {
sprintf(cmd,"%s: %s",text[64],arq);
if(strcmp(zip,"compress") == 0)
sprintf(cmd,"%s %s",zip,arq);
- system(cmd);
+ cstatus=system(cmd);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",cmd);
+ exit(1);
+ }
return;
}
int totuser=0;
time_t t;
struct tm *local;
+ int cstatus;
strcpy(wger,dirname);
strcpy(top1,dirname);
fclose(fp_top2);
sprintf(csort,"sort -n -T %s -r -k 2,2 -o '%s' '%s'", TempDir, top1, top2);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(top2);
printf("%s",buf);
} else {
sprintf(buf,"%s -s 'SARG %s, %s' %s <%s",MailUtility,text[55],asctime(local),email,top3);
- system(buf);
- }
+ cstatus=system(buf);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",buf);
+ exit(1);
+ }
+ }
sprintf(csort,"rm -rf %s/sarg",TempDir);
system(csort);
long long int tot;
time_t t;
struct tm *local;
+ int cstatus;
#ifdef HAVE_GD
if(strcmp(Graphs,"yes") != 0) {
if(strcmp(DateFormat,"e") == 0)
sprintf(csort,"sort -t'/' -k 1,1 -o '%s' '%s'",tmp5,wdirname);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(tmp5,"r"))==NULL) {
fprintf(stderr, "SARG: (grepday) %s: %s\n",text[8],tmp5);
float perc=0, perc2=0, ouperc=0, inperc=0;
char *s;
int x, count;
+ int cstatus;
if(strstr(ReportType,"users_sites") == 0) return;
fclose(fp_ip2);
sprintf(csort,"sort -n -T %s -k 1,1 -k 5,5 -o '%s' '%s'",TempDir,tmp3,tmp2);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
#if defined(HAVE_FOPEN64)
if ((fp_ip = (long)fopen64(tmp3, "r")) == 0) {
char ftime[128];
char day[4], mon[4], year[6], hour[10];
char h[3], m[3], s[3];
+ int cstatus;
if(LastLog[0] != '\0') mklastlog(outdir,debug);
sprintf(val5,"%s/images",val2);
if(access(val5, R_OK) != 0) {
sprintf(val5,"ln -s %simages %s/images",outdir,val2);
- system(val5);
+ cstatus=system(val5);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",val5);
+ exit(1);
+ }
}
} else {
if(!isdigit(direntp->d_name[0]) && !isdigit(direntp->d_name[1])) continue;
if(strcmp(IndexTree,"date") == 0) {
if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
else sprintf(warea,"sort -r -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
- system(warea);
- unlink(wdir_tmp);
+ cstatus=system(warea);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",warea);
+ exit(1);
+ }
if((fp_tmp=fopen(wdir_tmp2,"r"))==NULL) {
fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir_tmp2);
+ fprintf(stderr, "SARG: sort command: %s\n",warea);
exit(1);
}
+ unlink(wdir_tmp);
if((fp_ou=fopen(wdir,"w"))==NULL) {
fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir);
exit(1);
sprintf(wdir_tmp3,"%s%s/index.sort",outdir,tmp4);
if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp3, wdir_tmp3);
else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp3, wdir_tmp3);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(tmp3);
if((fp_tmp2=fopen(wdir_tmp3,"r"))==NULL) {
fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir_tmp3);
sprintf(tmp6,"%s%s/%s/index.sort",outdir,tmp4,wwork1);
if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp5, tmp6);
else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp5, tmp6);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(tmp5);
sprintf(val2,"%s%s/%s/index.html",outdir,tmp4,wwork1);
sprintf(val3,"%s/%s",tmp4,wwork1);
} else {
if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
else sprintf(warea,"sort -r -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
- system(warea);
+ cstatus=system(warea);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",warea);
+ exit(1);
+ }
+ if((fp_tmp2=fopen(wdir_tmp2,"r"))==NULL) {
+ fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir_tmp2);
+ fprintf(stderr, "SARG: sort command: %s\n",warea);
+ exit(1);
+ }
unlink(wdir_tmp);
if((fp_ou=fopen(wdir,"w"))==NULL) {
fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir);
}
write_html_header(fp_ou,".");
fprintf(fp_ou,"<tr><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc1,text[101],hbc1,text[102],hbc1,text[103],hbc1,text[93],hbc1,text[96]);
- if((fp_tmp2=fopen(wdir_tmp2,"r"))==NULL) {
- fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir_tmp2);
- exit(1);
- }
while(fgets(buf,MAXLEN,fp_tmp2)!=NULL) {
if (getword_multisep(period,sizeof(period),buf,';')<0) {
printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
time_t t;
struct tm *local;
struct stat statb;
+ int cstatus;
if(strcmp(LastLog,"0") == 0)
return;
fclose(fp_ou);
sprintf(buf,"sort -n -k 1,1 -o '%slastlog' '%s'",outdir,temp);
- system(buf);
+ cstatus=system(buf);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",buf);
+ exit(1);
+ }
unlink(temp);
int chm=0;
char uagent[MAXLEN];
char hexclude[MAXLEN];
- char csort[MAXLEN];
+ char csort[MAXLEN];
+ int cstatus;
char tbuf[128];
char tbuf2[128];
char zip[20];
if(strcmp(ParsedOutputLogCompress,"nocompress") != 0) {
sprintf(val1,"%s %s",ParsedOutputLogCompress,arq_log);
- system(val1);
+ cstatus=system(val1);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",val1);
+ exit(1);
+ }
}
if(debug) {
if(strstr(ReportType,"denied") != 0) {
sprintf(csort,"sort -T %s -k 3,3 -k 5,5 -o '%s' '%s'",tmp,tmp5,tmp4);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(tmp4);
}
char cmd[512];
char buf[512];
int fd1,fd2,nreg;
+ int cstatus;
if(UserTabFile[0] != '\0') {
if(debug) {
fclose(tmp);
sprintf(cmd,"sort -r -k 1,1 -k 2,2 -o %s %s",template2,template1);
- system(cmd);
+ cstatus=system(cmd);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",cmd);
+ exit(1);
+ }
unlink(template1);
datashow(template2);
}
int ucount=0;
char *users;
long long int llbytes=0;
+ int cstatus;
if(strcmp(Privacy,"yes") == 0)
return;
fclose(fp_in);
sprintf(csort,"sort -k 4,4 -k 1,1 -o '%s' '%s'",general2,general);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(general2,"r"))==NULL) {
fprintf(stderr, "SARG: (topsite) %s: %s\n",text[8],general2);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
exit(1);
}
char smartuser[MAXLEN];
char *str;
int fuser=0;
+ int cstatus;
ouser[0]='\0';
fclose(fp_in);
sprintf(csort,"sort -n -k 1,1 -k 2,2 -k 3,3 -o '%s' '%s'",smart_ou,smart_in);
- system(csort);
- unlink(smart_in);
-
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(smart_ou,"r"))==NULL) {
- fprintf(stderr, "SARG: (smartfilter) %s: %s\n",text[8],smart_ou);
- exit(1);
+ fprintf(stderr, "SARG: (smartfilter) %s: %s\n",text[8],smart_ou);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
}
+ unlink(smart_in);
if((fp_ou=fopen(report,"w"))==NULL) {
fprintf(stderr, "SARG: (smartfilter) %s: %s\n",text[8],report);
DIR *dirp;
struct dirent *direntp;
+ int cstatus;
char csort[MAXLEN];
char arqou[MAXLEN], arqin[MAXLEN], wnome[MAXLEN], wnome2[MAXLEN];
strcat(arqou,".txt");
sprintf(csort,"sort -n -T %s %s -k %s -k %s -k %s -o '%s' '%s'",TempDir,order,field1,field2,field3,arqou,arqin);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(arqin);
}
char wtmp[MAXLEN];
char wname2[MAXLEN];
char wdname[MAXLEN];
+ int cstatus;
if(debug) {
sprintf(msg,"%s",text[138]);
else
sprintf(csort,"sort -T %s -k 5,5 -k 1,1 -k 2,2 -o '%s/%s.log' '%s/%s.unsort'",
tmp, wtmp, user, wtmp, user);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
sprintf(wdname,"%s/%s.unsort",wtmp,user);
unlink(wdname);
bzero(user, MAXLEN);
char user[MAXLEN];
char ip[30];
int x, y;
+ int cstatus;
str2 = user;
}
sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
- system(tmp6);
+ cstatus=system(tmp6);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",tmp6);
+ exit(1);
+ }
unlink(guard_in);
return;
long long int tntime=0;
long long int twork1=0, twork2=0, twork3=0;
int regs=0;
+ int cstatus;
if(strcmp(Privacy,"yes") == 0)
return;
fclose(fp_in);
sprintf(csort,"sort -k 4,4 -o '%s' '%s'",general2,general);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(general2,"r"))==NULL) {
fprintf(stderr, "SARG: (topsite) %s: %s\n",text[8],general2);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
exit(1);
}
strcpy(sortt,"-r");
sprintf(csort,"sort %s -k %s -o '%s' '%s'",sortt,sortf,sites,general3);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
+ if((fp_in=fopen(sites,"r"))==NULL) {
+ fprintf(stderr, "SARG: (topsite) %s: %s\n",text[8],sites);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(general2);
unlink(general3);
- if((fp_in=fopen(sites,"r"))==NULL) {
- fprintf(stderr, "SARG: (topsite) %s: %s\n",text[8],sites);
- exit(1);
- }
-
if((fp_ou=fopen(report,"w"))==NULL) {
fprintf(stderr, "SARG: (topsite) %s: %s\n",text[8],report);
exit(1);
int totuser=0;
int topcount=0;
char *s;
+ int cstatus;
ipantes[0]='\0';
nameantes[0]='\0';
order[0]='\0';
sprintf(csort,"sort -n -T %s %s -k %s -o '%s' '%s'", TempDir, order, sfield, top1, top2);
- system(csort);
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
+ if((fp_top1=fopen(top1,"a"))==NULL) {
+ fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],top1);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
unlink(top2);
- if((fp_top1=fopen(top1,"a"))==NULL) {
- fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],top1);
- exit(1);
- }
fputs(preg,fp_top1);
fclose(fp_top1);
int regs=0;
long long int telap=0;
long long int tused=0;
+ int cstatus;
if(indexonly) return;
if(strstr(ReportType,"users_sites") == 0) return;
sprintf(sortout,"%s/%s.sort",tmp,user);
sprintf(csort,"sort -k 1,1 -k 2,2 -o '%s' '%s'",sortout,wdirname);
- system(csort);
-
- unlink(wdirname);
-
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(sortout,"r"))==NULL) {
- fprintf(stderr, "SARG: (totday) %s: %s\n",text[8],sortout);
- exit(1);
+ fprintf(stderr, "SARG: (totday) %s: %s\n",text[8],sortout);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
}
+ unlink(wdirname);
+
if((fp_ou=fopen(arqout,"w"))==NULL) {
fprintf(stderr, "SARG: (totday) %s: %s\n",text[8],arqout);
exit(1);
char idate[MAXLEN], fdate[MAXLEN];
int agentot=0, agentot2=0, agentdif=0, cont=0;
unsigned long totregsl=0;
+ int cstatus;
ip[0]='\0';
data[0]='\0';
}
sprintf(csort,"sort -n -t '\\' -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o '%s' '%s'",tmp2,tmp3);
- system(csort);
-
- unlink(tmp3);
-
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(tmp2,"r"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],tmp2);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
exit(1);
}
+ unlink(tmp3);
+
if((fp_ht=fopen(hfile,"w"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],hfile);
exit(1);
fclose(fp_ou);
sprintf(csort,"sort -n -t '\\' -k 3,3 -o '%s' '%s'",tmp3,tmp2);
- system(csort);
-
- unlink(tmp2);
-
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(tmp3,"r"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],tmp3);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
exit(1);
}
+ unlink(tmp2);
+
if((fp_ou=fopen(tmp2,"w"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],tmp2);
exit(1);
unlink(tmp3);
sprintf(csort,"sort -n -r -k 1,1 -o '%s' '%s'",tmp3,tmp2);
- system(csort);
-
- unlink(tmp2);
-
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
+ exit(1);
+ }
if((fp_in=fopen(tmp3,"r"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],tmp3);
+ fprintf(stderr, "SARG: sort command: %s\n",csort);
exit(1);
}
+ unlink(tmp2);
+
if((fp_ht=fopen(hfile,"a"))==NULL) {
fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],hfile);
exit(1);
char images[512];
DIR *dirp;
struct dirent *direntp;
+ int cstatus;
if(strcmp(IndexTree,"date") == 0) {
bzero(y1,5);
sprintf(images,"%simages",outdir);
mkdir(images,0755);
- sprintf(wdir,"date >%s/%s",dirname,"sarg-date");
- system(wdir);
+ sprintf(wdir,"date \"+%%a %%b %%d %%H:%%M:%%S %%Z %%Y\" >%s/sarg-date",dirname);
+ cstatus=system(wdir);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
+ fprintf(stderr, "SARG: command: %s\n",wdir);
+ exit(1);
+ }
sprintf(per2,"%s/images",SYSCONFDIR);