regex.h revision 203964
1251609Sdim/*- 2251609Sdim * Copyright (c) 1992 Henry Spencer. 3251609Sdim * Copyright (c) 1992, 1993 4251609Sdim * The Regents of the University of California. All rights reserved. 5251609Sdim * 6251609Sdim * This code is derived from software contributed to Berkeley by 7251609Sdim * Henry Spencer of the University of Toronto. 8251609Sdim * 9251609Sdim * Redistribution and use in source and binary forms, with or without 10251609Sdim * modification, are permitted provided that the following conditions 11251609Sdim * are met: 12251609Sdim * 1. Redistributions of source code must retain the above copyright 13251609Sdim * notice, this list of conditions and the following disclaimer. 14251609Sdim * 2. Redistributions in binary form must reproduce the above copyright 15251609Sdim * notice, this list of conditions and the following disclaimer in the 16251609Sdim * documentation and/or other materials provided with the distribution. 17251609Sdim * 3. Neither the name of the University nor the names of its contributors 18251609Sdim * may be used to endorse or promote products derived from this software 19251609Sdim * without specific prior written permission. 20263508Sdim * 21251609Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22251609Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23251609Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24251609Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25251609Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26251609Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27251609Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28263508Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29263508Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30263508Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31263508Sdim * SUCH DAMAGE. 32263508Sdim * 33263508Sdim * @(#)regex.h 8.2 (Berkeley) 1/3/94 34251609Sdim * $FreeBSD: head/include/regex.h 203964 2010-02-16 19:39:50Z imp $ 35251609Sdim */ 36263508Sdim 37263508Sdim#ifndef _REGEX_H_ 38263508Sdim#define _REGEX_H_ 39251609Sdim 40263508Sdim#include <sys/cdefs.h> 41263508Sdim#include <sys/_types.h> 42251609Sdim 43251609Sdim/* types */ 44263508Sdimtypedef __off_t regoff_t; 45263508Sdim 46263508Sdim#ifndef _SIZE_T_DECLARED 47263508Sdimtypedef __size_t size_t; 48263508Sdim#define _SIZE_T_DECLARED 49263508Sdim#endif 50263508Sdim 51263508Sdimtypedef struct { 52263508Sdim int re_magic; 53263508Sdim size_t re_nsub; /* number of parenthesized subexpressions */ 54263508Sdim __const char *re_endp; /* end pointer for REG_PEND */ 55263508Sdim struct re_guts *re_g; /* none of your business :-) */ 56263508Sdim} regex_t; 57251609Sdim 58251609Sdimtypedef struct { 59263508Sdim regoff_t rm_so; /* start of match */ 60263508Sdim regoff_t rm_eo; /* end of match */ 61251609Sdim} regmatch_t; 62251609Sdim 63263508Sdim/* regcomp() flags */ 64263508Sdim#define REG_BASIC 0000 65263508Sdim#define REG_EXTENDED 0001 66263508Sdim#define REG_ICASE 0002 67263508Sdim#define REG_NOSUB 0004 68263508Sdim#define REG_NEWLINE 0010 69263508Sdim#define REG_NOSPEC 0020 70263508Sdim#define REG_PEND 0040 71263508Sdim#define REG_DUMP 0200 72263508Sdim 73263508Sdim/* regerror() flags */ 74251609Sdim#define REG_ENOSYS (-1) 75263508Sdim#define REG_NOMATCH 1 76263508Sdim#define REG_BADPAT 2 77263508Sdim#define REG_ECOLLATE 3 78263508Sdim#define REG_ECTYPE 4 79263508Sdim#define REG_EESCAPE 5 80263508Sdim#define REG_ESUBREG 6 81251609Sdim#define REG_EBRACK 7 82263508Sdim#define REG_EPAREN 8 83263508Sdim#define REG_EBRACE 9 84263508Sdim#define REG_BADBR 10 85263508Sdim#define REG_ERANGE 11 86251609Sdim#define REG_ESPACE 12 87251609Sdim#define REG_BADRPT 13 88263508Sdim#define REG_EMPTY 14 89263508Sdim#define REG_ASSERT 15 90263508Sdim#define REG_INVARG 16 91263508Sdim#define REG_ILLSEQ 17 92251609Sdim#define REG_ATOI 255 /* convert name to number (!) */ 93263508Sdim#define REG_ITOA 0400 /* convert number to name (!) */ 94263508Sdim 95263508Sdim/* regexec() flags */ 96263508Sdim#define REG_NOTBOL 00001 97251609Sdim#define REG_NOTEOL 00002 98263508Sdim#define REG_STARTEND 00004 99263508Sdim#define REG_TRACE 00400 /* tracing of execution */ 100263508Sdim#define REG_LARGE 01000 /* force large representation */ 101263508Sdim#define REG_BACKR 02000 /* force use of backref code */ 102263508Sdim 103263508Sdim__BEGIN_DECLS 104251609Sdimint regcomp(regex_t * __restrict, const char * __restrict, int); 105263508Sdimsize_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); 106263508Sdim/* 107263508Sdim * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because 108263508Sdim * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a 109263508Sdim * syntax error. 110263508Sdim */ 111263508Sdimint regexec(const regex_t * __restrict, const char * __restrict, size_t, 112263508Sdim regmatch_t * __restrict, int); 113263508Sdimvoid regfree(regex_t *); 114251609Sdim__END_DECLS 115263508Sdim 116263508Sdim#endif /* !_REGEX_H_ */ 117263508Sdim