Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:10

0001 /*************************************************
0002 *       Perl-Compatible Regular Expressions      *
0003 *************************************************/
0004 
0005 #ifndef _PCREPOSIX_H
0006 #define _PCREPOSIX_H
0007 
0008 /* This is the header for the POSIX wrapper interface to the PCRE Perl-
0009 Compatible Regular Expression library. It defines the things POSIX says should
0010 be there. I hope.
0011 
0012             Copyright (c) 1997-2012 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 /* Have to include stdlib.h in order to ensure that size_t is defined. */
0044 
0045 #include <stdlib.h>
0046 
0047 /* Allow for C++ users */
0048 
0049 #ifdef __cplusplus
0050 extern "C" {
0051 #endif
0052 
0053 /* Options, mostly defined by POSIX, but with some extras. */
0054 
0055 #define REG_ICASE     0x0001   /* Maps to PCRE_CASELESS */
0056 #define REG_NEWLINE   0x0002   /* Maps to PCRE_MULTILINE */
0057 #define REG_NOTBOL    0x0004   /* Maps to PCRE_NOTBOL */
0058 #define REG_NOTEOL    0x0008   /* Maps to PCRE_NOTEOL */
0059 #define REG_DOTALL    0x0010   /* NOT defined by POSIX; maps to PCRE_DOTALL */
0060 #define REG_NOSUB     0x0020   /* Maps to PCRE_NO_AUTO_CAPTURE */
0061 #define REG_UTF8      0x0040   /* NOT defined by POSIX; maps to PCRE_UTF8 */
0062 #define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
0063 #define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
0064 #define REG_UNGREEDY  0x0200   /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
0065 #define REG_UCP       0x0400   /* NOT defined by POSIX; maps to PCRE_UCP */
0066 
0067 /* This is not used by PCRE, but by defining it we make it easier
0068 to slot PCRE into existing programs that make POSIX calls. */
0069 
0070 #define REG_EXTENDED  0
0071 
0072 /* Error values. Not all these are relevant or used by the wrapper. */
0073 
0074 enum {
0075   REG_ASSERT = 1,  /* internal error ? */
0076   REG_BADBR,       /* invalid repeat counts in {} */
0077   REG_BADPAT,      /* pattern error */
0078   REG_BADRPT,      /* ? * + invalid */
0079   REG_EBRACE,      /* unbalanced {} */
0080   REG_EBRACK,      /* unbalanced [] */
0081   REG_ECOLLATE,    /* collation error - not relevant */
0082   REG_ECTYPE,      /* bad class */
0083   REG_EESCAPE,     /* bad escape sequence */
0084   REG_EMPTY,       /* empty expression */
0085   REG_EPAREN,      /* unbalanced () */
0086   REG_ERANGE,      /* bad range inside [] */
0087   REG_ESIZE,       /* expression too big */
0088   REG_ESPACE,      /* failed to get memory */
0089   REG_ESUBREG,     /* bad back reference */
0090   REG_INVARG,      /* bad argument */
0091   REG_NOMATCH      /* match failed */
0092 };
0093 
0094 
0095 /* The structure representing a compiled regular expression. */
0096 
0097 typedef struct {
0098   void *re_pcre;
0099   size_t re_nsub;
0100   size_t re_erroffset;
0101 } regex_t;
0102 
0103 /* The structure in which a captured offset is returned. */
0104 
0105 typedef int regoff_t;
0106 
0107 typedef struct {
0108   regoff_t rm_so;
0109   regoff_t rm_eo;
0110 } regmatch_t;
0111 
0112 /* When an application links to a PCRE DLL in Windows, the symbols that are
0113 imported have to be identified as such. When building PCRE, the appropriate
0114 export settings are needed, and are set in pcreposix.c before including this
0115 file. */
0116 
0117 #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
0118 #  define PCREPOSIX_EXP_DECL  extern __declspec(dllimport)
0119 #  define PCREPOSIX_EXP_DEFN  __declspec(dllimport)
0120 #endif
0121 
0122 /* By default, we use the standard "extern" declarations. */
0123 
0124 #ifndef PCREPOSIX_EXP_DECL
0125 #  ifdef __cplusplus
0126 #    define PCREPOSIX_EXP_DECL  extern "C"
0127 #    define PCREPOSIX_EXP_DEFN  extern "C"
0128 #  else
0129 #    define PCREPOSIX_EXP_DECL  extern
0130 #    define PCREPOSIX_EXP_DEFN  extern
0131 #  endif
0132 #endif
0133 
0134 /* The functions */
0135 
0136 PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
0137 PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
0138                      regmatch_t *, int);
0139 PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
0140 PCREPOSIX_EXP_DECL void regfree(regex_t *);
0141 
0142 #ifdef __cplusplus
0143 }   /* extern "C" */
0144 #endif
0145 
0146 #endif /* End of pcreposix.h */