jpayne@69: /************************************************* jpayne@69: * Perl-Compatible Regular Expressions * jpayne@69: *************************************************/ jpayne@69: jpayne@69: #ifndef _PCREPOSIX_H jpayne@69: #define _PCREPOSIX_H jpayne@69: jpayne@69: /* This is the header for the POSIX wrapper interface to the PCRE Perl- jpayne@69: Compatible Regular Expression library. It defines the things POSIX says should jpayne@69: be there. I hope. jpayne@69: jpayne@69: Copyright (c) 1997-2012 University of Cambridge jpayne@69: jpayne@69: ----------------------------------------------------------------------------- jpayne@69: Redistribution and use in source and binary forms, with or without jpayne@69: modification, are permitted provided that the following conditions are met: jpayne@69: jpayne@69: * Redistributions of source code must retain the above copyright notice, jpayne@69: this list of conditions and the following disclaimer. jpayne@69: jpayne@69: * Redistributions in binary form must reproduce the above copyright jpayne@69: notice, this list of conditions and the following disclaimer in the jpayne@69: documentation and/or other materials provided with the distribution. jpayne@69: jpayne@69: * Neither the name of the University of Cambridge nor the names of its jpayne@69: contributors may be used to endorse or promote products derived from jpayne@69: this software without specific prior written permission. jpayne@69: jpayne@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" jpayne@69: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE jpayne@69: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE jpayne@69: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE jpayne@69: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR jpayne@69: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF jpayne@69: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS jpayne@69: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN jpayne@69: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) jpayne@69: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE jpayne@69: POSSIBILITY OF SUCH DAMAGE. jpayne@69: ----------------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: /* Have to include stdlib.h in order to ensure that size_t is defined. */ jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* Allow for C++ users */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Options, mostly defined by POSIX, but with some extras. */ jpayne@69: jpayne@69: #define REG_ICASE 0x0001 /* Maps to PCRE_CASELESS */ jpayne@69: #define REG_NEWLINE 0x0002 /* Maps to PCRE_MULTILINE */ jpayne@69: #define REG_NOTBOL 0x0004 /* Maps to PCRE_NOTBOL */ jpayne@69: #define REG_NOTEOL 0x0008 /* Maps to PCRE_NOTEOL */ jpayne@69: #define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE_DOTALL */ jpayne@69: #define REG_NOSUB 0x0020 /* Maps to PCRE_NO_AUTO_CAPTURE */ jpayne@69: #define REG_UTF8 0x0040 /* NOT defined by POSIX; maps to PCRE_UTF8 */ jpayne@69: #define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */ jpayne@69: #define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */ jpayne@69: #define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE_UNGREEDY */ jpayne@69: #define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE_UCP */ jpayne@69: jpayne@69: /* This is not used by PCRE, but by defining it we make it easier jpayne@69: to slot PCRE into existing programs that make POSIX calls. */ jpayne@69: jpayne@69: #define REG_EXTENDED 0 jpayne@69: jpayne@69: /* Error values. Not all these are relevant or used by the wrapper. */ jpayne@69: jpayne@69: enum { jpayne@69: REG_ASSERT = 1, /* internal error ? */ jpayne@69: REG_BADBR, /* invalid repeat counts in {} */ jpayne@69: REG_BADPAT, /* pattern error */ jpayne@69: REG_BADRPT, /* ? * + invalid */ jpayne@69: REG_EBRACE, /* unbalanced {} */ jpayne@69: REG_EBRACK, /* unbalanced [] */ jpayne@69: REG_ECOLLATE, /* collation error - not relevant */ jpayne@69: REG_ECTYPE, /* bad class */ jpayne@69: REG_EESCAPE, /* bad escape sequence */ jpayne@69: REG_EMPTY, /* empty expression */ jpayne@69: REG_EPAREN, /* unbalanced () */ jpayne@69: REG_ERANGE, /* bad range inside [] */ jpayne@69: REG_ESIZE, /* expression too big */ jpayne@69: REG_ESPACE, /* failed to get memory */ jpayne@69: REG_ESUBREG, /* bad back reference */ jpayne@69: REG_INVARG, /* bad argument */ jpayne@69: REG_NOMATCH /* match failed */ jpayne@69: }; jpayne@69: jpayne@69: jpayne@69: /* The structure representing a compiled regular expression. */ jpayne@69: jpayne@69: typedef struct { jpayne@69: void *re_pcre; jpayne@69: size_t re_nsub; jpayne@69: size_t re_erroffset; jpayne@69: } regex_t; jpayne@69: jpayne@69: /* The structure in which a captured offset is returned. */ jpayne@69: jpayne@69: typedef int regoff_t; jpayne@69: jpayne@69: typedef struct { jpayne@69: regoff_t rm_so; jpayne@69: regoff_t rm_eo; jpayne@69: } regmatch_t; jpayne@69: jpayne@69: /* When an application links to a PCRE DLL in Windows, the symbols that are jpayne@69: imported have to be identified as such. When building PCRE, the appropriate jpayne@69: export settings are needed, and are set in pcreposix.c before including this jpayne@69: file. */ jpayne@69: jpayne@69: #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL) jpayne@69: # define PCREPOSIX_EXP_DECL extern __declspec(dllimport) jpayne@69: # define PCREPOSIX_EXP_DEFN __declspec(dllimport) jpayne@69: #endif jpayne@69: jpayne@69: /* By default, we use the standard "extern" declarations. */ jpayne@69: jpayne@69: #ifndef PCREPOSIX_EXP_DECL jpayne@69: # ifdef __cplusplus jpayne@69: # define PCREPOSIX_EXP_DECL extern "C" jpayne@69: # define PCREPOSIX_EXP_DEFN extern "C" jpayne@69: # else jpayne@69: # define PCREPOSIX_EXP_DECL extern jpayne@69: # define PCREPOSIX_EXP_DEFN extern jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: /* The functions */ jpayne@69: jpayne@69: PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int); jpayne@69: PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t, jpayne@69: regmatch_t *, int); jpayne@69: PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t); jpayne@69: PCREPOSIX_EXP_DECL void regfree(regex_t *); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } /* extern "C" */ jpayne@69: #endif jpayne@69: jpayne@69: #endif /* End of pcreposix.h */