extensions/regex/pcre.h
author Nicholas Hastings <skamonkey@gmail.com>
Mon Jun 14 09:32:50 2010 -0400 (2010-06-14)
changeset 3041 a0587dee87ae
parent 1842 9a93a6e6ac01
child 3832 093c351b3957
permissions -rw-r--r--
Fixed outputname null pointer crash in sdktools (bug 4422, r=fyren)
pred@1842
     1
/*************************************************
pred@1842
     2
*       Perl-Compatible Regular Expressions      *
pred@1842
     3
*************************************************/
pred@1842
     4
pred@1842
     5
/* This is the public header file for the PCRE library, to be #included by
pred@1842
     6
applications that call the PCRE functions.
pred@1842
     7
pred@1842
     8
           Copyright (c) 1997-2007 University of Cambridge
pred@1842
     9
pred@1842
    10
-----------------------------------------------------------------------------
pred@1842
    11
Redistribution and use in source and binary forms, with or without
pred@1842
    12
modification, are permitted provided that the following conditions are met:
pred@1842
    13
pred@1842
    14
    * Redistributions of source code must retain the above copyright notice,
pred@1842
    15
      this list of conditions and the following disclaimer.
pred@1842
    16
pred@1842
    17
    * Redistributions in binary form must reproduce the above copyright
pred@1842
    18
      notice, this list of conditions and the following disclaimer in the
pred@1842
    19
      documentation and/or other materials provided with the distribution.
pred@1842
    20
pred@1842
    21
    * Neither the name of the University of Cambridge nor the names of its
pred@1842
    22
      contributors may be used to endorse or promote products derived from
pred@1842
    23
      this software without specific prior written permission.
pred@1842
    24
pred@1842
    25
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
pred@1842
    26
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
pred@1842
    27
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
pred@1842
    28
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
pred@1842
    29
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
pred@1842
    30
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
pred@1842
    31
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
pred@1842
    32
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
pred@1842
    33
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
pred@1842
    34
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
pred@1842
    35
POSSIBILITY OF SUCH DAMAGE.
pred@1842
    36
-----------------------------------------------------------------------------
pred@1842
    37
*/
pred@1842
    38
pred@1842
    39
#ifndef _PCRE_H
pred@1842
    40
#define _PCRE_H
pred@1842
    41
pred@1842
    42
/* The current PCRE version information. */
pred@1842
    43
pred@1842
    44
#define PCRE_MAJOR          7
pred@1842
    45
#define PCRE_MINOR          4
pred@1842
    46
#define PCRE_PRERELEASE     
pred@1842
    47
#define PCRE_DATE           2007-09-21
pred@1842
    48
pred@1842
    49
/* When an application links to a PCRE DLL in Windows, the symbols that are
pred@1842
    50
imported have to be identified as such. When building PCRE, the appropriate
pred@1842
    51
export setting is defined in pcre_internal.h, which includes this file. So we
pred@1842
    52
don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
pred@1842
    53
pred@1842
    54
#define PCRE_STATIC
pred@1842
    55
pred@1842
    56
#if defined(_WIN32) && !defined(PCRE_STATIC)
pred@1842
    57
#  ifndef PCRE_EXP_DECL
pred@1842
    58
#    define PCRE_EXP_DECL  extern __declspec(dllimport)
pred@1842
    59
#  endif
pred@1842
    60
#  ifdef __cplusplus
pred@1842
    61
#    ifndef PCRECPP_EXP_DECL
pred@1842
    62
#      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
pred@1842
    63
#    endif
pred@1842
    64
#    ifndef PCRECPP_EXP_DEFN
pred@1842
    65
#      define PCRECPP_EXP_DEFN  __declspec(dllimport)
pred@1842
    66
#    endif
pred@1842
    67
#  endif
pred@1842
    68
#endif
pred@1842
    69
pred@1842
    70
/* By default, we use the standard "extern" declarations. */
pred@1842
    71
pred@1842
    72
#ifndef PCRE_EXP_DECL
pred@1842
    73
#  ifdef __cplusplus
pred@1842
    74
#    define PCRE_EXP_DECL  extern "C"
pred@1842
    75
#  else
pred@1842
    76
#    define PCRE_EXP_DECL  extern
pred@1842
    77
#  endif
pred@1842
    78
#endif
pred@1842
    79
pred@1842
    80
#ifdef __cplusplus
pred@1842
    81
#  ifndef PCRECPP_EXP_DECL
pred@1842
    82
#    define PCRECPP_EXP_DECL  extern
pred@1842
    83
