1da2e3ebchin
2da2e3ebchin/* : : generated by proto : : */
3da2e3ebchin
4da2e3ebchin#if !defined(__PROTO__)
5da2e3ebchin#include <prototyped.h>
6da2e3ebchin#endif
7da2e3ebchin#if !defined(__LINKAGE__)
8da2e3ebchin#define __LINKAGE__		/* 2004-08-11 transition */
9da2e3ebchin#endif
10da2e3ebchin#ifdef	_AST_STD_I
11da2e3ebchin#define _REGEX_H	-1
12da2e3ebchin#define regex_t		int
13da2e3ebchin#define regmatch_t	int
14da2e3ebchin#endif
15da2e3ebchin#ifndef _REGEX_H
16da2e3ebchin#define _REGEX_H	1
17da2e3ebchin#undef	regex_t
18da2e3ebchin#undef	regmatch_t
19da2e3ebchin
20da2e3ebchin#include <ast_common.h>
21da2e3ebchin
22da2e3ebchin#define REG_VERSION	20030916L
23da2e3ebchin
24da2e3ebchin/* regcomp flags */
25da2e3ebchin
26da2e3ebchin#define REG_AUGMENTED	0x00000001	/* enable ! & < >		*/
27da2e3ebchin#define REG_EXTENDED	0x00000002	/* enable ( | )			*/
28da2e3ebchin#define REG_ICASE	0x00000004	/* ignore case in match		*/
29da2e3ebchin#define REG_NEWLINE	0x00000008	/* ^/$ match embedded \n	*/
30da2e3ebchin#define REG_NOSUB	0x00000010	/* don't report subexp matches	*/
31da2e3ebchin#define REG_SHELL	0x00000020	/* shell pattern syntax		*/
32da2e3ebchin
33da2e3ebchin/* nonstandard regcomp flags */
34da2e3ebchin
35da2e3ebchin#define REG_LEFT	0x00000100	/* implicit ^...		*/
36da2e3ebchin#define REG_LITERAL	0x00000200	/* no operators			*/
37da2e3ebchin#define REG_MINIMAL	0x00000400	/* minimal match		*/
38da2e3ebchin#define REG_NULL	0x00000800	/* allow null patterns		*/
39da2e3ebchin#define REG_RIGHT	0x00001000	/* implicit ...$		*/
40da2e3ebchin#define REG_LENIENT	0x00002000	/* look the other way		*/
41da2e3ebchin#define REG_ESCAPE	0x00004000	/* \ escapes delimiter in [...]	*/
42da2e3ebchin#define REG_FIRST	0x00008000	/* first match found will do	*/
43da2e3ebchin#define REG_MULTIPLE	0x00010000	/* multiple \n sep patterns	*/
44da2e3ebchin#define REG_DISCIPLINE	0x00020000	/* regex_t.re_disc is valid	*/
45da2e3ebchin#define REG_SPAN	0x00040000	/* . matches \n			*/
46da2e3ebchin#define REG_COMMENT	0x00080000	/* ignore pattern space & #...\n*/
47da2e3ebchin#define REG_MULTIREF	0x00100000	/* multiple digit backrefs	*/
48da2e3ebchin#define REG_MUSTDELIM	0x08000000	/* all delimiters required	*/
49da2e3ebchin#define REG_DELIMITED	0x10000000	/* pattern[0] is delimiter	*/
503e14f97Roger A. Faulkner#define REG_CLASS_ESCAPE 0x80000000	/* \ escapes in [...]		*/
51da2e3ebchin
52da2e3ebchin#define REG_SHELL_DOT	0x00200000	/* explicit leading . match	*/
53da2e3ebchin#define REG_SHELL_ESCAPED 0x00400000	/* \ not special		*/
543e14f97Roger A. Faulkner#define REG_SHELL_GROUP	0x20000000	/* (|&) inside [@|&](...) only	*/
55da2e3ebchin#define REG_SHELL_PATH	0x00800000	/* explicit / match		*/
5634f9b3eRoland Mainz
5734f9b3eRoland Mainz#define REG_REGEXP	0x40000000	/* <regexp.h> compatibility	*/
58da2e3ebchin
59da2e3ebchin/* regexec flags */
60da2e3ebchin
61da2e3ebchin#define REG_NOTBOL	0x00000040	/* ^ is not a special char	*/
62da2e3ebchin#define REG_NOTEOL	0x00000080	/* $ is not a special char	*/
63da2e3ebchin
64da2e3ebchin/* nonstandard regexec flags */
65da2e3ebchin
66da2e3ebchin#define REG_INVERT	0x01000000	/* invert regrexec match sense	*/
67da2e3ebchin#define REG_STARTEND	0x02000000	/* subject==match[0].rm_{so,eo} */
68da2e3ebchin#define REG_ADVANCE	0x04000000	/* advance match[0].rm_{so,eo}	*/
69da2e3ebchin
70da2e3ebchin/* regalloc flags */
71da2e3ebchin
72da2e3ebchin#define REG_NOFREE	0x00000001	/* don't free			*/
73da2e3ebchin
74da2e3ebchin/* regsub flags */
75da2e3ebchin
76da2e3ebchin#define REG_SUB_ALL	0x00000001	/* substitute all occurrences	*/
77da2e3ebchin#define REG_SUB_LOWER	0x00000002	/* substitute to lower case	*/
78da2e3ebchin#define REG_SUB_UPPER	0x00000004	/* substitute to upper case	*/
79da2e3ebchin#define REG_SUB_PRINT	0x00000010	/* internal no-op		*/
80da2e3ebchin#define REG_SUB_NUMBER	0x00000020	/* internal no-op		*/
81da2e3ebchin#define REG_SUB_STOP	0x00000040	/* internal no-op		*/
82da2e3ebchin#define REG_SUB_WRITE	0x00000080	/* internal no-op		*/
83da2e3ebchin#define REG_SUB_LAST	0x00000100	/* last substitution option	*/
84da2e3ebchin#define REG_SUB_FULL	0x00000200	/* fully delimited		*/
85da2e3ebchin#define REG_SUB_USER	0x00001000	/* first user flag bit		*/
86da2e3ebchin
87da2e3ebchin/* regex error codes */
88da2e3ebchin
89da2e3ebchin#define REG_ENOSYS	(-1)		/* not supported		*/
90da2e3ebchin#define REG_NOMATCH	1		/* regexec didn't match		*/
91da2e3ebchin#define REG_BADPAT	2		/* invalid regular expression	*/
92da2e3ebchin#define REG_ECOLLATE	3		/* invalid collation element	*/
93da2e3ebchin#define REG_ECTYPE	4		/* invalid character class	*/
94da2e3ebchin#define REG_EESCAPE	5		/* trailing \ in pattern	*/
95da2e3ebchin#define REG_ESUBREG	6		/* invalid \digit backreference	*/
96da2e3ebchin#define REG_EBRACK	7		/* [...] imbalance		*/
97da2e3ebchin#define REG_EPAREN	8		/* \(...\) or (...) imbalance	*/
98da2e3ebchin#define REG_EBRACE	9		/* \{...\} or {...} imbalance	*/
99da2e3ebchin#define REG_BADBR	10		/* invalid {...} digits		*/
100da2e3ebchin#define REG_ERANGE	11		/* invalid [...] range endpoint	*/
101da2e3ebchin#define REG_ESPACE	12		/* out of space			*/
1023e14f97Roger A. Faulkner#define REG_BADRPT	13		/* unary op not preceded by re	*/
103da2e3ebchin#define REG_ENULL	14		/* empty subexpr in pattern	*/
104da2e3ebchin#define REG_ECOUNT	15		/* re component count overflow	*/
105da2e3ebchin#define REG_BADESC	16		/* invalid \char escape		*/
106da2e3ebchin#define REG_VERSIONID	17		/* version id (pseudo error)	*/
107da2e3ebchin#define REG_EFLAGS	18		/* flags conflict		*/
108da2e3ebchin#define REG_EDELIM	19		/* invalid or omitted delimiter	*/
109da2e3ebchin#define REG_PANIC	20		/* unrecoverable internal error	*/
110da2e3ebchin
111da2e3ebchinstruct regex_s; typedef struct regex_s regex_t;
112da2e3ebchinstruct regdisc_s; typedef struct regdisc_s regdisc_t;
113da2e3ebchin
114da2e3ebchintypedef int (*regclass_t) __PROTO__((int));
1153e14f97Roger A. Faulknertypedef uint32_t regflags_t;
116da2e3ebchintypedef int regoff_t;
117da2e3ebchintypedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...));
118da2e3ebchintypedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*));
119da2e3ebchintypedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*));
120da2e3ebchintypedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t));
121da2e3ebchintypedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t));
122da2e3ebchin
123da2e3ebchintypedef struct regmatch_s
124da2e3ebchin{
125da2e3ebchin	regoff_t	rm_so;		/* offset of start		*/
126da2e3ebchin	regoff_t	rm_eo;		/* offset of end		*/
127da2e3ebchin} regmatch_t;
128da2e3ebchin
129da2e3ebchintypedef struct regsub_s
130da2e3ebchin{
131da2e3ebchin	regflags_t	re_flags;	/* regsubcomp() flags		*/
132da2e3ebchin	char*		re_buf;		/* regsubexec() output buffer	*/
133da2e3ebchin	size_t		re_len;		/* re_buf length		*/
134da2e3ebchin	int		re_min;		/* regsubcomp() min matches	*/
135da2e3ebchin#ifdef _REG_SUB_PRIVATE_
136da2e3ebchin	_REG_SUB_PRIVATE_
137da2e3ebchin#endif
138da2e3ebchin} regsub_t;
139da2e3ebchin
140da2e3ebchinstruct regdisc_s
141da2e3ebchin{
142da2e3ebchin	unsigned long	re_version;	/* discipline version		*/
143da2e3ebchin	regflags_t	re_flags;	/* discipline flags		*/
144da2e3ebchin	regerror_t	re_errorf;	/* error function		*/
145da2e3ebchin	int		re_errorlevel;	/* errorf level			*/
146da2e3ebchin	regresize_t	re_resizef;	/* alloc/free function		*/
147da2e3ebchin	__V_*		re_resizehandle;/* resizef handle		*/
148da2e3ebchin	regcomp_t	re_compf;	/* (?{...}) compile function	*/
149da2e3ebchin	regexec_t	re_execf;	/* (?{...}) execute function	*/
150da2e3ebchin	unsigned char*	re_map;		/* external to native ccode map	*/
151da2e3ebchin};
152da2e3ebchin
153da2e3ebchintypedef struct regstat_s
154da2e3ebchin{
155da2e3ebchin	regflags_t	re_flags;	/* REG_LEFT|REG_RIGHT		*/
156da2e3ebchin	ssize_t		re_min;		/* min anchored match length	*/
157da2e3ebchin	ssize_t		re_max;		/* max anchored match length	*/
158da2e3ebchin	ssize_t		re_record;	/* regrexec() match length	*/
159da2e3ebchin} regstat_t;
160da2e3ebchin
161da2e3ebchinstruct regex_s
162da2e3ebchin{
163da2e3ebchin	size_t		re_nsub;	/* number of subexpressions	*/
164da2e3ebchin	struct reglib_s*re_info;	/* library private info		*/
165da2e3ebchin	size_t		re_npat;	/* number of pattern chars used	*/
166da2e3ebchin	regdisc_t*	re_disc;	/* REG_DISCIPLINE discipline	*/
167da2e3ebchin	regsub_t*	re_sub;		/* regsubcomp() data		*/
168da2e3ebchin};
169da2e3ebchin
170da2e3ebchin#define reginit(disc)	(memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
171da2e3ebchin
172da2e3ebchin#if _BLD_ast && defined(__EXPORT__)
173da2e3ebchin#undef __MANGLE__
174da2e3ebchin#define __MANGLE__ __LINKAGE__		__EXPORT__
175da2e3ebchin#endif
176da2e3ebchin
177da2e3ebchinextern __MANGLE__ int	regcomp __PROTO__((regex_t*, const char*, regflags_t));
178da2e3ebchinextern __MANGLE__ size_t	regerror __PROTO__((int, const regex_t*, char*, size_t));
179da2e3ebchinextern __MANGLE__ int	regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t));
180da2e3ebchinextern __MANGLE__ void	regfree __PROTO__((regex_t*));
181da2e3ebchin
182da2e3ebchin/* nonstandard hooks */
183da2e3ebchin
184da2e3ebchin#define _REG_cache	1	/* have regcache()			*/
185da2e3ebchin#define _REG_class	1	/* have regclass()			*/
186da2e3ebchin#define _REG_collate	1	/* have regcollate(), regclass()	*/
187da2e3ebchin#define _REG_comb	1	/* have regcomb()			*/
188da2e3ebchin#define _REG_decomp	1	/* have regdecomp()			*/
189da2e3ebchin#define _REG_dup	1	/* have regdup()			*/
190da2e3ebchin#define _REG_fatal	1	/* have regfatal(), regfatalpat()	*/
191da2e3ebchin#define _REG_ncomp	1	/* have regncomp()			*/
192da2e3ebchin#define _REG_nexec	1	/* have regnexec()			*/
193da2e3ebchin#define _REG_rexec	1	/* have regrexec(), regrecord()		*/
194da2e3ebchin#define _REG_stat	1	/* have regstat()			*/
195da2e3ebchin#define _REG_subcomp	1	/* have regsubcomp(), regsubexec()	*/
196da2e3ebchin
197da2e3ebchinextern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**));
198da2e3ebchinextern __MANGLE__ int	regaddclass __PROTO__((const char*, regclass_t));
199da2e3ebchinextern __MANGLE__ int	regcollate __PROTO__((const char*, char**, char*, int));
200da2e3ebchinextern __MANGLE__ int	regcomb __PROTO__((regex_t*, regex_t*));
201da2e3ebchinextern __MANGLE__ size_t	regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t));
202da2e3ebchinextern __MANGLE__ int	regdup __PROTO__((regex_t*, regex_t*));
203da2e3ebchinextern __MANGLE__ int	regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t));
204da2e3ebchinextern __MANGLE__ int	regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t));
205da2e3ebchinextern __MANGLE__ void	regfatal __PROTO__((regex_t*, int, int));
206da2e3ebchinextern __MANGLE__ void	regfatalpat __PROTO__((regex_t*, int, int, const char*));
207da2e3ebchinextern __MANGLE__ int	regrecord __PROTO__((const regex_t*));
208da2e3ebchinextern __MANGLE__ int	regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t));
209da2e3ebchinextern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*));
210da2e3ebchin
211da2e3ebchinextern __MANGLE__ regex_t*	regcache __PROTO__((const char*, regflags_t, int*));
212da2e3ebchin
213da2e3ebchinextern __MANGLE__ int	regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t));
214da2e3ebchinextern __MANGLE__ int	regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*));
215da2e3ebchinextern __MANGLE__ int	regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*));
216da2e3ebchinextern __MANGLE__ void	regsubfree __PROTO__((regex_t*));
217da2e3ebchin
218da2e3ebchin/* obsolete hooks */
219da2e3ebchin
220da2e3ebchin#ifndef _SFIO_H
221da2e3ebchinstruct _sfio_s;
222da2e3ebchin#endif
223da2e3ebchin
224da2e3ebchinextern __MANGLE__ void	regalloc __PROTO__((__V_*, regresize_t, regflags_t));
225da2e3ebchinextern __MANGLE__ int	regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t));
226da2e3ebchin
227da2e3ebchin#undef __MANGLE__
228da2e3ebchin#define __MANGLE__ __LINKAGE__
229da2e3ebchin
230da2e3ebchin#endif
231