Commit 2835dc7e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the purgable variables into a CPP table, so we can share them with

the VCL compiler



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3538 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 99968684
......@@ -297,11 +297,23 @@ ban_parse_http(struct ban_test *bt, const char *a1)
bt->src[l + 2] = '\0';
}
static const struct pvar {
const char *name;
unsigned flag;
ban_cond_f *func;
} pvars[] = {
#define PVAR(a, b, c) { a, b, c },
#include "purge_vars.h"
#undef PVAR
{ 0, 0, 0}
};
static int
ban_parse_test(struct cli *cli, struct ban *b, const char *a1, const char *a2, const char *a3)
{
struct ban_test *bt;
struct vsb *sb;
const struct pvar *pv;
int i;
CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
......@@ -336,17 +348,15 @@ ban_parse_test(struct cli *cli, struct ban *b, const char *a1, const char *a2, c
}
if (!strcmp(a1, "req.url"))
bt->func = ban_cond_url;
else if (!strcmp(a1, "obj.hash"))
bt->func = ban_cond_hash;
else if (!strncmp(a1, "req.http.", 9)) {
bt->func = ban_cond_req_http;
ban_parse_http(bt, a1 + 9);
} else if (!strncmp(a1, "obj.http.", 9)) {
bt->func = ban_cond_obj_http;
ban_parse_http(bt, a1 + 9);
} else {
for (pv = pvars; pv->name != NULL; pv++) {
if (strncmp(a1, pv->name, strlen(pv->name)))
continue;
bt->func = pv->func;
if (pv->flag & 1)
ban_parse_http(bt, a1 + strlen(pv->name));
break;
}
if (pv->name == NULL) {
cli_out(cli, "unknown or unsupported field \"%s\"", a1);
cli_result(cli, CLIS_PARAM);
return (-1);
......
/*-
* Copyright (c) 2008 Linpro AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@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.
*
* $Id$
*
* Define which variables we can purge on, and which function does it.
*/
PVAR("req.url", 0, ban_cond_url)
PVAR("obj.hash", 0, ban_cond_hash)
PVAR("req.http.", 1, ban_cond_req_http)
PVAR("obj.http.", 1, ban_cond_obj_http)
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