if(strstr(linebuf,"logfile turned over") != 0) continue;
if(linebuf[0] == ' ') continue;
- // Record only hours usage which is required
- tt = (time_t) strtoul( linebuf, NULL, 10 );
- t = localtime( &tt );
-
- if( bsearch( &( t -> tm_wday ), weekdays.list, weekdays.len,
- sizeof( int ), compar ) == NULL )
- continue;
-
- if( bsearch( &( t -> tm_hour ), hours.list, hours.len,
- sizeof( int ), compar ) == NULL )
- continue;
-
// exclude_string
if(ExcludeString[0] != '\0') {
exstring=0;
if (ilf==ILF_Squid || ilf==ILF_Common || ilf==ILF_Unknown) {
getword_start(&gwarea,linebuf);
if (getword(data,sizeof(data),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken time in your access.log file.\n");
+ debuga(_("Maybe you have a broken time in your access.log file.\n"));
exit(1);
}
if((str=(char *) strchr(data, '.')) != (char *) NULL ) {
strcpy(elap,"0");
if(squid24) {
if (getword(user,sizeof(user),&gwarea,' ')<0 || getword_skip(255,&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
} else {
if (getword_skip(255,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
}
if (getword(data,sizeof(data),&gwarea,']')<0 || getword_skip(MAXLEN,&gwarea,'"')<0 ||
getword(fun,sizeof(fun),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword_ptr(linebuf,&url,&gwarea,' ')<0) {
}
if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(code2,sizeof(code2),&gwarea,' ')<0 ||
getword(tam,sizeof(tam),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if((str=(char *) strchr(gwarea.current, ' ')) != (char *) NULL ) {
if (getword(code,sizeof(code),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
} else {
if (getword(code,sizeof(code),&gwarea,'\0')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
}
if(ilf==ILF_Unknown || ilf==ILF_Squid) {
if (getword(elap,sizeof(elap),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken elapsed time in your %s file.\n"),arq);
exit(1);
}
while(strcmp(elap,"") == 0 && gwarea.current[0] != '\0')
if (getword(elap,sizeof(elap),&gwarea,' ')<0) {
- printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken elapsed time in your %s file.\n"),arq);
exit(1);
}
if(strlen(elap) < 1) continue;
if (getword(ip,sizeof(ip),&gwarea,' ')<0){
- printf("SARG: Maybe you have a broken client IP address in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken client IP address in your %s file.\n"),arq);
exit(1);
}
if (getword(code,sizeof(code),&gwarea,' ')<0){
- printf("SARG: Maybe you have a broken result code in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken result code in your %s file.\n"),arq);
exit(1);
}
if (getword(tam,sizeof(tam),&gwarea,' ')<0){
- printf("SARG: Maybe you have a broken amount of data in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken amount of data in your %s file.\n"),arq);
exit(1);
}
if (getword(fun,sizeof(fun),&gwarea,' ')<0){
- printf("SARG: Maybe you have a broken request method in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken request method in your %s file.\n"),arq);
exit(1);
}
if (getword_ptr(linebuf,&url,&gwarea,' ')<0){
exit(1);
}
if (getword(user,sizeof(user),&gwarea,' ')<0){
- printf("SARG: Maybe you have a broken user ID in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken user ID in your %s file.\n"),arq);
exit(1);
}
ilf=ILF_Squid;
if (ilf==ILF_Sarg) {
getword_start(&gwarea,linebuf);
if (getword(data,sizeof(data),&gwarea,'\t')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword_ptr(linebuf,&url,&gwarea,'\t')<0){
exit(1);
}
if (getword(tam,sizeof(tam),&gwarea,'\t')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(code,sizeof(code),&gwarea,'\t')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(elap,sizeof(elap),&gwarea,'\t')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if (getword(smartfilter,sizeof(smartfilter),&gwarea,'\0')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
}
ncols=0;
while(gwarea.current[0] != '\0') {
if (getword(val1,sizeof(val1),&gwarea,'\t')<0){
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+ debuga(_("Maybe you have a broken record or garbage in your %s file.\n"),arq);
exit(1);
}
if(strcmp(val1,"c-ip") == 0) cols[ISACOL_Ip]=ncols;
snprintf(tbuf,sizeof(tbuf),"%s%s%s",dia,mes,ano);
builddia(dia,mes,ano,df,wdata);
idata=atoi(wdata);
+ tt=computedate(ano,mes,dia);
+ t=localtime(&tt);
} else if (ilf==ILF_Sarg) {
getword_start(&gwarea,data);
if(strcmp(df,"u") == 0) {
}
snprintf(wdata,9,"%s%s%s",ano,mes,dia);
idata=atoi(wdata);
+ tt=computedate(ano,mes,dia);
+ t=localtime(&tt);
}
if(debugm)
if(idata < dfrom || idata > duntil) continue;
}
+ // Record only hours usage which is required
+ if( bsearch( &( t -> tm_wday ), weekdays.list, weekdays.len,
+ sizeof( int ), compar ) == NULL )
+ continue;
+
+ if( bsearch( &( t -> tm_hour ), hours.list, hours.len,
+ sizeof( int ), compar ) == NULL )
+ continue;
+
+
if(strlen(user) > MAX_USER_LEN) {
if (debugm) printf(_("User ID too long: %s\n"),user);
totregsx++;
exit(1);
}
if ((ufile->file = MY_FOPEN (tmp3, "a")) == NULL) {
- fprintf (stderr, "%s: (log) %s: %s - %s\n", argv[0], _("Cannot open temporary file"), tmp3, strerror(errno));
+ debuga(_("(log) Cannot open temporary file: %s - %s\n"), tmp3, strerror(errno));
exit (1);
}
}
if ( ! fp_Download_Unsort ) {
if ((fp_Download_Unsort = MY_FOPEN ( sz_Download_Unsort, "a")) == NULL) {
- fprintf (stderr, "%s: (log) %s: %s - %s\n", argv[0], _("Cannot open temporary file"), tmp3, strerror(errno));
+ debuga(_("(log) Cannot open temporary file: %s - %s\n"),tmp3, strerror(errno));
exit (1);
}
}
if (!from_stdin) {
fclose(fp_in);
if( ShowReadStatistics )
- printf("SARG: Records in file: %lu, reading: %3.2f%%\n",recs1, (float) 100 );
+ printf(_("SARG: Records in file: %lu, reading: %3.2f%%\n"),recs1, (float) 100 );
}
}
if(totalcount==0) {
if(!totregsg) {
- fprintf(stderr, "SARG: %s\n",_("No records found"));
- fprintf(stderr, "SARG: %s\n",_("End"));
- } else fprintf(stderr, "SARG: %s\n",_("Log with invalid format"));
+ debuga(_("No records found\n"));
+ debuga(_("End\n"));
+ } else debuga(_("Log with invalid format\n"));
if(fp_denied)
fclose(fp_denied);
if(fp_authfail)
}
if(!totregsg){
- fprintf(stderr, "SARG: %s\n",_("No records found"));
- fprintf(stderr, "SARG: %s\n",_("End"));
+ debuga(_("No records found\n"));
+ debuga(_("End\n"));
// fclose(fp_ou);
if(fp_denied)
fclose(fp_denied);
strcpy(end_hour,tbuf2);
getword_start(&gwarea,period);
if (getword(val2,sizeof(val2),&gwarea,'-')<0){
- printf("SARG: Maybe you have a broken date range definition.\n");
+ debuga(_("Maybe you have a broken date range definition.\n"));
exit(1);
}
if (getword(val1,sizeof(val1),&gwarea,'\0')<0){
- printf("SARG: Maybe you have a broken date range definition.\n");
+ debuga(_("Maybe you have a broken date range definition.\n"));
exit(1);
}
sprintf(val4,"%s/sarg-%s_%s-%s_%s.log",ParsedOutputLog,val2,start_hour,val1,end_hour);
if (rename(arq_log,val4)) {
- fprintf(stderr,"SARG: failed to rename %s to %s - %s\n",arq_log,val4,strerror(errno));
+ debuga(_("failed to rename %s to %s - %s\n"),arq_log,val4,strerror(errno));
} else {
strcpy(arq_log,val4);
sprintf(val1,"%s \"%s\"",ParsedOutputLogCompress,arq_log);
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);
+ debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(_("command: %s\n"),val1);
exit(1);
}
}
sprintf(csort,"sort -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,denied_sort,denied_unsort);
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);
+ debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(_("sort command: %s\n"),csort);
exit(1);
}
unlink(denied_unsort);
debuga(_("Loading password file from: %s\n"),pwdfile);
if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
- fprintf(stderr, "SARG: (getusers) %s: %s - %s\n",_("Cannot open file"),pwdfile,strerror(errno));
+ debuga(_("(getusers) Cannot open file: %s - %s\n"),pwdfile,strerror(errno));
exit(1);
}
fseek(fp_usr, 0, SEEK_END);
nreg = ftell(fp_usr);
if (nreg<0) {
- printf("SARG: Cannot get the size of file %s",pwdfile);
+ debuga(_("Cannot get the size of file %s\n"),pwdfile);
exit(1);
}
nreg = nreg+5000;
fseek(fp_usr, 0, SEEK_SET);
if((userfile=(char *) malloc(nreg))==NULL){
- fprintf(stderr, "SARG: %s (%ld):\n",_("malloc error"),nreg);
+ debuga(_("malloc error (%ld):\n"),nreg);
exit(1);
}
while(fgets(buf,sizeof(buf),fp_usr)!=NULL) {
str=strchr(buf,':');
if (!str) {
- printf("SARG: You have an invalid user in your %s file.\n",pwdfile);
+ debuga(_("You have an invalid user in your %s file.\n"),pwdfile);
exit(1);
}
str[1]=0;