Commit 7213f789 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More VRT work.

Use macros for trivial objects which are just a field in a struct.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@550 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 60d01510
...@@ -54,18 +54,6 @@ VRT_GetHdr(struct sess *sp, const char *n) ...@@ -54,18 +54,6 @@ VRT_GetHdr(struct sess *sp, const char *n)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
char *
VRT_GetReq(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(sp != NULL);
assert(sp->http != NULL);
return (sp->http->hd[HTTP_HDR_REQ].b);
}
/*--------------------------------------------------------------------*/
void void
VRT_handling(struct sess *sp, unsigned hand) VRT_handling(struct sess *sp, unsigned hand)
{ {
...@@ -77,34 +65,6 @@ VRT_handling(struct sess *sp, unsigned hand) ...@@ -77,34 +65,6 @@ VRT_handling(struct sess *sp, unsigned hand)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void
VRT_l_backend_host(struct backend *be, const char *h)
{
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
be->hostname = h;
}
const char *
VRT_r_backend_host(struct backend *be)
{
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
return (be->hostname);
}
void
VRT_l_backend_port(struct backend *be, const char *p)
{
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
be->portname = p;
}
const char *
VRT_r_backend_port(struct backend *be)
{
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
return (be->portname);
}
void void
VRT_set_backend_name(struct backend *be, const char *p) VRT_set_backend_name(struct backend *be, const char *p)
{ {
...@@ -128,6 +88,26 @@ VRT_alloc_backends(struct VCL_conf *cp) ...@@ -128,6 +88,26 @@ VRT_alloc_backends(struct VCL_conf *cp)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
#define VBACKEND(type,onm,field) \
void \
VRT_l_backend_##onm(struct backend *be, type a) \
{ \
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); \
be->field = a; \
} \
\
type \
VRT_r_backend_##onm(struct backend *be) \
{ \
CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); \
return (be->field); \
}
VBACKEND(const char *, host, hostname)
VBACKEND(const char *, port, portname)
/*--------------------------------------------------------------------*/
void void
VRT_l_obj_ttl(struct sess *sp, double a) VRT_l_obj_ttl(struct sess *sp, double a)
{ {
...@@ -144,40 +124,39 @@ VRT_r_obj_ttl(struct sess *sp) ...@@ -144,40 +124,39 @@ VRT_r_obj_ttl(struct sess *sp)
return (sp->obj->ttl - sp->t_req); return (sp->obj->ttl - sp->t_req);
} }
double
VRT_r_obj_valid(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
return (sp->obj->valid);
}
double
VRT_r_obj_cacheable(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
return (sp->obj->cacheable);
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
const char * #define VOBJ(type,onm,field) \
VRT_r_req_request(struct sess *sp) void \
{ VRT_l_obj_##onm(struct sess *sp, type a) \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); { \
CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
return (sp->http->hd[HTTP_HDR_REQ].b); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \
} sp->obj->field = a; \
} \
\
type \
VRT_r_obj_##onm(struct sess *sp) \
{ \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \
return (sp->obj->field); \
}
VOBJ(double, valid, valid)
VOBJ(double, cacheable, cacheable)
/*--------------------------------------------------------------------*/
const char * #define VREQ(n1, n2) \
VRT_r_req_url(struct sess *sp) const char * \
{ VRT_r_req_##n1(struct sess *sp) \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); { \
CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
return (sp->http->hd[HTTP_HDR_URL].b); CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); \
return (sp->http->hd[n2].b); \
} }
VREQ(request, HTTP_HDR_REQ)
VREQ(url, HTTP_HDR_URL)
VREQ(proto, HTTP_HDR_PROTO)
/* /*
* $Id: vcc_gen_obj.tcl 545 2006-07-21 20:43:56Z phk $ * $Id: vcc_gen_obj.tcl 548 2006-07-21 20:51:24Z phk $
* *
* NB: This file is machine generated, DO NOT EDIT! * NB: This file is machine generated, DO NOT EDIT!
* *
...@@ -14,6 +14,8 @@ const char * VRT_r_req_request(struct sess *); ...@@ -14,6 +14,8 @@ const char * VRT_r_req_request(struct sess *);
void VRT_l_req_request(struct sess *, const char *); void VRT_l_req_request(struct sess *, const char *);
const char * VRT_r_req_url(struct sess *); const char * VRT_r_req_url(struct sess *);
void VRT_l_req_url(struct sess *, const char *); void VRT_l_req_url(struct sess *, const char *);
const char * VRT_r_req_proto(struct sess *);
void VRT_l_req_proto(struct sess *, const char *);
double VRT_r_obj_valid(struct sess *); double VRT_r_obj_valid(struct sess *);
void VRT_l_obj_valid(struct sess *, double); void VRT_l_obj_valid(struct sess *, double);
double VRT_r_obj_cacheable(struct sess *); double VRT_r_obj_cacheable(struct sess *);
......
...@@ -14,6 +14,7 @@ set beobj { ...@@ -14,6 +14,7 @@ set beobj {
set spobj { set spobj {
{ req.request STRING } { req.request STRING }
{ req.url STRING } { req.url STRING }
{ req.proto STRING }
{ obj.valid BOOL } { obj.valid BOOL }
{ obj.cacheable BOOL } { obj.cacheable BOOL }
{ obj.backend BACKEND } { obj.backend BACKEND }
......
...@@ -30,6 +30,10 @@ struct var vcc_vars[] = { ...@@ -30,6 +30,10 @@ struct var vcc_vars[] = {
"VRT_r_req_url(sp)", "VRT_r_req_url(sp)",
"VRT_l_req_url(sp, ", "VRT_l_req_url(sp, ",
}, },
{ "req.proto", STRING, 9,
"VRT_r_req_proto(sp)",
"VRT_l_req_proto(sp, ",
},
{ "obj.valid", BOOL, 9, { "obj.valid", BOOL, 9,
"VRT_r_obj_valid(sp)", "VRT_r_obj_valid(sp)",
"VRT_l_obj_valid(sp, ", "VRT_l_obj_valid(sp, ",
...@@ -70,6 +74,8 @@ const char *vrt_obj_h = ...@@ -70,6 +74,8 @@ const char *vrt_obj_h =
"void VRT_l_req_request(struct sess *, const char *);\n" "void VRT_l_req_request(struct sess *, const char *);\n"
"const char * VRT_r_req_url(struct sess *);\n" "const char * VRT_r_req_url(struct sess *);\n"
"void VRT_l_req_url(struct sess *, const char *);\n" "void VRT_l_req_url(struct sess *, const char *);\n"
"const char * VRT_r_req_proto(struct sess *);\n"
"void VRT_l_req_proto(struct sess *, const char *);\n"
"double VRT_r_obj_valid(struct sess *);\n" "double VRT_r_obj_valid(struct sess *);\n"
"void VRT_l_obj_valid(struct sess *, double);\n" "void VRT_l_obj_valid(struct sess *, double);\n"
"double VRT_r_obj_cacheable(struct sess *);\n" "double VRT_r_obj_cacheable(struct sess *);\n"
......
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