From 6d9e5d4e27a221ac0308d6df006e20966fe22959 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 16 Jul 2007 06:26:39 +0000 Subject: integrated patch by Michel Samia to provide regex support for the filter engine - many thanks! --- stringbuf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'stringbuf.c') diff --git a/stringbuf.c b/stringbuf.c index 48c63b40..140f74aa 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -14,10 +14,13 @@ #include #include #include +#include +#include #include "rsyslog.h" #include "stringbuf.h" #include "srUtils.h" + /* ################################################################# * * private members * * ################################################################# */ @@ -535,6 +538,21 @@ int rsCStrStartsWithSzStr(rsCStrObj *pCS1, unsigned char *psz, int iLenSz) return -1; /* pCS1 is less then psz */ } +/* check if a CStr object matches a regex. + * msamia@redhat.com 2007-07-12 + * @return returns 0 if matched + * bug: doesn't work for CStr containing \0 + * rgerhards, 2007-07-16: bug is no real bug, because rsyslogd ensures there + * never is a \0 *inside* a property string. + */ +int rsCStrSzStrMatchRegex(rsCStrObj *pCS1, unsigned char *psz, int iLenSz) +{ + regex_t preq; + regcomp(&preq, rsCStrGetSzStr(pCS1), 0); + int iRet = regexec(&preq, psz, 0, NULL, 0); + regfree(&preq); + return iRet; +} /* compare a rsCStr object with a classical sz string. This function * is almost identical to rsCStrZsStrCmp(), but it also takes an offset -- cgit