From 1822a5aa965e38533c1e946bc3d5fdf1099ef5f8 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 25 Sep 2007 11:51:49 +0000 Subject: [PATCH] Constify a lot of the VRT API git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2042 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_vrt.c | 44 +++++----- varnish-cache/bin/varnishd/cache_vrt_acl.c | 4 +- varnish-cache/bin/varnishd/cache_vrt_re.c | 2 +- varnish-cache/include/vrt.h | 14 ++-- varnish-cache/include/vrt_obj.h | 68 ++++++++-------- varnish-cache/lib/libvcl/vcc_acl.c | 2 +- varnish-cache/lib/libvcl/vcc_fixed_token.c | 82 +++++++++---------- varnish-cache/lib/libvcl/vcc_gen_obj.tcl | 94 +++++++++++++++------- 8 files changed, 171 insertions(+), 139 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index e7813a49..6acabdb9 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -63,7 +63,7 @@ VRT_error(struct sess *sp, unsigned code, const char *reason) /*--------------------------------------------------------------------*/ void -VRT_count(struct sess *sp, unsigned u) +VRT_count(const struct sess *sp, unsigned u) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -101,7 +101,7 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where) } char * -VRT_GetHdr(struct sess *sp, enum gethdr_e where, const char *n) +VRT_GetHdr(const struct sess *sp, enum gethdr_e where, const char *n) { char *p; struct http *hp; @@ -155,7 +155,7 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) /*--------------------------------------------------------------------*/ void -VRT_SetHdr(struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...) +VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...) { struct http *hp; va_list ap; @@ -198,7 +198,7 @@ vrt_do_string(struct worker *w, int fd, struct http *hp, int fld, const char *er #define VRT_DO_HDR(obj, hdr, http, fld) \ void \ -VRT_l_##obj##_##hdr(struct sess *sp, const char *p, ...) \ +VRT_l_##obj##_##hdr(const struct sess *sp, const char *p, ...) \ { \ va_list ap; \ \ @@ -221,7 +221,7 @@ VRT_DO_HDR(resp, proto, sp->http, HTTP_HDR_PROTO) VRT_DO_HDR(resp, response, sp->http, HTTP_HDR_RESPONSE) void -VRT_l_obj_status(struct sess *sp, int num) +VRT_l_obj_status(const struct sess *sp, int num) { char *p; @@ -235,7 +235,7 @@ VRT_l_obj_status(struct sess *sp, int num) } int -VRT_r_obj_status(struct sess *sp) +VRT_r_obj_status(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); @@ -243,7 +243,7 @@ VRT_r_obj_status(struct sess *sp) } void -VRT_l_resp_status(struct sess *sp, int num) +VRT_l_resp_status(const struct sess *sp, int num) { char *p; @@ -279,7 +279,7 @@ VRT_handling(struct sess *sp, unsigned hand) */ void -VRT_l_obj_ttl(struct sess *sp, double a) +VRT_l_obj_ttl(const struct sess *sp, double a) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -294,7 +294,7 @@ VRT_l_obj_ttl(struct sess *sp, double a) } double -VRT_r_obj_ttl(struct sess *sp) +VRT_r_obj_ttl(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ @@ -305,7 +305,7 @@ VRT_r_obj_ttl(struct sess *sp) #define VOBJ(type,onm,field) \ void \ -VRT_l_obj_##onm(struct sess *sp, type a) \ +VRT_l_obj_##onm(const struct sess *sp, type a) \ { \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \ @@ -313,7 +313,7 @@ VRT_l_obj_##onm(struct sess *sp, type a) \ } \ \ type \ -VRT_r_obj_##onm(struct sess *sp) \ +VRT_r_obj_##onm(const struct sess *sp) \ { \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \ @@ -343,7 +343,7 @@ VRT_r_req_backend(struct sess *sp) #define VREQ(n1, n2) \ const char * \ -VRT_r_req_##n1(struct sess *sp) \ +VRT_r_req_##n1(const struct sess *sp) \ { \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); \ @@ -357,7 +357,7 @@ VREQ(proto, HTTP_HDR_PROTO) /*--------------------------------------------------------------------*/ const char * -VRT_r_resp_proto(struct sess *sp) +VRT_r_resp_proto(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); @@ -365,7 +365,7 @@ VRT_r_resp_proto(struct sess *sp) } const char * -VRT_r_resp_response(struct sess *sp) +VRT_r_resp_response(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); @@ -373,7 +373,7 @@ VRT_r_resp_response(struct sess *sp) } int -VRT_r_resp_status(struct sess *sp) +VRT_r_resp_status(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); @@ -383,7 +383,7 @@ VRT_r_resp_status(struct sess *sp) /*--------------------------------------------------------------------*/ struct sockaddr * -VRT_r_client_ip(struct sess *sp) +VRT_r_client_ip(const struct sess *sp) { return (sp->sockaddr); @@ -428,7 +428,7 @@ VRT_l_req_hash(struct sess *sp, const char *str) /*--------------------------------------------------------------------*/ double -VRT_r_now(struct sess *sp) +VRT_r_now(const struct sess *sp) { (void)sp; @@ -436,7 +436,7 @@ VRT_r_now(struct sess *sp) } double -VRT_r_obj_lastuse(struct sess *sp) +VRT_r_obj_lastuse(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -445,18 +445,18 @@ VRT_r_obj_lastuse(struct sess *sp) } int -VRT_r_backend_health(struct sess *sp) +VRT_r_backend_health(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); - return sp->backend->health; + return (sp->backend->health); } /*--------------------------------------------------------------------*/ char * -VRT_IP_string(struct sess *sp, struct sockaddr *sa) +VRT_IP_string(const struct sess *sp, const struct sockaddr *sa) { char h[64], p[8], *q; socklen_t len = 0; @@ -483,7 +483,7 @@ VRT_IP_string(struct sess *sp, struct sockaddr *sa) } char * -VRT_int_string(struct sess *sp, int num) +VRT_int_string(const struct sess *sp, int num) { char *p; int size = 12; diff --git a/varnish-cache/bin/varnishd/cache_vrt_acl.c b/varnish-cache/bin/varnishd/cache_vrt_acl.c index 1157d02a..23fed962 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_acl.c +++ b/varnish-cache/bin/varnishd/cache_vrt_acl.c @@ -60,7 +60,7 @@ static uint32_t ipv4mask[] = { }; static int -vrt_acl_vsl(struct sess *sp, const char *acln, struct vrt_acl *ap, int r) +vrt_acl_vsl(const struct sess *sp, const char *acln, const struct vrt_acl *ap, int r) { AN(ap); @@ -83,7 +83,7 @@ vrt_acl_vsl(struct sess *sp, const char *acln, struct vrt_acl *ap, int r) } int -VRT_acl_match(struct sess *sp, struct sockaddr *sa, const char *acln, struct vrt_acl *ap) +VRT_acl_match(const struct sess *sp, struct sockaddr *sa, const char *acln, const struct vrt_acl *ap) { struct addrinfo *a1; struct sockaddr_in *sin1, *sin2; diff --git a/varnish-cache/bin/varnishd/cache_vrt_re.c b/varnish-cache/bin/varnishd/cache_vrt_re.c index 221a33db..9272155c 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_re.c +++ b/varnish-cache/bin/varnishd/cache_vrt_re.c @@ -102,7 +102,7 @@ VRT_re_test(struct vsb *sb, const char *re, int sub) } const char * -VRT_regsub(struct sess *sp, const char *str, void *re, const char *sub) +VRT_regsub(const struct sess *sp, const char *str, void *re, const char *sub) { regmatch_t pm[10]; regex_t *t; diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 1f5b3d09..4b41c3c3 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -87,7 +87,7 @@ struct vrt_acl { }; /* ACL related */ -int VRT_acl_match(struct sess *, struct sockaddr *, const char *, struct vrt_acl *); +int VRT_acl_match(const struct sess *, struct sockaddr *, const char *, const struct vrt_acl *); void VRT_acl_init(struct vrt_acl *); void VRT_acl_fini(struct vrt_acl *); @@ -96,18 +96,18 @@ void VRT_re_init(void **, const char *, int sub); void VRT_re_fini(void *); int VRT_re_match(const char *, void *re); int VRT_re_test(struct vsb *, const char *, int sub); -const char *VRT_regsub(struct sess *sp, const char *, void *, const char *); +const char *VRT_regsub(const struct sess *sp, const char *, void *, const char *); void VRT_purge(const char *, int hash); -void VRT_count(struct sess *, unsigned); +void VRT_count(const struct sess *, unsigned); int VRT_rewrite(const char *, const char *); void VRT_error(struct sess *, unsigned, const char *); int VRT_switch_config(const char *); enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ }; -char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *); -void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...); +char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *); +void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...); void VRT_handling(struct sess *sp, unsigned hand); /* Simple stuff */ @@ -120,8 +120,8 @@ void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robi void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *); void VRT_fini_backend(struct backend *); -char *VRT_IP_string(struct sess *sp, struct sockaddr *sa); -char *VRT_int_string(struct sess *sp, int); +char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa); +char *VRT_int_string(const struct sess *sp, int); #define VRT_done(sp, hand) \ do { \ diff --git a/varnish-cache/include/vrt_obj.h b/varnish-cache/include/vrt_obj.h index 2bf6da68..ec7065d8 100644 --- a/varnish-cache/include/vrt_obj.h +++ b/varnish-cache/include/vrt_obj.h @@ -10,41 +10,41 @@ void VRT_l_backend_host(struct backend *, const char *); void VRT_l_backend_port(struct backend *, const char *); void VRT_l_backend_dnsttl(struct backend *, double); void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *); -struct sockaddr * VRT_r_client_ip(struct sess *); +struct sockaddr * VRT_r_client_ip(const struct sess *); struct sockaddr * VRT_r_server_ip(struct sess *); -const char * VRT_r_req_request(struct sess *); -void VRT_l_req_request(struct sess *, const char *, ...); -const char * VRT_r_req_url(struct sess *); -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 *, ...); +const char * VRT_r_req_request(const struct sess *); +void VRT_l_req_request(const struct sess *, const char *, ...); +const char * VRT_r_req_url(const struct sess *); +void VRT_l_req_url(const struct sess *, const char *, ...); +const char * VRT_r_req_proto(const struct sess *); +void VRT_l_req_proto(const struct sess *, const char *, ...); void VRT_l_req_hash(struct sess *, const char *); struct backend * VRT_r_req_backend(struct sess *); void VRT_l_req_backend(struct sess *, struct backend *); -const char * VRT_r_bereq_request(struct sess *); -void VRT_l_bereq_request(struct sess *, const char *, ...); -const char * VRT_r_bereq_url(struct sess *); -void VRT_l_bereq_url(struct sess *, const char *, ...); -const char * VRT_r_bereq_proto(struct sess *); -void VRT_l_bereq_proto(struct sess *, const char *, ...); -const char * VRT_r_obj_proto(struct sess *); -void VRT_l_obj_proto(struct sess *, const char *, ...); -int VRT_r_obj_status(struct sess *); -void VRT_l_obj_status(struct sess *, int); -const char * VRT_r_obj_response(struct sess *); -void VRT_l_obj_response(struct sess *, const char *, ...); -unsigned VRT_r_obj_valid(struct sess *); -void VRT_l_obj_valid(struct sess *, unsigned); -unsigned VRT_r_obj_cacheable(struct sess *); -void VRT_l_obj_cacheable(struct sess *, unsigned); -double VRT_r_obj_ttl(struct sess *); -void VRT_l_obj_ttl(struct sess *, double); -double VRT_r_obj_lastuse(struct sess *); -const char * VRT_r_resp_proto(struct sess *); -void VRT_l_resp_proto(struct sess *, const char *, ...); -int VRT_r_resp_status(struct sess *); -void VRT_l_resp_status(struct sess *, int); -const char * VRT_r_resp_response(struct sess *); -void VRT_l_resp_response(struct sess *, const char *, ...); -double VRT_r_now(struct sess *); -int VRT_r_backend_health(struct sess *); +const char * VRT_r_bereq_request(const struct sess *); +void VRT_l_bereq_request(const struct sess *, const char *, ...); +const char * VRT_r_bereq_url(const struct sess *); +void VRT_l_bereq_url(const struct sess *, const char *, ...); +const char * VRT_r_bereq_proto(const struct sess *); +void VRT_l_bereq_proto(const struct sess *, const char *, ...); +const char * VRT_r_obj_proto(const struct sess *); +void VRT_l_obj_proto(const struct sess *, const char *, ...); +int VRT_r_obj_status(const struct sess *); +void VRT_l_obj_status(const struct sess *, int); +const char * VRT_r_obj_response(const struct sess *); +void VRT_l_obj_response(const struct sess *, const char *, ...); +unsigned VRT_r_obj_valid(const struct sess *); +void VRT_l_obj_valid(const struct sess *, unsigned); +unsigned VRT_r_obj_cacheable(const struct sess *); +void VRT_l_obj_cacheable(const struct sess *, unsigned); +double VRT_r_obj_ttl(const struct sess *); +void VRT_l_obj_ttl(const struct sess *, double); +double VRT_r_obj_lastuse(const struct sess *); +const char * VRT_r_resp_proto(const struct sess *); +void VRT_l_resp_proto(const struct sess *, const char *, ...); +int VRT_r_resp_status(const struct sess *); +void VRT_l_resp_status(const struct sess *, int); +const char * VRT_r_resp_response(const struct sess *); +void VRT_l_resp_response(const struct sess *, const char *, ...); +double VRT_r_now(const struct sess *); +int VRT_r_backend_health(const struct sess *); diff --git a/varnish-cache/lib/libvcl/vcc_acl.c b/varnish-cache/lib/libvcl/vcc_acl.c index 0f14f7fa..06b7a396 100644 --- a/varnish-cache/lib/libvcl/vcc_acl.c +++ b/varnish-cache/lib/libvcl/vcc_acl.c @@ -42,7 +42,7 @@ static void vcc_acl_top(struct tokenlist *tl, const char *acln) { - Fh(tl, 1, "\nstatic struct vrt_acl acl_%s[] = {\n", acln); + Fh(tl, 1, "\nstatic const struct vrt_acl acl_%s[] = {\n", acln); tl->hindent += INDENT; } diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index 8f471d73..7f0643c8 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -465,7 +465,7 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "};\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "/* ACL related */\n"); - vsb_cat(sb, "int VRT_acl_match(struct sess *, struct sockaddr *, const char *, struct vrt_acl *);\n"); + vsb_cat(sb, "int VRT_acl_match(const struct sess *, struct sockaddr *, const char *, const struct vrt_acl *);\n"); vsb_cat(sb, "void VRT_acl_init(struct vrt_acl *);\n"); vsb_cat(sb, "void VRT_acl_fini(struct vrt_acl *);\n"); vsb_cat(sb, "\n"); @@ -474,18 +474,18 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "void VRT_re_fini(void *);\n"); vsb_cat(sb, "int VRT_re_match(const char *, void *re);\n"); vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n"); - vsb_cat(sb, "const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);\n"); + vsb_cat(sb, "const char *VRT_regsub(const struct sess *sp, const char *, void *, const char *);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "void VRT_purge(const char *, int hash);\n"); vsb_cat(sb, "\n"); - vsb_cat(sb, "void VRT_count(struct sess *, unsigned);\n"); + vsb_cat(sb, "void VRT_count(const struct sess *, unsigned);\n"); vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n"); vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n"); vsb_cat(sb, "int VRT_switch_config(const char *);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };\n"); - vsb_cat(sb, "char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *);\n"); - vsb_cat(sb, "void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...);\n"); + vsb_cat(sb, "char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);\n"); + vsb_cat(sb, "void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...);\n"); vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "/* Simple stuff */\n"); @@ -498,8 +498,8 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);\n"); vsb_cat(sb, "void VRT_fini_backend(struct backend *);\n"); vsb_cat(sb, "\n"); - vsb_cat(sb, "char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);\n"); - vsb_cat(sb, "char *VRT_int_string(struct sess *sp, int);\n"); + vsb_cat(sb, "char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);\n"); + vsb_cat(sb, "char *VRT_int_string(const struct sess *sp, int);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "#define VRT_done(sp, hand) \\\n"); vsb_cat(sb, " do { \\\n"); @@ -518,42 +518,42 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, "void VRT_l_backend_port(struct backend *, const char *);\n"); vsb_cat(sb, "void VRT_l_backend_dnsttl(struct backend *, double);\n"); vsb_cat(sb, "void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *);\n"); - vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(struct sess *);\n"); + vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n"); vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n"); - vsb_cat(sb, "const char * VRT_r_req_request(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_req_request(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "const char * VRT_r_req_url(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_req_url(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "const char * VRT_r_req_proto(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_req_proto(struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_req_url(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_req_proto(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_req_proto(const struct sess *, const char *, ...);\n"); vsb_cat(sb, "void VRT_l_req_hash(struct sess *, const char *);\n"); vsb_cat(sb, "struct backend * VRT_r_req_backend(struct sess *);\n"); vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct backend *);\n"); - vsb_cat(sb, "const char * VRT_r_bereq_request(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_bereq_request(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "const char * VRT_r_bereq_url(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_bereq_url(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "const char * VRT_r_bereq_proto(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_bereq_proto(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "const char * VRT_r_obj_proto(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_proto(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "int VRT_r_obj_status(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_status(struct sess *, int);\n"); - vsb_cat(sb, "const char * VRT_r_obj_response(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_response(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "unsigned VRT_r_obj_valid(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_valid(struct sess *, unsigned);\n"); - vsb_cat(sb, "unsigned VRT_r_obj_cacheable(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_cacheable(struct sess *, unsigned);\n"); - vsb_cat(sb, "double VRT_r_obj_ttl(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_obj_ttl(struct sess *, double);\n"); - vsb_cat(sb, "double VRT_r_obj_lastuse(struct sess *);\n"); - vsb_cat(sb, "const char * VRT_r_resp_proto(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_resp_proto(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "int VRT_r_resp_status(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_resp_status(struct sess *, int);\n"); - vsb_cat(sb, "const char * VRT_r_resp_response(struct sess *);\n"); - vsb_cat(sb, "void VRT_l_resp_response(struct sess *, const char *, ...);\n"); - vsb_cat(sb, "double VRT_r_now(struct sess *);\n"); - vsb_cat(sb, "int VRT_r_backend_health(struct sess *);\n"); + vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_bereq_url(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_bereq_proto(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_bereq_proto(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "const char * VRT_r_obj_proto(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_proto(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "int VRT_r_obj_status(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_status(const struct sess *, int);\n"); + vsb_cat(sb, "const char * VRT_r_obj_response(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_response(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "unsigned VRT_r_obj_valid(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_valid(const struct sess *, unsigned);\n"); + vsb_cat(sb, "unsigned VRT_r_obj_cacheable(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n"); + vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n"); + vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n"); + vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "int VRT_r_resp_status(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_resp_status(const struct sess *, int);\n"); + vsb_cat(sb, "const char * VRT_r_resp_response(const struct sess *);\n"); + vsb_cat(sb, "void VRT_l_resp_response(const struct sess *, const char *, ...);\n"); + vsb_cat(sb, "double VRT_r_now(const struct sess *);\n"); + vsb_cat(sb, "int VRT_r_backend_health(const struct sess *);\n"); } diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index 8070afa9..624c3454 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -32,10 +32,10 @@ # Objects available in backends set beobj { - { backend.host WO HOSTNAME {} } - { backend.port WO PORTNAME {} } - { backend.dnsttl WO TIME {} } - { backend.set WO SET {} } + { backend.host WO HOSTNAME {} "struct backend *"} + { backend.port WO PORTNAME {} "struct backend *"} + { backend.dnsttl WO TIME {} "struct backend *"} + { backend.set WO SET {} "struct backend *"} } # Variables available in sessions @@ -46,116 +46,138 @@ set spobj { { client.ip RO IP {recv pipe pass hash miss hit fetch deliver } + "const struct sess *" } { client.bandwidth # Not implemented yet NO + { } + "const struct sess *" } { server.ip RO IP {recv pipe pass hash miss hit fetch deliver } + "struct sess *" } # Request paramters { req.request RW STRING {recv pipe pass hash miss hit fetch } + "const struct sess *" } { req.url RW STRING {recv pipe pass hash miss hit fetch } + "const struct sess *" } { req.proto RW STRING {recv pipe pass hash miss hit fetch } + "const struct sess *" } { req.http. - RW HEADER + RW HDR_REQ {recv pipe pass hash miss hit fetch } - HDR_REQ + "const struct sess *" } # Possibly misnamed, not really part of the request { req.hash WO HASH { hash } + "struct sess *" } { req.backend RW BACKEND {recv pipe pass hash miss hit fetch } + "struct sess *" } # Request sent to backend { bereq.request RW STRING { pipe pass miss } + "const struct sess *" } { bereq.url RW STRING { pipe pass miss } + "const struct sess *" } { bereq.proto RW STRING { pipe pass miss } + "const struct sess *" } { bereq.http. - RW HEADER + RW HDR_BEREQ { pipe pass miss } - HDR_BEREQ + "const struct sess *" } # The (possibly) cached object { obj.proto RW STRING { hit fetch } + "const struct sess *" } { obj.status RW INT { fetch } + "const struct sess *" } { obj.response RW STRING { fetch } + "const struct sess *" } { obj.http. - RW HEADER + RW HDR_OBJ { hit fetch } - HDR_OBJ + "const struct sess *" } { obj.valid RW BOOL { hit fetch discard timeout} + "const struct sess *" } { obj.cacheable RW BOOL { hit fetch discard timeout} + "const struct sess *" } { obj.ttl RW TIME { hit fetch discard timeout} + "const struct sess *" } { obj.lastuse RO TIME { hit fetch deliver discard timeout} + "const struct sess *" } # The response we send back { resp.proto RW STRING { deliver } + "const struct sess *" } { resp.status RW INT { deliver } + "const struct sess *" } { resp.response RW STRING { deliver } + "const struct sess *" } { resp.http. - RW HEADER + RW HDR_RESP { deliver } - HDR_RESP + "const struct sess *" } # Miscellaneous @@ -164,24 +186,29 @@ set spobj { { now RO TIME {recv pipe pass hash miss hit fetch deliver discard timeout} + "const struct sess *" } { backend.health RO INT {recv pipe pass hash miss hit fetch deliver discard timeout} + "const struct sess *" } } -set tt(IP) "struct sockaddr *" -set tt(STRING) "const char *" -set tt(BOOL) "unsigned" -set tt(BACKEND) "struct backend *" -set tt(TIME) "double" -set tt(INT) "int" -set tt(HEADER) "const char *" -set tt(HOSTNAME) "const char *" -set tt(PORTNAME) "const char *" -set tt(HASH) "const char *" -set tt(SET) "struct vrt_backend_entry *" +set tt(IP) "struct sockaddr *" +set tt(STRING) "const char *" +set tt(BOOL) "unsigned" +set tt(BACKEND) "struct backend *" +set tt(TIME) "double" +set tt(INT) "int" +set tt(HDR_RESP) "const char *" +set tt(HDR_OBJ) "const char *" +set tt(HDR_REQ) "const char *" +set tt(HDR_BEREQ) "const char *" +set tt(HOSTNAME) "const char *" +set tt(PORTNAME) "const char *" +set tt(HASH) "const char *" +set tt(SET) "struct vrt_backend_entry *" #---------------------------------------------------------------------- # Boilerplate warning for all generated files. @@ -216,7 +243,7 @@ proc method_map {m} { return [string range $l 3 end] } -proc vars {v ty pa} { +proc vars {v pa} { global tt fo fp regsub -all "#\[^\n\]*\n" $v "" v @@ -226,10 +253,15 @@ proc vars {v ty pa} { set a [lindex $v 1] if {$a == "NO"} continue set t [lindex $v 2] - puts $fo "\t\{ \"$n\", $t, [string length $n]," + set ty [lindex $v 4] + if {[regexp HDR_ $t]} { + puts $fo "\t\{ \"$n\", HEADER, [string length $n]," + } else { + puts $fo "\t\{ \"$n\", $t, [string length $n]," + } if {$a == "RO" || $a == "RW"} { puts $fo "\t \"VRT_r_${m}($pa)\"," - if {$t != "HEADER"} { + if {![regexp HDR_ $t]} { puts $fp "$tt($t) VRT_r_${m}($ty);" } } else { @@ -237,7 +269,7 @@ proc vars {v ty pa} { } if {$a == "WO" || $a == "RW"} { puts $fo "\t \"VRT_l_${m}($pa, \"," - if {$t == "HEADER"} { + if {[regexp HDR_ $t]} { } elseif {$t == "STRING"} { puts $fp "void VRT_l_${m}($ty, $tt($t), ...);" } else { @@ -247,10 +279,10 @@ proc vars {v ty pa} { puts $fo "\t NULL," } puts $fo "\t V_$a," - if {$t != "HEADER"} { + if {![regexp HDR_ $t]} { puts $fo "\t 0," } else { - puts $fo "\t \"[lindex $v 4]\"," + puts $fo "\t \"$t\"," } puts $fo "\t [method_map [lindex $v 3]]" puts $fo "\t\}," @@ -264,13 +296,13 @@ puts $fo "#include \"vcc_compile.h\"" puts $fo "" puts $fo "struct var vcc_be_vars\[\] = {" -vars $beobj "struct backend *" "backend" +vars $beobj "backend" puts $fo "};" puts $fo "" puts $fo "struct var vcc_vars\[\] = {" -vars $spobj "struct sess *" "sp" +vars $spobj "sp" puts $fo "};" close $fp -- 2.39.5