r2042 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Tue Sep 25 13:51:49 CEST 2007


Author: phk
Date: 2007-09-25 13:51:49 +0200 (Tue, 25 Sep 2007)
New Revision: 2042

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
   trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
   trunk/varnish-cache/include/vrt.h
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_acl.c
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
Log:
Constify a lot of the VRT API


Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-09-25 11:51:49 UTC (rev 2042)
@@ -63,7 +63,7 @@
 /*--------------------------------------------------------------------*/
 
 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 @@
 }
 
 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 @@
 /*--------------------------------------------------------------------*/
 
 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 @@
 
 #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,  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 @@
 }
 
 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 @@
 }
 
 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 @@
  */
 
 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 @@
 }
 
 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 @@
 
 #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 @@
 }									\
 									\
 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 @@
 
 #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 @@
 /*--------------------------------------------------------------------*/
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 /*--------------------------------------------------------------------*/
 
 struct sockaddr *
-VRT_r_client_ip(struct sess *sp)
+VRT_r_client_ip(const struct sess *sp)
 {
 
 	return (sp->sockaddr);
@@ -428,7 +428,7 @@
 /*--------------------------------------------------------------------*/
 
 double
-VRT_r_now(struct sess *sp)
+VRT_r_now(const struct sess *sp)
 {
 
 	(void)sp;
@@ -436,7 +436,7 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 char *
-VRT_int_string(struct sess *sp, int num)
+VRT_int_string(const struct sess *sp, int num)
 {
 	char *p;
 	int size = 12;

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c	2007-09-25 11:51:49 UTC (rev 2042)
@@ -60,7 +60,7 @@
 };
 
 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 @@
 }
 
 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;

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c	2007-09-25 11:51:49 UTC (rev 2042)
@@ -102,7 +102,7 @@
 }
 
 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;

Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/include/vrt.h	2007-09-25 11:51:49 UTC (rev 2042)
@@ -87,7 +87,7 @@
 };
 
 /* 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_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_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 {					\

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/include/vrt_obj.h	2007-09-25 11:51:49 UTC (rev 2042)
@@ -10,41 +10,41 @@
 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 *);

Modified: trunk/varnish-cache/lib/libvcl/vcc_acl.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_acl.c	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_acl.c	2007-09-25 11:51:49 UTC (rev 2042)
@@ -42,7 +42,7 @@
 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;
 
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2007-09-25 11:51:49 UTC (rev 2042)
@@ -465,7 +465,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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");
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2007-09-25 11:51:49 UTC (rev 2042)
@@ -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 @@
 	{ 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 @@
 	{ 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 @@
 	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 @@
 		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 @@
 		}
 		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 @@
 			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 ""
 
 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




More information about the varnish-commit mailing list