SARG ChangeLog
-Dec-18-2009 Version 2.2.7
+Dec-21-2009 Version 2.2.7
- Extra compile and run time protection (FORTIFY_SOURCE) fixed in configure.
- Use tabulations as columns separator in intermediary files to avoid problems when a field of the log contains a space.
- Input log file type detection partly rewritten to clearly distinguish which type is processed where.
- Read the input log file from standard input if log file name is -.
- Use string pointers in getword instead of copying the strings over and over.
- Use LC_TIME to format some dates and times in the report according to the selected locale.
+ - Sarg.conf can list up to 255 access.log files.
+ - Downloaded files suffixes are matched against a sorted list and use a dicchotomic search.
+ - Added getword_atoll to read a number directly from a file without an intermediary string storage.
+ - Use boolean to enable some options instead of string compares.
Dec-17-2009 Version 2.2.6.1
- Remove unecessary dependency on off_t.
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(ip,sizeof(ip));
if(!z) {
exit(1);
}
- if(strcmp(UserIp,"yes") == 0)
+ if(UserIp)
strcpy(user,ip);
bzero(date, 15);
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(ip,sizeof(ip));
if(!z) {
exit(1);
}
- if(strcmp(Ip2Name,"yes") == 0) {
+ if(Ip2Name) {
if(strcmp(accip,ipantes) != 0) {
strcpy(ipantes,accip);
ip2name(accip,sizeof(accip));
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(ip,sizeof(ip));
if(!z) {
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(ip,sizeof(ip));
if(!z) {
return(1);
}
+static int getparam_bool(const char *param,char *buf,int *value)
+{
+ int plen;
+ char *str;
+ int i;
+
+ plen=strlen(param);
+ if (strncmp(buf,param,plen) != 0) return(0);
+ buf+=plen;
+ if ((unsigned char)*buf>' ') return(0);
+ while (*buf && (unsigned char)*buf<=' ') buf++;
+
+ *value=0;
+ for (str=text[144] ; *str ; str+=i) {
+ for (i=0 ; str[i] && str[i]!=',' ; i++);
+ if (strncasecmp(str,buf,i)==0) {
+ *value=1;
+ break;
+ }
+ if (str[i]==',') i++;
+ }
+ return(1);
+}
+
static void parmtest(char *buf)
{
char wbuf[50];
if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
- if (getparam_string("resolve_ip",buf,Ip2Name,sizeof(Ip2Name))>0) return;
+ if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
- if (getparam_string("user_ip",buf,UserIp,sizeof(UserIp))>0) return;
+ if (getparam_bool("user_ip",buf,&UserIp)>0) return;
if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
if (getparam_2words("topsites_sort_order",buf,TopsitesSortField,sizeof(TopsitesSortField),TopsitesSortType,sizeof(TopsitesSortType))>0) return;
- if (getparam_string("long_url",buf,LongUrl,sizeof(LongUrl))>0) return;
+ if (getparam_bool("long_url",buf,&LongUrl)>0) return;
if (getparam_string("language",buf,language,sizeof(language))>0) return;
if(strstr(wuser,"_") != 0)
fixip(wuser);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
if((str=(char *) strstr(name, ".")) != (char *) NULL) {
if((str=(char *) strstr(str+1, ".")) != (char *) NULL)
ip2name(wuser,sizeof(wuser));
strcpy(u2,usuario);
if(userip)
fixip(u2);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(u2,sizeof(u2));
get_usertab_name(u2,name2,sizeof(name2));
strcpy(wwork2,fixnum(nnbytes,1));
strcpy(wwork3,fixnum2(nnelap,1));
- if(strcmp(LongUrl,"yes") != 0) {
+ if(!LongUrl) {
char *endofhost=strchr(url,'/');
if (endofhost) *endofhost='\0';
strcpy(urly,url);
char UserTabFile[255];
char warea[MAXLEN];
char name[MAXLEN];
-char LongUrl[20];
-char Ip2Name[20];
+int LongUrl;
+int Ip2Name;
char language[255];
char bufy[MAXLEN];
int NAccessLog;
char DateFormat[2];
char PerUserLimitFile[255];
char PerUserLimit[20];
-char UserIp[5];
+int UserIp;
char MaxElapsed[255];
char datetimeby[10];
char csort[255];
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"fin du fichier atteinte prématurément pour"
"analyse du fichier suivant"
"Log produit par Microsoft ISA"
+"yes,true,on,1,oui,vrai"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
"unexpected end of file encountered in"
"skipping to next file"
"Log is from Microsoft ISA"
+"yes,true,on,1"
LogoText[0]='\0';
PasswdFile[0]='\0';
OutputEmail[0]='\0';
- Ip2Name[0]='\0';
UserAgentLog[0]='\0';
ExcludeHosts[0]='\0';
ExcludeUsers[0]='\0';
ConfigFile[0]='\0';
code[0]='\0';
LastLog[0]='\0';
- UserIp[0]='\0';
ReportType[0]='\0';
UserTabFile[0]='\0';
BlockIt[0]='\0';
strcpy(FontSize,"9px");
strcpy(TempDir,"/tmp");
strcpy(OutputDir,"/var/www/html/squid-reports");
- strcpy(Ip2Name,"no");
+ Ip2Name=0;
strcpy(DateFormat,"u");
strcpy(OverwriteReport,"no");
strcpy(RemoveTempFiles,"yes");
strcpy(UseComma,"no");
strcpy(MailUtility,"mailx");
strcpy(TopSitesNum,"100");
- strcpy(UserIp,"no");
+ UserIp=0;
strcpy(TopuserSortField,"BYTES");
strcpy(UserSortField,"BYTES");
strcpy(TopuserSortOrder,"reverse");
strcpy(UserSortOrder,"reverse");
strcpy(TopsitesSortField,"CONNECT");
strcpy(TopsitesSortType,"D");
- strcpy(LongUrl,"no");
+ LongUrl=0;
strcpy(language,"English");
strcpy(FontFace,"Verdana,Tahoma,Arial");
strcpy(datetimeby,"elap");
if(strcmp(ExcludeUsers,"indexonly") == 0) indexonly++;
if(strcmp(Index,"only") == 0) indexonly++;
- if(dns) strcpy(Ip2Name,"yes");
+ if(dns) Ip2Name=1;
- if(strcmp(UserIp,"yes") == 0) userip++;
+ if(UserIp) userip++;
if(strlen(MaxElapsed)>1) max_elapsed=atol(MaxElapsed);
fprintf(stderr, "SARG: %35s (-i) = %s\n",text[28],text[2]);
for (iarq=0 ; iarq<NAccessLog ; iarq++)
fprintf(stderr, "SARG: %35s (-l) = %s\n",text[37],AccessLog[iarq]);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
fprintf(stderr, "SARG: %35s (-n) = %s\n",text[65],text[1]);
else
fprintf(stderr, "SARG: %35s (-n) = %s\n",text[65],text[2]);
fprintf(stderr, "SARG: %35s (-o) = %s\n",text[38],outdir);
- if(strcmp(UserIp,"yes") == 0)
+ if(UserIp)
fprintf(stderr, "SARG: %35s (-p) = %s\n",text[29],text[1]);
else
fprintf(stderr, "SARG: %35s (-p) = %s\n",text[29],text[2]);
printf("%35s (-i) = %s\n",text[28],text[2]);
for (iarq=0 ; iarq<NAccessLog ; iarq++)
printf("%35s (-l) = %s\n",text[37],AccessLog[iarq]);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
printf("%35s (-n) = %s\n",text[65],text[1]);
else
printf("%35s (-n) = %s\n",text[65],text[2]);
printf("%35s (-o) = %s\n",text[38],outdir);
- if(strcmp(UserIp,"yes") == 0)
+ if(UserIp)
printf("%35s (-p) = %s\n",text[29],text[1]);
else
printf("%35s (-p) = %s\n",text[29],text[2]);
url[i]='\0';
}
- if(strcmp(LongUrl,"no") == 0) {
+ if(!LongUrl) {
char *endofhost=strchr(url,'/');
if (endofhost)
*endofhost='\0';
continue;
strcpy(u2,user);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(u2,sizeof(u2));
get_usertab_name(u2,name,sizeof(name));
if(strstr(wuser,"_") != 0)
fixip(wuser);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
if((str=(char *) strstr(name, ".")) != (char *) NULL) {
if((str=(char *) strstr(str+1, ".")) != (char *) NULL)
ip2name(wuser,sizeof(wuser));
maketmp_hour(user,tmp,indexonly);
strcpy(u2,user);
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(u2,sizeof(u2));
get_usertab_name(u2,name,sizeof(name));
grava_SmartFilter(wdirname,accuser,accip,accdia,acchora,accurl,accsmart);
}
- if(strcmp(Ip2Name,"yes") == 0) {
+ if(Ip2Name) {
if(strcmp(accip,ipantes) != 0) {
strcpy(ipantes,accip);
ip2name(accip,sizeof(accip));
exit(1);
}
- if(strcmp(UserIp,"yes") == 0)
+ if(UserIp)
strcpy(user,ip);
bzero(data, 15);
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(Ip2Name)
ip2name(ip,sizeof(ip));
if(!z) {
if(userip) {
fixip(user2);
- if(strcmp(Ip2Name,"yes") == 0) {
+ if(Ip2Name) {
if(strcmp(user2,ipantes) != 0) {
strcpy(ipantes,user2);
ip2name(user2,sizeof(user2));
if(strcmp(user2,"TOTAL") != 0) {
get_usertab_name(user2,name,sizeof(name));
- if((strcmp(Ip2Name,"yes") == 0) &&
+ if(Ip2Name &&
((str=(char *) strstr(name, ".")) != (char *) NULL) &&
((str=(char *) strstr(str+1, ".")) != (char *) NULL))
ip2name(name,sizeof(name));
exit(1);
}
- if(strcmp(Ip2Name,"yes") == 0) {
+ if(Ip2Name) {
if(strcmp(ip,ipbefore) != 0) {
strcpy(ipbefore,ip);
ip2name(ip,sizeof(ip));