1*cddc78eaSriastradh /* $NetBSD: regex.h,v 1.17 2024/10/30 15:56:10 riastradh Exp $ */ 2039cc956Sagc 3039cc956Sagc /*- 4039cc956Sagc * Copyright (c) 1992, 1993 5039cc956Sagc * The Regents of the University of California. All rights reserved. 6039cc956Sagc * 7039cc956Sagc * This code is derived from software contributed to Berkeley by 8039cc956Sagc * Henry Spencer of the University of Toronto. 9039cc956Sagc * 10039cc956Sagc * Redistribution and use in source and binary forms, with or without 11039cc956Sagc * modification, are permitted provided that the following conditions 12039cc956Sagc * are met: 13039cc956Sagc * 1. Redistributions of source code must retain the above copyright 14039cc956Sagc * notice, this list of conditions and the following disclaimer. 15039cc956Sagc * 2. Redistributions in binary form must reproduce the above copyright 16039cc956Sagc * notice, this list of conditions and the following disclaimer in the 17039cc956Sagc * documentation and/or other materials provided with the distribution. 18039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 19039cc956Sagc * may be used to endorse or promote products derived from this software 20039cc956Sagc * without specific prior written permission. 21039cc956Sagc * 22039cc956Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23039cc956Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24039cc956Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25039cc956Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26039cc956Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27039cc956Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28039cc956Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29039cc956Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30039cc956Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31039cc956Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32039cc956Sagc * SUCH DAMAGE. 33039cc956Sagc * 34039cc956Sagc * @(#)regex.h 8.2 (Berkeley) 1/3/94 35039cc956Sagc */ 364d2cbfceScgd 3705903d2bScgd /*- 3805903d2bScgd * Copyright (c) 1992 Henry Spencer. 3905903d2bScgd * 4005903d2bScgd * This code is derived from software contributed to Berkeley by 4105903d2bScgd * Henry Spencer of the University of Toronto. 4205903d2bScgd * 4305903d2bScgd * Redistribution and use in source and binary forms, with or without 4405903d2bScgd * modification, are permitted provided that the following conditions 4505903d2bScgd * are met: 4605903d2bScgd * 1. Redistributions of source code must retain the above copyright 4705903d2bScgd * notice, this list of conditions and the following disclaimer. 4805903d2bScgd * 2. Redistributions in binary form must reproduce the above copyright 4905903d2bScgd * notice, this list of conditions and the following disclaimer in the 5005903d2bScgd * documentation and/or other materials provided with the distribution. 5105903d2bScgd * 3. All advertising materials mentioning features or use of this software 5205903d2bScgd * must display the following acknowledgement: 5305903d2bScgd * This product includes software developed by the University of 5405903d2bScgd * California, Berkeley and its contributors. 5505903d2bScgd * 4. Neither the name of the University nor the names of its contributors 5605903d2bScgd * may be used to endorse or promote products derived from this software 5705903d2bScgd * without specific prior written permission. 5805903d2bScgd * 5905903d2bScgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 6005903d2bScgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 6105903d2bScgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 6205903d2bScgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 6305903d2bScgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 6405903d2bScgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 6505903d2bScgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6605903d2bScgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 6705903d2bScgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6805903d2bScgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6905903d2bScgd * SUCH DAMAGE. 7005903d2bScgd * 71b7b7322cSperry * @(#)regex.h 8.2 (Berkeley) 1/3/94 7205903d2bScgd */ 739f78fc2fSjtc 7405903d2bScgd #ifndef _REGEX_H_ 7505903d2bScgd #define _REGEX_H_ 7605903d2bScgd 7705903d2bScgd #include <sys/cdefs.h> 78*cddc78eaSriastradh #include <sys/featuretest.h> 79a15d9fa1Sexplorer #include <sys/types.h> 8005903d2bScgd 8105903d2bScgd /* types */ 829f78fc2fSjtc typedef off_t regoff_t; 8305903d2bScgd 849f78fc2fSjtc typedef struct { 859f78fc2fSjtc int re_magic; 869f78fc2fSjtc size_t re_nsub; /* number of parenthesized subexpressions */ 879f78fc2fSjtc const char *re_endp; /* end pointer for REG_PEND */ 889f78fc2fSjtc struct re_guts *re_g; /* none of your business :-) */ 899f78fc2fSjtc } regex_t; 9005903d2bScgd 919f78fc2fSjtc typedef struct { 929f78fc2fSjtc regoff_t rm_so; /* start of match */ 939f78fc2fSjtc regoff_t rm_eo; /* end of match */ 949f78fc2fSjtc } regmatch_t; 959f78fc2fSjtc 9605903d2bScgd /* regcomp() flags */ 979f78fc2fSjtc #define REG_BASIC 0000 989f78fc2fSjtc #define REG_EXTENDED 0001 999f78fc2fSjtc #define REG_ICASE 0002 1009f78fc2fSjtc #define REG_NOSUB 0004 1019f78fc2fSjtc #define REG_NEWLINE 0010 1029f78fc2fSjtc #define REG_NOSPEC 0020 1039f78fc2fSjtc #define REG_PEND 0040 1049f78fc2fSjtc #define REG_DUMP 0200 105cc8bab37Schristos #define REG_GNU 0400 1069f78fc2fSjtc 10705903d2bScgd /* regerror() flags */ 1089f78fc2fSjtc #define REG_NOMATCH 1 1099f78fc2fSjtc #define REG_BADPAT 2 1109f78fc2fSjtc #define REG_ECOLLATE 3 1119f78fc2fSjtc #define REG_ECTYPE 4 1129f78fc2fSjtc #define REG_EESCAPE 5 1139f78fc2fSjtc #define REG_ESUBREG 6 1149f78fc2fSjtc #define REG_EBRACK 7 1159f78fc2fSjtc #define REG_EPAREN 8 1169f78fc2fSjtc #define REG_EBRACE 9 1179f78fc2fSjtc #define REG_BADBR 10 1189f78fc2fSjtc #define REG_ERANGE 11 1199f78fc2fSjtc #define REG_ESPACE 12 1209f78fc2fSjtc #define REG_BADRPT 13 1219f78fc2fSjtc #define REG_EMPTY 14 1229f78fc2fSjtc #define REG_ASSERT 15 1239f78fc2fSjtc #define REG_INVARG 16 124cc8bab37Schristos #define REG_ILLSEQ 17 1259f78fc2fSjtc #define REG_ATOI 255 /* convert name to number (!) */ 1269f78fc2fSjtc #define REG_ITOA 0400 /* convert number to name (!) */ 1279f78fc2fSjtc 12805903d2bScgd /* regexec() flags */ 1299f78fc2fSjtc #define REG_NOTBOL 00001 1309f78fc2fSjtc #define REG_NOTEOL 00002 1319f78fc2fSjtc #define REG_STARTEND 00004 1329f78fc2fSjtc #define REG_TRACE 00400 /* tracing of execution */ 1339f78fc2fSjtc #define REG_LARGE 01000 /* force large representation */ 1349f78fc2fSjtc #define REG_BACKR 02000 /* force use of backref code */ 1359f78fc2fSjtc 13605903d2bScgd __BEGIN_DECLS 13719b7469aSperry int regcomp(regex_t * __restrict, const char * __restrict, int); 13819b7469aSperry size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); 13919b7469aSperry int regexec(const regex_t * __restrict, 14019b7469aSperry const char * __restrict, size_t, regmatch_t [], int); 14119b7469aSperry void regfree(regex_t *); 1424c892c32Schristos #ifdef _NETBSD_SOURCE 1431a175d5bSchristos ssize_t regnsub(char *, size_t, const char *, const regmatch_t *, const char *); 1444c892c32Schristos ssize_t regasub(char **buf, const char *, const regmatch_t *, const char *); 1454c892c32Schristos #endif 14605903d2bScgd __END_DECLS 1479f78fc2fSjtc 14805903d2bScgd #endif /* !_REGEX_H_ */ 149