13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, 24 };
static void getusers(const char *pwdfile, int debug);
-void gethexclude(char *hexfile, int debug);
-void getuexclude(char *uexfile, int debug);
-void ttx(char *user);
-
-#define _FILE_OFFSET_BITS 64
+static void gethexclude(const char *hexfile, int debug);
+static void getuexclude(const char *uexfile, int debug);
int main(int argc,char *argv[])
{
char fun[MAXLEN];
char wuser[MAXLEN];
char smartfilter[MAXLEN];
- char dia[128];
+ char dia[128];
char wdata[128];
char mes[30];
char ano[30];
char *str;
char bufz[MAXLEN];
char bufy[MAXLEN];
- int common;
+ int common;
int common_log=0;
int squid_log=0;
int ch;
int iarq=0;
int exstring=0;
int i0=0,i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0;
- long totregsl=0;
+ long totregsl=0;
long totregsg=0;
long totregsx=0;
long totper=0;
bzero(IncludeUsers, MAXLEN);
bzero(ExcludeString, MAXLEN);
- for(x=0; x<=254; x++)
+ for(x=0; x<=254; x++)
warq[x][0]='\0';
language_load(language);
sprintf(tmp3,"rm -rf %s",warea);
system(tmp3);
}
-
+
sprintf(tmp3,"%s/sarg",tmp);
my_mkdir(tmp3);
strcpy(tmp4,tmp3);
if( bool_ShowReadStatistics && ! --OutputNonZero) {
perc = recs2 * 100 ;
perc = perc / recs1 ;
- printf("SARG: Records in file: " OFFSET_STRING ", reading: %3.2f%%\r",recs1,perc);
+ printf("SARG: Records in file: " OFFSET_STRING", reading: %3.2f%%\r",recs1,perc);
fflush (stdout);
OutputNonZero = REPORT_EVERY_X_LINES ;
}
strcpy(bufy,bufz);
if ((str = strchr(bufz, '\n')) != NULL)
- *str = '\0'; /* strip \n */
+ *str = '\0'; /* strip \n */
totregsl++;
common=0;
else strcpy(code,bufz);
if ((str = strchr(code, ':')) != NULL)
- *str = '/';
+ *str = '/';
if(strcmp(tam,"\0") == 0)
strcpy(tam,"0");
}
if (strchr(url,'/')) {
+ // remove any protocol:// at the beginning of the URL
if (getword(w,sizeof(w),url,'/')<0){
printf("SARG: Maybe you have a broken url in your %s file.\n",arq);
exit(1);
exit(1);
}
strcpy(url,w);
- if(strlen(url) > 512 && strstr(url,"%") != 0) {
+ if(strlen(url) > 512 && strchr(url,'%') != NULL) {
if (getword_multisep(w,sizeof(w),url,'%')<0){
printf("SARG: Maybe you have a broken url in your %s file.\n",arq);
exit(1);
if(strcmp(user,"-") == 0 || strcmp(user," ") == 0 || strcmp(user,"") == 0) {
if(strcmp(RecordsWithoutUser,"ip") == 0)
- strcpy(user,ip);
+ strcpy(user,ip);
if(strcmp(RecordsWithoutUser,"ignore") == 0)
- continue;
+ continue;
if(strcmp(RecordsWithoutUser,"everybody") == 0)
- strcpy(user,"everybody");
+ strcpy(user,"everybody");
}
if(dotinuser) {
printf("SARG: Records in file: " OFFSET_STRING ", reading: %3.2f%%\n",recs1, (float) 100 );
}
- if ( fp_Download_Unsort )
+ if ( fp_Download_Unsort )
fclose (fp_Download_Unsort);
- if (fp_Write_User)
+ if (fp_Write_User)
fclose (fp_Write_User);
if(debug) {
if((common_log) && (squid_log))
debuga("%s",text[12]);
- if((common_log) && (!squid_log))
+ if((common_log) && (!squid_log))
debuga("%s",text[13]);
if((!common_log) && (squid_log))
fclose(fp_authfail);
if(strcmp(ParsedOutputLog, "no") != 0 && !sarglog) {
- fclose(fp_log);
+ fclose(fp_log);
strcpy(val1,period);
if (getword_multisep(val2,sizeof(val2),val1,'-')<0){
printf("SARG: Maybe you have a broken date range definition.\n");
}
-void gethexclude(char *hexfile, int debug)
+static void gethexclude(const char *hexfile, int debug)
{
FILE *fp_ex;
}
fseek(fp_ex, (off_t)0, SEEK_END);
- nreg = ftell(fp_ex);
+ nreg = ftell(fp_ex)+11;
fseek(fp_ex, (off_t)0, SEEK_SET);
- if((excludefile=(char *) malloc(nreg+11))==NULL){
+ if((excludefile=(char *) malloc(nreg))==NULL){
fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg);
exit(1);
}
- bzero(excludefile,nreg+11);
+ bzero(excludefile,nreg);
- while(fgets(buf,255,fp_ex)!=NULL){
- if(strstr(buf,"#") != 0)
+ while(fgets(buf,sizeof(buf),fp_ex)!=NULL){
+ if(strchr(buf,'#') != NULL)
continue;
- buf[strlen(buf)-1]='\0';
+ fixendofline(buf);
strcat(excludefile,buf);
strcat(excludefile," ");
}
}
-void getuexclude(char *uexfile, int debug)
+static void getuexclude(const char *uexfile, int debug)
{
FILE *fp_ex;
}
fseek(fp_ex, (off_t)0, SEEK_END);
- nreg = ftell(fp_ex);
+ nreg = ftell(fp_ex)+11;
fseek(fp_ex, (off_t)0, SEEK_SET);
- if((excludeuser=(char *) malloc(nreg+11))==NULL){
+ if((excludeuser=(char *) malloc(nreg))==NULL){
fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg);
exit(1);
}
- bzero(excludeuser,nreg+11);
+ bzero(excludeuser,nreg);
- while(fgets(buf,255,fp_ex)!=NULL){
- if(strstr(buf,"#") != 0)
+ while(fgets(buf,sizeof(buf),fp_ex)!=NULL){
+ if(strchr(buf,'#') != NULL)
continue;
- buf[strlen(buf)-1]='\0';
+ fixendofline(buf);
strcat(excludeuser,buf);
strcat(excludeuser," ");
}