r582 - trunk/varnish-cache/bin/varnishncsa
andersb at projects.linpro.no
andersb at projects.linpro.no
Tue Aug 1 00:21:02 CEST 2006
Author: andersb
Date: 2006-08-01 00:21:02 +0200 (Tue, 01 Aug 2006)
New Revision: 582
Modified:
trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
Log:
Added some more toying with the data. All is still a mess, and I am not sure of structure yet. PHK is also doing changes in areas that will be needed.
Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
===================================================================
--- trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2006-07-31 22:09:42 UTC (rev 581)
+++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2006-07-31 22:21:02 UTC (rev 582)
@@ -1,5 +1,5 @@
/*
- * $Id:$
+ * $Id$
*
* Program that will get data from the shared memory log. When it has the data
* it will order the data based on the sessionid. When the data is ordered
@@ -70,15 +70,29 @@
extended_log_format(unsigned char *p, char *w_opt)
{
unsigned u, v;
- int i,j;
- char *ans;
- char soek[1];
- strcpy(soek," ");
+ int i,j,k;
+ unsigned char *ans;
+ // Declare the int's that are used to determin if we have all data.
+ int ll_h = 0; // %h
+ int ll_l = 0; // %l
+ int ll_u = 0; // %u
+ int ll_t = 0; // %t
+ int ll_r = 0; // %r
+ int ll_s = 0; // %s
+ int ll_b = 0; // %b
+ int ll_R = 0; // %{Referer}i
+ int ll_U = 0; // %{User-agent}i
+ // Declare the data where we store the differnt parts
+ char df_h[4 * (3 + 1)]; // Datafield for %h (IP adress)
+ char df_l;
+ char df_u[65536];
+ char df_U[65536];
+
if (w_opt != NULL){
// printf(" Has w_opt\n");
} else {
- // printf(" Does not have w_opt\n");
+ //printf(" Does not have w_opt:\n");
}
u = (p[2] << 8) | p[3];
@@ -91,21 +105,34 @@
case SLT_SessionOpen:
- //ans = strchr(&p[4], (int)soek);
- //j = strlen(ans);
- //printf("%d\n",j);
+
+ // Finding the IP adress when data is: "XXX.XXX.XXX.XXX somenumber"
+
+ ans = strchr(p + 4, ' ');
+ j = ans - (p + 4); // length
+ //printf("Ip address: '%*.*s'\n", j, j, p + 4);
+ memcpy(df_h, p + 4, j);
+ df_h[j] = '\0';
+ //printf("Ip address: %s\n", df_h);
+ ll_h = 1;
+
break;
case SLT_RxHeader:
if (p[1] >= 11 && !strncasecmp((void *)&p[4], "user-agent:",11)){
- //printf(" User-Agent: %s\n", p[4]);
- //sbuf_printf(ob[u], "%s\n", &p[4]);
- sbuf_bcat(ob[u], p + 4, p[1]);
+ // Could actually check for ll_h = 1 also in line above.
+ // If it is equal 1 we know a new client is in, hence a new User-Agent.
+
+ memcpy(df_U, p + 4, p[1]);
+ df_U[p[1]] = '\0';
+ //printf("Ip address: %s\n", df_U);
+ /*sbuf_bcat(ob[u], p + 4, p[1]);
sbuf_cat(ob[u], "\n");
sbuf_finish(ob[u]);
printf("%s", sbuf_data(ob[u]));
sbuf_clear(ob[u]);
+ */
}
break;
@@ -115,7 +142,10 @@
v = 1;
break;
}
- if (v) {
+
+
+
+ if (ll_h && ll_U) {
/* XXX Need to write some code to make the logline
sbuf_printf(ob[u], "%02x %3d %4d %-12s",
More information about the varnish-commit
mailing list