static volatile sig_atomic_t reopen;
+static struct matcher {
+ enum shmlogtag tag;
+ char *fieldname;
+ char *format;
+} *matchers;
+
static struct logline {
char *df_H; /* %H, Protocol version */
char *df_Host; /* %{Host}i */
/*--------------------------------------------------------------------*/
+static int
+parse_format(char *format, struct matchers **m) {
+ char *t = format;
+ struct matcher *tmp;
+ int num_matchers = 0;
+ while (*t != NULL) {
+ tmp = malloc(sizeof struct struct matcher);
+ num_matchers++;
+ if (t[0] == '%') {
+ t++;
+ switch (*t) {
+ case 'h':
+ tmp->tag = SLT_ReqStart;
+ break;
+ case 'H':
+ tmp->tag = SLT_RxProtocol;
+ break;
+ default:
+ /* XXX Error out */
+ break;
+ }
+ } else {
+ char *end = strchr(t, '%');
+ int i;
+ if (end == NULL)
+ end = t + strlen(t);
+ i = asprintf(&tmp->format, "%*s", (end - t), t);
+ assert(i > 0);
+ t += i;
+ }
+ }
+ m = malloc(sizeof tmp * num_matchers);
+}
+/*--------------------------------------------------------------------*/
+
static void
usage(void)
{
struct pidfh *pfh = NULL;
struct VSL_data *vd;
FILE *of;
-
+ char *format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"";
+
vd = VSL_New();
while ((c = getopt(argc, argv, VSL_ARGS "aDn:P:Vw:f")) != -1) {
}
}
+ if (parse_format(format, &matchers))
+ exit(1);
+
if (VSL_OpenLog(vd, n_arg))
exit(1);