Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / wsutil / regex.h
blob199779a2af2ace824d6febf17fa059b0c7a1fb7a
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef __WSUTIL_REGEX_H__
11 #define __WSUTIL_REGEX_H__
13 #include <wireshark.h>
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 struct _ws_regex;
20 typedef struct _ws_regex ws_regex_t;
22 WS_DLL_PUBLIC ws_regex_t *
23 ws_regex_compile(const char *patt, char **errmsg);
25 #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 #define WS_REGEX_NEVER_UTF (1U << 1)
29 #define WS_REGEX_ANCHORED (1U << 2)
31 WS_DLL_PUBLIC ws_regex_t *
32 ws_regex_compile_ex(const char *patt, ssize_t size, char **errmsg, unsigned flags);
34 /** Matches a null-terminated subject string. */
35 WS_DLL_PUBLIC bool
36 ws_regex_matches(const ws_regex_t *re, const char *subj);
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);
43 /** Returns start and end position of the matched substring.
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.
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.
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]);
59 WS_DLL_PUBLIC void
60 ws_regex_free(ws_regex_t *re);
62 WS_DLL_PUBLIC const char *
63 ws_regex_pattern(const ws_regex_t *re);
65 #ifdef __cplusplus
67 #endif
69 #endif /* __WSUTIL_REGEX_H__ */