struct url_regexp_param *param = data;
struct uri *url = value;
- if (G_UNLIKELY (param->re->is_test)) {
- msg_info ("process test regexp /%s/ for url %s", struri (url));
- }
+
if (g_regex_match (param->regexp, struri (url), 0, NULL) == TRUE) {
if (G_UNLIKELY (param->re->is_test)) {
- msg_info ("process test regexp /%s/ for url %s returned TRUE", struri (url));
+ msg_info ("process test regexp %s for url %s returned TRUE", struri (url));
}
task_cache_add (param->task, param->re, 1);
param->found = TRUE;
return TRUE;
}
+ else if (G_UNLIKELY (param->re->is_test)) {
+ msg_info ("process test regexp %s for url %s returned FALSE", struri (url));
+ }
return FALSE;
}
if (additional != NULL) {
/* We have additional parameter defined, so ignore type of regexp expression and use it for parsing */
if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ with test %s", re->regexp_text, additional);
+ msg_info ("process test regexp %s with test %s", re->regexp_text, additional);
}
if (g_regex_match_full (re->regexp, additional, strlen (additional), 0, 0, NULL, NULL) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
- msg_info ("result of regexp /%s/ is true", re->regexp_text);
+ msg_info ("result of regexp %s is true", re->regexp_text);
}
task_cache_add (task, re, 1);
return 1;
switch (re->type) {
case REGEXP_NONE:
- msg_warn ("bad error detected: /%s/ has invalid regexp type", re->regexp_text);
+ msg_warn ("bad error detected: %s has invalid regexp type", re->regexp_text);
return 0;
case REGEXP_HEADER:
if (re->header == NULL) {
task_cache_add (task, re, 0);
return 0;
}
- debug_task ("checking header regexp: %s = /%s/", re->header, re->regexp_text);
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for header %s", re->regexp_text, re->header);
- }
+ debug_task ("checking header regexp: %s = %s", re->header, re->regexp_text);
+
headerlist = message_get_header (task->task_pool, task->message, re->header);
if (headerlist == NULL) {
+ if (G_UNLIKELY (re->is_test)) {
+ msg_info ("process test regexp %s for header %s returned FALSE: no header found", re->regexp_text, re->header);
+ }
task_cache_add (task, re, 0);
return 0;
}
cur = headerlist;
while (cur) {
debug_task ("found header \"%s\" with value \"%s\"", re->header, (const char *)cur->data);
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for header %s with value '%s'", re->regexp_text, re->header, (const char *)cur->data);
- }
+
if (cur->data && g_regex_match (re->regexp, cur->data, 0, NULL) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const char *)cur->data);
+ msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const char *)cur->data);
}
task_cache_add (task, re, 1);
return 1;
}
+ else if (G_UNLIKELY (re->is_test)) {
+ msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const char *)cur->data);
+ }
cur = g_list_next (cur);
}
task_cache_add (task, re, 0);
}
break;
case REGEXP_MIME:
- debug_task ("checking mime regexp: /%s/", re->regexp_text);
+ debug_task ("checking mime regexp: %s", re->regexp_text);
cur = g_list_first (task->text_parts);
while (cur) {
part = (struct mime_text_part *)cur->data;
else {
regexp = re->regexp;
}
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for mime part of length %d", re->regexp_text, (int)part->orig->len);
- }
+
if (g_regex_match_full (regexp, part->orig->data, part->orig->len, 0, 0, NULL, NULL) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for mime part returned true", re->regexp_text);
+ msg_info ("process test regexp %s for mime part returned TRUE", re->regexp_text);
}
task_cache_add (task, re, 1);
return 1;
}
+ else if (G_UNLIKELY (re->is_test)) {
+ msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (int)part->orig->len);
+ }
cur = g_list_next (cur);
}
task_cache_add (task, re, 0);
return 0;
case REGEXP_MESSAGE:
- debug_task ("checking message regexp: /%s/", re->regexp_text);
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for message of length %d", re->regexp_text, (int)task->msg->len);
- }
+ debug_task ("checking message regexp: %s", re->regexp_text);
+
if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, NULL) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for message of length %d returned TRUE", re->regexp_text, (int)task->msg->len);
+ msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (int)task->msg->len);
}
task_cache_add (task, re, 1);
return 1;
}
+ else if (G_UNLIKELY (re->is_test)) {
+ msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (int)task->msg->len);
+ }
task_cache_add (task, re, 0);
return 0;
case REGEXP_URL:
- debug_task ("checking url regexp: /%s/", re->regexp_text);
+ debug_task ("checking url regexp: %s", re->regexp_text);
cur = g_list_first (task->text_parts);
while (cur) {
part = (struct mime_text_part *)cur->data;
}
return 0;
case REGEXP_RAW_HEADER:
- debug_task ("checking for raw header: %s with regexp: /%s/", re->header, re->regexp_text);
+ debug_task ("checking for raw header: %s with regexp: %s", re->header, re->regexp_text);
if (task->raw_headers == NULL) {
debug_task ("cannot check for raw header in message, no headers found");
task_cache_add (task, re, 0);
t = *c;
*c = '\0';
debug_task ("found raw header \"%s\" with value \"%s\"", re->header, headerv);
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for header %s with value '%s'", re->regexp_text, re->header, headerv);
- }
+
if (g_regex_match (re->raw_regexp, headerv, 0, NULL) == TRUE) {
- if (G_UNLIKELY (re->is_test)) {
- msg_info ("process test regexp /%s/ for header %s with value '%s' returned TRUE", re->regexp_text, re->header, headerv);
+ if (re->is_test) {
+ msg_info ("process test regexp %s for raw header %s with value '%s' returned TRUE", re->regexp_text, re->header, headerv);
}
*c = t;
task_cache_add (task, re, 1);
return 1;
}
+ else if (re->is_test) {
+ msg_info ("process test regexp %s for raw header %s with value '%s' returned FALSE", re->regexp_text, re->header, headerv);
+ }
*c = t;
task_cache_add (task, re, 0);
return 0;