char hora[30];
char mes[30];
char tbuf2[128];
- char dia[128];
+ char dia[128]="";
char wuser[MAXLEN];
char tmp3[MAXLEN];
char sz_Download_Unsort[20000];
bool totper=false;
struct stat logstat;
struct getwordstruct gwarea;
- struct tm *t;
struct tm tt;
struct userfilestruct *prev_ufile;
struct userinfostruct *uinfo;
struct userfilestruct *first_user_file=NULL;
struct userfilestruct *ufile;
struct userfilestruct *ufile1;
+ struct ReadLogStruct log_entry;
time_t tnum;
for (ilf=0 ; ilf<ILF_Last ; ilf++) ilf_count[ilf]=0;
if(debugm)
printf("BUF=%s\n",linebuf);
- t=NULL;
+ log_entry.EntryTime=NULL;
if (ilf==ILF_Squid || ilf==ILF_Common || ilf==ILF_Unknown) {
getword_start(&gwarea,linebuf);
if (getword(data,sizeof(data),&gwarea,' ')<0) {
debuga(_("Invalid time found in %s\n"),arq);
exit(EXIT_FAILURE);
}
- t=&tt;
+ log_entry.EntryTime=&tt;
}
if(ilf==ILF_Unknown || ilf==ILF_Squid) {
ilf_count[ilf]++;
tnum=atoi(data);
- t=localtime(&tnum);
- if (t == NULL) {
+ log_entry.EntryTime=localtime(&tnum);
+ if (log_entry.EntryTime == NULL) {
debuga(_("Cannot convert the timestamp from the squid log file\n"));
exit(EXIT_FAILURE);
}
- strftime(tbuf2, sizeof(tbuf2), "%H%M", t);
+ strftime(tbuf2, sizeof(tbuf2), "%H%M", log_entry.EntryTime);
- idata=(t->tm_year+1900)*10000+(t->tm_mon+1)*100+t->tm_mday;
+ idata=(log_entry.EntryTime->tm_year+1900)*10000+(log_entry.EntryTime->tm_mon+1)*100+log_entry.EntryTime->tm_mday;
}
}
if (ilf==ILF_Sarg) {
debuga(_("Invalid time found in %s\n"),arq);
exit(EXIT_FAILURE);
}
- t=&tt;
+ log_entry.EntryTime=&tt;
}
if (ilf==ILF_Isa) {
if (linebuf[0] == '#') {
exit(EXIT_FAILURE);
}
}
- t=&tt;
+ log_entry.EntryTime=&tt;
}
- if (t==NULL) {
+ if (log_entry.EntryTime==NULL) {
debuga(_("Unknown input log file format\n"));
break;
}
- strftime(dia, sizeof(dia), "%d/%m/%Y", t);
- snprintf(hora,sizeof(hora),"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec);
-
if(debugm)
printf("DATE=%s IDATA=%d DFROM=%d DUNTIL=%d\n",Filter->DateRange,idata,dfrom,duntil);
}
// Record only hours usage which is required
- if (t) {
- if( bsearch( &( t -> tm_wday ), weekdays.list, weekdays.len, sizeof( int ), compar ) == NULL )
- continue;
+ if( bsearch( &( log_entry.EntryTime->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( bsearch( &( log_entry.EntryTime->tm_hour ), hours.list, hours.len, sizeof( int ), compar ) == NULL )
+ continue;
if(strlen(user) > MAX_USER_LEN) {
}
if(Filter->StartTime >= 0 && Filter->EndTime >= 0) {
- hmr=t->tm_hour*100+t->tm_min;
+ hmr=log_entry.EntryTime->tm_hour*100+log_entry.EntryTime->tm_min;
if(hmr < Filter->StartTime || hmr > Filter->EndTime) continue;
}
}
}
+ strftime(dia, sizeof(dia), "%d/%m/%Y", log_entry.EntryTime);
+ strftime(hora,sizeof(hora),"%H:%M:%S",log_entry.EntryTime);
+
/*if ( strcmp ( user , sz_Last_User ) != 0 ) {
if ( fp_Write_User )
fclose( fp_Write_User ) ;
if (ilf!=ILF_Sarg) {
if(!totper || idata<mindate){
mindate=idata;
- memcpy(&period.start,t,sizeof(*t));
+ memcpy(&period.start,log_entry.EntryTime,sizeof(*log_entry.EntryTime));
strcpy(start_hour,tbuf2);
}
if (!totper || idata>maxdate) {
maxdate=idata;
- memcpy(&period.end,t,sizeof(*t));
+ memcpy(&period.end,log_entry.EntryTime,sizeof(*log_entry.EntryTime));
}
totper=true;
}