[master] 765139f Remove more 'req' arguments from VRT
Poul-Henning Kamp
phk at varnish-cache.org
Tue Apr 16 12:17:33 CEST 2013
commit 765139fa6d2e244f8f3572175ed20b7fd6d059be
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 16 10:12:12 2013 +0000
Remove more 'req' arguments from VRT
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 1551790..df705cb 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -293,10 +293,9 @@ VRT_hashdata(struct req *req, const char *str, ...)
/*--------------------------------------------------------------------*/
double
-VRT_r_now(const struct req *req)
+VRT_r_now()
{
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
return (VTIM_real());
}
@@ -430,41 +429,7 @@ VRT_synth_page(const struct req *req, unsigned flags, const char *str, ...)
/*--------------------------------------------------------------------*/
void
-VRT_ban(const struct req *req, char *cmds, ...)
-{
- char *a1, *a2, *a3;
- va_list ap;
- struct ban *b;
- int good;
-
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- b = BAN_New();
- va_start(ap, cmds);
- a1 = cmds;
- good = 0;
- while (a1 != NULL) {
- good = 0;
- a2 = va_arg(ap, char *);
- if (a2 == NULL)
- break;
- a3 = va_arg(ap, char *);
- if (a3 == NULL)
- break;
- if (BAN_AddTest(NULL, b, a1, a2, a3))
- break;
- a1 = va_arg(ap, char *);
- good = 1;
- }
- if (!good)
- BAN_Free(b); /* XXX: report error how ? */
- else
- (void)BAN_Insert(b); /* XXX: report error how ? */
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-VRT_ban_string(const struct req *req, const char *str)
+VRT_ban_string(const char *str)
{
char *a1, *a2, *a3;
char **av;
@@ -472,7 +437,6 @@ VRT_ban_string(const struct req *req, const char *str)
int good;
int i;
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
av = VAV_Parse(str, NULL, ARGV_NOESC);
if (av[0] != NULL) {
/* XXX: report error how ? */
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 5ef7a9b..16f8c8b 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -232,7 +232,7 @@ VRT_l_client_identity(struct req *req, const char *str, ...)
/*--------------------------------------------------------------------*/
#define BEREQ_TIMEOUT(which) \
-void \
+void \
VRT_l_bereq_##which(const struct req *req, double num) \
{ \
\
diff --git a/include/vrt.h b/include/vrt.h
index 2c05a17..3d769b1 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -168,8 +168,7 @@ int VRT_re_match(struct req *, const char *, void *re);
const char *VRT_regsub(struct req *, int all, const char *,
void *, const char *);
-void VRT_ban(const struct req *, char *, ...);
-void VRT_ban_string(const struct req *, const char *);
+void VRT_ban_string(const char *);
void VRT_purge(struct req *, double ttl, double grace);
void VRT_count(struct req *, unsigned);
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 67486f1..9b64cb9 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -481,7 +481,7 @@ sp_variables = (
'TIME',
( 'all',),
( ),
- 'cR'
+ ''
),
)
@@ -851,6 +851,8 @@ const struct var vcc_vars[] = {
""")
def mk_proto(c, r=False):
+ if c == "":
+ return "void"
s = ""
for i in c:
if i == "c" and not r:
@@ -861,6 +863,20 @@ def mk_proto(c, r=False):
s += " struct req *"
return s[1:]
+
+def mk_args(c, r=False):
+ if c == "":
+ return ""
+ s = ""
+ for i in c:
+ if i == "c":
+ continue;
+ if i == "R":
+ s += "req"
+ if s != "" and not r:
+ s += ","
+ return s
+
for i in sp_variables:
typ = i[1]
cnam = i[0].replace(".", "_")
@@ -875,8 +891,10 @@ for i in sp_variables:
fo.write(i[0].split(".")[0].upper())
fo.write('",\n')
else:
- fo.write('\t "VRT_r_%s(req)",\n' % cnam)
- fh.write(ctyp + " VRT_r_%s(%s);\n" % (cnam, mk_proto(i[4], True)))
+ fo.write('\t "VRT_r_%s(%s)",\n' %
+ (cnam, mk_args(i[4], True)))
+ fh.write(ctyp + " VRT_r_%s(%s);\n" %
+ (cnam, mk_proto(i[4], True)))
restrict(fo, i[2])
if len(i[3]) == 0:
@@ -886,7 +904,8 @@ for i in sp_variables:
fo.write(i[0].split(".")[0].upper())
fo.write('",\n')
else:
- fo.write('\t "VRT_l_%s(req, ",\n' % cnam)
+ fo.write('\t "VRT_l_%s(%s",\n' %
+ (cnam, mk_args(i[4], False)))
fh.write("void VRT_l_%s(%s, " % (cnam, mk_proto(i[4], False)))
if typ != "STRING":
fh.write(ctyp + ");\n")
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index 86d089b..a912188 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -261,7 +261,7 @@ parse_ban(struct vcc *tl)
ExpectErr(tl, '(');
vcc_NextToken(tl);
- Fb(tl, 1, "VRT_ban_string(req, ");
+ Fb(tl, 1, "VRT_ban_string(");
vcc_Expr(tl, STRING);
ERRCHK(tl);
Fb(tl, 0, ");\n");
More information about the varnish-commit
mailing list