Index: include/zbxregexp.h =================================================================== --- include/zbxregexp.h (revision 81432) +++ include/zbxregexp.h (working copy) @@ -52,5 +52,6 @@ int regexp_match_ex(const zbx_vector_ptr_t *regexps, const char *string, const char *pattern, int case_sensitive); int regexp_sub_ex(const zbx_vector_ptr_t *regexps, const char *string, const char *pattern, int case_sensitive, const char *output_template, char **output); +int zbx_global_regexp_exists(const char *name, const zbx_vector_ptr_t *regexps); #endif /* ZABBIX_ZBXREGEXP_H */ Index: src/libs/zbxregexp/zbxregexp.c =================================================================== --- src/libs/zbxregexp/zbxregexp.c (revision 81432) +++ src/libs/zbxregexp/zbxregexp.c (working copy) @@ -774,3 +774,18 @@ { return regexp_sub_ex(regexps, string, pattern, case_sensitive, NULL, NULL); } + +int zbx_global_regexp_exists(const char *name, const zbx_vector_ptr_t *regexps) +{ + int i; + + for (i = 0; i < regexps->values_num; i++) + { + const zbx_expression_t *regexp = (const zbx_expression_t *)regexps->values[i]; + + if (0 == strcmp(regexp->name, name)) + return SUCCEED; + } + + return FAIL; +} Index: src/zabbix_agent/active.c =================================================================== --- src/zabbix_agent/active.c (revision 81432) +++ src/zabbix_agent/active.c (working copy) @@ -1074,24 +1074,6 @@ return ret; } -static int global_regexp_exists(const char *name) -{ - int i; - - if (0 == regexps.values_num) - return FAIL; - - for (i = 0; i < regexps.values_num; i++) - { - zbx_expression_t *regexp = (zbx_expression_t *)regexps.values[i]; - - if (0 == strcmp(regexp->name, name)) - break; - } - - return (i == regexps.values_num ? FAIL : SUCCEED); -} - static int process_log_check(char *server, unsigned short port, ZBX_ACTIVE_METRIC *metric, zbx_uint64_t *lastlogsize_sent, int *mtime_sent, char **error) { @@ -1139,7 +1121,7 @@ { pattern = ""; } - else if ('@' == *pattern && SUCCEED != global_regexp_exists(pattern + 1)) + else if ('@' == *pattern && SUCCEED != zbx_global_regexp_exists(pattern + 1, ®exps)) { *error = zbx_dsprintf(*error, "Global regular expression \"%s\" does not exist.", pattern + 1); goto out; @@ -1379,7 +1361,7 @@ { pattern = ""; } - else if ('@' == *pattern && SUCCEED != global_regexp_exists(pattern + 1)) + else if ('@' == *pattern && SUCCEED != zbx_global_regexp_exists(pattern + 1, ®exps)) { *error = zbx_dsprintf(*error, "Global regular expression \"%s\" does not exist.", pattern + 1); goto out; @@ -1389,7 +1371,7 @@ { key_severity = ""; } - else if ('@' == *key_severity && SUCCEED != global_regexp_exists(key_severity + 1)) + else if ('@' == *key_severity && SUCCEED != zbx_global_regexp_exists(key_severity + 1, ®exps)) { *error = zbx_dsprintf(*error, "Global regular expression \"%s\" does not exist.", key_severity + 1); goto out; @@ -1399,7 +1381,7 @@ { key_source = ""; } - else if ('@' == *key_source && SUCCEED != global_regexp_exists(key_source + 1)) + else if ('@' == *key_source && SUCCEED != zbx_global_regexp_exists(key_source + 1, ®exps)) { *error = zbx_dsprintf(*error, "Global regular expression \"%s\" does not exist.", key_source + 1); goto out; @@ -1409,7 +1391,7 @@ { key_logeventid = ""; } - else if ('@' == *key_logeventid && SUCCEED != global_regexp_exists(key_logeventid + 1)) + else if ('@' == *key_logeventid && SUCCEED != zbx_global_regexp_exists(key_logeventid + 1, ®exps)) { *error = zbx_dsprintf(*error, "Global regular expression \"%s\" does not exist.", key_logeventid + 1); goto out;