00001 /************************************************* 00002 * Perl-Compatible Regular Expressions * 00003 *************************************************/ 00004 00005 #ifndef _PCREPOSIX_H 00006 #define _PCREPOSIX_H 00007 00008 /* This is the header for the POSIX wrapper interface to the PCRE Perl- 00009 Compatible Regular Expression library. It defines the things POSIX says should 00010 be there. I hope. 00011 00012 Copyright (c) 1997-2008 University of Cambridge 00013 00014 ----------------------------------------------------------------------------- 00015 Redistribution and use in source and binary forms, with or without 00016 modification, are permitted provided that the following conditions are met: 00017 00018 * Redistributions of source code must retain the above copyright notice, 00019 this list of conditions and the following disclaimer. 00020 00021 * Redistributions in binary form must reproduce the above copyright 00022 notice, this list of conditions and the following disclaimer in the 00023 documentation and/or other materials provided with the distribution. 00024 00025 * Neither the name of the University of Cambridge nor the names of its 00026 contributors may be used to endorse or promote products derived from 00027 this software without specific prior written permission. 00028 00029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00030 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00031 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00032 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00033 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00034 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00035 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00036 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00037 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00039 POSSIBILITY OF SUCH DAMAGE. 00040 ----------------------------------------------------------------------------- 00041 */ 00042 00043 /* Have to include stdlib.h in order to ensure that size_t is defined. */ 00044 00045 #include <stdlib.h> 00046 00047 /* Allow for C++ users */ 00048 00049 #ifdef __cplusplus 00050 extern "C" { 00051 #endif 00052 00053 /* Options, mostly defined by POSIX, but with a couple of extras. */ 00054 00055 #define REG_ICASE 0x0001 00056 #define REG_NEWLINE 0x0002 00057 #define REG_NOTBOL 0x0004 00058 #define REG_NOTEOL 0x0008 00059 #define REG_DOTALL 0x0010 /* NOT defined by POSIX. */ 00060 #define REG_NOSUB 0x0020 00061 #define REG_UTF8 0x0040 /* NOT defined by POSIX. */ 00062 #define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */ 00063 00064 /* This is not used by PCRE, but by defining it we make it easier 00065 to slot PCRE into existing programs that make POSIX calls. */ 00066 00067 #define REG_EXTENDED 0 00068 00069 /* Error values. Not all these are relevant or used by the wrapper. */ 00070 00071 enum { 00072 REG_ASSERT = 1, /* internal error ? */ 00073 REG_BADBR, /* invalid repeat counts in {} */ 00074 REG_BADPAT, /* pattern error */ 00075 REG_BADRPT, /* ? * + invalid */ 00076 REG_EBRACE, /* unbalanced {} */ 00077 REG_EBRACK, /* unbalanced [] */ 00078 REG_ECOLLATE, /* collation error - not relevant */ 00079 REG_ECTYPE, /* bad class */ 00080 REG_EESCAPE, /* bad escape sequence */ 00081 REG_EMPTY, /* empty expression */ 00082 REG_EPAREN, /* unbalanced () */ 00083 REG_ERANGE, /* bad range inside [] */ 00084 REG_ESIZE, /* expression too big */ 00085 REG_ESPACE, /* failed to get memory */ 00086 REG_ESUBREG, /* bad back reference */ 00087 REG_INVARG, /* bad argument */ 00088 REG_NOMATCH /* match failed */ 00089 }; 00090 00091 00092 /* The structure representing a compiled regular expression. */ 00093 00094 typedef struct { 00095 void *re_pcre; 00096 size_t re_nsub; 00097 size_t re_erroffset; 00098 } regex_t; 00099 00100 /* The structure in which a captured offset is returned. */ 00101 00102 typedef int regoff_t; 00103 00104 typedef struct { 00105 regoff_t rm_so; 00106 regoff_t rm_eo; 00107 } regmatch_t; 00108 00109 /* When an application links to a PCRE DLL in Windows, the symbols that are 00110 imported have to be identified as such. When building PCRE, the appropriate 00111 export settings are needed, and are set in pcreposix.c before including this 00112 file. */ 00113 00114 #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL) 00115 # define PCREPOSIX_EXP_DECL extern __declspec(dllimport) 00116 # define PCREPOSIX_EXP_DEFN __declspec(dllimport) 00117 #endif 00118 00119 /* By default, we use the standard "extern" declarations. */ 00120 00121 #ifndef PCREPOSIX_EXP_DECL 00122 # ifdef __cplusplus 00123 # define PCREPOSIX_EXP_DECL extern "C" 00124 # define PCREPOSIX_EXP_DEFN extern "C" 00125 # else 00126 # define PCREPOSIX_EXP_DECL extern 00127 # define PCREPOSIX_EXP_DEFN extern 00128 # endif 00129 #endif 00130 00131 /* The functions */ 00132 00133 PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int); 00134 PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t, 00135 regmatch_t *, int); 00136 PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t); 00137 PCREPOSIX_EXP_DECL void regfree(regex_t *); 00138 00139 #ifdef __cplusplus 00140 } /* extern "C" */ 00141 #endif 00142 00143 #endif /* End of pcreposix.h */