11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1992 Henry Spencer. 31539Srgrimes * Copyright (c) 1992, 1993 41539Srgrimes * The Regents of the University of California. All rights reserved. 51539Srgrimes * 61539Srgrimes * This code is derived from software contributed to Berkeley by 71539Srgrimes * Henry Spencer of the University of Toronto. 81539Srgrimes * 91539Srgrimes * Redistribution and use in source and binary forms, with or without 101539Srgrimes * modification, are permitted provided that the following conditions 111539Srgrimes * are met: 121539Srgrimes * 1. Redistributions of source code must retain the above copyright 131539Srgrimes * notice, this list of conditions and the following disclaimer. 141539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151539Srgrimes * notice, this list of conditions and the following disclaimer in the 161539Srgrimes * documentation and/or other materials provided with the distribution. 17203964Simp * 3. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 331539Srgrimes * @(#)regex.h 8.2 (Berkeley) 1/3/94 3493032Simp * $FreeBSD$ 351539Srgrimes */ 361539Srgrimes 371539Srgrimes#ifndef _REGEX_H_ 381539Srgrimes#define _REGEX_H_ 391539Srgrimes 401539Srgrimes#include <sys/cdefs.h> 41104356Smike#include <sys/_types.h> 421539Srgrimes 431539Srgrimes/* types */ 44104356Smiketypedef __off_t regoff_t; 451539Srgrimes 46104356Smike#ifndef _SIZE_T_DECLARED 47104356Smiketypedef __size_t size_t; 48104356Smike#define _SIZE_T_DECLARED 49104356Smike#endif 50104356Smike 511539Srgrimestypedef struct { 521539Srgrimes int re_magic; 531539Srgrimes size_t re_nsub; /* number of parenthesized subexpressions */ 54228468Sed const char *re_endp; /* end pointer for REG_PEND */ 551539Srgrimes struct re_guts *re_g; /* none of your business :-) */ 561539Srgrimes} regex_t; 571539Srgrimes 581539Srgrimestypedef struct { 591539Srgrimes regoff_t rm_so; /* start of match */ 601539Srgrimes regoff_t rm_eo; /* end of match */ 611539Srgrimes} regmatch_t; 621539Srgrimes 631539Srgrimes/* regcomp() flags */ 641539Srgrimes#define REG_BASIC 0000 651539Srgrimes#define REG_EXTENDED 0001 661539Srgrimes#define REG_ICASE 0002 671539Srgrimes#define REG_NOSUB 0004 681539Srgrimes#define REG_NEWLINE 0010 691539Srgrimes#define REG_NOSPEC 0020 701539Srgrimes#define REG_PEND 0040 711539Srgrimes#define REG_DUMP 0200 721539Srgrimes 731539Srgrimes/* regerror() flags */ 74123636Sjkh#define REG_ENOSYS (-1) 751539Srgrimes#define REG_NOMATCH 1 761539Srgrimes#define REG_BADPAT 2 771539Srgrimes#define REG_ECOLLATE 3 781539Srgrimes#define REG_ECTYPE 4 791539Srgrimes#define REG_EESCAPE 5 801539Srgrimes#define REG_ESUBREG 6 811539Srgrimes#define REG_EBRACK 7 821539Srgrimes#define REG_EPAREN 8 831539Srgrimes#define REG_EBRACE 9 841539Srgrimes#define REG_BADBR 10 851539Srgrimes#define REG_ERANGE 11 861539Srgrimes#define REG_ESPACE 12 871539Srgrimes#define REG_BADRPT 13 881539Srgrimes#define REG_EMPTY 14 891539Srgrimes#define REG_ASSERT 15 901539Srgrimes#define REG_INVARG 16 91132017Stjr#define REG_ILLSEQ 17 921539Srgrimes#define REG_ATOI 255 /* convert name to number (!) */ 931539Srgrimes#define REG_ITOA 0400 /* convert number to name (!) */ 941539Srgrimes 951539Srgrimes/* regexec() flags */ 961539Srgrimes#define REG_NOTBOL 00001 971539Srgrimes#define REG_NOTEOL 00002 981539Srgrimes#define REG_STARTEND 00004 991539Srgrimes#define REG_TRACE 00400 /* tracing of execution */ 1001539Srgrimes#define REG_LARGE 01000 /* force large representation */ 1011539Srgrimes#define REG_BACKR 02000 /* force use of backref code */ 1021539Srgrimes 1031539Srgrimes__BEGIN_DECLS 104104356Smikeint regcomp(regex_t * __restrict, const char * __restrict, int); 105104356Smikesize_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); 106104416Smike/* 107104416Smike * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because 108104416Smike * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a 109104416Smike * syntax error. 110104416Smike */ 111104356Smikeint regexec(const regex_t * __restrict, const char * __restrict, size_t, 112104416Smike regmatch_t * __restrict, int); 11393032Simpvoid regfree(regex_t *); 1141539Srgrimes__END_DECLS 1151539Srgrimes 1161539Srgrimes#endif /* !_REGEX_H_ */ 117