Back to index

php5  5.3.10
pcreposix.h
Go to the documentation of this file.
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-2009 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 some extras. */
00054 
00055 #define REG_ICASE     0x0001   /* Maps to PCRE_CASELESS */
00056 #define REG_NEWLINE   0x0002   /* Maps to PCRE_MULTILINE */
00057 #define REG_NOTBOL    0x0004   /* Maps to PCRE_NOTBOL */
00058 #define REG_NOTEOL    0x0008   /* Maps to PCRE_NOTEOL */
00059 #define REG_DOTALL    0x0010   /* NOT defined by POSIX; maps to PCRE_DOTALL */
00060 #define REG_NOSUB     0x0020   /* Maps to PCRE_NO_AUTO_CAPTURE */
00061 #define REG_UTF8      0x0040   /* NOT defined by POSIX; maps to PCRE_UTF8 */
00062 #define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
00063 #define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
00064 #define REG_UNGREEDY  0x0200   /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
00065 #define REG_UCP       0x0400   /* NOT defined by POSIX; maps to PCRE_UCP */
00066 
00067 /* This is not used by PCRE, but by defining it we make it easier
00068 to slot PCRE into existing programs that make POSIX calls. */
00069 
00070 #define REG_EXTENDED  0
00071 
00072 /* Error values. Not all these are relevant or used by the wrapper. */
00073 
00074 enum {
00075   REG_ASSERT = 1,  /* internal error ? */
00076   REG_BADBR,       /* invalid repeat counts in {} */
00077   REG_BADPAT,      /* pattern error */
00078   REG_BADRPT,      /* ? * + invalid */
00079   REG_EBRACE,      /* unbalanced {} */
00080   REG_EBRACK,      /* unbalanced [] */
00081   REG_ECOLLATE,    /* collation error - not relevant */
00082   REG_ECTYPE,      /* bad class */
00083   REG_EESCAPE,     /* bad escape sequence */
00084   REG_EMPTY,       /* empty expression */
00085   REG_EPAREN,      /* unbalanced () */
00086   REG_ERANGE,      /* bad range inside [] */
00087   REG_ESIZE,       /* expression too big */
00088   REG_ESPACE,      /* failed to get memory */
00089   REG_ESUBREG,     /* bad back reference */
00090   REG_INVARG,      /* bad argument */
00091   REG_NOMATCH      /* match failed */
00092 };
00093 
00094 
00095 /* The structure representing a compiled regular expression. */
00096 
00097 typedef struct {
00098   void *re_pcre;
00099   size_t re_nsub;
00100   size_t re_erroffset;
00101 } regex_t;
00102 
00103 /* The structure in which a captured offset is returned. */
00104 
00105 typedef int regoff_t;
00106 
00107 typedef struct {
00108   regoff_t rm_so;
00109   regoff_t rm_eo;
00110 } regmatch_t;
00111 
00112 /* When an application links to a PCRE DLL in Windows, the symbols that are
00113 imported have to be identified as such. When building PCRE, the appropriate
00114 export settings are needed, and are set in pcreposix.c before including this
00115 file. */
00116 
00117 #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
00118 #  define PCREPOSIX_EXP_DECL  extern __declspec(dllimport)
00119 #  define PCREPOSIX_EXP_DEFN  __declspec(dllimport)
00120 #endif
00121 
00122 /* By default, we use the standard "extern" declarations. */
00123 
00124 #ifndef PCREPOSIX_EXP_DECL
00125 #  ifdef __cplusplus
00126 #    define PCREPOSIX_EXP_DECL  extern "C"
00127 #    define PCREPOSIX_EXP_DEFN  extern "C"
00128 #  else
00129 #    define PCREPOSIX_EXP_DECL  extern
00130 #    define PCREPOSIX_EXP_DEFN  extern
00131 #  endif
00132 #endif
00133 
00134 /* The functions */
00135 
00136 PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
00137 PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
00138                      regmatch_t *, int);
00139 PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
00140 PCREPOSIX_EXP_DECL void regfree(regex_t *);
00141 
00142 #ifdef __cplusplus
00143 }   /* extern "C" */
00144 #endif
00145 
00146 #endif /* End of pcreposix.h */