[master] 69328819e Introduce a `hdr_t` typedef for our "pascal-string" H_* style args.
Poul-Henning Kamp
phk at FreeBSD.org
Tue May 11 11:12:05 UTC 2021
commit 69328819e484a7e74a1cd5aa5e8f90c56e7480f3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 11 11:11:08 2021 +0000
Introduce a `hdr_t` typedef for our "pascal-string" H_* style args.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2ea190180..e770e23f1 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -69,6 +69,8 @@ struct body_status {
typedef const struct body_status *body_status_t;
+typedef const char *hdr_t;
+
/*--------------------------------------------------------------------*/
enum sess_close {
@@ -594,40 +596,40 @@ void http_PutResponse(struct http *to, const char *proto, uint16_t status,
void http_FilterReq(struct http *to, const struct http *fm, unsigned how);
void HTTP_Encode(const struct http *fm, uint8_t *, unsigned len, unsigned how);
int HTTP_Decode(struct http *to, const uint8_t *fm);
-void http_ForceHeader(struct http *to, const char *hdr, const char *val);
+void http_ForceHeader(struct http *to, hdr_t, const char *val);
void http_PrintfHeader(struct http *to, const char *fmt, ...)
v_printflike_(2, 3);
void http_TimeHeader(struct http *to, const char *fmt, vtim_real now);
void http_Proto(struct http *to);
-void http_SetHeader(struct http *to, const char *hdr);
-void http_SetH(struct http *to, unsigned n, const char *fm);
+void http_SetHeader(struct http *to, const char *header);
+void http_SetH(struct http *to, unsigned n, const char *header);
void http_ForceField(struct http *to, unsigned n, const char *t);
void HTTP_Setup(struct http *, struct ws *, struct vsl_log *, enum VSL_tag_e);
void http_Teardown(struct http *ht);
-int http_GetHdr(const struct http *hp, const char *hdr, const char **ptr);
-int http_GetHdrToken(const struct http *hp, const char *hdr,
+int http_GetHdr(const struct http *hp, hdr_t, const char **ptr);
+int http_GetHdrToken(const struct http *hp, hdr_t,
const char *token, const char **pb, const char **pe);
-int http_GetHdrField(const struct http *hp, const char *hdr,
+int http_GetHdrField(const struct http *hp, hdr_t,
const char *field, const char **ptr);
-double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field);
+double http_GetHdrQ(const struct http *hp, hdr_t, const char *field);
ssize_t http_GetContentLength(const struct http *hp);
uint16_t http_GetStatus(const struct http *hp);
int http_IsStatus(const struct http *hp, int);
void http_SetStatus(struct http *to, uint16_t status, const char *reason);
const char *http_GetMethod(const struct http *hp);
-int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
+int http_HdrIs(const struct http *hp, hdr_t, const char *val);
void http_CopyHome(const struct http *hp);
-void http_Unset(struct http *hp, const char *hdr);
-unsigned http_CountHdr(const struct http *hp, const char *hdr);
-void http_CollectHdr(struct http *hp, const char *hdr);
-void http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep);
+void http_Unset(struct http *hp, hdr_t);
+unsigned http_CountHdr(const struct http *hp, hdr_t);
+void http_CollectHdr(struct http *hp, hdr_t);
+void http_CollectHdrSep(struct http *hp, hdr_t, const char *sep);
void http_VSL_log(const struct http *hp);
void HTTP_Merge(struct worker *, struct objcore *, struct http *to);
uint16_t HTTP_GetStatusPack(struct worker *, struct objcore *oc);
int HTTP_IterHdrPack(struct worker *, struct objcore *, const char **);
#define HTTP_FOREACH_PACK(wrk, oc, ptr) \
for ((ptr) = NULL; HTTP_IterHdrPack(wrk, oc, &(ptr));)
-const char *HTTP_GetHdrPack(struct worker *, struct objcore *, const char *hdr);
+const char *HTTP_GetHdrPack(struct worker *, struct objcore *, hdr_t);
enum sess_close http_DoConnection(struct http *hp, enum sess_close sc_close);
int http_IsFiltered(const struct http *hp, unsigned u, unsigned how);
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index db0dad004..ec0739ee6 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -390,12 +390,12 @@ http_Proto(struct http *to)
/*--------------------------------------------------------------------*/
void
-http_SetH(struct http *to, unsigned n, const char *fm)
+http_SetH(struct http *to, unsigned n, const char *header)
{
assert(n < to->nhd);
- AN(fm);
- to->hd[n].b = TRUST_ME(fm);
+ AN(header);
+ to->hd[n].b = TRUST_ME(header);
to->hd[n].e = strchr(to->hd[n].b, '\0');
to->hdf[n] = 0;
http_VSLH(to, n);
@@ -423,7 +423,7 @@ http_PutField(struct http *to, int field, const char *string)
/*--------------------------------------------------------------------*/
static int
-http_IsHdr(const txt *hh, const char *hdr)
+http_IsHdr(const txt *hh, hdr_t hdr)
{
unsigned l;
@@ -461,7 +461,7 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr)
*/
unsigned
-http_CountHdr(const struct http *hp, const char *hdr)
+http_CountHdr(const struct http *hp, hdr_t hdr)
{
unsigned retval = 0;
unsigned u;
@@ -482,7 +482,7 @@ http_CountHdr(const struct http *hp, const char *hdr)
*/
void
-http_CollectHdr(struct http *hp, const char *hdr)
+http_CollectHdr(struct http *hp, hdr_t hdr)
{
http_CollectHdrSep(hp, hdr, NULL);
@@ -495,7 +495,7 @@ http_CollectHdr(struct http *hp, const char *hdr)
*/
void
-http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
+http_CollectHdrSep(struct http *hp, hdr_t hdr, const char *sep)
{
unsigned u, l, lsep, ml, f, x, d;
char *b = NULL, *e = NULL;
@@ -578,7 +578,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
/*--------------------------------------------------------------------*/
int
-http_GetHdr(const struct http *hp, const char *hdr, const char **ptr)
+http_GetHdr(const struct http *hp, hdr_t hdr, const char **ptr)
{
unsigned u, l;
const char *p;
@@ -705,7 +705,7 @@ http_istoken(const char **bp, const char *e, const char *token)
*/
int
-http_GetHdrToken(const struct http *hp, const char *hdr,
+http_GetHdrToken(const struct http *hp, hdr_t hdr,
const char *token, const char **pb, const char **pe)
{
const char *h, *b, *e;
@@ -742,7 +742,7 @@ http_GetHdrToken(const struct http *hp, const char *hdr,
*/
double
-http_GetHdrQ(const struct http *hp, const char *hdr, const char *field)
+http_GetHdrQ(const struct http *hp, hdr_t hdr, const char *field)
{
const char *hb, *he, *b, *e;
int i;
@@ -791,7 +791,7 @@ http_GetHdrQ(const struct http *hp, const char *hdr, const char *field)
*/
int
-http_GetHdrField(const struct http *hp, const char *hdr,
+http_GetHdrField(const struct http *hp, hdr_t hdr,
const char *field, const char **ptr)
{
const char *h;
@@ -903,7 +903,7 @@ http_DoConnection(struct http *hp, enum sess_close sc_close)
/*--------------------------------------------------------------------*/
int
-http_HdrIs(const struct http *hp, const char *hdr, const char *val)
+http_HdrIs(const struct http *hp, hdr_t hdr, const char *val)
{
const char *p;
@@ -1183,7 +1183,7 @@ HTTP_IterHdrPack(struct worker *wrk, struct objcore *oc, const char **p)
}
const char *
-HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
+HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, hdr_t hdr)
{
const char *ptr;
unsigned l;
@@ -1343,22 +1343,22 @@ http_CopyHome(const struct http *hp)
/*--------------------------------------------------------------------*/
void
-http_SetHeader(struct http *to, const char *hdr)
+http_SetHeader(struct http *to, const char *header)
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
if (to->nhd >= to->shd) {
- VSLb(to->vsl, SLT_LostHeader, "%s", hdr);
+ VSLb(to->vsl, SLT_LostHeader, "%s", header);
http_fail(to);
return;
}
- http_SetH(to, to->nhd++, hdr);
+ http_SetH(to, to->nhd++, header);
}
/*--------------------------------------------------------------------*/
void
-http_ForceHeader(struct http *to, const char *hdr, const char *val)
+http_ForceHeader(struct http *to, hdr_t hdr, const char *val)
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
@@ -1420,7 +1420,7 @@ http_TimeHeader(struct http *to, const char *fmt, vtim_real now)
/*--------------------------------------------------------------------*/
void
-http_Unset(struct http *hp, const char *hdr)
+http_Unset(struct http *hp, hdr_t hdr)
{
uint16_t u, v;
More information about the varnish-commit
mailing list