Commit 9db2cf28 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Some boilerplate stuff for VMOD's.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4998 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 2a2153f2
......@@ -81,6 +81,7 @@ int mgt_push_vcls_and_start(unsigned *status, char **p);
int mgt_has_vcl(void);
extern char *mgt_cc_cmd;
extern char *mgt_vcl_dir;
extern char *mgt_vmod_dir;
#define REPORT0(pri, fmt) \
......
......@@ -827,6 +827,10 @@ static const struct parspec input_parspec[] = {
"include) are opened.",
0,
".", NULL },
{ "vmod_dir", tweak_string, &mgt_vmod_dir, 0, 0,
"Directory where VCL modules are to be found.",
0,
".", NULL },
{ NULL, NULL, NULL }
};
......
......@@ -69,6 +69,7 @@ static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead);
char *mgt_cc_cmd;
char *mgt_vcl_dir;
char *mgt_vmod_dir;
static struct vcc *vcc;
......@@ -145,6 +146,7 @@ run_vcc(void *priv)
sb = vsb_newauto();
XXXAN(sb);
VCC_VCL_dir(vcc, mgt_vcl_dir);
VCC_VMOD_dir(vcc, mgt_vmod_dir);
csrc = VCC_Compile(vcc, sb, vp->vcl);
vsb_finish(sb);
AZ(vsb_overflowed(sb));
......
......@@ -34,6 +34,7 @@ struct vcc;
struct vcc *VCC_New(void);
void VCC_Default_VCL(struct vcc *, const char *str);
void VCC_VCL_dir(struct vcc *, const char *str);
void VCC_VMOD_dir(struct vcc *, const char *str);
char *VCC_Compile(const struct vcc *, struct vsb *sb, const char *b);
const char *VCC_Return_Name(unsigned action);
/*-
* Copyright (c) 2010 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$
*
* VCL modules
*
* XXX: When this file is changed, lib/libvcl/generate.py *MUST* be rerun.
*/
struct vmod_conf {
unsigned magic;
#define VMOD_CONF_MAGIC 0x3f017730
};
......@@ -573,6 +573,7 @@ vcl_output_lang_h(struct vsb *sb)
""")
emit_file(fo, "../../include/vcl.h")
emit_file(fo, "../../include/vmod.h")
emit_file(fo, "../../include/vrt.h")
emit_file(fo, "../../include/vrt_obj.h")
......
......@@ -709,3 +709,15 @@ VCC_VCL_dir(struct vcc *tl, const char *str)
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
REPLACE(tl->vcl_dir, str);
}
/*--------------------------------------------------------------------
* Configure default VMOD directory
*/
void
VCC_VMOD_dir(struct vcc *tl, const char *str)
{
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
REPLACE(tl->vmod_dir, str);
}
......@@ -71,6 +71,7 @@ struct vcc {
/* Parameter/Template section */
char *default_vcl;
char *vcl_dir;
char *vmod_dir;
/* Instance section */
struct tokenhead tokens;
......
......@@ -189,6 +189,37 @@ vcl_output_lang_h(struct vsb *sb)
"\tvcl_func_f\t*fetch_func;\n\tvcl_func_f\t*deliver_func;\n"
"\tvcl_func_f\t*error_func;\n};\n");
/* ../../include/vmod.h */
vsb_cat(sb, "/*-\n * Copyright (c) 2010 Linpro AS\n"
" * All rights reserved.\n *\n * Author: Poul-Henning Kamp "
"<phk@phk.freebsd.dk>\n *\n * Redistribution and use in source "
"and binary forms, with or without\n * modification, are permitte"
"d provided that the following conditions\n * are met:\n"
" * 1. Redistributions of source code must retain the above "
"copyright\n * notice, this list of conditions and the followi"
"ng disclaimer.\n * 2. Redistributions in binary form must "
"reproduce the above copyright\n * notice, this list of "
"conditions and the following disclaimer in the\n * documentat"
"ion and/or other materials provided with the distribution.\n"
" *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "
"``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, "
"BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILIT"
"Y AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. "
" IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n"
" * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, "
"OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, "
"PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, "
"DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED "
"AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n"
" * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) "
"ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN "
"IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n"
" *\n * $Id$\n *\n * VCL modules\n *\n * XXX: When this file "
"is changed, lib/libvcl/generate.py *MUST* be rerun.\n"
" */\n\nstruct vmod_conf {\n\tunsigned\t\tmagic;\n"
"#define VMOD_CONF_MAGIC\t\t0x3f017730\n};\n");
/* ../../include/vrt.h */
vsb_cat(sb, "/*-\n * Copyright (c) 2006 Verdens Gang AS\n"
......@@ -215,8 +246,8 @@ vcl_output_lang_h(struct vsb *sb)
"OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR "
"TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n"
" * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE "
"POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $Id: vrt.h 4735 2010-04-"
"27 15:19:41Z phk $\n *\n * Runtime support for compiled VCL "
"POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $Id: vrt.h 4984 2010-06-"
"22 13:01:22Z phk $\n *\n * Runtime support for compiled VCL "
"programs.\n *\n * XXX: When this file is changed, lib/libvcl/gen"
"erate.py *MUST* be rerun.\n */\n\nstruct sess;\nstruct vsb;\n"
"struct cli;\nstruct director;\nstruct VCL_conf;\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