NetSurf
regex.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Vincent Sanders <vince@netxurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf 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.
14 *
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/>.
17 */
18
19#ifndef NETSURF_UTILS_REGEX_H_
20#define NETSURF_UTILS_REGEX_H_
21
22#include "utils/config.h"
23
24#ifdef HAVE_REGEX
25#include <sys/types.h>
26#include <regex.h>
27#else
28
29#define REG_NOMATCH 1
30
31#define REG_EXTENDED 1
32#define REG_ICASE (1 << 1)
33#define REG_NEWLINE (1 << 2)
34#define REG_NOSUB (1 << 3)
35
36typedef ssize_t regoff_t;
37
38typedef struct {
39 size_t re_nsub; /* Number of parenthesized subexpressions.*/
40} regex_t;
41
42
43typedef struct {
44 regoff_t rm_so; /* Byte offset from start of string to start
45 * of substring.
46 */
47 regoff_t rm_eo; /* Byte offset from start of string of the
48 * first character after the end of substring.
49 */
51
52
53int regcomp(regex_t *restrict preg, const char *restrictregex, int cflags);
54
55size_t regerror(int errorcode, const regex_t *restrict preg, char *restrict errbuf, size_t errbuf_size);
56
57int regexec(const regex_t *restrict preg, const char *restrict string, size_t nmatch, regmatch_t pmatch[restrict], int eflags);
58
59void regfree(regex_t *preg);
60
61#endif
62
63#endif
size_t regerror(int errorcode, const regex_t *restrict preg, char *restrict errbuf, size_t errbuf_size)
Definition: utils.c:548
int regexec(const regex_t *restrict preg, const char *restrict string, size_t nmatch, regmatch_t pmatch[restrict], int eflags)
Definition: utils.c:560
ssize_t regoff_t
Definition: regex.h:36
void regfree(regex_t *preg)
Definition: utils.c:569
int regcomp(regex_t *restrict preg, const char *restrictregex, int cflags)
Definition: utils.c:542
Definition: regex.h:38
size_t re_nsub
Definition: regex.h:39
regoff_t rm_eo
Definition: regex.h:47
regoff_t rm_so
Definition: regex.h:44