From efc9f1243ac238624fdcb72c2f68a1091c398adc Mon Sep 17 00:00:00 2001 From: Dag Haavi Finstad Date: Thu, 20 Mar 2014 16:43:59 +0100 Subject: [PATCH 1/4] Remove broken example and clarify global/non-global variable lifespan. --- README | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README b/README index caa7250..1f1103d 100644 --- a/README +++ b/README @@ -1,17 +1,12 @@ This VMOD implements basic variable in VCL. Well. It's more of an association list with support for strings, ints and reals. -import var; - -sub vcl_recv { - - # count the number of iDevices: - if (req.http.user-agent ~ iP(od|ad|hone) ) { - var.set_int("idevs", var.get_int("i1") + 1 ); - } - There are methods to get and set each type. +Global variables have a lifespan that extends across requests and +VCLs, for as long as the vmod is loaded. Non-globals are local to a +single request. + Prototype, most should be self-explaining: Function VOID set(STRING, STRING) @@ -34,4 +29,4 @@ Function DURATION get_duration(STRING) Function VOID clear() -clear() clears the whole variable space. \ No newline at end of file +clear() clears the whole non-global variable space. From 4c18987665a134e48c7bae1ee0339555026cadb1 Mon Sep 17 00:00:00 2001 From: Lasse Karstensen Date: Fri, 4 Apr 2014 14:41:05 +0200 Subject: [PATCH 2/4] Rebuild packages --- debian/changelog | 6 ++++++ vmod-var.spec | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index bb91328..0a523f9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libvmod-var (0.1) unstable; urgency=medium + + * Rebuild packages. + + -- Lasse Karstensen Fri, 04 Apr 2014 14:40:38 +0200 + libvmod-var (0.1) unstable; urgency=low * First version diff --git a/vmod-var.spec b/vmod-var.spec index cd4ac58..67361b1 100644 --- a/vmod-var.spec +++ b/vmod-var.spec @@ -1,7 +1,7 @@ -Summary: Variable VMOD for Varnish +Summary: Variable VMOD for Varnish %{VARNISHVER} Name: vmod-var Version: 0.1 -Release: 1%{?dist} +Release: 2%{?dist} License: BSD Group: System Environment/Daemons Source0: libvmod-var.tar.gz @@ -10,7 +10,7 @@ Requires: varnish > 3.0 BuildRequires: make, python-docutils %description -Variables for Varnish +VCL variables for Varnish %{VARNISHVER}. %prep %setup -n libvmod-var From cf82e26f01a10c1312f3fcbba25e643fb5d55798 Mon Sep 17 00:00:00 2001 From: Hans Huebner Date: Sat, 5 Apr 2014 17:48:55 +0000 Subject: [PATCH 3/4] doc cleanup, add global_get/global_set to manual --- man/vmod_var.rst | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 man/vmod_var.rst diff --git a/man/vmod_var.rst b/man/vmod_var.rst new file mode 100644 index 0000000..629f951 --- /dev/null +++ b/man/vmod_var.rst @@ -0,0 +1,118 @@ +======== +vmod_var +======== + +------------------------ +Varnish Variables Module +------------------------ + +:Author: Tollef Fog Heen +:Date: 2011-09-28 +:Version: 1.1 +:Manual section: 3 + +SYNOPSIS +======== + +import var; + +DESCRIPTION +=========== + +Association list in VCL. Can be used to mimick variables. + +FUNCTIONS +========= + +set_string +---------- + +Prototype + set_string(STRING S, STRING T) + set(STRING S, STRING T) - shorthand +Return value + NONE +Description + Sets the variable identified by S to the value T. The variable is + associated with the current request and will go away when the request + has been processed. +Example + var.set_string("bar", "some random string"); + +get_string +---------- + +Prototype + get_string(STRING S) + get(STRING S) - shorthand +Return value + STRING +Description + Returns the session variable string identified by the supplied string. +Example + set resp.http.foo = var.get_string("bar"); + +Similar functions +----------------- + +There are similar functions named: + +* set_int(STRING, INT) +* get_int(STRING) +* set_real(STRING, REAL) +* get_real(STRING) +* set_duration(STRING, DURATION) +* get_duration(STRING) + +get and set are shorthand for get_string and set_string. + +global_set +---------- + +Prototype + global_set(STRING S, STRING T) +Return value + NONE +Description + Sets the variable identified by S to the value T. The variable is + global and will persist as long as the vmod is loaded. +Example + var.global_set("bar", "some random string"); + +global_get +---------- + +Prototype + global_get(STRING S) +Return value + STRING +Description + Returns the global variable string identified by the supplied string. +Example + set resp.http.foo = var.global_get("bar"); + +clear +----- + +Prototype + Function VOID clear() +Returns + NONE +Description + Clears out all the variables. +Example + + +HISTORY +======= + +This manual page was written by Per Buer. It might contain +errors. Patches are welcome. + +COPYRIGHT +========= + +This document is licensed under the same license as the +libvmod-var project. See LICENSE for details. + +* Copyright (c) 2012 Varnish Software From 6d552a1e48cd9143709e5b7eca05f851cc1c59eb Mon Sep 17 00:00:00 2001 From: Hans Huebner Date: Sat, 5 Apr 2014 17:56:31 +0000 Subject: [PATCH 4/4] package building updates --- debian/.gitignore | 4 ++ debian/rules | 11 ++++-- man/.gitignore | 1 + man/Makefile.am | 8 ++-- man/vmod_example.rst | 91 -------------------------------------------- package.sh | 11 ++++++ 6 files changed, 27 insertions(+), 99 deletions(-) create mode 100644 debian/.gitignore create mode 100644 man/.gitignore delete mode 100644 man/vmod_example.rst create mode 100755 package.sh diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..5b7e2ab --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,4 @@ +files +libvmod-var +*substvars +*log diff --git a/debian/rules b/debian/rules index 82ac88f..061b520 100755 --- a/debian/rules +++ b/debian/rules @@ -1,17 +1,20 @@ #!/usr/bin/make -f export DH_VERBOSE=1 -VARNISHSRC = $(DEBIAN_VARNISH_SRC) -VMODDIR = $(shell PKG_CONFIG_PATH="$(VARNISHSRC)" pkg-config --variable=vmoddir varnishapi) +VARNISHSRC ?= $(DEBIAN_VARNISH_SRC) +VMODDIR ?= $(shell PKG_CONFIG_PATH="$(VARNISHSRC)" pkg-config --variable=vmoddir varnishapi) +VMOD_ABI ?= $(shell printf '\#include "vmod_abi.h"\nVMOD_ABI_Version' | cpp - -I$(DEBIAN_VARNISH_SRC)/include | sed '/^\#/D;s/"//g;s/\([A-Z]\)/\L\1/g;s/[^a-z0-9.]/-/g;s/varnish/varnishabi/') override_dh_auto_configure: dh_auto_configure -- VMODDIR="$(VMODDIR)" VARNISHSRC="$(VARNISHSRC)" override_dh_gencontrol: + echo "Varnish:ABI=$(VMOD_ABI)" >> debian/substvars + if [ -n "$$DEBIAN_OVERRIDE_BINARY_VERSION" ]; then \ - dh_gencontrol -- -v$$DEBIAN_OVERRIDE_BINARY_VERSION; \ + dh_gencontrol -- -Tdebian/substvars -v$$DEBIAN_OVERRIDE_BINARY_VERSION; \ else \ - dh_gencontrol ; \ + dh_gencontrol -- -Tdebian/substvars; \ fi %: diff --git a/man/.gitignore b/man/.gitignore new file mode 100644 index 0000000..9f706da --- /dev/null +++ b/man/.gitignore @@ -0,0 +1 @@ +vmod_var.3 diff --git a/man/Makefile.am b/man/Makefile.am index f0257ed..91ab35e 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,12 +1,12 @@ # -dist_man_MANS = vmod_example.3 +dist_man_MANS = vmod_var.3 MAINTAINERCLEANFILES = $(dist_man_MANS) -EXTRA_DIST = vmod_example.rst +EXTRA_DIST = vmod_var.rst -vmod_example.3: vmod_example.rst +vmod_var.3: vmod_var.rst if HAVE_RST2MAN - ${RST2MAN} vmod_example.rst $@ + ${RST2MAN} vmod_var.rst $@ else @echo "========================================" @echo "You need rst2man installed to make dist" diff --git a/man/vmod_example.rst b/man/vmod_example.rst deleted file mode 100644 index c8e91b1..0000000 --- a/man/vmod_example.rst +++ /dev/null @@ -1,91 +0,0 @@ -============ -vmod_example -============ - ----------------------- -Varnish Example Module ----------------------- - -:Author: Tollef Fog Heen -:Date: 2011-09-28 -:Version: 1.0 -:Manual section: 3 - -SYNOPSIS -======== - -import var; - -DESCRIPTION -=========== - -Association list in VCL. Can be used to mimick variables. - -FUNCTIONS -========= - -set_string ----------- - -Prototype - set_string(STRING S, STRING T) - set(STRING S, STRING T) - shorthand -Return value - NONE -Description - Sets the variable identified by S to the value T. -Example - var.set_string("bar", "some random string"); - -get_string ----------- - -Prototype - get_string(STRING S) - get(STRING S) - shorthand -Return value - STRING -Description - Returns the string identified by the supplied string. -Example - set resp.http.foo = var.get_string("bar"); - -Similar functions ------------------ - -There are similar functions named: - -* set_int(STRING, INT) -* get_int(STRING) -* set_real(STRING, REAL) -* get_real(STRING) -* set_duration(STRING, DURATION) -* get_duration(STRING) - -get and set are shorthand for get_string and set_string. - -clear ------ - -Prototype - Function VOID clear() -Returns - NONE -Description - Clears out all the variables. -Example - - -HISTORY -======= - -This manual page was written by Per Buer. It might contain -errors. Patches are welcome. - -COPYRIGHT -========= - -This document is licensed under the same license as the -libvmod-example project. See LICENSE for details. - -* Copyright (c) 2012 Varnish Software diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..99fa377 --- /dev/null +++ b/package.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -x + +export VARNISH_VERSION=${VARNISH_VERSION:="3.0.5"} +export VARNISHSRC=../varnish-${VARNISH_VERSION} +export DEBIAN_VARNISH_SRC=$VARNISHSRC +export VMODDIR=/usr/lib/varnish/vmods + +git submodule update --init +./autogen.sh && ./configure && make +dpkg-buildpackage -uc -us -b