r4188 - in trunk/varnish-cache: include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Tue Aug 18 10:29:28 CEST 2009
Author: phk
Date: 2009-08-18 10:29:27 +0200 (Tue, 18 Aug 2009)
New Revision: 4188
Removed:
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
Modified:
trunk/varnish-cache/include/vcl.h
trunk/varnish-cache/include/vcl_returns.h
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/Makefile.am
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
I can never remember which of the two VCC generation scripts to run
first, so combine them into one and avoid the issue entirely.
Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/include/vcl.h 2009-08-18 08:29:27 UTC (rev 4188)
@@ -27,18 +27,16 @@
#define VCL_MET_MAX 9
/* VCL Returns */
-#define VCL_RET_ERROR 0
-#define VCL_RET_LOOKUP 1
-#define VCL_RET_HASH 2
-#define VCL_RET_PIPE 3
-#define VCL_RET_PASS 4
-#define VCL_RET_FETCH 5
-#define VCL_RET_DELIVER 6
-#define VCL_RET_DISCARD 7
-#define VCL_RET_KEEP 8
-#define VCL_RET_RESTART 9
+#define VCL_RET_DELIVER 0
+#define VCL_RET_ERROR 1
+#define VCL_RET_FETCH 2
+#define VCL_RET_HASH 3
+#define VCL_RET_LOOKUP 4
+#define VCL_RET_PASS 5
+#define VCL_RET_PIPE 6
+#define VCL_RET_RESTART 7
-#define VCL_RET_MAX 10
+#define VCL_RET_MAX 8
struct VCL_conf {
unsigned magic;
Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/include/vcl_returns.h 2009-08-18 08:29:27 UTC (rev 4188)
@@ -7,15 +7,13 @@
*/
#ifdef VCL_RET_MAC
+VCL_RET_MAC(deliver, DELIVER)
VCL_RET_MAC(error, ERROR)
-VCL_RET_MAC(lookup, LOOKUP)
+VCL_RET_MAC(fetch, FETCH)
VCL_RET_MAC(hash, HASH)
-VCL_RET_MAC(pipe, PIPE)
+VCL_RET_MAC(lookup, LOOKUP)
VCL_RET_MAC(pass, PASS)
-VCL_RET_MAC(fetch, FETCH)
-VCL_RET_MAC(deliver, DELIVER)
-VCL_RET_MAC(discard, DISCARD)
-VCL_RET_MAC(keep, KEEP)
+VCL_RET_MAC(pipe, PIPE)
VCL_RET_MAC(restart, RESTART)
#endif
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/include/vrt_obj.h 2009-08-18 08:29:27 UTC (rev 4188)
@@ -3,7 +3,7 @@
*
* NB: This file is machine generated, DO NOT EDIT!
*
- * Edit vcc_gen_obj.tcl instead
+ * Edit and run vcc_gen_fixed_token.tcl instead
*/
struct sockaddr * VRT_r_client_ip(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/Makefile.am
===================================================================
--- trunk/varnish-cache/lib/libvcl/Makefile.am 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/lib/libvcl/Makefile.am 2009-08-18 08:29:27 UTC (rev 4188)
@@ -25,11 +25,11 @@
vcc_var.c \
vcc_xref.c
-EXTRA_DIST = vcc_gen_obj.tcl \
+EXTRA_DIST = \
vcc_gen_fixed_token.tcl
-$(srcdir)/vcc_obj.c: $(srcdir)/vcc_gen_obj.tcl
- cd $(srcdir) && @TCLSH@ vcc_gen_obj.tcl || true
+$(srcdir)/vcc_obj.c: $(srcdir)/vcc_gen_fixed_token.tcl
+ cd $(srcdir) && @TCLSH@ vcc_gen_fixed_token.tcl || true
$(srcdir)/vcc_fixed_token.c: $(srcdir)/vcc_gen_fixed_token.tcl $(top_srcdir)/include/vcl.h $(top_srcdir)/include/vrt.h $(top_srcdir)/include/vrt_obj.h
cd $(srcdir) && @TCLSH@ vcc_gen_fixed_token.tcl || true
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-08-18 08:29:27 UTC (rev 4188)
@@ -176,17 +176,15 @@
vsb_cat(sb, "#define VCL_MET_DELIVER\t\t(1 << 7)\n");
vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 8)\n");
vsb_cat(sb, "\n#define VCL_MET_MAX\t\t9\n\n/* VCL Returns */\n");
- vsb_cat(sb, "#define VCL_RET_ERROR\t\t0\n#define VCL_RET_LOOKUP\t\t");
- vsb_cat(sb, "1\n#define VCL_RET_HASH\t\t2\n#define VCL_RET_PIPE\t\t");
- vsb_cat(sb, "3\n#define VCL_RET_PASS\t\t4\n#define VCL_RET_FETCH\t\t");
- vsb_cat(sb, "5\n#define VCL_RET_DELIVER\t\t6\n");
- vsb_cat(sb, "#define VCL_RET_DISCARD\t\t7\n#define VCL_RET_KEEP\t\t");
- vsb_cat(sb, "8\n#define VCL_RET_RESTART\t\t9\n");
- vsb_cat(sb, "\n#define VCL_RET_MAX\t\t10\n\n");
- vsb_cat(sb, "struct VCL_conf {\n\tunsigned\tmagic;\n");
- vsb_cat(sb, "#define VCL_CONF_MAGIC\t0x7406c509\t/* from /dev/rando");
- vsb_cat(sb, "m */\n\n\tstruct director\t**director;\n");
- vsb_cat(sb, "\tunsigned\tndirector;\n\tstruct vrt_ref\t*ref;\n");
+ vsb_cat(sb, "#define VCL_RET_DELIVER\t\t0\n#define VCL_RET_ERROR\t\t");
+ vsb_cat(sb, "1\n#define VCL_RET_FETCH\t\t2\n");
+ vsb_cat(sb, "#define VCL_RET_HASH\t\t3\n#define VCL_RET_LOOKUP\t\t4");
+ vsb_cat(sb, "\n#define VCL_RET_PASS\t\t5\n#define VCL_RET_PIPE\t\t6");
+ vsb_cat(sb, "\n#define VCL_RET_RESTART\t\t7\n");
+ vsb_cat(sb, "\n#define VCL_RET_MAX\t\t8\n\nstruct VCL_conf {\n");
+ vsb_cat(sb, "\tunsigned\tmagic;\n#define VCL_CONF_MAGIC\t0x7406c509");
+ vsb_cat(sb, "\t/* from /dev/random */\n\n\tstruct director\t**direc");
+ vsb_cat(sb, "tor;\n\tunsigned\tndirector;\n\tstruct vrt_ref\t*ref;\n");
vsb_cat(sb, "\tunsigned\tnref;\n\tunsigned\tbusy;\n");
vsb_cat(sb, "\tunsigned\tdiscard;\n\n\tunsigned\tnsrc;\n");
vsb_cat(sb, "\tconst char\t**srcname;\n\tconst char\t**srcbody;\n");
@@ -230,8 +228,8 @@
vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
- vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4025 2009-04-03 21:");
- vsb_cat(sb, "52:44Z des $\n *\n * Runtime support for compiled VCL ");
+ vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4185 2009-08-17 11:");
+ vsb_cat(sb, "53:01Z phk $\n *\n * Runtime support for compiled VCL ");
vsb_cat(sb, "programs.\n *\n * XXX: When this file is changed, lib/");
vsb_cat(sb, "libvcl/vcc_gen_fixed_token.tcl\n");
vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n");
@@ -319,26 +317,26 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4099 2009-06-08 21:40:48Z ");
- vsb_cat(sb, "phk $\n *\n * NB: This file is machine generated, DO ");
- vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
- vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
- vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
- vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
- vsb_cat(sb, "*);\nconst char * VRT_r_server_identity(struct sess *)");
- vsb_cat(sb, ";\nint VRT_r_server_port(struct sess *);\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");
- vsb_cat(sb, " *, ...);\nconst char * VRT_r_req_url(const struct ses");
- vsb_cat(sb, "s *);\nvoid VRT_l_req_url(const struct sess *, const c");
- vsb_cat(sb, "har *, ...);\nconst char * VRT_r_req_proto(const struc");
- vsb_cat(sb, "t sess *);\nvoid VRT_l_req_proto(const struct sess *, ");
- vsb_cat(sb, "const char *, ...);\nvoid VRT_l_req_hash(struct sess *");
- vsb_cat(sb, ", const char *);\nstruct director * VRT_r_req_backend(");
- vsb_cat(sb, "struct sess *);\nvoid VRT_l_req_backend(struct sess *,");
- vsb_cat(sb, " struct director *);\nint VRT_r_req_restarts(const str");
- vsb_cat(sb, "uct sess *);\ndouble VRT_r_req_grace(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_grace(struct sess *, double);\n");
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4100 2009-06-09 10");
+ vsb_cat(sb, ":41:38Z phk $\n *\n * NB: This file is machine genera");
+ vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
+ vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sockaddr * VRT_r_clien");
+ vsb_cat(sb, "t_ip(const struct sess *);\nstruct sockaddr * VRT_r_se");
+ vsb_cat(sb, "rver_ip(struct sess *);\nconst char * VRT_r_server_hos");
+ vsb_cat(sb, "tname(struct sess *);\nconst char * VRT_r_server_ident");
+ vsb_cat(sb, "ity(struct sess *);\nint VRT_r_server_port(struct sess");
+ vsb_cat(sb, " *);\nconst char * VRT_r_req_request(const struct sess");
+ vsb_cat(sb, " *);\nvoid VRT_l_req_request(const struct sess *, cons");
+ vsb_cat(sb, "t char *, ...);\nconst char * VRT_r_req_url(const stru");
+ vsb_cat(sb, "ct sess *);\nvoid VRT_l_req_url(const struct sess *, c");
+ vsb_cat(sb, "onst char *, ...);\nconst char * VRT_r_req_proto(const");
+ vsb_cat(sb, " struct sess *);\nvoid VRT_l_req_proto(const struct se");
+ vsb_cat(sb, "ss *, const char *, ...);\nvoid VRT_l_req_hash(struct ");
+ vsb_cat(sb, "sess *, const char *);\nstruct director * VRT_r_req_ba");
+ vsb_cat(sb, "ckend(struct sess *);\nvoid VRT_l_req_backend(struct s");
+ vsb_cat(sb, "ess *, struct director *);\nint VRT_r_req_restarts(con");
+ vsb_cat(sb, "st struct sess *);\ndouble VRT_r_req_grace(struct sess");
+ vsb_cat(sb, " *);\nvoid VRT_l_req_grace(struct sess *, double);\n");
vsb_cat(sb, "const char * VRT_r_req_xid(struct sess *);\n");
vsb_cat(sb, "unsigned VRT_r_req_esi(struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_esi(struct sess *, unsigned);\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-08-18 08:29:27 UTC (rev 4188)
@@ -45,21 +45,6 @@
{error {restart deliver}}
}
-# These are the return actions
-#
-set returns {
- error
- lookup
- hash
- pipe
- pass
- fetch
- deliver
- discard
- keep
- restart
-}
-
# Language keywords
#
set keywords {
@@ -97,6 +82,292 @@
set extras {ID VAR CNUM CSTR EOI CSRC}
#----------------------------------------------------------------------
+# Variables available in sessions
+# Comments are stripped from #...\n
+set spobj {
+
+ # Connection related parameters
+ { client.ip
+ RO IP
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+ { client.bandwidth # Not implemented yet
+ NO
+ { }
+ "const struct sess *"
+ }
+ { server.ip
+ RO IP
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+ { server.hostname
+ RO STRING
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+ { server.identity
+ RO STRING
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+ { server.port
+ RO INT
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+ # Request paramters
+ { req.request
+ RW STRING
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+ { req.url
+ RW STRING
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+ { req.proto
+ RW STRING
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+ { req.http.
+ RW HDR_REQ
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+
+ # Possibly misnamed, not really part of the request
+ { req.hash
+ WO HASH
+ { hash error }
+ "struct sess *"
+ }
+ { req.backend
+ RW BACKEND
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+ { req.restarts
+ RO INT
+ {recv pipe pass hash miss hit fetch deliver error }
+ "const struct sess *"
+ }
+ { req.grace
+ RW TIME
+ {recv pipe pass hash miss hit fetch deliver error }
+ "struct sess *"
+ }
+
+ { req.xid
+ RO STRING
+ {recv pipe pass hash miss hit fetch deliver error}
+ "struct sess *"
+ }
+
+ { req.esi
+ RW BOOL
+ {recv fetch deliver error}
+ "struct sess *"
+ }
+
+ #######################################################################
+ # Request sent to backend
+ { bereq.request
+ RW STRING
+ { pipe pass miss fetch }
+ "const struct sess *"
+ }
+ { bereq.url
+ RW STRING
+ { pipe pass miss fetch }
+ "const struct sess *"
+ }
+ { bereq.proto
+ RW STRING
+ { pipe pass miss fetch }
+ "const struct sess *"
+ }
+ { bereq.http.
+ RW HDR_BEREQ
+ { pipe pass miss fetch }
+ "const struct sess *"
+ }
+ { bereq.connect_timeout
+ RW TIME
+ { pass miss }
+ "struct sess *"
+ }
+ { bereq.first_byte_timeout
+ RW TIME
+ { pass miss }
+ "struct sess *"
+ }
+ { bereq.between_bytes_timeout
+ RW TIME
+ { pass miss }
+ "struct sess *"
+ }
+
+ #######################################################################
+ # Response from the backend
+ { beresp.proto
+ RW STRING
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.status
+ RW INT
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.response
+ RW STRING
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.http.
+ RW HDR_BERESP
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.cacheable
+ RW BOOL
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.ttl
+ RW TIME
+ { fetch }
+ "const struct sess *"
+ }
+ { beresp.grace
+ RW TIME
+ { fetch }
+ "const struct sess *"
+ }
+
+ #######################################################################
+ # The (possibly) cached object
+ { obj.proto
+ RW STRING
+ { hit error}
+ "const struct sess *"
+ }
+ { obj.status
+ RW INT
+ { error}
+ "const struct sess *"
+ }
+ { obj.response
+ RW STRING
+ { error}
+ "const struct sess *"
+ }
+ { obj.hits
+ RO INT
+ { hit deliver }
+ "const struct sess *"
+ }
+ { obj.http.
+ RW HDR_OBJ
+ { hit error}
+ "const struct sess *"
+ }
+
+ { obj.cacheable
+ RW BOOL
+ { hit }
+ "const struct sess *"
+ }
+ { obj.ttl
+ RW TIME
+ { hit error}
+ "const struct sess *"
+ }
+ { obj.grace
+ RW TIME
+ { hit error}
+ "const struct sess *"
+ }
+ { obj.lastuse
+ RO TIME
+ { hit deliver error}
+ "const struct sess *"
+ }
+ { obj.hash
+ RO STRING
+ { miss hit deliver error}
+ "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 HDR_RESP
+ { deliver }
+ "const struct sess *"
+ }
+
+ # Miscellaneous
+ # XXX: I'm not happy about this one. All times should be relative
+ # XXX: or delta times in VCL programs, so this shouldn't be needed /phk
+ { now
+ RO TIME
+ {recv pipe pass hash miss hit fetch deliver }
+ "const struct sess *"
+ }
+ { req.backend.healthy RO BOOL
+ {recv pipe pass hash miss hit fetch deliver }
+ "const struct sess *"
+ }
+
+}
+
+set tt(IP) "struct sockaddr *"
+set tt(STRING) "const char *"
+set tt(BOOL) "unsigned"
+set tt(BACKEND) "struct director *"
+set tt(TIME) "double"
+set tt(RTIME) "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 *"
+
+#----------------------------------------------------------------------
+# Figure out the union list of return actions
+foreach i $methods {
+ foreach j [lindex $i 1] {
+ set tmp($j) 1
+ }
+}
+set returns [lsort [array names tmp]]
+unset tmp
+
+#----------------------------------------------------------------------
# Boilerplate warning for all generated files.
proc warns {fd} {
@@ -113,6 +384,148 @@
}
#----------------------------------------------------------------------
+# Include a .h file as a string.
+
+proc copy_include {n} {
+ global fo
+
+ puts $fo "\n\t/* $n */\n"
+ set fi [open $n]
+ set n 0
+ while {[gets $fi a] >= 0} {
+ for {set b 0} {$b < [string length $a]} {incr b} {
+ if {$n == 0} {
+ puts -nonewline $fo "\tvsb_cat(sb, \""
+ }
+ set c [string index $a $b]
+ if {"$c" == "\\"} {
+ puts -nonewline $fo "\\\\"
+ incr n
+ } elseif {"$c" == "\t"} {
+ puts -nonewline $fo "\\t"
+ incr n
+ } else {
+ puts -nonewline $fo "$c"
+ }
+ incr n
+ if {$n > 53} {
+ puts $fo "\");"
+ set n 0
+ }
+ }
+ if {$n == 0} {
+ puts -nonewline $fo "\tvsb_cat(sb, \""
+ }
+ puts -nonewline $fo "\\n"
+ incr n 2
+ if {$n > 30} {
+ puts $fo "\");"
+ set n 0
+ }
+ }
+ if {$n > 0} {
+ puts $fo "\");"
+ }
+ close $fi
+}
+
+#----------------------------------------------------------------------
+# Build the variable related .c and .h files
+
+set fo [open vcc_obj.c w]
+warns $fo
+set fp [open ../../include/vrt_obj.h w]
+warns $fp
+
+proc method_map {m} {
+
+ set l1 ""
+ set l2 ""
+ foreach i $m {
+ if {[string length $l2] > 55} {
+ if {$l1 != ""} {
+ append l1 "\n\t "
+ }
+ append l1 "$l2"
+ set l2 ""
+ }
+ if {$l2 != "" || $l1 != ""} {
+ append l2 " | "
+ }
+ append l2 VCL_MET_[string toupper $i]
+ }
+ if {$l2 != ""} {
+ if {$l1 != ""} {
+ append l1 "\n\t "
+ }
+ append l1 "$l2"
+ }
+ if {$l1 == ""} {
+ return "0"
+ }
+ return $l1
+}
+
+proc vars {v pa} {
+ global tt fo fp
+
+ regsub -all "#\[^\n\]*\n" $v "" v
+ foreach v $v {
+ set n [lindex $v 0]
+ regsub -all {[.]} $n "_" m
+ set a [lindex $v 1]
+ if {$a == "NO"} continue
+ set t [lindex $v 2]
+ 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 -nonewline $fo "\t \"VRT_r_${m}($pa)\","
+ if {![regexp HDR_ $t]} {
+ puts $fp "$tt($t) VRT_r_${m}($ty);"
+ }
+ } else {
+ puts -nonewline $fo "\t NULL,"
+ }
+ if {$a == "WO" || $a == "RW"} {
+ puts $fo "\t \"VRT_l_${m}($pa, \","
+ if {[regexp HDR_ $t]} {
+ } elseif {$t == "STRING"} {
+ puts $fp "void VRT_l_${m}($ty, $tt($t), ...);"
+ } else {
+ puts $fp "void VRT_l_${m}($ty, $tt($t));"
+ }
+ } else {
+ puts $fo "\t NULL,"
+ }
+ puts -nonewline $fo "\t V_$a,"
+ if {![regexp HDR_ $t]} {
+ puts $fo "\t 0,"
+ } else {
+ puts $fo "\t \"$t\","
+ }
+ puts $fo "\t [method_map [lindex $v 3]]"
+ puts $fo "\t\},"
+
+ }
+ puts $fo "\t{ NULL }"
+}
+
+puts $fo "#include \"config.h\""
+puts $fo "#include <stdio.h>"
+puts $fo "#include \"vcc_compile.h\""
+puts $fo ""
+
+puts $fo "struct var vcc_vars\[\] = {"
+vars $spobj "sp"
+puts $fo "};"
+close $fp
+
+
+#----------------------------------------------------------------------
# Build the vcl.h #include file
set fo [open ../../include/vcl.h w]
@@ -290,8 +703,8 @@
puts $fo " case '$ch':"
set retval "0"
set m1 0
- foreach tt $l {
- set k [lindex $tt 0]
+ foreach ty $l {
+ set k [lindex $ty 0]
if {[string length $k] == 1} {
puts $fo "\t\tM1();"
set m1 1
@@ -300,7 +713,7 @@
if {[string length $k] == 2} {
puts -nonewline $fo " M2("
puts -nonewline $fo "'[string index $k 1]'"
- puts $fo ", [lindex $tt 1]);"
+ puts $fo ", [lindex $ty 1]);"
continue;
}
puts -nonewline $fo " if ("
@@ -314,7 +727,7 @@
}
puts -nonewline $fo "p\[$i\] == '[string index $k $i]'"
}
- if {[lindex $tt 2]} {
+ if {[lindex $ty 2]} {
if {[expr $i % 3] == 1} {
puts -nonewline $fo "\n\t\t "
}
@@ -322,7 +735,7 @@
}
puts $fo ") {"
puts $fo "\t\t\t*q = p + [string length $k];"
- puts $fo "\t\t\treturn ([lindex $tt 1]);"
+ puts $fo "\t\t\treturn ([lindex $ty 1]);"
puts $fo "\t\t}"
}
if {$m1 == 0} {
@@ -345,53 +758,6 @@
}
puts $fo "};"
-#----------------------------------------------------------------------
-# Create the C-code which emits the boilerplate definitions for the
-# generated C code output
-
-proc copy_include {n} {
- global fo
-
- puts $fo "\n\t/* $n */\n"
- set fi [open $n]
- set n 0
- while {[gets $fi a] >= 0} {
- for {set b 0} {$b < [string length $a]} {incr b} {
- if {$n == 0} {
- puts -nonewline $fo "\tvsb_cat(sb, \""
- }
- set c [string index $a $b]
- if {"$c" == "\\"} {
- puts -nonewline $fo "\\\\"
- incr n
- } elseif {"$c" == "\t"} {
- puts -nonewline $fo "\\t"
- incr n
- } else {
- puts -nonewline $fo "$c"
- }
- incr n
- if {$n > 53} {
- puts $fo "\");"
- set n 0
- }
- }
- if {$n == 0} {
- puts -nonewline $fo "\tvsb_cat(sb, \""
- }
- puts -nonewline $fo "\\n"
- incr n 2
- if {$n > 30} {
- puts $fo "\");"
- set n 0
- }
- }
- if {$n > 0} {
- puts $fo "\");"
- }
- close $fi
-}
-
puts $fo ""
puts $fo "void"
puts $fo "vcl_output_lang_h(struct vsb *sb)"
@@ -405,3 +771,4 @@
close $foh
close $fo
+
Deleted: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2009-08-18 08:29:27 UTC (rev 4188)
@@ -1,415 +0,0 @@
-#!/usr/local/bin/tclsh8.4
-#-
-# Copyright (c) 2006 Verdens Gang AS
-# Copyright (c) 2006-2009 Linpro AS
-# All rights reserved.
-#
-# Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# Generate various .c and .h files for the VCL compiler and the interfaces
-# for it.
-
-
-# Variables available in sessions
-# Comments are stripped from #...\n
-set spobj {
-
- # Connection related parameters
- { client.ip
- RO IP
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
- { client.bandwidth # Not implemented yet
- NO
- { }
- "const struct sess *"
- }
- { server.ip
- RO IP
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
- { server.hostname
- RO STRING
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
- { server.identity
- RO STRING
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
- { server.port
- RO INT
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
- # Request paramters
- { req.request
- RW STRING
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
- { req.url
- RW STRING
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
- { req.proto
- RW STRING
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
- { req.http.
- RW HDR_REQ
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
-
- # Possibly misnamed, not really part of the request
- { req.hash
- WO HASH
- { hash error }
- "struct sess *"
- }
- { req.backend
- RW BACKEND
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
- { req.restarts
- RO INT
- {recv pipe pass hash miss hit fetch deliver error }
- "const struct sess *"
- }
- { req.grace
- RW TIME
- {recv pipe pass hash miss hit fetch deliver error }
- "struct sess *"
- }
-
- { req.xid
- RO STRING
- {recv pipe pass hash miss hit fetch deliver error}
- "struct sess *"
- }
-
- { req.esi
- RW BOOL
- {recv fetch deliver error}
- "struct sess *"
- }
-
- #######################################################################
- # Request sent to backend
- { bereq.request
- RW STRING
- { pipe pass miss fetch }
- "const struct sess *"
- }
- { bereq.url
- RW STRING
- { pipe pass miss fetch }
- "const struct sess *"
- }
- { bereq.proto
- RW STRING
- { pipe pass miss fetch }
- "const struct sess *"
- }
- { bereq.http.
- RW HDR_BEREQ
- { pipe pass miss fetch }
- "const struct sess *"
- }
- { bereq.connect_timeout
- RW TIME
- { pass miss }
- "struct sess *"
- }
- { bereq.first_byte_timeout
- RW TIME
- { pass miss }
- "struct sess *"
- }
- { bereq.between_bytes_timeout
- RW TIME
- { pass miss }
- "struct sess *"
- }
-
- #######################################################################
- # Response from the backend
- { beresp.proto
- RW STRING
- { fetch }
- "const struct sess *"
- }
- { beresp.status
- RW INT
- { fetch }
- "const struct sess *"
- }
- { beresp.response
- RW STRING
- { fetch }
- "const struct sess *"
- }
- { beresp.http.
- RW HDR_BERESP
- { fetch }
- "const struct sess *"
- }
- { beresp.cacheable
- RW BOOL
- { fetch }
- "const struct sess *"
- }
- { beresp.ttl
- RW TIME
- { fetch }
- "const struct sess *"
- }
- { beresp.grace
- RW TIME
- { fetch }
- "const struct sess *"
- }
-
- #######################################################################
- # The (possibly) cached object
- { obj.proto
- RW STRING
- { hit error}
- "const struct sess *"
- }
- { obj.status
- RW INT
- { error}
- "const struct sess *"
- }
- { obj.response
- RW STRING
- { error}
- "const struct sess *"
- }
- { obj.hits
- RO INT
- { hit deliver }
- "const struct sess *"
- }
- { obj.http.
- RW HDR_OBJ
- { hit error}
- "const struct sess *"
- }
-
- { obj.cacheable
- RW BOOL
- { hit }
- "const struct sess *"
- }
- { obj.ttl
- RW TIME
- { hit error}
- "const struct sess *"
- }
- { obj.grace
- RW TIME
- { hit error}
- "const struct sess *"
- }
- { obj.lastuse
- RO TIME
- { hit deliver error}
- "const struct sess *"
- }
- { obj.hash
- RO STRING
- { miss hit deliver error}
- "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 HDR_RESP
- { deliver }
- "const struct sess *"
- }
-
- # Miscellaneous
- # XXX: I'm not happy about this one. All times should be relative
- # XXX: or delta times in VCL programs, so this shouldn't be needed /phk
- { now
- RO TIME
- {recv pipe pass hash miss hit fetch deliver }
- "const struct sess *"
- }
- { req.backend.healthy RO BOOL
- {recv pipe pass hash miss hit fetch deliver }
- "const struct sess *"
- }
-
-}
-
-set tt(IP) "struct sockaddr *"
-set tt(STRING) "const char *"
-set tt(BOOL) "unsigned"
-set tt(BACKEND) "struct director *"
-set tt(TIME) "double"
-set tt(RTIME) "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.
-
-proc warns {fd} {
-
- puts $fd "/*"
- puts $fd { * $Id$}
- puts $fd " *"
- puts $fd " * NB: This file is machine generated, DO NOT EDIT!"
- puts $fd " *"
- puts $fd " * Edit vcc_gen_obj.tcl instead"
- puts $fd " */"
- puts $fd ""
-}
-
-set fo [open vcc_obj.c w]
-warns $fo
-set fp [open ../../include/vrt_obj.h w]
-warns $fp
-
-proc method_map {m} {
-
- set l1 ""
- set l2 ""
- foreach i $m {
- if {[string length $l2] > 55} {
- if {$l1 != ""} {
- append l1 "\n\t "
- }
- append l1 "$l2"
- set l2 ""
- }
- if {$l2 != "" || $l1 != ""} {
- append l2 " | "
- }
- append l2 VCL_MET_[string toupper $i]
- }
- if {$l2 != ""} {
- if {$l1 != ""} {
- append l1 "\n\t "
- }
- append l1 "$l2"
- }
- if {$l1 == ""} {
- return "0"
- }
- return $l1
-}
-
-proc vars {v pa} {
- global tt fo fp
-
- regsub -all "#\[^\n\]*\n" $v "" v
- foreach v $v {
- set n [lindex $v 0]
- regsub -all {[.]} $n "_" m
- set a [lindex $v 1]
- if {$a == "NO"} continue
- set t [lindex $v 2]
- 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 -nonewline $fo "\t \"VRT_r_${m}($pa)\","
- if {![regexp HDR_ $t]} {
- puts $fp "$tt($t) VRT_r_${m}($ty);"
- }
- } else {
- puts -nonewline $fo "\t NULL,"
- }
- if {$a == "WO" || $a == "RW"} {
- puts $fo "\t \"VRT_l_${m}($pa, \","
- if {[regexp HDR_ $t]} {
- } elseif {$t == "STRING"} {
- puts $fp "void VRT_l_${m}($ty, $tt($t), ...);"
- } else {
- puts $fp "void VRT_l_${m}($ty, $tt($t));"
- }
- } else {
- puts $fo "\t NULL,"
- }
- puts -nonewline $fo "\t V_$a,"
- if {![regexp HDR_ $t]} {
- puts $fo "\t 0,"
- } else {
- puts $fo "\t \"$t\","
- }
- puts $fo "\t [method_map [lindex $v 3]]"
- puts $fo "\t\},"
-
- }
- puts $fo "\t{ NULL }"
-}
-
-puts $fo "#include \"config.h\""
-puts $fo "#include <stdio.h>"
-puts $fo "#include \"vcc_compile.h\""
-puts $fo ""
-
-puts $fo "struct var vcc_vars\[\] = {"
-vars $spobj "sp"
-puts $fo "};"
-
-close $fp
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-08-17 12:44:03 UTC (rev 4187)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-08-18 08:29:27 UTC (rev 4188)
@@ -1,9 +1,9 @@
/*
- * $Id: vcc_gen_obj.tcl 4099 2009-06-08 21:40:48Z phk $
+ * $Id: vcc_gen_fixed_token.tcl 4100 2009-06-09 10:41:38Z phk $
*
* NB: This file is machine generated, DO NOT EDIT!
*
- * Edit vcc_gen_obj.tcl instead
+ * Edit and run vcc_gen_fixed_token.tcl instead
*/
#include "config.h"
More information about the varnish-commit
mailing list