Commit 61367de4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Simplify the CPP magic involved in HTTP headers, now that we can rely

on everybody agreeing about the order of these fields.
parent e4996efa
...@@ -82,13 +82,9 @@ body_status(enum body_status e) ...@@ -82,13 +82,9 @@ body_status(enum body_status e)
enum { enum {
/* Fields from the first line of HTTP proto */ /* Fields from the first line of HTTP proto */
HTTP_HDR_REQ, #define SLTH(aa, bb) bb,
HTTP_HDR_URL, #include "tbl/vsl_tags_http.h"
HTTP_HDR_PROTO, #undef SLTH
HTTP_HDR_STATUS,
HTTP_HDR_RESPONSE,
/* HTTP header lines */
HTTP_HDR_FIRST,
}; };
struct SHA256Context; struct SHA256Context;
......
...@@ -41,24 +41,11 @@ ...@@ -41,24 +41,11 @@
#include "tbl/http_headers.h" #include "tbl/http_headers.h"
#undef HTTPH #undef HTTPH
/*lint -save -e773 not () */ static const enum VSL_tag_e foo[] = {
#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx [HTTP_Rx] = SLT_RxRequest,
[HTTP_Tx] = SLT_TxRequest,
#define LOGMTX1(ax) { \ [HTTP_Obj] = SLT_ObjRequest,
LOGMTX2(ax, HTTP_HDR_REQ, Request), \
LOGMTX2(ax, HTTP_HDR_RESPONSE, Response), \
LOGMTX2(ax, HTTP_HDR_STATUS, Status), \
LOGMTX2(ax, HTTP_HDR_URL, URL), \
LOGMTX2(ax, HTTP_HDR_PROTO, Protocol), \
LOGMTX2(ax, HTTP_HDR_FIRST, Header), \
}
static const enum VSL_tag_e logmtx[][HTTP_HDR_FIRST + 1] = {
[HTTP_Rx] = LOGMTX1(Rx),
[HTTP_Tx] = LOGMTX1(Tx),
[HTTP_Obj] = LOGMTX1(Obj)
}; };
/*lint -restore */
static enum VSL_tag_e static enum VSL_tag_e
http2shmlog(const struct http *hp, int t) http2shmlog(const struct http *hp, int t)
...@@ -69,7 +56,7 @@ http2shmlog(const struct http *hp, int t) ...@@ -69,7 +56,7 @@ http2shmlog(const struct http *hp, int t)
t = HTTP_HDR_FIRST; t = HTTP_HDR_FIRST;
assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/ assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/
assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST); assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST);
return (logmtx[hp->logtag][t]); return ((enum VSL_tag_e)(foo[hp->logtag] + t));
} }
static void static void
......
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