Commit 765139fa authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Remove more 'req' arguments from VRT

parent 8641ba85
......@@ -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 ? */
......
......@@ -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) \
{ \
\
......
......@@ -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);
......
......@@ -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")
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment