r5011 - trunk/varnish-cache/lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Mon Jul 5 22:14:48 CEST 2010
Author: phk
Date: 2010-07-05 22:14:48 +0200 (Mon, 05 Jul 2010)
New Revision: 5011
Modified:
trunk/varnish-cache/lib/libvcl/generate.py
trunk/varnish-cache/lib/libvcl/vcc_action.c
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_obj.c
trunk/varnish-cache/lib/libvcl/vcc_parse.c
trunk/varnish-cache/lib/libvcl/vcc_string.c
trunk/varnish-cache/lib/libvcl/vcc_var.c
Log:
Move the variable set from being an argument to FindVar to being
a property of the VCC instance.
Modified: trunk/varnish-cache/lib/libvcl/generate.py
===================================================================
--- trunk/varnish-cache/lib/libvcl/generate.py 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/generate.py 2010-07-05 20:14:48 UTC (rev 5011)
@@ -732,7 +732,7 @@
#include <stdio.h>
#include "vcc_compile.h"
-struct var vcc_vars[] = {
+const struct var vcc_vars[] = {
""")
for i in sp_variables:
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -65,11 +65,11 @@
static void
parse_error(struct vcc *tl)
{
- struct var *vp;
+ const struct var *vp;
vcc_NextToken(tl);
if (tl->t->tok == ID) {
- vp = vcc_FindVar(tl, tl->t, vcc_vars, 0, "cannot be read");
+ vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
ERRCHK(tl);
assert(vp != NULL);
if (vp->fmt == INT) {
@@ -114,13 +114,13 @@
static void
parse_set(struct vcc *tl)
{
- struct var *vp;
+ const struct var *vp;
struct token *at, *vt;
vcc_NextToken(tl);
ExpectErr(tl, ID);
vt = tl->t;
- vp = vcc_FindVar(tl, tl->t, vcc_vars, 1, "cannot be set");
+ vp = vcc_FindVar(tl, tl->t, 1, "cannot be set");
ERRCHK(tl);
assert(vp != NULL);
Fb(tl, 1, "%s", vp->lname);
@@ -237,11 +237,11 @@
static void
parse_unset(struct vcc *tl)
{
- struct var *vp;
+ const struct var *vp;
vcc_NextToken(tl);
ExpectErr(tl, ID);
- vp = vcc_FindVar(tl, tl->t, vcc_vars, 1, "cannot be unset");
+ vp = vcc_FindVar(tl, tl->t, 1, "cannot be unset");
ERRCHK(tl);
assert(vp != NULL);
if (vp->fmt != STRING || vp->hdr == NULL) {
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -461,6 +461,7 @@
if (tl0 != NULL) {
REPLACE(tl->default_vcl, tl0->default_vcl);
REPLACE(tl->vcl_dir, tl0->vcl_dir);
+ tl->vars = tl0->vars;
}
VTAILQ_INIT(&tl->hosts);
VTAILQ_INIT(&tl->membits);
@@ -684,6 +685,7 @@
struct vcc *tl;
tl = vcc_NewVcc(NULL);
+ tl->vars = vcc_vars;
return (tl);
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-07-05 20:14:48 UTC (rev 5011)
@@ -73,6 +73,8 @@
char *vcl_dir;
char *vmod_dir;
+ const struct var *vars;
+
/* Instance section */
struct tokenhead tokens;
VTAILQ_HEAD(, source) sources;
@@ -208,7 +210,7 @@
parsedirector_f vcc_ParseRoundRobinDirector;
/* vcc_obj.c */
-extern struct var vcc_vars[];
+extern const struct var vcc_vars[];
/* vcc_parse.c */
void vcc_Parse(struct vcc *tl);
@@ -240,8 +242,8 @@
const char *e);
/* vcc_var.c */
-struct var *vcc_FindVar(struct vcc *tl, const struct token *t,
- struct var *vl, int wr_access, const char *use);
+const struct var *vcc_FindVar(struct vcc *tl, const struct token *t,
+ int wr_access, const char *use);
void vcc_VarVal(struct vcc *tl, const struct var *vp,
const struct token *vt);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -160,10 +160,11 @@
/* ../../include/vcl.h */
- vsb_cat(sb, "\n/*\n * $Id$\n *\n * NB: This file is machine "
- "generated, DO NOT EDIT!\n *\n * Edit and run generate.py instead"
- "\n */\n\nstruct sess;\nstruct cli;\n\ntypedef void vcl_init_f(st"
- "ruct cli *);\ntypedef void vcl_fini_f(struct cli *);\n"
+ vsb_cat(sb, "\n/*\n * $Id: vcl.h 5007 2010-07-05 09:37:53Z "
+ "phk $\n *\n * NB: This file is machine generated, DO NOT "
+ "EDIT!\n *\n * Edit and run generate.py instead\n */\n"
+ "\nstruct sess;\nstruct cli;\n\ntypedef void vcl_init_f(struct "
+ "cli *);\ntypedef void vcl_fini_f(struct cli *);\n"
"typedef int vcl_func_f(struct sess *sp);\n\n/* VCL Methods "
"*/\n#define VCL_MET_RECV\t\t(1U << 0)\n#define VCL_MET_PIPE\t"
"\t(1U << 1)\n#define VCL_MET_PASS\t\t(1U << 2)\n#define VCL_MET_"
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -11,7 +11,7 @@
#include <stdio.h>
#include "vcc_compile.h"
-struct var vcc_vars[] = {
+const struct var vcc_vars[] = {
{ "client.ip", IP, 9,
"VRT_r_client_ip(sp)",
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -326,7 +326,7 @@
static void
vcc_Cond_2(struct vcc *tl)
{
- struct var *vp;
+ const struct var *vp;
C(tl, ",");
if (tl->t->tok == '!') {
@@ -340,7 +340,7 @@
vcc_Cond_0(tl);
SkipToken(tl, ')');
} else if (tl->t->tok == ID) {
- vp = vcc_FindVar(tl, tl->t, vcc_vars, 0, "cannot be read");
+ vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
ERRCHK(tl);
assert(vp != NULL);
vcc_NextToken(tl);
Modified: trunk/varnish-cache/lib/libvcl/vcc_string.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_string.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_string.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -142,7 +142,7 @@
int
vcc_StringVal(struct vcc *tl)
{
- struct var *vp;
+ const struct var *vp;
if (tl->t->tok == CSTR) {
EncToken(tl->fb, tl->t);
@@ -159,7 +159,7 @@
return 1;
}
if (tl->t->tok == ID) {
- vp = vcc_FindVar(tl, tl->t, vcc_vars, 0, "cannot be read");
+ vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
if (tl->err)
return (0);
assert(vp != NULL);
Modified: trunk/varnish-cache/lib/libvcl/vcc_var.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_var.c 2010-07-05 11:56:09 UTC (rev 5010)
+++ trunk/varnish-cache/lib/libvcl/vcc_var.c 2010-07-05 20:14:48 UTC (rev 5011)
@@ -86,13 +86,14 @@
/*--------------------------------------------------------------------*/
-struct var *
-vcc_FindVar(struct vcc *tl, const struct token *t, struct var *vl,
- int wr_access, const char *use)
+const struct var *
+vcc_FindVar(struct vcc *tl, const struct token *t, int wr_access,
+ const char *use)
{
- struct var *v;
+ const struct var *v;
- for (v = vl; v->name != NULL; v++) {
+ AN(tl->vars);
+ for (v = tl->vars; v->name != NULL; v++) {
if (v->fmt == HEADER && (t->e - t->b) <= v->len)
continue;
if (v->fmt != HEADER && t->e - t->b != v->len)
More information about the varnish-commit
mailing list