103 |
|
|
104 |
|
|
105 |
/* ************************** Interface Functions ************************** */ |
/* ************************** Interface Functions ************************** */ |
106 |
|
#define ASSERT_RE(re,vp) \ |
107 |
|
if (!(re) || (vp = regex_vtab_lookup((re)->flags)) == NULL) {\ |
108 |
|
anubis_error(HARD,\ |
109 |
|
_("INTERNAL ERROR at %s:%d: missing or invalid regex"),\ |
110 |
|
__FILE__, __LINE__);\ |
111 |
|
abort();\ |
112 |
|
} |
113 |
|
|
114 |
void |
void |
115 |
regex_print_flags(int flags) |
regex_print_flags(int flags) |
116 |
{ |
{ |
141 |
int so, eo; |
int so, eo; |
142 |
struct regex_vtab *vp; |
struct regex_vtab *vp; |
143 |
|
|
144 |
if (!re) |
ASSERT_RE(re, vp); |
|
return -1; |
|
|
vp = regex_vtab_lookup(re->flags); |
|
|
if (!vp) |
|
|
return -1; |
|
145 |
return vp->match(re, line, refc, refv, &so, &eo) == 0; |
return vp->match(re, line, refc, refv, &so, &eo) == 0; |
146 |
} |
} |
147 |
|
|
158 |
int alloc = 0; |
int alloc = 0; |
159 |
struct regex_vtab *vp; |
struct regex_vtab *vp; |
160 |
|
|
161 |
if (!re) |
ASSERT_RE(re, vp); |
|
return NULL; |
|
|
vp = regex_vtab_lookup(re->flags); |
|
|
if (!vp) |
|
|
return NULL; |
|
162 |
while (vp->match(re, line + off, &refc, &refv, &so, &eo) == 0) { |
while (vp->match(re, line + off, &refc, &refv, &so, &eo) == 0) { |
163 |
char *p; |
char *p; |
164 |
int plen; |
int plen; |
202 |
{ |
{ |
203 |
struct regex_vtab *vp; |
struct regex_vtab *vp; |
204 |
|
|
205 |
if (!re) |
ASSERT_RE(re, vp); |
|
return 0; |
|
|
vp = regex_vtab_lookup(re->flags); |
|
|
if (!vp) |
|
|
return 0; |
|
206 |
return vp->refcnt(re); |
return vp->refcnt(re); |
207 |
} |
} |
208 |
|
|
211 |
{ |
{ |
212 |
struct regex_vtab *vp = regex_vtab_lookup(opt); |
struct regex_vtab *vp = regex_vtab_lookup(opt); |
213 |
RC_REGEX *p; |
RC_REGEX *p; |
214 |
|
|
215 |
if (!vp) |
if (!vp) |
216 |
return 0; |
return 0; |
217 |
p = xmalloc(sizeof(*p)); |
p = xmalloc(sizeof(*p)); |
225 |
} |
} |
226 |
|
|
227 |
void |
void |
228 |
anubis_regex_free(RC_REGEX *re) |
anubis_regex_free(RC_REGEX **pre) |
229 |
{ |
{ |
230 |
struct regex_vtab *vp; |
struct regex_vtab *vp; |
231 |
|
|
232 |
if (!re) |
ASSERT_RE(*pre, vp); |
233 |
return; |
free((*pre)->src); |
234 |
vp = regex_vtab_lookup(re->flags); |
vp->free(*pre); |
235 |
free(re->src); |
xfree(*pre); |
|
if (vp) |
|
|
vp->free(re); |
|
|
xfree(re); |
|
236 |
} |
} |
237 |
|
|
238 |
char * |
char * |