#  endif
pred@1842
    84
#  ifndef PCRECPP_EXP_DEFN
pred@1842
    85
#    define PCRECPP_EXP_DEFN
pred@1842
    86
#  endif
pred@1842
    87
#endif
pred@1842
    88
pred@1842
    89
/* Have to include stdlib.h in order to ensure that size_t is defined;
pred@1842
    90
it is needed here for malloc. */
pred@1842
    91
pred@1842
    92
#include <stdlib.h>
pred@1842
    93
pred@1842
    94
/* Allow for C++ users */
pred@1842
    95
pred@1842
    96
#ifdef __cplusplus
pred@1842
    97
extern "C" {
pred@1842
    98
#endif
pred@1842
    99
pred@1842
   100
/* Options */
pred@1842
   101
pred@1842
   102
#define PCRE_CASELESS           0x00000001
pred@1842
   103
#define PCRE_MULTILINE          0x00000002
pred@1842
   104
#define PCRE_DOTALL             0x00000004
pred@1842
   105
#define PCRE_EXTENDED           0x00000008
pred@1842
   106
#define PCRE_ANCHORED           0x00000010
pred@1842
   107
#define PCRE_DOLLAR_ENDONLY     0x00000020
pred@1842
   108
#define PCRE_EXTRA              0x00000040
pred@1842
   109
#define PCRE_NOTBOL             0x00000080
pred@1842
   110
#define PCRE_NOTEOL             0x00000100
pred@1842
   111
#define PCRE_UNGREEDY           0x00000200
pred@1842
   112
#define PCRE_NOTEMPTY           0x00000400
pred@1842
   113
#define PCRE_UTF8               0x00000800
pred@1842
   114
#define PCRE_NO_AUTO_CAPTURE    0x00001000
pred@1842
   115
#define PCRE_NO_UTF8_CHECK      0x00002000
pred@1842
   116
#define PCRE_AUTO_CALLOUT       0x00004000
pred@1842
   117
#define PCRE_PARTIAL            0x00008000
pred@1842
   118
#define PCRE_DFA_SHORTEST       0x00010000
pred@1842
   119
#define PCRE_DFA_RESTART        0x00020000
pred@1842
   120
#define PCRE_FIRSTLINE          0x00040000
pred@1842
   121
#define PCRE_DUPNAMES           0x00080000
pred@1842
   122
#define PCRE_NEWLINE_CR         0x00100000
pred@1842
   123
#define PCRE_NEWLINE_LF         0x00200000
pred@1842
   124
#define PCRE_NEWLINE_CRLF       0x00300000
pred@1842
   125
#define PCRE_NEWLINE_ANY        0x00400000
pred@1842
   126
#define PCRE_NEWLINE_ANYCRLF    0x00500000
pred@1842
   127
#define PCRE_BSR_ANYCRLF        0x00800000
pred@1842
   128
#define PCRE_BSR_UNICODE        0x01000000
pred@1842
   129
pred@1842
   130
/* Exec-time and get/set-time error codes */
pred@1842
   131
pred@1842
   132
#define PCRE_ERROR_NOMATCH         (-1)
pred@1842
   133
#define PCRE_ERROR_NULL            (-2)
pred@1842
   134
#define PCRE_ERROR_BADOPTION       (-3)
pred@1842
   135
#define PCRE_ERROR_BADMAGIC        (-4)
pred@1842
   136
#define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
pred@1842
   137
#define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
pred@1842
   138
#define PCRE_ERROR_NOMEMORY        (-6)
pred@1842
   139
#define PCRE_ERROR_NOSUBSTRING     (-7)
pred@1842
   140
#define PCRE_ERROR_MATCHLIMIT      (-8)
pred@1842
   141
#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
pred@1842
   142
#define PCRE_ERROR_BADUTF8        (-10)
pred@1842
   143
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
pred@1842
   144
#define PCRE_ERROR_PARTIAL        (-12)
pred@1842
   145
#define PCRE_ERROR_BADPARTIAL     (-13)
pred@1842
   146
#define PCRE_ERROR_INTERNAL       (-14)
pred@1842
   147
#define PCRE_ERROR_BADCOUNT       (-15)
pred@1842
   148
#define PCRE_ERROR_DFA_UITEM      (-16)
pred@1842
   149
#define PCRE_ERROR_DFA_UCOND      (-17)
pred@1842
   150
#define PCRE_ERROR_DFA_UMLIMIT    (-18)
pred@1842
   151
#define PCRE_ERROR_DFA_WSSIZE     (-19)
pred@1842
   152
#define PCRE_ERROR_DFA_RECURSE    (-20)
pred@1842
   153
#define PCRE_ERROR_RECURSIONLIMIT (-21)
pred@1842
   154
#define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
pred@1842
   155
#define PCRE_ERROR_BADNEWLINE     (-23)
pred@1842
   156
pred@1842
   157
/* Request types for pcre_fullinfo() */
pred@1842
   158
pred@1842
   159
#define PCRE_INFO_OPTIONS            0
pred@1842
   160
#define PCRE_INFO_SIZE               1
pred@1842
   161
#define PCRE_INFO_CAPTURECOUNT       2
pred@1842
   162
#define PCRE_INFO_BACKREFMAX         3
pred@1842
   163
#define PCRE_INFO_FIRSTBYTE          4
pred@1842
   164
#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
pred@1842
   165
#define PCRE_INFO_FIRSTTABLE         5
pred@1842
   166
#define PCRE_INFO_LASTLITERAL        6
pred@1842
   167
#define PCRE_INFO_NAMEENTRYSIZE      7
pred@1842
   168
#define PCRE_INFO_NAMECOUNT          8
pred@1842
   169
#define PCRE_INFO_NAMETABLE          9
pred@1842
   170
#define PCRE_INFO_STUDYSIZE         10
pred@1842
   171
#define PCRE_INFO_DEFAULT_TABLES    11
pred@1842
   172
#define PCRE_INFO_OKPARTIAL         12
pred@1842
   173
#define PCRE_INFO_JCHANGED          13
pred@1842
   174
#define PCRE_INFO_HASCRORLF         14
pred@1842
   175
pred@1842
   176
/* Request types for pcre_config(). Do not re-arrange, in order to remain
pred@1842
   177
compatible. */
pred@1842
   178
pred@1842
   179
#define PCRE_CONFIG_UTF8                    0
pred@1842
   180
#define PCRE_CONFIG_NEWLINE                 1
pred@1842
   181
#define PCRE_CONFIG_LINK_SIZE               2
pred@1842
   182
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
pred@1842
   183
#define PCRE_CONFIG_MATCH_LIMIT             4
pred@1842
   184
#define PCRE_CONFIG_STACKRECURSE            5
pred@1842
   185
#define PCRE_CONFIG_UNICODE_PROPERTIES      6
pred@1842
   186
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
pred@1842
   187
#define PCRE_CONFIG_BSR                     8
pred@1842
   188
pred@1842
   189
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
pred@1842
   190
these bits, just add new ones on the end, in order to remain compatible. */
pred@1842
   191
pred@1842
   192
#define PCRE_EXTRA_STUDY_DATA             0x0001
pred@1842
   193
#define PCRE_EXTRA_MATCH_LIMIT            0x0002
pred@1842
   194
#define PCRE_EXTRA_CALLOUT_DATA           0x0004
pred@1842
   195
#define PCRE_EXTRA_TABLES                 0x0008
pred@1842
   196
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
pred@1842
   197
pred@1842
   198
/* Types */
pred@1842
   199
pred@1842
   200
struct real_pcre;                 /* declaration; the definition is private  */
pred@1842
   201
typedef struct real_pcre pcre;
pred@1842
   202
pred@1842
   203
/* When PCRE is compiled as a C++ library, the subject pointer type can be
pred@1842
   204
replaced with a custom type. For conventional use, the public interface is a
pred@1842
   205
const char *. */
pred@1842
   206
pred@1842
   207
#ifndef PCRE_SPTR
pred@1842
   208
#define PCRE_SPTR const char *
pred@1842
   209
#endif
pred@1842
   210
pred@1842
   211
/* The structure for passing additional data to pcre_exec(). This is defined in
pred@1842
   212
such as way as to be extensible. Always add new fields at the end, in order to
pred@1842
   213
remain compatible. */
pred@1842
   214
pred@1842
   215
typedef struct pcre_extra {
pred@1842
   216
  unsigned long int flags;        /* Bits for which fields are set */
pred@1842
   217
  void *study_data;               /* Opaque data from pcre_study() */
pred@1842
   218
  unsigned long int match_limit;  /* Maximum number of calls to match() */
pred@1842
   219
  void *callout_data;             /* Data passed back in callouts */
pred@1842
   220
  const unsigned char *tables;    /* Pointer to character tables */
pred@1842
   221
  unsigned long int match_limit_recursion; /* Max recursive calls to match() */
pred@1842
   222
} pcre_extra;
pred@1842
   223
pred@1842
   224
/* The structure for passing out data via the pcre_callout_function. We use a
pred@1842
   225
structure so that new fields can be added on the end in future versions,
pred@1842
   226
without changing the API of the function, thereby allowing old clients to work
pred@1842
   227
without modification. */
pred@1842
   228
pred@1842
   229
typedef struct pcre_callout_block {
pred@1842
   230
  int          version;           /* Identifies version of block */
pred@1842
   231
  /* ------------------------ Version 0 ------------------------------- */
pred@1842
   232
  int          callout_number;    /* Number compiled into pattern */
pred@1842
   233
  int         *offset_vector;     /* The offset vector */
pred@1842
   234
  PCRE_SPTR    subject;           /* The subject being matched */
pred@1842
   235
  int          subject_length;    /* The length of the subject */
pred@1842
   236
  int          start_match;       /* Offset to start of this match attempt */
pred@1842
   237
  int          current_position;  /* Where we currently are in the subject */
pred@1842
   238
  int          capture_top;       /* Max current capture */
pred@1842
   239
  int          capture_last;      /* Most recently closed capture */
pred@1842
   240
  void        *callout_data;      /* Data passed in with the call */
pred@1842
   241
  /* ------------------- Added for Version 1 -------------------------- */
pred@1842
   242
  int          pattern_position;  /* Offset to next item in the pattern */
pred@1842
   243
  int          next_item_length;  /* Length of next item in the pattern */
pred@1842
   244
  /* ------------------------------------------------------------------ */
pred@1842
   245
} pcre_callout_block;
pred@1842
   246
pred@1842
   247
/* Indirection for store get and free functions. These can be set to
pred@1842
   248
alternative malloc/free functions if required. Special ones are used in the
pred@1842
   249
non-recursive case for "frames". There is also an optional callout function
pred@1842
   250
that is triggered by the (?) regex item. For Virtual Pascal, these definitions
pred@1842
   251
have to take another form. */
pred@1842
   252
pred@1842
   253
#ifndef VPCOMPAT
pred@1842
   254
PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
pred@1842
   255
PCRE_EXP_DECL void  (*pcre_free)(void *);
pred@1842
   256
PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
pred@1842
   257
PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
pred@1842
   258
PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
pred@1842
   259
#else   /* VPCOMPAT */
pred@1842
   260
PCRE_EXP_DECL void *pcre_malloc(size_t);
pred@1842
   261
PCRE_EXP_DECL void  pcre_free(void *);
pred@1842
   262
PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
pred@1842
   263
PCRE_EXP_DECL void  pcre_stack_free(void *);
pred@1842
   264
PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
pred@1842
   265
#endif  /* VPCOMPAT */
pred@1842
   266
pred@1842
   267
/* Exported PCRE functions */
pred@1842
   268
pred@1842
   269
PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
pred@1842
   270
                  const unsigned char *);
