summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/global.h2
-rw-r--r--src/bin/rules.c23
2 files changed, 13 insertions, 12 deletions
diff --git a/src/bin/global.h b/src/bin/global.h
index 07143f8..f8611e2 100644
--- a/src/bin/global.h
+++ b/src/bin/global.h
@@ -28,6 +28,7 @@
28#include <Eina.h> 28#include <Eina.h>
29#include <Ecore.h> 29#include <Ecore.h>
30#include <Ecore_File.h> 30#include <Ecore_File.h>
31#include <regex.h>
31 32
32#ifndef GLOBALVARS 33#ifndef GLOBALVARS
33#define GLOBALVARS 34#define GLOBALVARS
@@ -62,6 +63,7 @@ struct regex
62{ 63{
63 char *message; 64 char *message;
64 int must_match; 65 int must_match;
66 regex_t preg;
65}; 67};
66 68
67/** 69/**
diff --git a/src/bin/rules.c b/src/bin/rules.c
index 8cf75d8..91227b2 100644
--- a/src/bin/rules.c
+++ b/src/bin/rules.c
@@ -128,8 +128,18 @@ int rules_load_rule_loadspec(char *variable, char *value)
128 ) 128 )
129 { 129 {
130 struct regex *tmp_regex; 130 struct regex *tmp_regex;
131 int ret;
132
131 tmp_regex = malloc(sizeof(struct regex)); 133 tmp_regex = malloc(sizeof(struct regex));
132 134
135 ret = regcomp(&(tmp_regex->preg), value, REG_EXTENDED);
136 if( ret )
137 {
138 EINA_LOG_DOM_ERR(einadom_rules, "Regcomp failed to compile regexp %s", value);
139 free(tmp_regex);
140 return(0);
141 }
142
133 tmp_regex->message = malloc(sizeof(char) * ( strlen(value) + 1 )); 143 tmp_regex->message = malloc(sizeof(char) * ( strlen(value) + 1 ));
134 strcpy(tmp_regex->message, value); 144 strcpy(tmp_regex->message, value);
135 145
@@ -262,27 +272,16 @@ int rules_filtermessage(struct logmessage *new_logmessage)
262 // Now we check for message filtering 272 // Now we check for message filtering
263 EINA_LIST_FOREACH(foundrule->list_regex, l2, foundregex) 273 EINA_LIST_FOREACH(foundrule->list_regex, l2, foundregex)
264 { 274 {
265 regex_t preg;
266 size_t nmatch = 2; 275 size_t nmatch = 2;
267 regmatch_t pmatch[2]; 276 regmatch_t pmatch[2];
268 277
269 ret = regcomp(&preg, foundregex->message, REG_EXTENDED); 278 ret = regexec(&(foundregex->preg), new_logmessage->message,nmatch, pmatch, 0);
270 if( ret )
271 {
272 EINA_LOG_DOM_ERR(einadom_rules, "Regcomp failed to compile regexp %s", foundregex->message);
273 regfree(&preg);
274 continue;
275 }
276
277 ret = regexec(&preg, new_logmessage->message,nmatch, pmatch, 0);
278 if( ret == foundregex->must_match ) 279 if( ret == foundregex->must_match )
279 { 280 {
280 EINA_LOG_DOM_INFO(einadom_rules, "Log \"%s\" from \"%s\" is not affected by rule %s (message exclude : %s / %d / %d)", new_logmessage->message, new_logmessage->source_path, foundrule->name, foundregex->message, foundregex->must_match, ret); 281 EINA_LOG_DOM_INFO(einadom_rules, "Log \"%s\" from \"%s\" is not affected by rule %s (message exclude : %s / %d / %d)", new_logmessage->message, new_logmessage->source_path, foundrule->name, foundregex->message, foundregex->must_match, ret);
281 regfree(&preg);
282 excluded = 1; 282 excluded = 1;
283 break; 283 break;
284 } 284 }
285 regfree(&preg);
286 } 285 }
287 286
288 if( excluded ) 287 if( excluded )