diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-16 06:26:39 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-16 06:26:39 +0000 |
commit | 6d9e5d4e27a221ac0308d6df006e20966fe22959 (patch) | |
tree | 449827c651b0af0f87a30c33d9f54b4563f778c1 /stringbuf.c | |
parent | 594ef8b85342fcb2aab5ac1d39623a07d643c921 (diff) | |
download | rsyslog-6d9e5d4e27a221ac0308d6df006e20966fe22959.tar.gz rsyslog-6d9e5d4e27a221ac0308d6df006e20966fe22959.tar.xz rsyslog-6d9e5d4e27a221ac0308d6df006e20966fe22959.zip |
integrated patch by Michel Samia to provide regex support for the filter
engine - many thanks!
Diffstat (limited to 'stringbuf.c')
-rwxr-xr-x | stringbuf.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/stringbuf.c b/stringbuf.c index 48c63b40..140f74aa 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -14,10 +14,13 @@ #include <assert.h> #include <string.h> #include <ctype.h> +#include <sys/types.h> +#include <regex.h> #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 |