r4998 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Sat Jul 3 12:23:28 CEST 2010


Author: phk
Date: 2010-07-03 12:23:28 +0200 (Sat, 03 Jul 2010)
New Revision: 4998

Added:
   trunk/varnish-cache/include/vmod.h
Modified:
   trunk/varnish-cache/bin/varnishd/mgt.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
   trunk/varnish-cache/bin/varnishd/mgt_vcc.c
   trunk/varnish-cache/include/libvcl.h
   trunk/varnish-cache/lib/libvcl/generate.py
   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
Log:
Some boilerplate stuff for VMOD's.



Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/bin/varnishd/mgt.h	2010-07-03 10:23:28 UTC (rev 4998)
@@ -81,6 +81,7 @@
 int mgt_has_vcl(void);
 extern char *mgt_cc_cmd;
 extern char *mgt_vcl_dir;
+extern char *mgt_vmod_dir;
 
 
 #define REPORT0(pri, fmt)				\

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2010-07-03 10:23:28 UTC (rev 4998)
@@ -827,6 +827,10 @@
 		"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 }
 };
 

Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2010-07-03 10:23:28 UTC (rev 4998)
@@ -69,6 +69,7 @@
 
 char *mgt_cc_cmd;
 char *mgt_vcl_dir;
+char *mgt_vmod_dir;
 
 static struct vcc *vcc;
 
@@ -145,6 +146,7 @@
 	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));

Modified: trunk/varnish-cache/include/libvcl.h
===================================================================
--- trunk/varnish-cache/include/libvcl.h	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/include/libvcl.h	2010-07-03 10:23:28 UTC (rev 4998)
@@ -34,6 +34,7 @@
 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);

Added: trunk/varnish-cache/include/vmod.h
===================================================================
--- trunk/varnish-cache/include/vmod.h	                        (rev 0)
+++ trunk/varnish-cache/include/vmod.h	2010-07-03 10:23:28 UTC (rev 4998)
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2010 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at 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
+};

Modified: trunk/varnish-cache/lib/libvcl/generate.py
===================================================================
--- trunk/varnish-cache/lib/libvcl/generate.py	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/lib/libvcl/generate.py	2010-07-03 10:23:28 UTC (rev 4998)
@@ -573,6 +573,7 @@
 """)
 
 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")
 

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-03 10:23:28 UTC (rev 4998)
@@ -709,3 +709,15 @@
 	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);
+}

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-07-03 10:23:28 UTC (rev 4998)
@@ -71,6 +71,7 @@
 	/* Parameter/Template section */
 	char			*default_vcl;
 	char			*vcl_dir;
+	char			*vmod_dir;
 
 	/* Instance section */
 	struct tokenhead	tokens;

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-07-03 09:59:07 UTC (rev 4997)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-07-03 10:23:28 UTC (rev 4998)
@@ -189,6 +189,37 @@
 	    "\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 at 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 @@
 	    "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"




More information about the varnish-commit mailing list