Vmod constants

Federico Schwindt fgsch at lodoss.net
Fri Jun 12 03:45:43 CEST 2015


Hi,

I've been wanting something like this for a while so I decided to give it a
try last night after Dridi moaned about the use of somewhat magic numbers
in the utf8 vmod.
The result is that you can now define constants in .vcc like this:

$Const TYPE name value

e.g.:

$Const INT CASEFOLD 0x0400
$Const INT LUMP 0x1000
$Const INT STRIPMARK 0x2000

And access it in VCL via <vmod>.<name>.

e.g.:

set req.url = utf8.transform(req.url, utf8.CASEFOLD + utf8.LUMP +
utf8.STRIPMARK);

This doesn't generate any C code in the current incarnation, it merely
creates the symbol and replaces the value when referencing it so the
resulting C will have e.g. 0x0001 but I could change it if required.

Personally I think this is quite useful but I might be biased so before I
clean the patches and post them here is there any interest?

Comments welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150612/0f23c515/attachment.html>


More information about the varnish-dev mailing list