struct logline {
char df_h[4 * (3 + 1)]; // Datafield for %h (IP adress)
- // int y;
+ // XXX Set to 1 if we have a IP adress. Not sure when to unset.
+ // Know for sure when we have a real SessionClose. Probably
+ // When we clean also. When we have timeout. Are there any more?
+ int w;
// unsigned char *df_l; // Datafield for %l
// unsigned char *df_u; // Datafield for %u
struct tm *logline_time; // Datafield for %t
static void
extended_log_format(unsigned char *p, char *w_opt)
{
- unsigned u,v;
+ unsigned u,v,w;
int i,j;
unsigned char *tmpPtr;
char *tmpPtra;
i = 0;
v = 0;
+ w = 0;
switch (p[0]) {
strncpy(ll[u].df_h, p + 4, j);
ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer.
//printf("New session [%d]: %s \n",u, ll[u].df_h);
+ ll[u].w = 1; // We have IP
+ //printf("w = 1\n");
break;
ll[u].df_R = strdup(p + 4);
ll[u].df_R[0] = '-';
ll[u].df_R[1] = '\0';
+ cm_R = 1;
}
break;
req_time = timesec;
ll[u].logline_time = localtime(&req_time);
strftime (temp_time, 50, "[%d/%b/%Y:%X %z] ", ll[u].logline_time);
+ cm_r = 1;
break;
case SLT_SessionClose:
if (p[1] >= 7 && !strncasecmp((void *)&p[4], "timeout",7)){
+ // XXX what to do with the timeout?
+ // Right now I am gonna just let it pass, and not even clean memory.
//printf("Timeout...\n");
+ ll[u].w = 0;
}
else{
-
-
+
+ v = 1; // We are done, clean memory
+ ll[u].w = 0;
}
- v = 1; // We are done, clean memory
-
break;
case SLT_SessionReuse:
j = strlen(p + 4) - strlen(tmpPtr); // length of IP
strncpy(ll[u].df_h, p + 4, j);
ll[u].df_h[j] = '\0'; // put on a NULL at end of buffer.
+ ll[u].w = 1; // We have a IP
+ //printf("w = 1\n");
}
break;
}
- // Memorycleaner and stringwriter.
- if (v) {
+ // Memorycleaner and stringwriter. v is 1 after SLT_SessionClose OR SLT_SessionReuse that
+ // do something useful. w is set when we have a real IP adress, somewhere we are getting
+ // requests without.
+ //
+ // XXX Find out why we don't have IP and get rid of w.
+ //
+ if (v && ll[u].w) {
// Clean memory for User-Agent
free(ll[u].df_U);
}
+ if (cm_r){
+ // Clean memory for Date variables
+ free(tmpPtrb);
+ }
}