1*2fe8fb19SBen Gras /* $NetBSD: regex.h,v 1.13 2005/09/13 01:44:32 christos Exp $ */ 2*2fe8fb19SBen Gras 39865aeaaSBen Gras /*- 49865aeaaSBen Gras * Copyright (c) 1992, 1993 59865aeaaSBen Gras * The Regents of the University of California. All rights reserved. 69865aeaaSBen Gras * 79865aeaaSBen Gras * This code is derived from software contributed to Berkeley by 89865aeaaSBen Gras * Henry Spencer of the University of Toronto. 99865aeaaSBen Gras * 109865aeaaSBen Gras * Redistribution and use in source and binary forms, with or without 119865aeaaSBen Gras * modification, are permitted provided that the following conditions 129865aeaaSBen Gras * are met: 139865aeaaSBen Gras * 1. Redistributions of source code must retain the above copyright 149865aeaaSBen Gras * notice, this list of conditions and the following disclaimer. 159865aeaaSBen Gras * 2. Redistributions in binary form must reproduce the above copyright 169865aeaaSBen Gras * notice, this list of conditions and the following disclaimer in the 179865aeaaSBen Gras * documentation and/or other materials provided with the distribution. 18*2fe8fb19SBen Gras * 3. Neither the name of the University nor the names of its contributors 19*2fe8fb19SBen Gras * may be used to endorse or promote products derived from this software 20*2fe8fb19SBen Gras * without specific prior written permission. 21*2fe8fb19SBen Gras * 22*2fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23*2fe8fb19SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*2fe8fb19SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*2fe8fb19SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*2fe8fb19SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*2fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*2fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*2fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*2fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*2fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*2fe8fb19SBen Gras * SUCH DAMAGE. 33*2fe8fb19SBen Gras * 34*2fe8fb19SBen Gras * @(#)regex.h 8.2 (Berkeley) 1/3/94 35*2fe8fb19SBen Gras */ 36*2fe8fb19SBen Gras 37*2fe8fb19SBen Gras /*- 38*2fe8fb19SBen Gras * Copyright (c) 1992 Henry Spencer. 39*2fe8fb19SBen Gras * 40*2fe8fb19SBen Gras * This code is derived from software contributed to Berkeley by 41*2fe8fb19SBen Gras * Henry Spencer of the University of Toronto. 42*2fe8fb19SBen Gras * 43*2fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without 44*2fe8fb19SBen Gras * modification, are permitted provided that the following conditions 45*2fe8fb19SBen Gras * are met: 46*2fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright 47*2fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer. 48*2fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 49*2fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the 50*2fe8fb19SBen Gras * documentation and/or other materials provided with the distribution. 519865aeaaSBen Gras * 3. All advertising materials mentioning features or use of this software 529865aeaaSBen Gras * must display the following acknowledgement: 539865aeaaSBen Gras * This product includes software developed by the University of 549865aeaaSBen Gras * California, Berkeley and its contributors. 559865aeaaSBen Gras * 4. Neither the name of the University nor the names of its contributors 569865aeaaSBen Gras * may be used to endorse or promote products derived from this software 579865aeaaSBen Gras * without specific prior written permission. 589865aeaaSBen Gras * 599865aeaaSBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 609865aeaaSBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 619865aeaaSBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 629865aeaaSBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 639865aeaaSBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 649865aeaaSBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 659865aeaaSBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 669865aeaaSBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 679865aeaaSBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 689865aeaaSBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 699865aeaaSBen Gras * SUCH DAMAGE. 709865aeaaSBen Gras * 719865aeaaSBen Gras * @(#)regex.h 8.2 (Berkeley) 1/3/94 729865aeaaSBen Gras */ 739865aeaaSBen Gras 749865aeaaSBen Gras #ifndef _REGEX_H_ 759865aeaaSBen Gras #define _REGEX_H_ 769865aeaaSBen Gras 77*2fe8fb19SBen Gras #include <sys/cdefs.h> 78*2fe8fb19SBen Gras #include <sys/types.h> 799865aeaaSBen Gras 809865aeaaSBen Gras /* types */ 819865aeaaSBen Gras typedef off_t regoff_t; 829865aeaaSBen Gras 839865aeaaSBen Gras typedef struct { 849865aeaaSBen Gras int re_magic; 859865aeaaSBen Gras size_t re_nsub; /* number of parenthesized subexpressions */ 869865aeaaSBen Gras const char *re_endp; /* end pointer for REG_PEND */ 879865aeaaSBen Gras struct re_guts *re_g; /* none of your business :-) */ 889865aeaaSBen Gras } regex_t; 899865aeaaSBen Gras 909865aeaaSBen Gras typedef struct { 919865aeaaSBen Gras regoff_t rm_so; /* start of match */ 929865aeaaSBen Gras regoff_t rm_eo; /* end of match */ 939865aeaaSBen Gras } regmatch_t; 949865aeaaSBen Gras 959865aeaaSBen Gras /* regcomp() flags */ 969865aeaaSBen Gras #define REG_BASIC 0000 979865aeaaSBen Gras #define REG_EXTENDED 0001 989865aeaaSBen Gras #define REG_ICASE 0002 999865aeaaSBen Gras #define REG_NOSUB 0004 1009865aeaaSBen Gras #define REG_NEWLINE 0010 1019865aeaaSBen Gras #define REG_NOSPEC 0020 1029865aeaaSBen Gras #define REG_PEND 0040 1039865aeaaSBen Gras #define REG_DUMP 0200 1049865aeaaSBen Gras 1059865aeaaSBen Gras /* regerror() flags */ 1069865aeaaSBen Gras #define REG_NOMATCH 1 1079865aeaaSBen Gras #define REG_BADPAT 2 1089865aeaaSBen Gras #define REG_ECOLLATE 3 1099865aeaaSBen Gras #define REG_ECTYPE 4 1109865aeaaSBen Gras #define REG_EESCAPE 5 1119865aeaaSBen Gras #define REG_ESUBREG 6 1129865aeaaSBen Gras #define REG_EBRACK 7 1139865aeaaSBen Gras #define REG_EPAREN 8 1149865aeaaSBen Gras #define REG_EBRACE 9 1159865aeaaSBen Gras #define REG_BADBR 10 1169865aeaaSBen Gras #define REG_ERANGE 11 1179865aeaaSBen Gras #define REG_ESPACE 12 1189865aeaaSBen Gras #define REG_BADRPT 13 1199865aeaaSBen Gras #define REG_EMPTY 14 1209865aeaaSBen Gras #define REG_ASSERT 15 1219865aeaaSBen Gras #define REG_INVARG 16 122*2fe8fb19SBen Gras #define REG_ENOSYS 17 1239865aeaaSBen Gras #define REG_ATOI 255 /* convert name to number (!) */ 1249865aeaaSBen Gras #define REG_ITOA 0400 /* convert number to name (!) */ 1259865aeaaSBen Gras 1269865aeaaSBen Gras /* regexec() flags */ 1279865aeaaSBen Gras #define REG_NOTBOL 00001 1289865aeaaSBen Gras #define REG_NOTEOL 00002 1299865aeaaSBen Gras #define REG_STARTEND 00004 1309865aeaaSBen Gras #define REG_TRACE 00400 /* tracing of execution */ 1319865aeaaSBen Gras #define REG_LARGE 01000 /* force large representation */ 1329865aeaaSBen Gras #define REG_BACKR 02000 /* force use of backref code */ 1339865aeaaSBen Gras 134*2fe8fb19SBen Gras __BEGIN_DECLS 135*2fe8fb19SBen Gras int regcomp(regex_t * __restrict, const char * __restrict, int); 136*2fe8fb19SBen Gras size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); 137*2fe8fb19SBen Gras int regexec(const regex_t * __restrict, 138*2fe8fb19SBen Gras const char * __restrict, size_t, regmatch_t [], int); 1399865aeaaSBen Gras void regfree(regex_t *); 140*2fe8fb19SBen Gras __END_DECLS 1419865aeaaSBen Gras 1429865aeaaSBen Gras #endif /* !_REGEX_H_ */ 143