pred@1842
   271
PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
pred@1842
   272
                  int *, const unsigned char *);
pred@1842
   273
PCRE_EXP_DECL int  pcre_config(int, void *);
pred@1842
   274
PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
pred@1842
   275
                  int *, int, const char *, char *, int);
pred@1842
   276
PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
pred@1842
   277
                  int);
pred@1842
   278
PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
pred@1842
   279
                  const char *, int, int, int, int *, int , int *, int);
pred@1842
   280
PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
pred@1842
   281
                   int, int, int, int *, int);
pred@1842
   282
PCRE_EXP_DECL void pcre_free_substring(const char *);
pred@1842
   283
PCRE_EXP_DECL void pcre_free_substring_list(const char **);
pred@1842
   284
PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
pred@1842
   285
                  void *);
pred@1842
   286
PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
pred@1842
   287
                  int *, int, const char *, const char **);
pred@1842
   288
PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
pred@1842
   289
PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
pred@1842
   290
                  char **, char **);
pred@1842
   291
PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
pred@1842
   292
                  const char **);
pred@1842
   293
PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
pred@1842
   294
                  const char ***);
pred@1842
   295
PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
pred@1842
   296
PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
pred@1842
   297
PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
pred@1842
   298
PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
pred@1842
   299
PCRE_EXP_DECL const char *pcre_version(void);
pred@1842
   300
pred@1842
   301
#ifdef __cplusplus
pred@1842
   302
}  /* extern "C" */
pred@1842
   303
#endif
pred@1842
   304
pred@1842
   305
#endif /* End of pcre.h */