regex.h revision 104416
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. 171539Srgrimes * 3. All advertising materials mentioning features or use of this software 181539Srgrimes * must display the following acknowledgement: 191539Srgrimes * This product includes software developed by the University of 201539Srgrimes * California, Berkeley and its contributors. 211539Srgrimes * 4. Neither the name of the University nor the names of its contributors 221539Srgrimes * may be used to endorse or promote products derived from this software 231539Srgrimes * without specific prior written permission. 241539Srgrimes * 251539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 351539Srgrimes * SUCH DAMAGE. 361539Srgrimes * 371539Srgrimes * @(#)regex.h 8.2 (Berkeley) 1/3/94 3893032Simp * $FreeBSD: head/include/regex.h 104416 2002-10-03 18:12:03Z mike $ 391539Srgrimes */ 401539Srgrimes 411539Srgrimes#ifndef _REGEX_H_ 421539Srgrimes#define _REGEX_H_ 431539Srgrimes 441539Srgrimes#include <sys/cdefs.h> 45104356Smike#include <sys/_types.h> 461539Srgrimes 471539Srgrimes/* types */ 48104356Smiketypedef __off_t regoff_t; 491539Srgrimes 50104356Smike#ifndef _SIZE_T_DECLARED 51104356Smiketypedef __size_t size_t; 52104356Smike#define _SIZE_T_DECLARED 53104356Smike#endif 54104356Smike 551539Srgrimestypedef struct { 561539Srgrimes int re_magic; 571539Srgrimes size_t re_nsub; /* number of parenthesized subexpressions */ 581539Srgrimes __const char *re_endp; /* end pointer for REG_PEND */ 591539Srgrimes struct re_guts *re_g; /* none of your business :-) */ 601539Srgrimes} regex_t; 611539Srgrimes 621539Srgrimestypedef struct { 631539Srgrimes regoff_t rm_so; /* start of match */ 641539Srgrimes regoff_t rm_eo; /* end of match */ 651539Srgrimes} regmatch_t; 661539Srgrimes 671539Srgrimes/* regcomp() flags */ 681539Srgrimes#define REG_BASIC 0000 691539Srgrimes#define REG_EXTENDED 0001 701539Srgrimes#define REG_ICASE 0002 711539Srgrimes#define REG_NOSUB 0004 721539Srgrimes#define REG_NEWLINE 0010 731539Srgrimes#define REG_NOSPEC 0020 741539Srgrimes#define REG_PEND 0040 751539Srgrimes#define REG_DUMP 0200 761539Srgrimes 771539Srgrimes/* regerror() flags */ 781539Srgrimes#define REG_NOMATCH 1 791539Srgrimes#define REG_BADPAT 2 801539Srgrimes#define REG_ECOLLATE 3 811539Srgrimes#define REG_ECTYPE 4 821539Srgrimes#define REG_EESCAPE 5 831539Srgrimes#define REG_ESUBREG 6 841539Srgrimes#define REG_EBRACK 7 851539Srgrimes#define REG_EPAREN 8 861539Srgrimes#define REG_EBRACE 9 871539Srgrimes#define REG_BADBR 10 881539Srgrimes#define REG_ERANGE 11 891539Srgrimes#define REG_ESPACE 12 901539Srgrimes#define REG_BADRPT 13 911539Srgrimes#define REG_EMPTY 14 921539Srgrimes#define REG_ASSERT 15 931539Srgrimes#define REG_INVARG 16 941539Srgrimes#define REG_ATOI 255 /* convert name to number (!) */ 951539Srgrimes#define REG_ITOA 0400 /* convert number to name (!) */ 961539Srgrimes 971539Srgrimes/* regexec() flags */ 981539Srgrimes#define REG_NOTBOL 00001 991539Srgrimes#define REG_NOTEOL 00002 1001539Srgrimes#define REG_STARTEND 00004 1011539Srgrimes#define REG_TRACE 00400 /* tracing of execution */ 1021539Srgrimes#define REG_LARGE 01000 /* force large representation */ 1031539Srgrimes#define REG_BACKR 02000 /* force use of backref code */ 1041539Srgrimes 1051539Srgrimes__BEGIN_DECLS 106104356Smikeint regcomp(regex_t * __restrict, const char * __restrict, int); 107104356Smikesize_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); 108104416Smike/* 109104416Smike * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because 110104416Smike * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a 111104416Smike * syntax error. 112104416Smike */ 113104356Smikeint regexec(const regex_t * __restrict, const char * __restrict, size_t, 114104416Smike regmatch_t * __restrict, int); 11593032Simpvoid regfree(regex_t *); 1161539Srgrimes__END_DECLS 1171539Srgrimes 1181539Srgrimes#endif /* !_REGEX_H_ */ 119