char date[80];
if (fp_authfail && (strstr(log_entry->HttpCode,"DENIED/401") != 0 || strstr(log_entry->HttpCode,"DENIED/407") != 0)) {
- strftime(date,sizeof(date),"%d/%m/%Y\t%H:%M:%S",log_entry->EntryTime);
+ strftime(date,sizeof(date),"%d/%m/%Y\t%H:%M:%S",&log_entry->EntryTime);
fprintf(fp_authfail, "%s\t%s\t%s\t%s\n",date,log_entry->User,log_entry->Ip,log_entry->Url);
authfail_exists=true;
}
char date[80];
if (fp_denied && strstr(log_entry->HttpCode,"DENIED/403") != 0) {
- strftime(date,sizeof(date),"%d/%m/%Y\t%H:%M:%S",log_entry->EntryTime);
+ strftime(date,sizeof(date),"%d/%m/%Y\t%H:%M:%S",&log_entry->EntryTime);
fprintf(fp_denied, "%s\t%s\t%s\t%s\n",date,log_entry->User,log_entry->Ip,log_entry->Url);
denied_exists=true;
}
struct ReadLogStruct
{
//! The time corresponding to the entry.
- struct tm *EntryTime;
+ struct tm EntryTime;
//! The IP address connecting to internet.
char *Ip;
//! The user's name.
log_entry.EntryTime=&tt;
}
#endif
- if (log_entry.EntryTime==NULL) {
- debuga(_("Unknown input log file format: no time\n"));
- break;
- }
if (log_entry.Ip==NULL) {
debuga(_("Unknown input log file format: no IP addresses\n"));
break;
}
// Record only hours usage which is required
- if( bsearch( &( log_entry.EntryTime->tm_wday ), weekdays.list, weekdays.len, sizeof( int ), compar ) == NULL )
+ if( bsearch( &( log_entry.EntryTime.tm_wday ), weekdays.list, weekdays.len, sizeof( int ), compar ) == NULL )
continue;
- if( bsearch( &( log_entry.EntryTime->tm_hour ), hours.list, hours.len, sizeof( int ), compar ) == NULL )
+ if( bsearch( &( log_entry.EntryTime.tm_hour ), hours.list, hours.len, sizeof( int ), compar ) == NULL )
continue;
}
if(Filter->StartTime >= 0 && Filter->EndTime >= 0) {
- hmr=log_entry.EntryTime->tm_hour*100+log_entry.EntryTime->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);
+ strftime(dia, sizeof(dia), "%d/%m/%Y",&log_entry.EntryTime);
+ strftime(hora,sizeof(hora),"%H:%M:%S",&log_entry.EntryTime);
if (fprintf(ufile->file, "%s\t%s\t%s\t%s\t%"PRIu64"\t%s\t%ld\t%s\n",dia,hora,
log_entry.Ip,url,(uint64_t)log_entry.DataSize,
if (current_format!=&ReadSargLog) {
if(!totper || idata<mindate){
mindate=idata;
- memcpy(&period.start,log_entry.EntryTime,sizeof(*log_entry.EntryTime));
+ memcpy(&period.start,&log_entry.EntryTime,sizeof(log_entry.EntryTime));
strcpy(start_hour,tbuf2);
}
if (!totper || idata>maxdate) {
maxdate=idata;
- memcpy(&period.end,log_entry.EntryTime,sizeof(*log_entry.EntryTime));
+ memcpy(&period.end,&log_entry.EntryTime,sizeof(log_entry.EntryTime));
}
totper=true;
}
int Hour;
int Minute;
int Second;
- static struct tm tt;
// get IP address
Entry->Ip=Line;
while (*Line && *Line!=']') Line++;
if (*Line!=']') return(RLRC_Unknown);
- tt.tm_year=Year-1900;
- tt.tm_mon=Month;
- tt.tm_mday=Day;
- tt.tm_hour=Hour;
- tt.tm_min=Minute;
- tt.tm_sec=Second;
- Entry->EntryTime=&tt;
+ Entry->EntryTime.tm_year=Year-1900;
+ Entry->EntryTime.tm_mon=Month;
+ Entry->EntryTime.tm_mday=Day;
+ Entry->EntryTime.tm_hour=Hour;
+ Entry->EntryTime.tm_min=Minute;
+ Entry->EntryTime.tm_sec=Second;
// the URL is enclosed between double qhotes
++Line;
int Hour;
int Minute;
int Second;
- static struct tm tt;
if (strncmp(Line,"*** SARG Log ***",16)==0) {
InSargLog=true;
while (isdigit(*Line)) Second=Second*10+(*Line++-'0');
if (*Line!='\t' || Second>60) return(RLRC_Unknown); //second can be 60 due to a leap second
- tt.tm_year=Year-1900;
- tt.tm_mon=Month-1;
- tt.tm_mday=Day;
- tt.tm_hour=Hour;
- tt.tm_min=Minute;
- tt.tm_sec=Second;
- Entry->EntryTime=&tt;
+ Entry->EntryTime.tm_year=Year-1900;
+ Entry->EntryTime.tm_mon=Month-1;
+ Entry->EntryTime.tm_mday=Day;
+ Entry->EntryTime.tm_hour=Hour;
+ Entry->EntryTime.tm_min=Minute;
+ Entry->EntryTime.tm_sec=Second;
// the ID of the user
Entry->User=++Line;
int HttpCodeLen;
int UrlLen;
int UserLen;
+ struct tm *tt;
// get log time.
Begin=Line;
if (*Line!=' ' || UserLen==0) return(RLRC_Unknown);
// now, the format is known with a good confidence. If the time doesn't decode, it is an error.
- Entry->EntryTime=localtime(&log_time);
- if (Entry->EntryTime == NULL) {
+ tt=localtime(&log_time);
+ if (tt==NULL) {
debuga(_("Cannot convert the timestamp from the squid log file\n"));
return(RLRC_InternalError);
}
+ memcpy(&Entry->EntryTime,tt,sizeof(struct tm));
// it is safe to alter the line buffer now that we are returning a valid entry
Entry->Ip[IpLen]='\0';