33 |
# elif defined (HAVE_PCRE_PCRE_H) |
# elif defined (HAVE_PCRE_PCRE_H) |
34 |
# include <pcre/pcre.h> |
# include <pcre/pcre.h> |
35 |
# endif |
# endif |
36 |
#endif |
#endif /* HAVE_PCRE */ |
37 |
|
|
38 |
/**************************** |
/**************************** |
39 |
Regular Expressions support |
Regular Expressions support |
40 |
*****************************/ |
*****************************/ |
41 |
|
|
42 |
typedef int (*_match_fp) (RC_REGEX *re, char *line, int *refc, char ***refv); |
typedef int (*_match_fp) (RC_REGEX *, char *, int *, char ***); |
43 |
typedef int (*_refcnt_fp) (RC_REGEX *re); |
typedef int (*_refcnt_fp) (RC_REGEX *); |
44 |
typedef int (*_compile_fp) (RC_REGEX *re, char *line, int opt); |
typedef int (*_compile_fp) (RC_REGEX *, char *, int); |
45 |
typedef void (*_free_fp) (RC_REGEX *regex); |
typedef void (*_free_fp) (RC_REGEX *); |
46 |
|
|
47 |
struct regex_vtab { |
struct regex_vtab { |
48 |
int mask; |
int mask; |
49 |
_match_fp match; |
_match_fp match; |
50 |
_refcnt_fp refcnt; |
_refcnt_fp refcnt; |
51 |
_compile_fp compile; |
_compile_fp compile; |
52 |
_free_fp free; |
_free_fp free; |
53 |
}; |
}; |
54 |
|
|
55 |
static int posix_compile(RC_REGEX *regex, char *line, int opt); |
static int posix_compile(RC_REGEX *, char *, int); |
56 |
static void posix_free(RC_REGEX *regex); |
static void posix_free(RC_REGEX *); |
57 |
static int posix_match(RC_REGEX *regex, char *line, int *refc, char ***refv); |
static int posix_match(RC_REGEX *, char *, int *, char ***); |
58 |
static int posix_refcnt(RC_REGEX *regex); |
static int posix_refcnt(RC_REGEX *); |
59 |
#ifdef HAVE_PCRE |
#ifdef HAVE_PCRE |
60 |
static int perl_compile(RC_REGEX *regex, char *line, int opt); |
static int perl_compile(RC_REGEX *, char *, int); |
61 |
static void perl_free(RC_REGEX *regex); |
static void perl_free(RC_REGEX *); |
62 |
static int perl_match(RC_REGEX *regex, char *line, int *refc, char ***refv); |
static int perl_match(RC_REGEX *, char *, int *, char ***); |
63 |
static int perl_refcnt(RC_REGEX *regex); |
static int perl_refcnt(RC_REGEX *); |
64 |
#endif |
#endif /* HAVE_PCRE */ |
65 |
|
|
66 |
static struct regex_vtab vtab[] = { |
static struct regex_vtab vtab[] = { |
67 |
#ifdef HAVE_PCRE |
#ifdef HAVE_PCRE |
70 |
{ 0, posix_match, posix_refcnt, posix_compile, posix_free }, |
{ 0, posix_match, posix_refcnt, posix_compile, posix_free }, |
71 |
}; |
}; |
72 |
|
|
73 |
struct rc_regex { /* Regular expression */ |
struct rc_regex { /* Regular expression */ |
74 |
char *src; /* Raw-text representation */ |
char *src; /* Raw-text representation */ |
75 |
int flags; /* Compilation flags */ |
int flags; /* Compilation flags */ |
76 |
union { |
union { |
77 |
regex_t re; /* POSIX regex */ |
regex_t re; /* POSIX regex */ |
78 |
#ifdef HAVE_PCRE |
#ifdef HAVE_PCRE |
79 |
pcre *pre; /* Perl */ |
pcre *pre; /* Perl */ |
80 |
#endif |
#endif |
81 |
} v; |
} v; |
82 |
}; |
}; |
83 |
|
|
84 |
static struct regex_vtab * |
static struct regex_vtab * |
297 |
pcre_fullinfo(regex->v.pre, NULL, PCRE_INFO_CAPTURECOUNT, &count); |
pcre_fullinfo(regex->v.pre, NULL, PCRE_INFO_CAPTURECOUNT, &count); |
298 |
return count; |
return count; |
299 |
} |
} |
300 |
#endif |
#endif /* HAVE_PCRE */ |
301 |
|
|
302 |
|
/* EOF */ |
303 |
|
|