10b57cec5SDimitry Andric /*- 20b57cec5SDimitry Andric * This code is derived from OpenBSD's libc/regex, original license follows: 30b57cec5SDimitry Andric * 40b57cec5SDimitry Andric * Copyright (c) 1992 Henry Spencer. 50b57cec5SDimitry Andric * Copyright (c) 1992, 1993 60b57cec5SDimitry Andric * The Regents of the University of California. All rights reserved. 70b57cec5SDimitry Andric * 80b57cec5SDimitry Andric * This code is derived from software contributed to Berkeley by 90b57cec5SDimitry Andric * Henry Spencer of the University of Toronto. 100b57cec5SDimitry Andric * 110b57cec5SDimitry Andric * Redistribution and use in source and binary forms, with or without 120b57cec5SDimitry Andric * modification, are permitted provided that the following conditions 130b57cec5SDimitry Andric * are met: 140b57cec5SDimitry Andric * 1. Redistributions of source code must retain the above copyright 150b57cec5SDimitry Andric * notice, this list of conditions and the following disclaimer. 160b57cec5SDimitry Andric * 2. Redistributions in binary form must reproduce the above copyright 170b57cec5SDimitry Andric * notice, this list of conditions and the following disclaimer in the 180b57cec5SDimitry Andric * documentation and/or other materials provided with the distribution. 190b57cec5SDimitry Andric * 3. Neither the name of the University nor the names of its contributors 200b57cec5SDimitry Andric * may be used to endorse or promote products derived from this software 210b57cec5SDimitry Andric * without specific prior written permission. 220b57cec5SDimitry Andric * 230b57cec5SDimitry Andric * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 240b57cec5SDimitry Andric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 250b57cec5SDimitry Andric * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 260b57cec5SDimitry Andric * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 270b57cec5SDimitry Andric * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 280b57cec5SDimitry Andric * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 290b57cec5SDimitry Andric * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 300b57cec5SDimitry Andric * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 310b57cec5SDimitry Andric * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 320b57cec5SDimitry Andric * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 330b57cec5SDimitry Andric * SUCH DAMAGE. 340b57cec5SDimitry Andric * 350b57cec5SDimitry Andric * @(#)regex.h 8.1 (Berkeley) 6/2/93 360b57cec5SDimitry Andric */ 370b57cec5SDimitry Andric 38*06c3fb27SDimitry Andric #ifndef LLVM_SUPPORT_REGEX_IMPL_H 39*06c3fb27SDimitry Andric #define LLVM_SUPPORT_REGEX_IMPL_H 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric #include <sys/types.h> 420b57cec5SDimitry Andric typedef off_t llvm_regoff_t; 430b57cec5SDimitry Andric typedef struct { 440b57cec5SDimitry Andric llvm_regoff_t rm_so; /* start of match */ 450b57cec5SDimitry Andric llvm_regoff_t rm_eo; /* end of match */ 460b57cec5SDimitry Andric } llvm_regmatch_t; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric typedef struct llvm_regex { 490b57cec5SDimitry Andric int re_magic; 500b57cec5SDimitry Andric size_t re_nsub; /* number of parenthesized subexpressions */ 510b57cec5SDimitry Andric const char *re_endp; /* end pointer for REG_PEND */ 520b57cec5SDimitry Andric struct re_guts *re_g; /* none of your business :-) */ 530b57cec5SDimitry Andric } llvm_regex_t; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /* llvm_regcomp() flags */ 560b57cec5SDimitry Andric #define REG_BASIC 0000 570b57cec5SDimitry Andric #define REG_EXTENDED 0001 580b57cec5SDimitry Andric #define REG_ICASE 0002 590b57cec5SDimitry Andric #define REG_NOSUB 0004 600b57cec5SDimitry Andric #define REG_NEWLINE 0010 610b57cec5SDimitry Andric #define REG_NOSPEC 0020 620b57cec5SDimitry Andric #define REG_PEND 0040 630b57cec5SDimitry Andric #define REG_DUMP 0200 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric /* llvm_regerror() flags */ 660b57cec5SDimitry Andric #define REG_NOMATCH 1 670b57cec5SDimitry Andric #define REG_BADPAT 2 680b57cec5SDimitry Andric #define REG_ECOLLATE 3 690b57cec5SDimitry Andric #define REG_ECTYPE 4 700b57cec5SDimitry Andric #define REG_EESCAPE 5 710b57cec5SDimitry Andric #define REG_ESUBREG 6 720b57cec5SDimitry Andric #define REG_EBRACK 7 730b57cec5SDimitry Andric #define REG_EPAREN 8 740b57cec5SDimitry Andric #define REG_EBRACE 9 750b57cec5SDimitry Andric #define REG_BADBR 10 760b57cec5SDimitry Andric #define REG_ERANGE 11 770b57cec5SDimitry Andric #define REG_ESPACE 12 780b57cec5SDimitry Andric #define REG_BADRPT 13 790b57cec5SDimitry Andric #define REG_EMPTY 14 800b57cec5SDimitry Andric #define REG_ASSERT 15 810b57cec5SDimitry Andric #define REG_INVARG 16 820b57cec5SDimitry Andric #define REG_ATOI 255 /* convert name to number (!) */ 830b57cec5SDimitry Andric #define REG_ITOA 0400 /* convert number to name (!) */ 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric /* llvm_regexec() flags */ 860b57cec5SDimitry Andric #define REG_NOTBOL 00001 870b57cec5SDimitry Andric #define REG_NOTEOL 00002 880b57cec5SDimitry Andric #define REG_STARTEND 00004 890b57cec5SDimitry Andric #define REG_TRACE 00400 /* tracing of execution */ 900b57cec5SDimitry Andric #define REG_LARGE 01000 /* force large representation */ 910b57cec5SDimitry Andric #define REG_BACKR 02000 /* force use of backref code */ 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric #ifdef __cplusplus 940b57cec5SDimitry Andric extern "C" { 950b57cec5SDimitry Andric #endif 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric int llvm_regcomp(llvm_regex_t *, const char *, int); 980b57cec5SDimitry Andric size_t llvm_regerror(int, const llvm_regex_t *, char *, size_t); 990b57cec5SDimitry Andric int llvm_regexec(const llvm_regex_t *, const char *, size_t, 1000b57cec5SDimitry Andric llvm_regmatch_t [], int); 1010b57cec5SDimitry Andric void llvm_regfree(llvm_regex_t *); 1020b57cec5SDimitry Andric size_t llvm_strlcpy(char *dst, const char *src, size_t siz); 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric #ifdef __cplusplus 1050b57cec5SDimitry Andric } 1060b57cec5SDimitry Andric #endif 1070b57cec5SDimitry Andric 108*06c3fb27SDimitry Andric #endif /* LLVM_SUPPORT_REGEX_IMPL_H */ 109