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