1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 1998-2000, 2004-2006, 2008 Peter Miller
4 //
5 //	This program is free software; you can redistribute it and/or modify
6 //	it under the terms of the GNU General Public License as published by
7 //	the Free Software Foundation; either version 3 of the License, or
8 //	(at your option) any later version.
9 //
10 //	This program is distributed in the hope that it will be useful,
11 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //	GNU General Public License for more details.
14 //
15 //	You should have received a copy of the GNU General Public License
16 //	along with this program. If not, see
17 //	<http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef COMMON_AC_REGEX_H
21 #define COMMON_AC_REGEX_H
22 
23 //
24 // The rxposix.h and regex.h include files need size_t.  We make this
25 // file indempotent, so that code which includes *this* file doesn't
26 // need to worry about the include file ordering.
27 //
28 #include <common/ac/stddef.h>
29 #include <common/ac/sys/types.h>
30 
31 #if HAVE_RXPOSIX_H && HAVE_LIBRX
32 extern "C" {
33 #include <rxposix.h>
34 }
35 #else
36 #if HAVE_REGEX_H
37 
38 //
39 // The GNU Rx library has a broken usage of __restrict,
40 // and we need to make sure it doesn't foul the compiler.
41 //
42 #undef __restrict_arr
43 #define __restrict_arr
44 #include <regex.h>
45 #undef __restrict_arr
46 #else
47 
48 //
49 // Fake just enough to get things to compile.
50 //
51 #define regex_t int
52 
53 struct regmatch_t
54 {
55     int rm_so;
56     int rm_eo;
57 };
58 
59 #define REG_EXTENDED 0
60 #define REG_NOSUB 0
61 #define REG_NOMATCH -1
62 #define REG_NOTBOL 0
63 
64 int regcomp(regex_t *preg, const char *regex, int cflags);
65 int regexec(const regex_t *preg, const char *string, size_t nmatch,
66     regmatch_t *pmatch, int eflags);
67 size_t regerror(int errcode, const regex_t *preg, char *errbuf,
68     size_t errbuf_size);
69 void regfree(regex_t *preg);
70 
71 #endif
72 #endif
73 
74 #endif // COMMON_AC_REGEX_H
75