2 * This file is part of DisOrder
3 * Copyright (C) 2017 Mark Wooding
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file lib/regexp.h
19 * @brief Regular expressions
24 #if defined(HAVE_LIBPCRE2)
25 # ifndef PCRE2_CODE_UNIT_WIDTH
26 # define PCRE2_CODE_UNIT_WIDTH 8
29 typedef pcre2_code regexp
;
30 # define RXF_CASELESS PCRE2_CASELESS
31 # define RXERR_NOMATCH PCRE2_ERROR_NOMATCH
32 #elif defined(HAVE_PCRE_H)
35 # define RXF_CASELESS PCRE_CASELESS
36 # define RXERR_NOMATCH PCRE_ERROR_NOMATCH
38 # error "no supported regular expression library found"
41 void regexp_setup(void);
43 #define RXCERR_LEN 128
44 regexp
*regexp_compile(const char *pat
, unsigned f
,
45 char *errbuf
, size_t errlen
, size_t *erroff_out
);
47 int regexp_match(const regexp
*re
, const char *s
, size_t n
, unsigned f
,
48 size_t *ov
, size_t on
);
50 void regexp_free(regexp
*re
);