1 2 /* : : generated by proto : : */ 3 4 #if !defined(__PROTO__) 5 #include <prototyped.h> 6 #endif 7 #if !defined(__LINKAGE__) 8 #define __LINKAGE__ /* 2004-08-11 transition */ 9 #endif 10 #ifdef _AST_STD_I 11 #define _REGEX_H -1 12 #define regex_t int 13 #define regmatch_t int 14 #endif 15 #ifndef _REGEX_H 16 #define _REGEX_H 1 17 #undef regex_t 18 #undef regmatch_t 19 20 #include <ast_common.h> 21 22 #define REG_VERSION 20030916L 23 24 /* regcomp flags */ 25 26 #define REG_AUGMENTED 0x00000001 /* enable ! & < > */ 27 #define REG_EXTENDED 0x00000002 /* enable ( | ) */ 28 #define REG_ICASE 0x00000004 /* ignore case in match */ 29 #define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */ 30 #define REG_NOSUB 0x00000010 /* don't report subexp matches */ 31 #define REG_SHELL 0x00000020 /* shell pattern syntax */ 32 33 /* nonstandard regcomp flags */ 34 35 #define REG_LEFT 0x00000100 /* implicit ^... */ 36 #define REG_LITERAL 0x00000200 /* no operators */ 37 #define REG_MINIMAL 0x00000400 /* minimal match */ 38 #define REG_NULL 0x00000800 /* allow null patterns */ 39 #define REG_RIGHT 0x00001000 /* implicit ...$ */ 40 #define REG_LENIENT 0x00002000 /* look the other way */ 41 #define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */ 42 #define REG_FIRST 0x00008000 /* first match found will do */ 43 #define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */ 44 #define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */ 45 #define REG_SPAN 0x00040000 /* . matches \n */ 46 #define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/ 47 #define REG_MULTIREF 0x00100000 /* multiple digit backrefs */ 48 #define REG_MUSTDELIM 0x08000000 /* all delimiters required */ 49 #define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */ 50 #define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */ 51 52 #define REG_SHELL_DOT 0x00200000 /* explicit leading . match */ 53 #define REG_SHELL_ESCAPED 0x00400000 /* \ not special */ 54 #define REG_SHELL_PATH 0x00800000 /* explicit / match */ 55 56 /* regexec flags */ 57 58 #define REG_NOTBOL 0x00000040 /* ^ is not a special char */ 59 #define REG_NOTEOL 0x00000080 /* $ is not a special char */ 60 61 /* nonstandard regexec flags */ 62 63 #define REG_INVERT 0x01000000 /* invert regrexec match sense */ 64 #define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */ 65 #define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */ 66 67 /* regalloc flags */ 68 69 #define REG_NOFREE 0x00000001 /* don't free */ 70 71 /* regsub flags */ 72 73 #define REG_SUB_ALL 0x00000001 /* substitute all occurrences */ 74 #define REG_SUB_LOWER 0x00000002 /* substitute to lower case */ 75 #define REG_SUB_UPPER 0x00000004 /* substitute to upper case */ 76 #define REG_SUB_PRINT 0x00000010 /* internal no-op */ 77 #define REG_SUB_NUMBER 0x00000020 /* internal no-op */ 78 #define REG_SUB_STOP 0x00000040 /* internal no-op */ 79 #define REG_SUB_WRITE 0x00000080 /* internal no-op */ 80 #define REG_SUB_LAST 0x00000100 /* last substitution option */ 81 #define REG_SUB_FULL 0x00000200 /* fully delimited */ 82 #define REG_SUB_USER 0x00001000 /* first user flag bit */ 83 84 /* regex error codes */ 85 86 #define REG_ENOSYS (-1) /* not supported */ 87 #define REG_NOMATCH 1 /* regexec didn't match */ 88 #define REG_BADPAT 2 /* invalid regular expression */ 89 #define REG_ECOLLATE 3 /* invalid collation element */ 90 #define REG_ECTYPE 4 /* invalid character class */ 91 #define REG_EESCAPE 5 /* trailing \ in pattern */ 92 #define REG_ESUBREG 6 /* invalid \digit backreference */ 93 #define REG_EBRACK 7 /* [...] imbalance */ 94 #define REG_EPAREN 8 /* \(...\) or (...) imbalance */ 95 #define REG_EBRACE 9 /* \{...\} or {...} imbalance */ 96 #define REG_BADBR 10 /* invalid {...} digits */ 97 #define REG_ERANGE 11 /* invalid [...] range endpoint */ 98 #define REG_ESPACE 12 /* out of space */ 99 #define REG_BADRPT 13 /* unary op not preceeded by re */ 100 #define REG_ENULL 14 /* empty subexpr in pattern */ 101 #define REG_ECOUNT 15 /* re component count overflow */ 102 #define REG_BADESC 16 /* invalid \char escape */ 103 #define REG_VERSIONID 17 /* version id (pseudo error) */ 104 #define REG_EFLAGS 18 /* flags conflict */ 105 #define REG_EDELIM 19 /* invalid or omitted delimiter */ 106 #define REG_PANIC 20 /* unrecoverable internal error */ 107 108 struct regex_s; typedef struct regex_s regex_t; 109 struct regdisc_s; typedef struct regdisc_s regdisc_t; 110 111 typedef int (*regclass_t) __PROTO__((int)); 112 typedef int32_t regflags_t; 113 typedef int regoff_t; 114 typedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...)); 115 typedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*)); 116 typedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*)); 117 typedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t)); 118 typedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t)); 119 120 typedef struct regmatch_s 121 { 122 regoff_t rm_so; /* offset of start */ 123 regoff_t rm_eo; /* offset of end */ 124 } regmatch_t; 125 126 typedef struct regsub_s 127 { 128 regflags_t re_flags; /* regsubcomp() flags */ 129 char* re_buf; /* regsubexec() output buffer */ 130 size_t re_len; /* re_buf length */ 131 int re_min; /* regsubcomp() min matches */ 132 #ifdef _REG_SUB_PRIVATE_ 133 _REG_SUB_PRIVATE_ 134 #endif 135 } regsub_t; 136 137 struct regdisc_s 138 { 139 unsigned long re_version; /* discipline version */ 140 regflags_t re_flags; /* discipline flags */ 141 regerror_t re_errorf; /* error function */ 142 int re_errorlevel; /* errorf level */ 143 regresize_t re_resizef; /* alloc/free function */ 144 __V_* re_resizehandle;/* resizef handle */ 145 regcomp_t re_compf; /* (?{...}) compile function */ 146 regexec_t re_execf; /* (?{...}) execute function */ 147 unsigned char* re_map; /* external to native ccode map */ 148 }; 149 150 typedef struct regstat_s 151 { 152 regflags_t re_flags; /* REG_LEFT|REG_RIGHT */ 153 ssize_t re_min; /* min anchored match length */ 154 ssize_t re_max; /* max anchored match length */ 155 ssize_t re_record; /* regrexec() match length */ 156 } regstat_t; 157 158 struct regex_s 159 { 160 size_t re_nsub; /* number of subexpressions */ 161 struct reglib_s*re_info; /* library private info */ 162 size_t re_npat; /* number of pattern chars used */ 163 regdisc_t* re_disc; /* REG_DISCIPLINE discipline */ 164 regsub_t* re_sub; /* regsubcomp() data */ 165 }; 166 167 #define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION) 168 169 #if _BLD_ast && defined(__EXPORT__) 170 #undef __MANGLE__ 171 #define __MANGLE__ __LINKAGE__ __EXPORT__ 172 #endif 173 174 extern __MANGLE__ int regcomp __PROTO__((regex_t*, const char*, regflags_t)); 175 extern __MANGLE__ size_t regerror __PROTO__((int, const regex_t*, char*, size_t)); 176 extern __MANGLE__ int regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t)); 177 extern __MANGLE__ void regfree __PROTO__((regex_t*)); 178 179 /* nonstandard hooks */ 180 181 #define _REG_cache 1 /* have regcache() */ 182 #define _REG_class 1 /* have regclass() */ 183 #define _REG_collate 1 /* have regcollate(), regclass() */ 184 #define _REG_comb 1 /* have regcomb() */ 185 #define _REG_decomp 1 /* have regdecomp() */ 186 #define _REG_dup 1 /* have regdup() */ 187 #define _REG_fatal 1 /* have regfatal(), regfatalpat() */ 188 #define _REG_ncomp 1 /* have regncomp() */ 189 #define _REG_nexec 1 /* have regnexec() */ 190 #define _REG_rexec 1 /* have regrexec(), regrecord() */ 191 #define _REG_stat 1 /* have regstat() */ 192 #define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */ 193 194 extern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**)); 195 extern __MANGLE__ int regaddclass __PROTO__((const char*, regclass_t)); 196 extern __MANGLE__ int regcollate __PROTO__((const char*, char**, char*, int)); 197 extern __MANGLE__ int regcomb __PROTO__((regex_t*, regex_t*)); 198 extern __MANGLE__ size_t regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t)); 199 extern __MANGLE__ int regdup __PROTO__((regex_t*, regex_t*)); 200 extern __MANGLE__ int regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t)); 201 extern __MANGLE__ int regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t)); 202 extern __MANGLE__ void regfatal __PROTO__((regex_t*, int, int)); 203 extern __MANGLE__ void regfatalpat __PROTO__((regex_t*, int, int, const char*)); 204 extern __MANGLE__ int regrecord __PROTO__((const regex_t*)); 205 extern __MANGLE__ int regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t)); 206 extern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*)); 207 208 extern __MANGLE__ regex_t* regcache __PROTO__((const char*, regflags_t, int*)); 209 210 extern __MANGLE__ int regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t)); 211 extern __MANGLE__ int regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*)); 212 extern __MANGLE__ int regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*)); 213 extern __MANGLE__ void regsubfree __PROTO__((regex_t*)); 214 215 /* obsolete hooks */ 216 217 #ifndef _SFIO_H 218 struct _sfio_s; 219 #endif 220 221 extern __MANGLE__ void regalloc __PROTO__((__V_*, regresize_t, regflags_t)); 222 extern __MANGLE__ int regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t)); 223 224 #undef __MANGLE__ 225 #define __MANGLE__ __LINKAGE__ 226 227 #endif 228