1
2
3
4
8
9
10
11
12
13
14
15
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef JIMREGEXP_H
#define JIMREGEXP_H
/* ... */
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
typedef struct {
int rm_so;
int rm_eo;
...} regmatch_t;
/* ... */
typedef struct regexp {
int re_nsub;
int cflags;
int err;
int regstart;
int reganch;
int regmust;
int regmlen;
int *program;
const char *regparse;
int p;
int proglen;
int eflags;
const char *start;
const char *reginput;
const char *regbol;
regmatch_t *pmatch;
int nmatch;
...} regexp;
typedef regexp regex_t;
#define REG_EXTENDED 0
#define REG_NEWLINE 1
#define REG_ICASE 2
#define REG_NOTBOL 16
enum {
REG_NOERROR,
REG_NOMATCH,
REG_BADPAT,
REG_ERR_NULL_ARGUMENT,
REG_ERR_UNKNOWN,
REG_ERR_TOO_BIG,
REG_ERR_NOMEM,
REG_ERR_TOO_MANY_PAREN,
REG_ERR_UNMATCHED_PAREN,
REG_ERR_UNMATCHED_BRACES,
REG_ERR_BAD_COUNT,
REG_ERR_JUNK_ON_END,
REG_ERR_OPERAND_COULD_BE_EMPTY,
REG_ERR_NESTED_COUNT,
REG_ERR_INTERNAL,
REG_ERR_COUNT_FOLLOWS_NOTHING,
REG_ERR_INVALID_ESCAPE,
REG_ERR_CORRUPTED,
REG_ERR_NULL_CHAR,
REG_ERR_UNMATCHED_BRACKET,
REG_ERR_NUM
...};
int jim_regcomp(regex_t *preg, const char *regex, int cflags);
int jim_regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
size_t jim_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size);
void jim_regfree(regex_t *preg);
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif