Debian Codegraph @

crt/aws-c-sdkutils/include/aws/sdkutils/private/endpoints_regex.h

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #ifndef AWS_SDKUTILS_ENDPOINTS_REGEX_H
7 #define AWS_SDKUTILS_ENDPOINTS_REGEX_H
8
9 #include <aws/common/byte_buf.h>
10 #include <aws/sdkutils/sdkutils.h>
11
12 /*
13 * Warning: this is a minimal regex implementation that only covers cases needed
14 * for endpoint resolution and it is missing a lot of regex features.
15 * Please reconsider if you are planning to use below functions in any other
16 * context than endpoint resolution.
17 * Refer to source/endpoints_regex.c for limitations.
18 */
19
20 struct aws_endpoints_regex;
21
22 /*
23 * Parse regex pattern and construct "compiled" regex from it.
24 * Returns NULL on failure and raises following error code:
25 * - AWS_ERROR_INVALID_ARGUMENT - regex is invalid for some reason
26 * - AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_REGEX - regex is valid, but
27 * implementation does not support some of regex features
28 */
29 AWS_SDKUTILS_API struct aws_endpoints_regex *aws_endpoints_regex_new(
30 struct aws_allocator *allocator,
31 struct aws_byte_cursor regex_pattern);
32
33 /*
34 * Destroys compiled regex.
35 */
36 AWS_SDKUTILS_API void aws_endpoints_regex_destroy(struct aws_endpoints_regex *regex);
37
38 /*
39 * Matches text against regex.
40 * returns AWS_OP_SUCCESS on successful match and
41 * AWS_ERROR_SDKUTILS_ENDPOINTS_REGEX_NO_MATCH if text didn't match or
42 * AWS_ERROR_INVALID_ARGUMENT if inputs are invalid.
43 *
44 */
45 AWS_SDKUTILS_API int aws_endpoints_regex_match(const struct aws_endpoints_regex *regex, struct aws_byte_cursor text);
46
47 #endif /* AWS_SDKUTILS_ENDPOINTS_REGEX_H */