pcre.h

Go to the documentation of this file.
00001 /*************************************************
00002 *       Perl-Compatible Regular Expressions      *
00003 *************************************************/
00004 
00005 /* This is the public header file for the PCRE library, to be #included by
00006 applications that call the PCRE functions.
00007 
00008            Copyright (c) 1997-2007 University of Cambridge
00009 
00010 -----------------------------------------------------------------------------
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014     * Redistributions of source code must retain the above copyright notice,
00015       this list of conditions and the following disclaimer.
00016 
00017     * Redistributions in binary form must reproduce the above copyright
00018       notice, this list of conditions and the following disclaimer in the
00019       documentation and/or other materials provided with the distribution.
00020 
00021     * Neither the name of the University of Cambridge nor the names of its
00022       contributors may be used to endorse or promote products derived from
00023       this software without specific prior written permission.
00024 
00025 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00029 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00030 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00031 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00032 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00033 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00034 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035 POSSIBILITY OF SUCH DAMAGE.
00036 -----------------------------------------------------------------------------
00037 */
00038 
00039 #ifndef _PCRE_H
00040 #define _PCRE_H
00041 
00042 /* The current PCRE version information. */
00043 
00044 #define PCRE_MAJOR          7
00045 #define PCRE_MINOR          4
00046 #define PCRE_PRERELEASE     
00047 #define PCRE_DATE           2007-09-21
00048 
00049 #define PCRE_STATIC
00050 
00051 /* When an application links to a PCRE DLL in Windows, the symbols that are
00052 imported have to be identified as such. When building PCRE, the appropriate
00053 export setting is defined in pcre_internal.h, which includes this file. So we
00054 don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
00055 
00056 #if defined(_WIN32) && !defined(PCRE_STATIC)
00057 #  ifndef PCRE_EXP_DECL
00058 #    define PCRE_EXP_DECL  extern __declspec(dllimport)
00059 #  endif
00060 #  ifdef __cplusplus
00061 #    ifndef PCRECPP_EXP_DECL
00062 #      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
00063 #    endif
00064 #    ifndef PCRECPP_EXP_DEFN
00065 #      define PCRECPP_EXP_DEFN  __declspec(dllimport)
00066 #    endif
00067 #  endif
00068 #endif
00069 
00070 /* By default, we use the standard "extern" declarations. */
00071 
00072 #ifndef PCRE_EXP_DECL
00073 #  ifdef __cplusplus
00074 #    define PCRE_EXP_DECL  extern "C"
00075 #  else
00076 #    define PCRE_EXP_DECL  extern
00077 #  endif
00078 #endif
00079 
00080 #ifdef __cplusplus
00081 #  ifndef PCRECPP_EXP_DECL
00082 #    define PCRECPP_EXP_DECL  extern
00083 #  endif
00084 #  ifndef PCRECPP_EXP_DEFN
00085 #    define PCRECPP_EXP_DEFN
00086 #  endif
00087 #endif
00088 
00089 /* Have to include stdlib.h in order to ensure that size_t is defined;
00090 it is needed here for malloc. */
00091 
00092 #include <stdlib.h>
00093 
00094 /* Allow for C++ users */
00095 
00096 #ifdef __cplusplus
00097 extern "C" {
00098 #endif
00099 
00100 /* Options */
00101 
00102 #define PCRE_CASELESS           0x00000001
00103 #define PCRE_MULTILINE          0x00000002
00104 #define PCRE_DOTALL             0x00000004
00105 #define PCRE_EXTENDED           0x00000008
00106 #define PCRE_ANCHORED           0x00000010
00107 #define PCRE_DOLLAR_ENDONLY     0x00000020
00108 #define PCRE_EXTRA              0x00000040
00109 #define PCRE_NOTBOL             0x00000080
00110 #define PCRE_NOTEOL             0x00000100
00111 #define PCRE_UNGREEDY           0x00000200
00112 #define PCRE_NOTEMPTY           0x00000400
00113 #define PCRE_UTF8               0x00000800
00114 #define PCRE_NO_AUTO_CAPTURE    0x00001000
00115 #define PCRE_NO_UTF8_CHECK      0x00002000
00116 #define PCRE_AUTO_CALLOUT       0x00004000
00117 #define PCRE_PARTIAL            0x00008000
00118 #define PCRE_DFA_SHORTEST       0x00010000
00119 #define PCRE_DFA_RESTART        0x00020000
00120 #define PCRE_FIRSTLINE          0x00040000
00121 #define PCRE_DUPNAMES           0x00080000
00122 #define PCRE_NEWLINE_CR         0x00100000
00123 #define PCRE_NEWLINE_LF         0x00200000
00124 #define PCRE_NEWLINE_CRLF       0x00300000
00125 #define PCRE_NEWLINE_ANY        0x00400000
00126 #define PCRE_NEWLINE_ANYCRLF    0x00500000
00127 #define PCRE_BSR_ANYCRLF        0x00800000
00128 #define PCRE_BSR_UNICODE        0x01000000
00129 #define PCRE_JAVASCRIPT_COMPAT  0x02000000
00130 
00131 /* Exec-time and get/set-time error codes */
00132 
00133 #define PCRE_ERROR_NOMATCH         (-1)
00134 #define PCRE_ERROR_NULL            (-2)
00135 #define PCRE_ERROR_BADOPTION       (-3)
00136 #define PCRE_ERROR_BADMAGIC        (-4)
00137 #define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
00138 #define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
00139 #define PCRE_ERROR_NOMEMORY        (-6)
00140 #define PCRE_ERROR_NOSUBSTRING     (-7)
00141 #define PCRE_ERROR_MATCHLIMIT      (-8)
00142 #define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
00143 #define PCRE_ERROR_BADUTF8        (-10)
00144 #define PCRE_ERROR_BADUTF8_OFFSET (-11)
00145 #define PCRE_ERROR_PARTIAL        (-12)
00146 #define PCRE_ERROR_BADPARTIAL     (-13)
00147 #define PCRE_ERROR_INTERNAL       (-14)
00148 #define PCRE_ERROR_BADCOUNT       (-15)
00149 #define PCRE_ERROR_DFA_UITEM      (-16)
00150 #define PCRE_ERROR_DFA_UCOND      (-17)
00151 #define PCRE_ERROR_DFA_UMLIMIT    (-18)
00152 #define PCRE_ERROR_DFA_WSSIZE     (-19)
00153 #define PCRE_ERROR_DFA_RECURSE    (-20)
00154 #define PCRE_ERROR_RECURSIONLIMIT (-21)
00155 #define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
00156 #define PCRE_ERROR_BADNEWLINE     (-23)
00157 
00158 /* Request types for pcre_fullinfo() */
00159 
00160 #define PCRE_INFO_OPTIONS            0
00161 #define PCRE_INFO_SIZE               1
00162 #define PCRE_INFO_CAPTURECOUNT       2
00163 #define PCRE_INFO_BACKREFMAX         3
00164 #define PCRE_INFO_FIRSTBYTE          4
00165 #define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
00166 #define PCRE_INFO_FIRSTTABLE         5
00167 #define PCRE_INFO_LASTLITERAL        6
00168 #define PCRE_INFO_NAMEENTRYSIZE      7
00169 #define PCRE_INFO_NAMECOUNT          8
00170 #define PCRE_INFO_NAMETABLE          9
00171 #define PCRE_INFO_STUDYSIZE         10
00172 #define PCRE_INFO_DEFAULT_TABLES    11
00173 #define PCRE_INFO_OKPARTIAL         12
00174 #define PCRE_INFO_JCHANGED          13
00175 #define PCRE_INFO_HASCRORLF         14
00176 
00177 /* Request types for pcre_config(). Do not re-arrange, in order to remain
00178 compatible. */
00179 
00180 #define PCRE_CONFIG_UTF8                    0
00181 #define PCRE_CONFIG_NEWLINE                 1
00182 #define PCRE_CONFIG_LINK_SIZE               2
00183 #define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
00184 #define PCRE_CONFIG_MATCH_LIMIT             4
00185 #define PCRE_CONFIG_STACKRECURSE            5
00186 #define PCRE_CONFIG_UNICODE_PROPERTIES      6
00187 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
00188 #define PCRE_CONFIG_BSR                     8
00189 
00190 /* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
00191 these bits, just add new ones on the end, in order to remain compatible. */
00192 
00193 #define PCRE_EXTRA_STUDY_DATA             0x0001
00194 #define PCRE_EXTRA_MATCH_LIMIT            0x0002
00195 #define PCRE_EXTRA_CALLOUT_DATA           0x0004
00196 #define PCRE_EXTRA_TABLES                 0x0008
00197 #define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
00198 
00199 /* Types */
00200 
00201 struct real_pcre;                 /* declaration; the definition is private  */
00202 typedef struct real_pcre pcre;
00203 
00204 /* When PCRE is compiled as a C++ library, the subject pointer type can be
00205 replaced with a custom type. For conventional use, the public interface is a
00206 const char *. */
00207 
00208 #ifndef PCRE_SPTR
00209 #define PCRE_SPTR const char *
00210 #endif
00211 
00212 /* The structure for passing additional data to pcre_exec(). This is defined in
00213 such as way as to be extensible. Always add new fields at the end, in order to
00214 remain compatible. */
00215 
00216 typedef struct pcre_extra {
00217   unsigned long int flags;        /* Bits for which fields are set */
00218   void *study_data;               /* Opaque data from pcre_study() */
00219   unsigned long int match_limit;  /* Maximum number of calls to match() */
00220   void *callout_data;             /* Data passed back in callouts */
00221   const unsigned char *tables;    /* Pointer to character tables */
00222   unsigned long int match_limit_recursion; /* Max recursive calls to match() */
00223 } pcre_extra;
00224 
00225 /* The structure for passing out data via the pcre_callout_function. We use a
00226 structure so that new fields can be added on the end in future versions,
00227 without changing the API of the function, thereby allowing old clients to work
00228 without modification. */
00229 
00230 typedef struct pcre_callout_block {
00231   int          version;           /* Identifies version of block */
00232   /* ------------------------ Version 0 ------------------------------- */
00233   int          callout_number;    /* Number compiled into pattern */
00234   int         *offset_vector;     /* The offset vector */
00235   PCRE_SPTR    subject;           /* The subject being matched */
00236   int          subject_length;    /* The length of the subject */
00237   int          start_match;       /* Offset to start of this match attempt */
00238   int          current_position;  /* Where we currently are in the subject */
00239   int          capture_top;       /* Max current capture */
00240   int          capture_last;      /* Most recently closed capture */
00241   void        *callout_data;      /* Data passed in with the call */
00242   /* ------------------- Added for Version 1 -------------------------- */
00243   int          pattern_position;  /* Offset to next item in the pattern */
00244   int          next_item_length;  /* Length of next item in the pattern */
00245   /* ------------------------------------------------------------------ */
00246 } pcre_callout_block;
00247 
00248 /* Indirection for store get and free functions. These can be set to
00249 alternative malloc/free functions if required. Special ones are used in the
00250 non-recursive case for "frames". There is also an optional callout function
00251 that is triggered by the (?) regex item. For Virtual Pascal, these definitions
00252 have to take another form. */
00253 
00254 #ifndef VPCOMPAT
00255 PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
00256 PCRE_EXP_DECL void  (*pcre_free)(void *);
00257 PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
00258 PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
00259 PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
00260 #else   /* VPCOMPAT */
00261 PCRE_EXP_DECL void *pcre_malloc(size_t);
00262 PCRE_EXP_DECL void  pcre_free(void *);
00263 PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
00264 PCRE_EXP_DECL void  pcre_stack_free(void *);
00265 PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
00266 #endif  /* VPCOMPAT */
00267 
00268 /* Exported PCRE functions */
00269 
00270 PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
00271                   const unsigned char *);
00272 PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
00273                   int *, const unsigned char *);
00274 PCRE_EXP_DECL int  pcre_config(int, void *);
00275 PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
00276                   int *, int, const char *, char *, int);
00277 PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
00278                   int);
00279 PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
00280                   const char *, int, int, int, int *, int , int *, int);
00281 PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
00282                    int, int, int, int *, int);
00283 PCRE_EXP_DECL void pcre_free_substring(const char *);
00284 PCRE_EXP_DECL void pcre_free_substring_list(const char **);
00285 PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
00286                   void *);
00287 PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
00288                   int *, int, const char *, const char **);
00289 PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
00290 PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
00291                   char **, char **);
00292 PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
00293                   const char **);
00294 PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
00295                   const char ***);
00296 PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
00297 PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
00298 PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
00299 PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
00300 PCRE_EXP_DECL const char *pcre_version(void);
00301 
00302 #ifdef __cplusplus
00303 }  /* extern "C" */
00304 #endif
00305 
00306 #endif /* End of pcre.h */

Generated on Tue Jul 5 14:11:56 2011 for ROOT_528-00b_version by  doxygen 1.5.1