| 2 |
* Perl-Compatible Regular Expressions * |
* Perl-Compatible Regular Expressions * |
| 3 |
*************************************************/ |
*************************************************/ |
| 4 |
|
|
| 5 |
/* Copyright (c) 1997-2001 University of Cambridge */ |
/* Copyright (c) 1997-2003 University of Cambridge */ |
| 6 |
|
|
| 7 |
#ifndef _PCRE_H |
#ifndef _PCRE_H |
| 8 |
#define _PCRE_H |
#define _PCRE_H |
| 17 |
/* Win32 uses DLL by default */ |
/* Win32 uses DLL by default */ |
| 18 |
|
|
| 19 |
#ifdef _WIN32 |
#ifdef _WIN32 |
| 20 |
# ifdef STATIC |
# ifdef PCRE_DEFINITION |
| 21 |
# define PCRE_DL_IMPORT |
# ifdef DLL_EXPORT |
| 22 |
# else |
# define PCRE_DATA_SCOPE __declspec(dllexport) |
| 23 |
# define PCRE_DL_IMPORT __declspec(dllimport) |
# endif |
| 24 |
# endif |
# else |
| 25 |
#else |
# ifndef PCRE_STATIC |
| 26 |
# define PCRE_DL_IMPORT |
# define PCRE_DATA_SCOPE __declspec(dllimport) |
| 27 |
|
# endif |
| 28 |
|
# endif |
| 29 |
|
#endif |
| 30 |
|
#ifndef PCRE_DATA_SCOPE |
| 31 |
|
# define PCRE_DATA_SCOPE extern |
| 32 |
#endif |
#endif |
| 33 |
|
|
| 34 |
/* Have to include stdlib.h in order to ensure that size_t is defined; |
/* Have to include stdlib.h in order to ensure that size_t is defined; |
| 44 |
|
|
| 45 |
/* Options */ |
/* Options */ |
| 46 |
|
|
| 47 |
#define PCRE_CASELESS 0x0001 |
#define PCRE_CASELESS 0x0001 |
| 48 |
#define PCRE_MULTILINE 0x0002 |
#define PCRE_MULTILINE 0x0002 |
| 49 |
#define PCRE_DOTALL 0x0004 |
#define PCRE_DOTALL 0x0004 |
| 50 |
#define PCRE_EXTENDED 0x0008 |
#define PCRE_EXTENDED 0x0008 |
| 51 |
#define PCRE_ANCHORED 0x0010 |
#define PCRE_ANCHORED 0x0010 |
| 52 |
#define PCRE_DOLLAR_ENDONLY 0x0020 |
#define PCRE_DOLLAR_ENDONLY 0x0020 |
| 53 |
#define PCRE_EXTRA 0x0040 |
#define PCRE_EXTRA 0x0040 |
| 54 |
#define PCRE_NOTBOL 0x0080 |
#define PCRE_NOTBOL 0x0080 |
| 55 |
#define PCRE_NOTEOL 0x0100 |
#define PCRE_NOTEOL 0x0100 |
| 56 |
#define PCRE_UNGREEDY 0x0200 |
#define PCRE_UNGREEDY 0x0200 |
| 57 |
#define PCRE_NOTEMPTY 0x0400 |
#define PCRE_NOTEMPTY 0x0400 |
| 58 |
#define PCRE_UTF8 0x0800 |
#define PCRE_UTF8 0x0800 |
| 59 |
|
#define PCRE_NO_AUTO_CAPTURE 0x1000 |
| 60 |
|
|
| 61 |
/* Exec-time and get-time error codes */ |
/* Exec-time and get/set-time error codes */ |
| 62 |
|
|
| 63 |
#define PCRE_ERROR_NOMATCH (-1) |
#define PCRE_ERROR_NOMATCH (-1) |
| 64 |
#define PCRE_ERROR_NULL (-2) |
#define PCRE_ERROR_NULL (-2) |
| 67 |
#define PCRE_ERROR_UNKNOWN_NODE (-5) |
#define PCRE_ERROR_UNKNOWN_NODE (-5) |
| 68 |
#define PCRE_ERROR_NOMEMORY (-6) |
#define PCRE_ERROR_NOMEMORY (-6) |
| 69 |
#define PCRE_ERROR_NOSUBSTRING (-7) |
#define PCRE_ERROR_NOSUBSTRING (-7) |
| 70 |
|
#define PCRE_ERROR_MATCHLIMIT (-8) |
| 71 |
|
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */ |
| 72 |
|
|
| 73 |
/* Request types for pcre_fullinfo() */ |
/* Request types for pcre_fullinfo() */ |
| 74 |
|
|
| 75 |
#define PCRE_INFO_OPTIONS 0 |
#define PCRE_INFO_OPTIONS 0 |
| 76 |
#define PCRE_INFO_SIZE 1 |
#define PCRE_INFO_SIZE 1 |
| 77 |
#define PCRE_INFO_CAPTURECOUNT 2 |
#define PCRE_INFO_CAPTURECOUNT 2 |
| 78 |
#define PCRE_INFO_BACKREFMAX 3 |
#define PCRE_INFO_BACKREFMAX 3 |
| 79 |
#define PCRE_INFO_FIRSTCHAR 4 |
#define PCRE_INFO_FIRSTBYTE 4 |
| 80 |
#define PCRE_INFO_FIRSTTABLE 5 |
#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */ |
| 81 |
#define PCRE_INFO_LASTLITERAL 6 |
#define PCRE_INFO_FIRSTTABLE 5 |
| 82 |
|
#define PCRE_INFO_LASTLITERAL 6 |
| 83 |
|
#define PCRE_INFO_NAMEENTRYSIZE 7 |
| 84 |
|
#define PCRE_INFO_NAMECOUNT 8 |
| 85 |
|
#define PCRE_INFO_NAMETABLE 9 |
| 86 |
|
#define PCRE_INFO_STUDYSIZE 10 |
| 87 |
|
|
| 88 |
|
/* Request types for pcre_config() */ |
| 89 |
|
|
| 90 |
|
#define PCRE_CONFIG_UTF8 0 |
| 91 |
|
#define PCRE_CONFIG_NEWLINE 1 |
| 92 |
|
#define PCRE_CONFIG_LINK_SIZE 2 |
| 93 |
|
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3 |
| 94 |
|
#define PCRE_CONFIG_MATCH_LIMIT 4 |
| 95 |
|
|
| 96 |
|
/* Bit flags for the pcre_extra structure */ |
| 97 |
|
|
| 98 |
|
#define PCRE_EXTRA_STUDY_DATA 0x0001 |
| 99 |
|
#define PCRE_EXTRA_MATCH_LIMIT 0x0002 |
| 100 |
|
#define PCRE_EXTRA_CALLOUT_DATA 0x0004 |
| 101 |
|
|
| 102 |
/* Types */ |
/* Types */ |
| 103 |
|
|
| 104 |
struct real_pcre; /* declaration; the definition is private */ |
struct real_pcre; /* declaration; the definition is private */ |
|
struct real_pcre_extra; /* declaration; the definition is private */ |
|
|
|
|
| 105 |
typedef struct real_pcre pcre; |
typedef struct real_pcre pcre; |
|
typedef struct real_pcre_extra pcre_extra; |
|
|
|
|
|
/* Store get and free functions. These can be set to alternative malloc/free |
|
|
functions if required. Some magic is required for Win32 DLL; it is null on |
|
|
other OS. */ |
|
|
|
|
|
PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t); |
|
|
PCRE_DL_IMPORT extern void (*pcre_free)(void *); |
|
|
|
|
|
#undef PCRE_DL_IMPORT |
|
| 106 |
|
|
| 107 |
/* Functions */ |
/* The structure for passing additional data to pcre_exec(). This is defined in |
| 108 |
|
such as way as to be extensible. */ |
| 109 |
|
|
| 110 |
extern pcre *pcre_compile(const char *, int, const char **, int *, |
typedef struct pcre_extra { |
| 111 |
const unsigned char *); |
unsigned long int flags; /* Bits for which fields are set */ |
| 112 |
extern int pcre_copy_substring(const char *, int *, int, int, char *, int); |
void *study_data; /* Opaque data from pcre_study() */ |
| 113 |
extern int pcre_exec(const pcre *, const pcre_extra *, const char *, |
unsigned long int match_limit; /* Maximum number of calls to match() */ |
| 114 |
int, int, int, int *, int); |
void *callout_data; /* Data passed back in callouts */ |
| 115 |
|
} pcre_extra; |
| 116 |
|
|
| 117 |
|
/* The structure for passing out data via the pcre_callout_function. We use a |
| 118 |
|
structure so that new fields can be added on the end in future versions, |
| 119 |
|
without changing the API of the function, thereby allowing old clients to work |
| 120 |
|
without modification. */ |
| 121 |
|
|
| 122 |
|
typedef struct pcre_callout_block { |
| 123 |
|
int version; /* Identifies version of block */ |
| 124 |
|
/* ------------------------ Version 0 ------------------------------- */ |
| 125 |
|
int callout_number; /* Number compiled into pattern */ |
| 126 |
|
int *offset_vector; /* The offset vector */ |
| 127 |
|
const char *subject; /* The subject being matched */ |
| 128 |
|
int subject_length; /* The length of the subject */ |
| 129 |
|
int start_match; /* Offset to start of this match attempt */ |
| 130 |
|
int current_position; /* Where we currently are */ |
| 131 |
|
int capture_top; /* Max current capture */ |
| 132 |
|
int capture_last; /* Most recently closed capture */ |
| 133 |
|
void *callout_data; /* Data passed in with the call */ |
| 134 |
|
/* ------------------------------------------------------------------ */ |
| 135 |
|
} pcre_callout_block; |
| 136 |
|
|
| 137 |
|
/* Indirection for store get and free functions. These can be set to |
| 138 |
|
alternative malloc/free functions if required. There is also an optional |
| 139 |
|
callout function that is triggered by the (?) regex item. Some magic is |
| 140 |
|
required for Win32 DLL; it is null on other OS. For Virtual Pascal, these |
| 141 |
|
have to be different again. */ |
| 142 |
|
|
| 143 |
|
#ifndef VPCOMPAT |
| 144 |
|
PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t); |
| 145 |
|
PCRE_DATA_SCOPE void (*pcre_free)(void *); |
| 146 |
|
PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *); |
| 147 |
|
#else /* VPCOMPAT */ |
| 148 |
|
extern void *pcre_malloc(size_t); |
| 149 |
|
extern void pcre_free(void *); |
| 150 |
|
extern int pcre_callout(pcre_callout_block *); |
| 151 |
|
#endif /* VPCOMPAT */ |
| 152 |
|
|
| 153 |
|
/* Exported PCRE functions */ |
| 154 |
|
|
| 155 |
|
extern pcre *pcre_compile(const char *, int, const char **, |
| 156 |
|
int *, const unsigned char *); |
| 157 |
|
extern int pcre_config(int, void *); |
| 158 |
|
extern int pcre_copy_named_substring(const pcre *, const char *, |
| 159 |
|
int *, int, const char *, char *, int); |
| 160 |
|
extern int pcre_copy_substring(const char *, int *, int, int, |
| 161 |
|
char *, int); |
| 162 |
|
extern int pcre_exec(const pcre *, const pcre_extra *, |
| 163 |
|
const char *, int, int, int, int *, int); |
| 164 |
extern void pcre_free_substring(const char *); |
extern void pcre_free_substring(const char *); |
| 165 |
extern void pcre_free_substring_list(const char **); |
extern void pcre_free_substring_list(const char **); |
| 166 |
extern int pcre_get_substring(const char *, int *, int, int, const char **); |
extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, |
| 167 |
extern int pcre_get_substring_list(const char *, int *, int, const char ***); |
void *); |
| 168 |
|
extern int pcre_get_named_substring(const pcre *, const char *, |
| 169 |
|
int *, int, const char *, const char **); |
| 170 |
|
extern int pcre_get_stringnumber(const pcre *, const char *); |
| 171 |
|
extern int pcre_get_substring(const char *, int *, int, int, |
| 172 |
|
const char **); |
| 173 |
|
extern int pcre_get_substring_list(const char *, int *, int, |
| 174 |
|
const char ***); |
| 175 |
extern int pcre_info(const pcre *, int *, int *); |
extern int pcre_info(const pcre *, int *, int *); |
|
extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *); |
|
| 176 |
extern const unsigned char *pcre_maketables(void); |
extern const unsigned char *pcre_maketables(void); |
| 177 |
extern pcre_extra *pcre_study(const pcre *, int, const char **); |
extern pcre_extra *pcre_study(const pcre *, int, const char **); |
| 178 |
extern const char *pcre_version(void); |
extern const char *pcre_version(void); |