diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-01 18:17:55 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-01 18:17:55 +0000 |
commit | 0e26d4843d7f993547e3d0acf5b91c5bb29ee743 (patch) | |
tree | 788ef636cf131aa3e738668a105796b50c37bbc8 /src/libutil/regexp.c | |
parent | e9d134bb883087391bcc998042be89d79f668683 (diff) | |
download | rspamd-0e26d4843d7f993547e3d0acf5b91c5bb29ee743.tar.gz rspamd-0e26d4843d7f993547e3d0acf5b91c5bb29ee743.zip |
Add routines to get count of captures and backrefs
Diffstat (limited to 'src/libutil/regexp.c')
-rw-r--r-- | src/libutil/regexp.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 5ebcf7db8..2bf21ca1e 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -53,6 +53,7 @@ struct rspamd_regexp_s { gpointer ud; gint flags; gint ncaptures; + gint nbackref; }; struct rspamd_regexp_cache { @@ -340,6 +341,12 @@ fin: res->ncaptures = ncaptures; } + /* Check number of backrefs */ + if (pcre_fullinfo (res->raw_re, res->extra, PCRE_INFO_BACKREFMAX, + &ncaptures) == 0) { + res->nbackref = ncaptures; + } + return res; } @@ -476,6 +483,22 @@ rspamd_regexp_get_pattern (rspamd_regexp_t *re) return re->pattern; } +gint +rspamd_regexp_get_nbackrefs (rspamd_regexp_t *re) +{ + g_assert (re != NULL); + + return re->nbackref; +} + +gint +rspamd_regexp_get_ncaptures (rspamd_regexp_t *re) +{ + g_assert (re != NULL); + + return re->ncaptures; +} + gboolean rspamd_regexp_match (rspamd_regexp_t *re, const gchar *text, gsize len, gboolean raw) |