[syslog-ng] [PATCH] basicfuncs: Implement a few numeric template functions.

Gergely Nagy algernon at balabit.hu
Mon May 2 21:56:51 CEST 2011

Gergely Nagy <algernon at balabit.hu> writes:

> From: Gergely Nagy <algernon at madhouse-project.org>
> Implement addition, substraction, multiplication, division and modulus
> template functions: $(+ N M), $(- N M), $(* N M), $(/ N M) and $(% N
> M), respectively.

This is against 3.4, but should apply to 3.3 aswell, provided the
$(substr) patch sent earlier is applied too, because this patch reuses
the tf_substr_parse_int() introduced there.

I chose short function names because, well... they're short, and for
numbers, they made sense. Could've used $(add-int) and similar, but that
seemed unnatural to me.

As for the reasoning behind these functions - apart from getting the
template function sub-language closer to Turing completeness - is to be
able to fix priority numbers coming from sources that are off by one,
for example (or going to destinations that expect it off by one). At
least, that's for $(+). The rest is just for fun, because I was there.


More information about the syslog-ng mailing list