xref: /original-bsd/include/regex.h (revision ab6c2785)
1 /*-
2  * Copyright (c) 1992 Henry Spencer.
3  * Copyright (c) 1992 The Regents of the University of California.
4  * 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	5.3 (Berkeley) 05/21/93
12  */
13 
14 #ifndef _REGEX_H_
15 #define	_REGEX_H_
16 
17 /* types */
18 typedef off_t regoff_t;
19 
20 typedef struct {
21 	int re_magic;
22 	size_t re_nsub;		/* number of parenthesized subexpressions */
23 	const char *re_endp;	/* end pointer for REG_PEND */
24 	struct re_guts *re_g;	/* none of your business :-) */
25 } regex_t;
26 
27 typedef struct {
28 	regoff_t rm_so;		/* start of match */
29 	regoff_t rm_eo;		/* end of match */
30 } regmatch_t;
31 
32 /* regcomp() flags */
33 #define	REG_BASIC	0000
34 #define	REG_EXTENDED	0001
35 #define	REG_ICASE	0002
36 #define	REG_NOSUB	0004
37 #define	REG_NEWLINE	0010
38 #define	REG_NOSPEC	0020
39 #define	REG_PEND	0040
40 #define	REG_DUMP	0200
41 
42 /* regerror() flags */
43 #define	REG_NOMATCH	 1
44 #define	REG_BADPAT	 2
45 #define	REG_ECOLLATE	 3
46 #define	REG_ECTYPE	 4
47 #define	REG_EESCAPE	 5
48 #define	REG_ESUBREG	 6
49 #define	REG_EBRACK	 7
50 #define	REG_EPAREN	 8
51 #define	REG_EBRACE	 9
52 #define	REG_BADBR	10
53 #define	REG_ERANGE	11
54 #define	REG_ESPACE	12
55 #define	REG_BADRPT	13
56 #define	REG_EMPTY	14
57 #define	REG_ASSERT	15
58 #define	REG_INVARG	16
59 #define	REG_ATOI	255	/* convert name to number (!) */
60 #define	REG_ITOA	0400	/* convert number to name (!) */
61 
62 /* regexec() flags */
63 #define	REG_NOTBOL	00001
64 #define	REG_NOTEOL	00002
65 #define	REG_STARTEND	00004
66 #define	REG_TRACE	00400	/* tracing of execution */
67 #define	REG_LARGE	01000	/* force large representation */
68 #define	REG_BACKR	02000	/* force use of backref code */
69 
70 #include <sys/cdefs.h>
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