summaryrefslogtreecommitdiffstats
path: root/runtime/stringbuf.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-03-04 18:22:48 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-03-04 18:22:48 +0100
commit5005bce38763051b5b12e48ac60c3ff17097a952 (patch)
tree9e8519e33c0e530791768cb28882679446703505 /runtime/stringbuf.c
parent924ceb305dc1dced54beaa6ffe4b72b9f2609c6a (diff)
downloadrsyslog-5005bce38763051b5b12e48ac60c3ff17097a952.tar.gz
rsyslog-5005bce38763051b5b12e48ac60c3ff17097a952.tar.xz
rsyslog-5005bce38763051b5b12e48ac60c3ff17097a952.zip
added ERE support in filter conditions
new comparison operation "ereregex"
Diffstat (limited to 'runtime/stringbuf.c')
-rw-r--r--runtime/stringbuf.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/runtime/stringbuf.c b/runtime/stringbuf.c
index 93d1e1ef..150439a1 100644
--- a/runtime/stringbuf.c
+++ b/runtime/stringbuf.c
@@ -694,6 +694,32 @@ int rsCStrCaseInsensitveStartsWithSzStr(cstr_t *pCS1, uchar *psz, size_t iLenSz)
return -1; /* pCS1 is less then psz */
}
+#if 0
+/* check if a CStr object matches a POSIX ERE regex.
+ * added 2009-03-04 by rgerhards
+ * TODO: we should merge this with rsCStrSzStrMatchReg
+ */
+rsRetVal rsCStrSzStrMatchRegexERE(cstr_t *pCS1, uchar *psz)
+{
+ regex_t preq;
+ DEFiRet;
+
+ BEGINfunc
+
+ if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) {
+ regexp.regcomp(&preq, (char*) rsCStrGetSzStr(pCS1), REG_EXTENDED);
+ ret = regexp.regexec(&preq, (char*) psz, 0, NULL, 0);
+ regexp.regfree(&preq);
+ } else {
+ ret = 1; /* simulate "not found" */
+ }
+
+ ENDfunc
+ RETiRet;
+}
+#endif
+
+
/* check if a CStr object matches a regex.
* msamia@redhat.com 2007-07-12
* @return returns 0 if matched
@@ -701,25 +727,23 @@ int rsCStrCaseInsensitveStartsWithSzStr(cstr_t *pCS1, uchar *psz, size_t iLenSz)
* rgerhards, 2007-07-16: bug is no real bug, because rsyslogd ensures there
* never is a \0 *inside* a property string.
* Note that the function returns -1 if regexp functionality is not available.
- * TODO: change calling interface! -- rgerhards, 2008-03-07
+ * rgerhards: 2009-03-04: ERE support added, via parameter iType: 0 - BRE, 1 - ERE
*/
-int rsCStrSzStrMatchRegex(cstr_t *pCS1, uchar *psz)
+rsRetVal rsCStrSzStrMatchRegex(cstr_t *pCS1, uchar *psz, int iType)
{
regex_t preq;
- int ret;
-
- BEGINfunc
+ DEFiRet;
if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) {
- regexp.regcomp(&preq, (char*) rsCStrGetSzStr(pCS1), 0);
- ret = regexp.regexec(&preq, (char*) psz, 0, NULL, 0);
+ regexp.regcomp(&preq, (char*) rsCStrGetSzStr(pCS1), iType == 1 ? REG_EXTENDED : 0);
+ CHKiRet(regexp.regexec(&preq, (char*) psz, 0, NULL, 0));
regexp.regfree(&preq);
} else {
- ret = 1; /* simulate "not found" */
+ ABORT_FINALIZE(RS_RET_NOT_FOUND);
}
- ENDfunc
- return ret;
+finalize_it:
+ RETiRet;
}