Rizin
unix-like reverse engineering framework and cli tools
rz_regex.h
Go to the documentation of this file.
1 #ifndef RZ_REGEX_H
2 #define RZ_REGEX_H
3 
4 #include <rz_types.h>
5 #include <rz_list.h>
6 #include <sys/types.h>
7 
8 typedef struct rz_regex_t {
9  int re_magic;
10  size_t re_nsub; /* number of parenthesized subexpressions */
11  const char *re_endp; /* end pointer for RZ_REGEX_PEND */
12  struct re_guts *re_g; /* none of your business :-) */
13  int re_flags;
15 
16 typedef struct rz_regmatch_t {
17  st64 rm_so; /* start of match */
18  st64 rm_eo; /* end of match */
20 
21 /* regcomp() flags */
22 #define RZ_REGEX_BASIC 0000
23 #define RZ_REGEX_EXTENDED 0001
24 #define RZ_REGEX_ICASE 0002
25 #define RZ_REGEX_NOSUB 0004
26 #define RZ_REGEX_NEWLINE 0010
27 #define RZ_REGEX_NOSPEC 0020
28 #define RZ_REGEX_PEND 0040
29 #define RZ_REGEX_DUMP 0200
30 
31 /* regerror() flags */
32 #define RZ_REGEX_ENOSYS (-1) /* Reserved */
33 #define RZ_REGEX_NOMATCH 1
34 #define RZ_REGEX_BADPAT 2
35 #define RZ_REGEX_ECOLLATE 3
36 #define RZ_REGEX_ECTYPE 4
37 #define RZ_REGEX_EESCAPE 5
38 #define RZ_REGEX_ESUBREG 6
39 #define RZ_REGEX_EBRACK 7
40 #define RZ_REGEX_EPAREN 8
41 #define RZ_REGEX_EBRACE 9
42 #define RZ_REGEX_BADBR 10
43 #define RZ_REGEX_ERANGE 11
44 #define RZ_REGEX_ESPACE 12
45 #define RZ_REGEX_BADRPT 13
46 #define RZ_REGEX_EMPTY 14
47 #define RZ_REGEX_ASSERT 15
48 #define RZ_REGEX_INVARG 16
49 #define RZ_REGEX_ILLSEQ 17
50 #define RZ_REGEX_ATOI 255 /* convert name to number (!) */
51 #define RZ_REGEX_ITOA 0400 /* convert number to name (!) */
52 
53 /* regexec() flags */
54 #define RZ_REGEX_NOTBOL 00001
55 #define RZ_REGEX_NOTEOL 00002
56 #define RZ_REGEX_STARTEND 00004
57 #define RZ_REGEX_TRACE 00400 /* tracing of execution */
58 #define RZ_REGEX_LARGE 01000 /* force large representation */
59 #define RZ_REGEX_BACKR 02000 /* force use of backref code */
60 
61 RZ_API RzRegex *rz_regex_new(const char *pattern, const char *cflags);
62 RZ_API int rz_regex_match(const char *pattern, const char *flags, const char *text);
63 RZ_API RzList *rz_regex_get_match_list(const char *pattern, const char *flags, const char *text);
64 RZ_API int rz_regex_flags(const char *flags);
65 RZ_API int rz_regex_comp(RzRegex *, const char *, int);
66 RZ_API size_t rz_regex_error(int, const RzRegex *, char *, size_t);
67 /*
68  * gcc under c99 mode won't compile "[]" by itself. As a workaround,
69  * a dummy argument name is added.
70  */
71 RZ_API bool rz_regex_check(const RzRegex *rr, const char *str);
72 RZ_API int rz_regex_exec(const RzRegex *preg, const char *string, size_t nmatch, RzRegexMatch __pmatch[], int eflags);
75 
76 #endif /* !_REGEX_H_ */
#define RZ_API
RZ_API RzRegex * rz_regex_new(const char *pattern, const char *cflags)
Definition: regcomp.c:183
struct rz_regex_t RzRegex
RZ_API int rz_regex_exec(const RzRegex *preg, const char *string, size_t nmatch, RzRegexMatch __pmatch[], int eflags)
Definition: regexec.c:149
struct rz_regmatch_t RzRegexMatch
RZ_API void rz_regex_fini(RzRegex *)
Definition: regcomp.c:226
RZ_API int rz_regex_comp(RzRegex *, const char *, int)
Definition: regcomp.c:258
RZ_API RzList * rz_regex_get_match_list(const char *pattern, const char *flags, const char *text)
Definition: regcomp.c:155
RZ_API size_t rz_regex_error(int, const RzRegex *, char *, size_t)
Definition: regerror.c:78
RZ_API void rz_regex_free(RzRegex *)
Definition: regcomp.c:249
RZ_API int rz_regex_flags(const char *flags)
Definition: regcomp.c:197
RZ_API int rz_regex_match(const char *pattern, const char *flags, const char *text)
Definition: regcomp.c:142
RZ_API bool rz_regex_check(const RzRegex *rr, const char *str)
Definition: regexec.c:138
#define st64
Definition: rz_types_base.h:10
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
const char * re_endp
Definition: rz_regex.h:11
int re_flags
Definition: rz_regex.h:13
size_t re_nsub
Definition: rz_regex.h:10
int re_magic
Definition: rz_regex.h:9
struct re_guts * re_g
Definition: rz_regex.h:12
st64 rm_so
Definition: rz_regex.h:17
st64 rm_eo
Definition: rz_regex.h:18