|
||||
File indexing completed on 2025-01-17 09:55:54
0001 /************************************************* 0002 * Perl-Compatible Regular Expressions * 0003 *************************************************/ 0004 0005 /* PCRE2 is a library of functions to support regular expressions whose syntax 0006 and semantics are as close as possible to those of the Perl 5 language. This is 0007 the public header file to be #included by applications that call PCRE2 via the 0008 POSIX wrapper interface. 0009 0010 Written by Philip Hazel 0011 Original API code Copyright (c) 1997-2012 University of Cambridge 0012 New API code Copyright (c) 2016-2023 University of Cambridge 0013 0014 ----------------------------------------------------------------------------- 0015 Redistribution and use in source and binary forms, with or without 0016 modification, are permitted provided that the following conditions are met: 0017 0018 * Redistributions of source code must retain the above copyright notice, 0019 this list of conditions and the following disclaimer. 0020 0021 * Redistributions in binary form must reproduce the above copyright 0022 notice, this list of conditions and the following disclaimer in the 0023 documentation and/or other materials provided with the distribution. 0024 0025 * Neither the name of the University of Cambridge nor the names of its 0026 contributors may be used to endorse or promote products derived from 0027 this software without specific prior written permission. 0028 0029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0030 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0031 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0032 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0033 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0034 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0035 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0036 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0037 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0039 POSSIBILITY OF SUCH DAMAGE. 0040 ----------------------------------------------------------------------------- 0041 */ 0042 0043 #ifndef PCRE2POSIX_H_IDEMPOTENT_GUARD 0044 #define PCRE2POSIX_H_IDEMPOTENT_GUARD 0045 0046 /* Have to include stdlib.h in order to ensure that size_t is defined. */ 0047 0048 #include <stdlib.h> 0049 0050 /* Allow for C++ users */ 0051 0052 #ifdef __cplusplus 0053 extern "C" { 0054 #endif 0055 0056 /* Options, mostly defined by POSIX, but with some extras. */ 0057 0058 #define REG_ICASE 0x0001 /* Maps to PCRE2_CASELESS */ 0059 #define REG_NEWLINE 0x0002 /* Maps to PCRE2_MULTILINE */ 0060 #define REG_NOTBOL 0x0004 /* Maps to PCRE2_NOTBOL */ 0061 #define REG_NOTEOL 0x0008 /* Maps to PCRE2_NOTEOL */ 0062 #define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE2_DOTALL */ 0063 #define REG_NOSUB 0x0020 /* Do not report what was matched */ 0064 #define REG_UTF 0x0040 /* NOT defined by POSIX; maps to PCRE2_UTF */ 0065 #define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */ 0066 #define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE2_NOTEMPTY */ 0067 #define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE2_UNGREEDY */ 0068 #define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE2_UCP */ 0069 #define REG_PEND 0x0800 /* GNU feature: pass end pattern by re_endp */ 0070 #define REG_NOSPEC 0x1000 /* Maps to PCRE2_LITERAL */ 0071 0072 /* This is not used by PCRE2, but by defining it we make it easier 0073 to slot PCRE2 into existing programs that make POSIX calls. */ 0074 0075 #define REG_EXTENDED 0 0076 0077 /* Error values. Not all these are relevant or used by the wrapper. */ 0078 0079 enum { 0080 REG_ASSERT = 1, /* internal error ? */ 0081 REG_BADBR, /* invalid repeat counts in {} */ 0082 REG_BADPAT, /* pattern error */ 0083 REG_BADRPT, /* ? * + invalid */ 0084 REG_EBRACE, /* unbalanced {} */ 0085 REG_EBRACK, /* unbalanced [] */ 0086 REG_ECOLLATE, /* collation error - not relevant */ 0087 REG_ECTYPE, /* bad class */ 0088 REG_EESCAPE, /* bad escape sequence */ 0089 REG_EMPTY, /* empty expression */ 0090 REG_EPAREN, /* unbalanced () */ 0091 REG_ERANGE, /* bad range inside [] */ 0092 REG_ESIZE, /* expression too big */ 0093 REG_ESPACE, /* failed to get memory */ 0094 REG_ESUBREG, /* bad back reference */ 0095 REG_INVARG, /* bad argument */ 0096 REG_NOMATCH /* match failed */ 0097 }; 0098 0099 0100 /* The structure representing a compiled regular expression. It is also used 0101 for passing the pattern end pointer when REG_PEND is set. */ 0102 0103 typedef struct { 0104 void *re_pcre2_code; 0105 void *re_match_data; 0106 const char *re_endp; 0107 size_t re_nsub; 0108 size_t re_erroffset; 0109 int re_cflags; 0110 } regex_t; 0111 0112 /* The structure in which a captured offset is returned. */ 0113 0114 typedef int regoff_t; 0115 0116 typedef struct { 0117 regoff_t rm_so; 0118 regoff_t rm_eo; 0119 } regmatch_t; 0120 0121 /* When compiling with the MSVC compiler, it is sometimes necessary to include 0122 a "calling convention" before exported function names. (This is secondhand 0123 information; I know nothing about MSVC myself). For example, something like 0124 0125 void __cdecl function(....) 0126 0127 might be needed. In order to make this easy, all the exported functions have 0128 PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not 0129 set, we ensure here that it has no effect. */ 0130 0131 #ifndef PCRE2_CALL_CONVENTION 0132 #define PCRE2_CALL_CONVENTION 0133 #endif 0134 0135 #ifndef PCRE2_EXPORT 0136 #define PCRE2_EXPORT 0137 #endif 0138 0139 /* When an application links to a PCRE2 DLL in Windows, the symbols that are 0140 imported have to be identified as such. When building PCRE2, the appropriate 0141 export settings are needed, and are set in pcre2posix.c before including this 0142 file. */ 0143 0144 /* By default, we use the standard "extern" declarations. */ 0145 0146 #ifndef PCRE2POSIX_EXP_DECL 0147 # if defined(_WIN32) && defined(PCRE2POSIX_SHARED) && !defined(PCRE2_STATIC) 0148 # define PCRE2POSIX_EXP_DECL extern __declspec(dllimport) 0149 # define PCRE2POSIX_EXP_DEFN __declspec(dllimport) 0150 # else 0151 # define PCRE2POSIX_EXP_DECL extern PCRE2_EXPORT 0152 # define PCRE2POSIX_EXP_DEFN 0153 # endif 0154 #endif 0155 0156 /* The functions. The actual code is in functions with pcre2_xxx names for 0157 uniqueness. POSIX names are provided as macros for API compatibility with POSIX 0158 regex functions. It's done this way to ensure to they are always linked from 0159 the PCRE2 library and not by accident from elsewhere (regex_t differs in size 0160 elsewhere). */ 0161 0162 PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regcomp(regex_t *, const char *, int); 0163 PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regexec(const regex_t *, const char *, size_t, 0164 regmatch_t *, int); 0165 PCRE2POSIX_EXP_DECL size_t PCRE2_CALL_CONVENTION pcre2_regerror(int, const regex_t *, char *, size_t); 0166 PCRE2POSIX_EXP_DECL void PCRE2_CALL_CONVENTION pcre2_regfree(regex_t *); 0167 0168 #define regcomp pcre2_regcomp 0169 #define regexec pcre2_regexec 0170 #define regerror pcre2_regerror 0171 #define regfree pcre2_regfree 0172 0173 /* Debian had a patch that used different names. These are now here to save 0174 them having to maintain their own patch, but are not documented by PCRE2. */ 0175 0176 #define PCRE2regcomp pcre2_regcomp 0177 #define PCRE2regexec pcre2_regexec 0178 #define PCRE2regerror pcre2_regerror 0179 #define PCRE2regfree pcre2_regfree 0180 0181 #ifdef __cplusplus 0182 } /* extern "C" */ 0183 #endif 0184 0185 #endif /* PCRE2POSIX_H_IDEMPOTENT_GUARD */ 0186 0187 /* End of pcre2posix.h */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |