-
Notifications
You must be signed in to change notification settings - Fork 1
/
regexec.h
75 lines (64 loc) · 3.96 KB
/
regexec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Copyright (c) 2019-2024 Griefer@Work *
* *
* This software is provided 'as-is', without any express or implied *
* warranty. In no event will the authors be held liable for any damages *
* arising from the use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose, *
* including commercial applications, and to alter it and redistribute it *
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must not *
* claim that you wrote the original software. If you use this software *
* in a product, an acknowledgement (see the following) in the product *
* documentation is required: *
* Portions Copyright (c) 2019-2024 Griefer@Work *
* 2. Altered source versions must be plainly marked as such, and must not be *
* misrepresented as being the original software. *
* 3. This notice may not be removed or altered from any source distribution. *
*/
#ifndef GUARD_LIBREGEX_REGEXEC_H
#define GUARD_LIBREGEX_REGEXEC_H 1
#include "api.h"
#ifndef LIBREGEX_NO_SYSTEM_INCLUDES
#include <hybrid/compiler.h>
#include <kos/types.h>
#include <libregex/regexec.h>
#endif /* !LIBREGEX_NO_SYSTEM_INCLUDES */
DECL_BEGIN
/* Execute a regular expression.
* @return: >= 0: The # of bytes starting at `exec->rx_startoff' that got matched.
* @return: -RE_NOMATCH: Nothing was matched
* @return: -RE_ESPACE: Out of memory
* @return: -RE_ESIZE: On-failure stack became too large. */
INTDEF WUNUSED NONNULL((1)) ssize_t
NOTHROW_NCX(CC libre_exec_match)(struct re_exec const *__restrict exec);
/* Similar to `re_exec_match', try to match a pattern against the given input buffer. Do this
* with increasing offsets for the first `search_range' bytes, meaning at most `search_range'
* regex matches will be performed.
* @param: search_range: One plus the max starting byte offset (from `exec->rx_startoff') to
* check. Too great values for `search_range' are automatically clamped.
* @param: p_match_size: When non-NULL, set to the # of bytes that were actually matched.
* This would have been the return value of `re_exec_match(3R)'.
* @return: >= 0: The offset where the matched area starts (in `[exec->rx_startoff, exec->rx_startoff + search_range)').
* @return: -RE_NOMATCH: Nothing was matched
* @return: -RE_ESPACE: Out of memory
* @return: -RE_ESIZE: On-failure stack became too large. */
INTDEF WUNUSED NONNULL((1)) ssize_t
NOTHROW_NCX(CC libre_exec_search)(struct re_exec const *__restrict exec,
size_t search_range, size_t *p_match_size);
/* Similar to `re_exec_search(3)', but never returns epsilon.
* Instead, keep on searching if epsilon happens to be matched. */
INTDEF WUNUSED NONNULL((1)) ssize_t
NOTHROW_NCX(CC libre_exec_search_noepsilon)(struct re_exec const *__restrict exec,
size_t search_range, size_t *p_match_size);
/* Same as `re_exec_search(3R)', but perform searching with starting
* offsets in `[exec->rx_endoff - search_range, exec->rx_endoff)'
* Too great values for `search_range' are automatically clamped.
* The return value will thus be the greatest byte-offset where the
* given pattern matches that is still within that range. */
INTDEF WUNUSED NONNULL((1)) ssize_t
NOTHROW_NCX(CC libre_exec_rsearch)(struct re_exec const *__restrict exec,
size_t search_range, size_t *p_match_size);
DECL_END
#endif /* !GUARD_LIBREGEX_REGEXEC_H */