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