Commit 524b9dcb authored by Federico G. Schwindt's avatar Federico G. Schwindt

More cleanup

parent cf5cd43d
......@@ -487,7 +487,7 @@ addf_int32(int32_t *i)
}
static void
addf_time(char type, const char *fmt, const char *str)
addf_time(char type, const char *fmt)
{
struct format *f;
......@@ -499,10 +499,6 @@ addf_time(char type, const char *fmt, const char *str)
f->time_fmt = strdup(fmt);
AN(f->time_fmt);
}
if (str != NULL) {
f->string = strdup(str);
AN(f->string);
}
VTAILQ_INSERT_TAIL(&CTX.format, f, list);
}
......@@ -526,8 +522,7 @@ addf_vcl_log(const char *key, const char *str)
AN(key);
ALLOC_OBJ(w, WATCH_MAGIC);
AN(w);
w->key = strdup(key);
AN(w->key);
assert(asprintf(&w->key, "%s:", key) > 0);
w->keylen = strlen(w->key);
VTAILQ_INSERT_TAIL(&CTX.watch_vcl_log, w, list);
......@@ -727,7 +722,7 @@ parse_format(const char *format)
addf_fragment(&CTX.frag[F_b], "-");
break;
case 'D': /* Float request time */
addf_time(*p, NULL, NULL);
addf_time(*p, NULL);
break;
case 'h': /* Client host name / IP Address */
addf_fragment(&CTX.frag[F_h], "-");
......@@ -757,10 +752,10 @@ parse_format(const char *format)
addf_fragment(&CTX.frag[F_s], "-");
break;
case 't': /* strftime */
addf_time(*p, TIME_FMT, NULL);
addf_time(*p, TIME_FMT);
break;
case 'T': /* Int request time */
addf_time(*p, NULL, NULL);
addf_time(*p, NULL);
break;
case 'u': /* Remote user from auth */
addf_auth("-");
......@@ -790,7 +785,7 @@ parse_format(const char *format)
addf_hdr(&CTX.watch_resphdr, buf, "-");
break;
case 't':
addf_time(*q, buf, NULL);
addf_time(*q, buf);
break;
case 'x':
parse_x_format(buf);
......@@ -903,11 +898,12 @@ static void
process_hdr(const struct watch_head *head, const char *b, const char *e)
{
struct watch *w;
const char *p;
VTAILQ_FOREACH(w, head, list) {
if (e - b < w->keylen || strncasecmp(b, w->key, w->keylen))
if (!isprefix(w->key, w->keylen, b, e, &p))
continue;
frag_line(1, b + w->keylen, e, &w->frag);
frag_line(1, p, e, &w->frag);
}
}
......@@ -942,6 +938,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
const char *b, *e, *p;
struct watch *w;
int i, skip, be_mark;
(void)vsl;
(void)priv;
......@@ -1087,15 +1084,10 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
case SLT_VCL_Log:
VTAILQ_FOREACH(w, &CTX.watch_vcl_log, list) {
CHECK_OBJ_NOTNULL(w, WATCH_MAGIC);
if (e - b <= w->keylen ||
if (e - b < w->keylen ||
strncmp(b, w->key, w->keylen))
continue;
p = b + w->keylen;
if (*p != ':')
continue;
p++;
if (p > e)
continue;
frag_line(0, p, e, &w->frag);
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment