Source
16
16
** along with this program; if not, write to the Free Software
17
17
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
18
**/
19
19
#ifndef ZABBIX_ZBXREGEXP_H
20
20
#define ZABBIX_ZBXREGEXP_H
21
21
22
22
#include "zbxalgo.h"
23
23
24
24
#define ZBX_REGEXP_NO_MATCH 0
25
25
#define ZBX_REGEXP_MATCH 1
26
+
#define ZBX_REGEXP_COMPILE_FAIL -1
27
+
#define ZBX_REGEXP_RUNTIME_FAIL -2 /* a regexp compiled successfully but an error occurred during matching */
26
28
27
29
#define ZBX_IGNORE_CASE 0
28
30
#define ZBX_CASE_SENSITIVE 1
29
31
30
32
typedef struct zbx_regexp zbx_regexp_t;
31
33
32
34
typedef struct
33
35
{
34
36
char *name;
35
37
char *expression;
36
38
int expression_type;
37
39
char exp_delimiter;
38
40
unsigned char case_sensitive;
39
41
}
40
42
zbx_expression_t;
41
43
42
44
ZBX_PTR_VECTOR_DECL(expression, zbx_expression_t *)
43
45
44
46
/* regular expressions */
45
-
int zbx_regexp_compile(const char *pattern, zbx_regexp_t **regexp, const char **err_msg);
46
-
int zbx_regexp_compile_ext(const char *pattern, zbx_regexp_t **regexp, int flags, const char **err_msg);
47
+
int zbx_regexp_compile(const char *pattern, zbx_regexp_t **regexp, char **err_msg);
48
+
int zbx_regexp_compile_ext(const char *pattern, zbx_regexp_t **regexp, int flags, char **err_msg);
47
49
void zbx_regexp_free(zbx_regexp_t *regexp);
48
50
int zbx_regexp_match_precompiled(const char *string, const zbx_regexp_t *regexp);
51
+
int zbx_regexp_match_precompiled2(const char *string, const zbx_regexp_t *regexp, char **err_msg);
49
52
char *zbx_regexp_match(const char *string, const char *pattern, int *len);
50
53
int zbx_regexp_sub(const char *string, const char *pattern, const char *output_template, char **out);
51
54
int zbx_mregexp_sub(const char *string, const char *pattern, const char *output_template, char **out);
52
55
int zbx_iregexp_sub(const char *string, const char *pattern, const char *output_template, char **out);
53
56
int zbx_mregexp_sub_precompiled(const char *string, const zbx_regexp_t *regexp, const char *output_template,
54
57
size_t limit, char **out);
55
58
56
59
void zbx_regexp_clean_expressions(zbx_vector_expression_t *expressions);
57
60
58
61
void zbx_add_regexp_ex(zbx_vector_expression_t *regexps, const char *name, const char *expression,
59
62
int expression_type, char exp_delimiter, int case_sensitive);
60
63
int zbx_regexp_match_ex(const zbx_vector_expression_t *regexps, const char *string, const char *pattern,
61
64
int case_sensitive);
62
65
int zbx_regexp_sub_ex(const zbx_vector_expression_t *regexps, const char *string, const char *pattern,
63
66
int case_sensitive, const char *output_template, char **output);
67
+
int zbx_regexp_sub_ex2(const zbx_vector_expression_t *regexps, const char *string, const char *pattern,
68
+
int case_sensitive, const char *output_template, char **output, char **err_msg);
64
69
int zbx_global_regexp_exists(const char *name, const zbx_vector_expression_t *regexps);
65
70
void zbx_regexp_escape(char **string);
66
71
67
72
/* wildcards */
68
73
void zbx_wildcard_minimize(char *str);
69
74
int zbx_wildcard_match(const char *value, const char *wildcard);
70
75
71
-
void zbx_regexp_err_msg_free(const char *err_msg);
72
-
73
76
void zbx_init_regexp_env(void);
74
77
75
78
#endif /* ZABBIX_ZBXREGEXP_H */