From c8276250aac98441ebf2dd2bae9069b1d8b7cba3 Mon Sep 17 00:00:00 2001 From: des Date: Wed, 9 Aug 2006 11:22:55 +0000 Subject: [PATCH] Cosmetic: redefine HTTP_HDR_* as an enum and rename MAX_HTTP_HDRS to HTTP_HDR_MAX. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@777 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 22 ++++++++++++---------- varnish-cache/bin/varnishd/cache_http.c | 14 +++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 3eea0c73..0af83397 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -17,16 +17,18 @@ #include "common.h" #include "miniobj.h" -#define MAX_HTTP_HDRS 32 - -#define MAX_IOVS (MAX_HTTP_HDRS * 2) +enum { + HTTP_HDR_REQ, + HTTP_HDR_URL, + HTTP_HDR_PROTO, + HTTP_HDR_STATUS, + HTTP_HDR_RESPONSE, + /* add more here */ + HTTP_HDR_FIRST, + HTTP_HDR_MAX = 32 +}; -#define HTTP_HDR_REQ 0 -#define HTTP_HDR_URL 1 -#define HTTP_HDR_PROTO 2 -#define HTTP_HDR_STATUS 3 -#define HTTP_HDR_RESPONSE 4 -#define HTTP_HDR_FIRST 5 +#define MAX_IOVS (HTTP_HDR_MAX * 2) struct cli; struct vsb; @@ -70,7 +72,7 @@ struct http { HTTP_Obj } logtag; - struct http_hdr hd[MAX_HTTP_HDRS]; + struct http_hdr hd[HTTP_HDR_MAX]; unsigned nhd; }; diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 53c6039e..cf9a6df3 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -274,7 +274,7 @@ http_dissect_hdrs(struct http *hp, int fd, char *p) p[2] == '-') hp->conds = 1; - if (hp->nhd < MAX_HTTP_HDRS) { + if (hp->nhd < HTTP_HDR_MAX) { hp->hd[hp->nhd].b = p; hp->hd[hp->nhd].e = q; VSLH(HTTP_T_Header, fd, hp, hp->nhd); @@ -573,7 +573,7 @@ http_CopyHttp(struct http *to, struct http *fm) static void http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm) { - assert(n < MAX_HTTP_HDRS); + assert(n < HTTP_HDR_MAX); assert(fm != NULL); to->hd[n].b = (void*)(uintptr_t)fm; to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0'); @@ -584,7 +584,7 @@ static void http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum httptag tag) { - assert(n < MAX_HTTP_HDRS); + assert(n < HTTP_HDR_MAX); assert(fm->hd[n].b != NULL); to->hd[n].b = fm->hd[n].b; to->hd[n].e = fm->hd[n].e; @@ -640,9 +640,9 @@ http_copyheader(int fd, struct http *to, struct http *fm, unsigned n) CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - assert(n < MAX_HTTP_HDRS); + assert(n < HTTP_HDR_MAX); assert(fm->hd[n].b != NULL); - if (to->nhd < MAX_HTTP_HDRS) { + if (to->nhd < HTTP_HDR_MAX) { to->hd[to->nhd].b = fm->hd[n].b; to->hd[to->nhd].e = fm->hd[n].e; VSLH(HTTP_T_Header, fd, to, to->nhd); @@ -692,7 +692,7 @@ http_SetHeader(int fd, struct http *to, const char *hdr) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - if (to->nhd >= MAX_HTTP_HDRS) { + if (to->nhd >= HTTP_HDR_MAX) { VSL_stats->losthdr++; VSL(T(to, HTTP_T_LostHeader), fd, "%s", hdr); return; @@ -712,7 +712,7 @@ http_PrintfHeader(int fd, struct http *to, const char *fmt, ...) va_start(ap, fmt); l = to->e - to->f; n = vsnprintf(to->f, l, fmt, ap); - if (n + 1 > l || to->nhd >= MAX_HTTP_HDRS) { + if (n + 1 > l || to->nhd >= HTTP_HDR_MAX) { VSL_stats->losthdr++; VSL(T(to, HTTP_T_LostHeader), fd, "%s", to->f); } else { -- 2.39.5