a case for vmod VARARGS
Geoff Simmons
geoff at uplex.de
Sat Nov 9 16:02:21 UTC 2019
On 11/9/19 13:34, Nils Goroll wrote:
>
> Could we extend the .vmod interface by something like
>
> $Function VOID foo (STRING, ...)
>
> which would turn into a va_args argument of the previous type?
It's worth pointing out that the variable arg syntax in the VMOD
function call is one thing, and the way it gets handed off the C
function implementing is another. There are some choices.
A function call as above could be seen in C as varargs. But if it's
STRING, the C function could see the args as STRANDS. That would be
almost perfect for our external exec/pipe filter use case, because the
array of strings can be handed off the one of the "v" forms of the
exec() family (it just needs the NULL member on the end).
We don't have something like STRANDS for foo(INT,...) etc, but a general
solution could be for the VMOD varags of type T to be translated to an
array of T in C.
That wouldn't work if you want to have differing data types in the
vararg list. But it seems to me that if you know the types in advance,
you could just declare them explicitly.
VMOD varags as C varargs would work well if you intend to hand off the
args to a C function that takes a va_list parameter (something like
vfprintf). Maybe a good option would be to declare in VCC whether you
want the VMOD varargs to become C varags or an array of TYPE.
So IMO +1 to vararg syntax in VMOD declarations, and consider the
options for translating the varargs to C.
Best,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung
Scheffelstraße 32
22301 Hamburg
Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753
http://uplex.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20191109/7750aff5/attachment.bin>
More information about the varnish-dev
mailing list