Open SCAP Library
oscap_pcre.h
1 /*
2  * Copyright 2023 Red Hat Inc., Durham, North Carolina.
3  * All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Authors:
20  * Evgenii Kolesnikov <ekolesni@redhat.com>
21  */
22 
23 #ifndef OSCAP_PCRE_
24 #define OSCAP_PCRE_
25 
26 typedef struct oscap_pcre oscap_pcre_t;
27 
28 typedef enum {
29  OSCAP_PCRE_OPTS_NONE = 0x0001,
30  OSCAP_PCRE_OPTS_UTF8 = 0x0002,
31  OSCAP_PCRE_OPTS_MULTILINE = 0x0004,
32  OSCAP_PCRE_OPTS_DOTALL = 0x0008,
33  OSCAP_PCRE_OPTS_CASELESS = 0x0010,
34  OSCAP_PCRE_OPTS_NO_UTF8_CHECK = 0x0020,
35  OSCAP_PCRE_OPTS_PARTIAL = 0x0040,
36 } oscap_pcre_options_t;
37 
38 typedef enum {
39  OSCAP_PCRE_ERR_NOMATCH = -1,
40  OSCAP_PCRE_ERR_PARTIAL = -2,
41  OSCAP_PCRE_ERR_BADPARTIAL = -3,
42  OSCAP_PCRE_ERR_BADUTF8 = -10,
43  OSCAP_PCRE_ERR_RECURSIONLIMIT = -21,
44  OSCAP_PCRE_ERR_UNKNOWN = -100,
45 } oscap_pcre_error_t;
46 
47 
59 oscap_pcre_t* oscap_pcre_compile(const char *pattern, oscap_pcre_options_t options,
60  char **errptr, int *erroffset);
61 
75 int oscap_pcre_exec(const oscap_pcre_t *opcre, const char *subject,
76  int length, int startoffset, oscap_pcre_options_t options,
77  int *ovector, int ovecsize);
78 
83 void oscap_pcre_free(oscap_pcre_t *opcre);
84 
91 void oscap_pcre_set_match_limit_recursion(oscap_pcre_t *opcre, unsigned long limit);
92 
97 void oscap_pcre_optimize(oscap_pcre_t *opcre);
98 
110 int oscap_pcre_get_substrings(char *str, int *ofs, oscap_pcre_t *re, int want_substrs, char ***substrings);
111 
116 void oscap_pcre_err_free(char *err);
117 
118 #endif
Definition: oscap_pcre.c:43