Coverage Report

Created: 2025-04-03 08:45

/src/wireshark/wsutil/regex.h
Line
Count
Source (jump to first uncovered line)
1
/** @file
2
 *
3
 * Wireshark - Network traffic analyzer
4
 * By Gerald Combs <gerald@wireshark.org>
5
 * Copyright 1998 Gerald Combs
6
 *
7
 * SPDX-License-Identifier: GPL-2.0-or-later
8
 */
9
10
#ifndef __WSUTIL_REGEX_H__
11
#define __WSUTIL_REGEX_H__
12
13
#include <wireshark.h>
14
15
#ifdef __cplusplus
16
extern "C" {
17
#endif
18
19
struct _ws_regex;
20
typedef struct _ws_regex ws_regex_t;
21
22
WS_DLL_PUBLIC ws_regex_t *
23
ws_regex_compile(const char *patt, char **errmsg);
24
25
0
#define WS_REGEX_CASELESS       (1U << 0)
26
/* By default UTF-8 is off. This option also prevents it from being
27
 * turned on using a pattern option. */
28
0
#define WS_REGEX_NEVER_UTF      (1U << 1)
29
0
#define WS_REGEX_ANCHORED       (1U << 2)
30
31
WS_DLL_PUBLIC ws_regex_t *
32
ws_regex_compile_ex(const char *patt, ssize_t size, char **errmsg, unsigned flags);
33
34
/** Matches a null-terminated subject string. */
35
WS_DLL_PUBLIC bool
36
ws_regex_matches(const ws_regex_t *re, const char *subj);
37
38
/** Matches a subject string length in 8 bit code units. */
39
WS_DLL_PUBLIC bool
40
ws_regex_matches_length(const ws_regex_t *re,
41
                        const char *subj, ssize_t subj_length);
42
43
/** Returns start and end position of the matched substring.
44
 *
45
 * @note Using a nonzero subj_offset produces different results than
46
 * passing a pointer to the later offset as subj when the pattern
47
 * begins with a lookbehind.
48
 *
49
 *  pos_vect[0] is first codepoint in the matched substring.
50
 *  pos_vect[1] is first codepoint past the matched substring.
51
 *  pos_vect[1] - pos_vect[0] is the matched substring length.
52
 *
53
 */
54
WS_DLL_PUBLIC bool
55
ws_regex_matches_pos(const ws_regex_t *re,
56
                        const char *subj, ssize_t subj_length,
57
                        size_t subj_offset, size_t pos_vect[2]);
58
59
WS_DLL_PUBLIC void
60
ws_regex_free(ws_regex_t *re);
61
62
WS_DLL_PUBLIC const char *
63
ws_regex_pattern(const ws_regex_t *re);
64
65
#ifdef __cplusplus
66
}
67
#endif
68
69
#endif /* __WSUTIL_REGEX_H__ */