1 /* @(#)_regex.h 1.6 10/08/27 2010 J. Schilling */ 2 /* 3 * regex.h code taken from FreeBSD 4 * 5 * Portions Copyright (c) 2010 J. Schilling 6 */ 7 /* 8 * Copyright (c) 1992 Henry Spencer. 9 * Copyright (c) 1992, 1993 10 * The Regents of the University of California. All rights reserved. 11 * 12 * This code is derived from software contributed to Berkeley by 13 * Henry Spencer of the University of Toronto. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * 3. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)regex.h 8.2 (Berkeley) 1/3/94 40 * $FreeBSD: src/include/regex.h,v 1.12 2010/02/16 19:39:50 imp Exp $ 41 */ 42 43 #ifndef _SCHILY__REGEX_H 44 #define _SCHILY__REGEX_H 45 46 #ifndef _SCHILY_MCONFIG_H 47 #include <schily/mconfig.h> 48 #endif 49 50 #ifndef _SCHILY_TYPES_H 51 #include <schily/types.h> 52 #endif 53 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 58 #define __restrict 59 60 /* types */ 61 typedef ssize_t regoff_t; 62 63 typedef struct { 64 int re_magic; 65 size_t re_nsub; /* number of parenthesized subexpressions */ 66 const char *re_endp; /* end pointer for REG_PEND */ 67 struct re_guts *re_g; /* none of your business :-) */ 68 } regex_t; 69 70 typedef struct { 71 regoff_t rm_so; /* start of match */ 72 regoff_t rm_eo; /* end of match */ 73 } regmatch_t; 74 75 /* regcomp() flags */ 76 #define REG_BASIC 0000 77 #define REG_EXTENDED 0001 78 #define REG_ICASE 0002 79 #define REG_NOSUB 0004 80 #define REG_NEWLINE 0010 81 #define REG_NOSPEC 0020 82 #define REG_PEND 0040 83 #define REG_DUMP 0200 84 85 /* regerror() flags */ 86 #define REG_ENOSYS (-1) 87 #define REG_NOMATCH 1 88 #define REG_BADPAT 2 89 #define REG_ECOLLATE 3 90 #define REG_ECTYPE 4 91 #define REG_EESCAPE 5 92 #define REG_ESUBREG 6 93 #define REG_EBRACK 7 94 #define REG_EPAREN 8 95 #define REG_EBRACE 9 96 #define REG_BADBR 10 97 #define REG_ERANGE 11 98 #define REG_ESPACE 12 99 #define REG_BADRPT 13 100 #define REG_EMPTY 14 101 #define REG_ASSERT 15 102 #define REG_INVARG 16 103 #define REG_ILLSEQ 17 104 #define REG_ATOI 255 /* convert name to number (!) */ 105 #define REG_ITOA 0400 /* convert number to name (!) */ 106 107 /* regexec() flags */ 108 #define REG_NOTBOL 00001 109 #define REG_NOTEOL 00002 110 #define REG_STARTEND 00004 111 #define REG_TRACE 00400 /* tracing of execution */ 112 #define REG_LARGE 01000 /* force large representation */ 113 #define REG_BACKR 02000 /* force use of backref code */ 114 115 extern int regcomp __PR((regex_t *__restrict, const char *__restrict, 116 int)); 117 extern size_t regerror __PR((int, const regex_t *__restrict, char *__restrict, 118 size_t)); 119 /* 120 * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because 121 * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a 122 * syntax error. 123 */ 124 extern int regexec __PR((const regex_t *__restrict, const char *__restrict, 125 size_t, 126 regmatch_t *__restrict, int)); 127 extern void regfree __PR((regex_t *)); 128 129 #undef __restrict 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* _SCHILY__REGEX_H */ 136