xref: /original-bsd/include/regex.h (revision 333da485)
1 /*-
2  * Copyright (c) 1992 Henry Spencer.
3  * Copyright (c) 1992, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * Henry Spencer of the University of Toronto.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)regex.h	8.2 (Berkeley) 01/03/94
12  */
13 
14 #ifndef _REGEX_H_
15 #define	_REGEX_H_
16 
17 #include <sys/cdefs.h>
18 
19 /* types */
20 typedef off_t regoff_t;
21 
22 typedef struct {
23 	int re_magic;
24 	size_t re_nsub;		/* number of parenthesized subexpressions */
25 	__const char *re_endp;	/* end pointer for REG_PEND */
26 	struct re_guts *re_g;	/* none of your business :-) */
27 } regex_t;
28 
29 typedef struct {
30 	regoff_t rm_so;		/* start of match */
31 	regoff_t rm_eo;		/* end of match */
32 } regmatch_t;
33 
34 /* regcomp() flags */
35 #define	REG_BASIC	0000
36 #define	REG_EXTENDED	0001
37 #define	REG_ICASE	0002
38 #define	REG_NOSUB	0004
39 #define	REG_NEWLINE	0010
40 #define	REG_NOSPEC	0020
41 #define	REG_PEND	0040
42 #define	REG_DUMP	0200
43 
44 /* regerror() flags */
45 #define	REG_NOMATCH	 1
46 #define	REG_BADPAT	 2
47 #define	REG_ECOLLATE	 3
48 #define	REG_ECTYPE	 4
49 #define	REG_EESCAPE	 5
50 #define	REG_ESUBREG	 6
51 #define	REG_EBRACK	 7
52 #define	REG_EPAREN	 8
53 #define	REG_EBRACE	 9
54 #define	REG_BADBR	10
55 #define	REG_ERANGE	11
56 #define	REG_ESPACE	12
57 #define	REG_BADRPT	13
58 #define	REG_EMPTY	14
59 #define	REG_ASSERT	15
60 #define	REG_INVARG	16
61 #define	REG_ATOI	255	/* convert name to number (!) */
62 #define	REG_ITOA	0400	/* convert number to name (!) */
63 
64 /* regexec() flags */
65 #define	REG_NOTBOL	00001
66 #define	REG_NOTEOL	00002
67 #define	REG_STARTEND	00004
68 #define	REG_TRACE	00400	/* tracing of execution */
69 #define	REG_LARGE	01000	/* force large representation */
70 #define	REG_BACKR	02000	/* force use of backref code */
71 
72 __BEGIN_DECLS
73 int	regcomp __P((regex_t *, const char *, int));
74 size_t	regerror __P((int, const regex_t *, char *, size_t));
75 int	regexec __P((const regex_t *,
76 	    const char *, size_t, regmatch_t [], int));
77 void	regfree __P((regex_t *));
78 __END_DECLS
79 
80 #endif /* !_REGEX_H_ */
81