summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-05-30 15:18:03 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-05-30 15:18:03 +0200
commit6a815063f37e7126f63fa00038f2d050574a6d52 (patch)
tree236a11b836b3a591dcb72056d56888875ef521d2 /template.c
parent99f18190a1f911224d45ca61706ae3fbc9ad7a80 (diff)
downloadrsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.tar.gz
rsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.tar.xz
rsyslog-6a815063f37e7126f63fa00038f2d050574a6d52.zip
capability for replacement text in no match regex case added
implemented in property replacer: if a regular expression does not match, it can now either return "**NO MATCH** (default, as before), a blank property or the full original property text
Diffstat (limited to 'template.c')
-rw-r--r--template.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/template.c b/template.c
index bccc6516..2b336ba9 100644
--- a/template.c
+++ b/template.c
@@ -521,10 +521,10 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
/* first come the regex type */
if(*p == ',') {
++p; /* eat ',' */
- if(*p == 'B' && *(p+1) == 'R' && *(p+2) == 'E' && *(p+3) == ',') {
+ if(p[0] == 'B' && p[1] == 'R' && p[2] == 'E' && (p[3] == ',' || p[3] == ':')) {
pTpe->data.field.typeRegex = TPL_REGEX_BRE;
p += 3; /* eat indicator sequence */
- } else if(*p == 'E' && *(p+1) == 'R' && *(p+2) == 'E' && *(p+3) == ',') {
+ } else if(p[0] == 'E' && p[1] == 'R' && p[2] == 'E' && (p[3] == ',' || p[3] == ':')) {
pTpe->data.field.typeRegex = TPL_REGEX_ERE;
p += 3; /* eat indicator sequence */
} else {
@@ -546,6 +546,27 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
}
}
+ /* now pull what to do if we do not find a match */
+ if(*p == ',') {
+ ++p; /* eat ',' */
+ if(p[0] == 'D' && p[1] == 'F' && p[2] == 'L' && p[3] == 'T'
+ && (p[4] == ',' || p[4] == ':')) {
+ pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_DFLTSTR;
+ p += 4; /* eat indicator sequence */
+ } else if(p[0] == 'B' && p[1] == 'L' && p[2] == 'A' && p[3] == 'N' && p[4] == 'K'
+ && (p[5] == ',' || p[5] == ':')) {
+ pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_BLANK;
+ p += 5; /* eat indicator sequence */
+ } else if(p[0] == 'F' && p[1] == 'I' && p[2] == 'E' && p[3] == 'L' && p[4] == 'D'
+ && (p[5] == ',' || p[5] == ':')) {
+ pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_WHOLE_FIELD;
+ p += 5; /* eat indicator sequence */
+ } else {
+ errmsg.LogError(NO_ERRCODE, "error: invalid regular expression type, rest of line %s",
+ (char*) p);
+ }
+ }
+
if(*p != ':') {
/* There is something more than an R , this is invalid ! */
/* Complain on extra characters */