1f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/*	$OpenBSD: regex.h,v 1.6 2003/06/02 19:34:12 millert Exp $	*/
2f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/*	$NetBSD: regex.h,v 1.4.6.1 1996/06/10 18:57:07 explorer Exp $	*/
3f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
4f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/*-
5f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * Copyright (c) 1992 Henry Spencer.
6f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * Copyright (c) 1992, 1993
7f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *	The Regents of the University of California.  All rights reserved.
8f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *
9f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * This code is derived from software contributed to Berkeley by
10f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * Henry Spencer of the University of Toronto.
11f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *
12f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * Redistribution and use in source and binary forms, with or without
13f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * modification, are permitted provided that the following conditions
14f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * are met:
15f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * 1. Redistributions of source code must retain the above copyright
16f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *    notice, this list of conditions and the following disclaimer.
17f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * 2. Redistributions in binary form must reproduce the above copyright
18f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *    notice, this list of conditions and the following disclaimer in the
19f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *    documentation and/or other materials provided with the distribution.
20f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * 3. Neither the name of the University nor the names of its contributors
21f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *    may be used to endorse or promote products derived from this software
22f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *    without specific prior written permission.
23f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *
24f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine * SUCH DAMAGE.
35f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *
36f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine *	@(#)regex.h	8.1 (Berkeley) 6/2/93
37f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine */
38f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
39f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#ifndef _REGEX_H_
40f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	_REGEX_H_
41f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
42f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#if 0
43f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#include <sys/cdefs.h>
44f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#include <sys/types.h>
45f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#else
46f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#include <sys/types.h>
47f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#endif
48f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
49f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/* types */
50f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkinetypedef off_t regoff_t;
51f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
52f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkinetypedef struct {
53f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	int re_magic;
54f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	size_t re_nsub;		/* number of parenthesized subexpressions */
55f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	const char *re_endp;	/* end pointer for REG_PEND */
56f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	struct re_guts *re_g;	/* none of your business :-) */
57f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine} regex_t;
58f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
59f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkinetypedef struct {
60f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	regoff_t rm_so;		/* start of match */
61f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine	regoff_t rm_eo;		/* end of match */
62f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine} regmatch_t;
63f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
64f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/* regcomp() flags */
65f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_BASIC	0000
66f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EXTENDED	0001
67f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ICASE	0002
68f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NOSUB	0004
69f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NEWLINE	0010
70f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NOSPEC	0020
71f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_PEND	0040
72f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_DUMP	0200
73f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
74f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/* regerror() flags */
75f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NOMATCH	 1
76f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_BADPAT	 2
77f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ECOLLATE	 3
78f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ECTYPE	 4
79f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EESCAPE	 5
80f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ESUBREG	 6
81f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EBRACK	 7
82f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EPAREN	 8
83f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EBRACE	 9
84f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_BADBR	10
85f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ERANGE	11
86f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ESPACE	12
87f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_BADRPT	13
88f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_EMPTY	14
89f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ASSERT	15
90f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_INVARG	16
91f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ATOI	255	/* convert name to number (!) */
92f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_ITOA	0400	/* convert number to name (!) */
93f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
94f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine/* regexec() flags */
95f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NOTBOL	00001
96f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_NOTEOL	00002
97f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_STARTEND	00004
98f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_TRACE	00400	/* tracing of execution */
99f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_LARGE	01000	/* force large representation */
100f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#define	REG_BACKR	02000	/* force use of backref code */
101f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
102f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine// __BEGIN_DECLS
103f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkineint	regcomp(regex_t *, const char *, int);
104f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkinesize_t	regerror(int, const regex_t *, char *, size_t);
105f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkineint	regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
106f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkinevoid	regfree(regex_t *);
107f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine// __END_DECLS
108f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine
109f9e88edc21c894886747e899dc29c02a28728d65Vladimir Chtchetkine#endif /* !_REGEX_H_ */
110