hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

regex.h (5981B)


      1 /*
      2  * Changes by Gunnar Ritter, Freiburg i. Br., Germany, November 2002.
      3  *
      4  * Sccsid @(#)regex.h	1.13 (gritter) 2/6/05
      5  */
      6 /*  UNIX(R) Regular Expresssion Library
      7  *
      8  *  Note: Code is released under the GNU LGPL
      9  *
     10  *  Copyright (C) 2001 Caldera International, Inc.
     11  *
     12  *  This library is free software; you can redistribute it and/or
     13  *  modify it under the terms of the GNU Lesser General Public
     14  *  License as published by the Free Software Foundation; either
     15  *  version 2 of the License, or (at your option) any later version.
     16  *
     17  *  This library is distributed in the hope that it will be useful,
     18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     20  *  Lesser General Public License for more details.
     21  *
     22  *  You should have received a copy of the GNU Lesser General Public
     23  *  License along with this library; if not, write to:
     24  *        Free Software Foundation, Inc.
     25  *        59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     26  */
     27 
     28 #ifndef LIBUXRE_REGEX_H
     29 #define LIBUXRE_REGEX_H
     30 /*	from unixsrc:usr/src/common/head/regex.h /main/uw7_nj/1	*/
     31 
     32 #include <sys/types.h>	/* really only want [s]size_t */
     33 
     34 	/*
     35 	* Official regexec() flags.
     36 	*/
     37 #define REG_NOTBOL	0x000001 /* start of string does not match ^ */
     38 #define REG_NOTEOL	0x000002 /* end of string does not match $ */
     39 
     40 	/*
     41 	* Additional regexec() flags.
     42 	*/
     43 #define REG_NONEMPTY	0x000004 /* do not match empty at start of string */
     44 
     45 	/*
     46 	* Extensions to provide individual control over each
     47 	* of the differences between basic and extended REs.
     48 	*/
     49 #define REG_OR		0x0000001 /* enable | operator */
     50 #define REG_PLUS	0x0000002 /* enable + operator */
     51 #define REG_QUEST	0x0000004 /* enable ? operator */
     52 #define REG_BRACES	0x0000008 /* use {m,n} (instead of \{m,n\}) */
     53 #define REG_PARENS	0x0000010 /* use (...) [instead of \(...\)] */
     54 #define REG_ANCHORS	0x0000020 /* ^ and $ are anchors anywhere */
     55 #define REG_NOBACKREF	0x0000040 /* disable \digit */
     56 #define REG_NOAUTOQUOTE	0x0000080 /* no automatic quoting of REG_BADRPTs */
     57 
     58 	/*
     59 	* Official regcomp() flags.
     60 	*/
     61 #define REG_EXTENDED	(REG_OR | REG_PLUS | REG_QUEST | REG_BRACES | \
     62 				REG_PARENS | REG_ANCHORS | \
     63 				REG_NOBACKREF | REG_NOAUTOQUOTE)
     64 #define REG_ICASE	0x0000100 /* ignore case */
     65 #define REG_NOSUB	0x0000200 /* only success/fail for regexec() */
     66 #define REG_NEWLINE	0x0000400 /* take \n as line separator for ^ and $ */
     67 
     68 	/*
     69 	* Additional regcomp() flags.
     70 	* Some of these assume that int is >16 bits!
     71 	* Beware: 0x20000000 and above are used in re.h.
     72 	*/
     73 #define REG_ONESUB	0x0000800 /* regexec() only needs pmatch[0] */
     74 #define REG_MTPARENFAIL	0x0001000 /* take empty \(\) or () as match failure */
     75 #define REG_MTPARENBAD	0x0002000 /* disallow empty \(\) or () */
     76 #define REG_BADRANGE	0x0004000 /* accept [m-a] ranges as [ma] */
     77 #define	REG_ODDRANGE	0x0008000 /* oawk oddity: [m-a] means [m] */
     78 #define REG_SEPRANGE	0x0010000 /* disallow [a-m-z] style ranges */
     79 #define REG_BKTQUOTE	0x0020000 /* allow \ in []s to quote \, -, ^ or ] */
     80 #define REG_BKTEMPTY	0x0040000 /* allow empty []s (w/BKTQUOTE, BKTESCAPE) */
     81 #define REG_ANGLES	0x0080000 /* enable \<, \> operators */
     82 #define REG_ESCNL	0x0100000 /* take \n as newline character */
     83 #define REG_NLALT	0x0200000 /* take newline as alternation */
     84 #define REG_ESCSEQ	0x0400000 /* otherwise, take \ as start of C escapes */
     85 #define REG_BKTESCAPE	0x0800000 /* allow \ in []s to quote next anything */
     86 #define	REG_NOBRACES	0x1000000 /* disable {n,m} */
     87 #define	REG_ADDITIVE	0x2000000 /* a+*b means + and * additive, ^+ is valid */
     88 #define	REG_NOI18N	0x4000000 /* disable I18N features ([::] etc.) */
     89 #define	REG_OLDESC	0x8000000 /* recognize \b \f \n \r \t \123 only */
     90 #define	REG_AVOIDNULL	0x10000000/* avoid null subexpression matches */
     91 #define REG_OLDBRE	(REG_BADRANGE | REG_ANGLES | REG_ESCNL)
     92 #define REG_OLDERE	(REG_OR | REG_PLUS | REG_QUEST | REG_NOBRACES | \
     93 				REG_PARENS | REG_ANCHORS | REG_ODDRANGE | \
     94 				REG_NOBACKREF | REG_ADDITIVE | REG_NOAUTOQUOTE)
     95 
     96 	/*
     97 	* Error return values.
     98 	*/
     99 #define REG_ENOSYS	(-1)	/* unsupported */
    100 #define	REG_NOMATCH	1	/* regexec() failed to match */
    101 #define	REG_BADPAT	2	/* invalid regular expression */
    102 #define	REG_ECOLLATE	3	/* invalid collating element construct */
    103 #define	REG_ECTYPE	4	/* invalid character class construct */
    104 #define REG_EEQUIV	5	/* invalid equivalence class construct */
    105 #define REG_EBKTCHAR	6	/* invalid character in [] construct */
    106 #define	REG_EESCAPE	7	/* trailing \ in pattern */
    107 #define	REG_ESUBREG	8	/* number in \digit invalid or in error */
    108 #define	REG_EBRACK	9	/* [] imbalance */
    109 #define REG_EMPTYSUBBKT	10	/* empty sub-bracket construct */
    110 #define REG_EMPTYPAREN	11	/* empty \(\) or () [REG_MTPARENBAD] */
    111 #define REG_NOPAT	12	/* no (empty) pattern */
    112 #define	REG_EPAREN	13	/* \(\) or () imbalance */
    113 #define	REG_EBRACE	14	/* \{\} or {} imbalance */
    114 #define	REG_BADBR	15	/* contents of \{\} or {} invalid */
    115 #define	REG_ERANGE	16	/* invalid endpoint in expression */
    116 #define	REG_ESPACE	17	/* out of memory */
    117 #define	REG_BADRPT	18	/* *,+,?,\{\} or {} not after r.e. */
    118 #define REG_BADESC	19	/* invalid escape sequence (e.g. \0) */
    119 #define	REG_ILLSEQ	20	/* illegal byte sequence */
    120 
    121 typedef struct
    122 {
    123 	size_t		re_nsub;	/* only advertised member */
    124 	unsigned long	re_flags;	/* augmented regcomp() flags */
    125 	struct re_dfa_	*re_dfa;	/* DFA engine */
    126 	struct re_nfa_	*re_nfa;	/* NFA engine */
    127 	struct re_coll_	*re_col;	/* current collation info */
    128 	int		re_mb_cur_max;	/* MB_CUR_MAX acceleration */
    129 	void		*re_more;	/* just in case... */
    130 } regex_t;
    131 
    132 typedef ssize_t regoff_t;
    133 
    134 typedef struct
    135 {
    136 	regoff_t	rm_so;
    137 	regoff_t	rm_eo;
    138 } regmatch_t;
    139 
    140 #ifdef __cplusplus
    141 extern "C" {
    142 #endif
    143 
    144 int	regcomp(regex_t *, const char *, int);
    145 int	regexec(const regex_t *, const char *, size_t, regmatch_t *, int);
    146 size_t	regerror(int, const regex_t *, char *, size_t);
    147 void	regfree(regex_t *);
    148 
    149 #ifdef __cplusplus
    150 }
    151 #endif
    152 
    153 #endif /* !LIBUXRE_REGEX_H */