Commit | Line | Data |
---|---|---|
9c55c241 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com> |
9c55c241 | 3 | * |
c922647d | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
9c55c241 | 5 | * |
9c55c241 PP |
6 | */ |
7 | ||
8 | #ifndef _STRING_UTILS_H | |
9 | #define _STRING_UTILS_H | |
10 | ||
c9e313bc | 11 | #include <common/dynamic-array.hpp> |
28f23191 JG |
12 | #include <common/macros.hpp> |
13 | ||
14 | #include <stdbool.h> | |
9c55c241 PP |
15 | |
16 | void strutils_normalize_star_glob_pattern(char *pattern); | |
f181fa5a | 17 | |
9c55c241 | 18 | bool strutils_is_star_glob_pattern(const char *pattern); |
f181fa5a | 19 | |
9c55c241 | 20 | bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern); |
f181fa5a | 21 | |
9c55c241 | 22 | char *strutils_unescape_string(const char *input, char only_char); |
f181fa5a | 23 | |
28f23191 JG |
24 | int strutils_split(const char *input, |
25 | char delim, | |
26 | bool escape_delim, | |
27 | struct lttng_dynamic_pointer_array *out_strings); | |
f181fa5a | 28 | |
9c55c241 | 29 | void strutils_free_null_terminated_array_of_strings(char **array); |
f181fa5a | 30 | |
28f23191 | 31 | size_t strutils_array_of_strings_len(char *const *array); |
9c55c241 | 32 | |
4ff75060 SM |
33 | /* |
34 | * Append `append` to the malloc-end string `str`. | |
35 | * | |
36 | * On success, `str` is free'd (if not NULL) and assigned a new malloc-ed | |
37 | * string. On failure, `str` is not modified. | |
38 | * | |
39 | * Return 0 on success, -ENOMEM on failure. | |
40 | */ | |
d50d200a SM |
41 | C_LINKAGE int strutils_append_str(char **str, const char *append); |
42 | ||
43 | /* | |
44 | * Like `strutils_append_str`, but the appended string is formatted using | |
45 | * `fmt` and the following arguments. | |
46 | */ | |
28f23191 | 47 | C_LINKAGE ATTR_FORMAT_PRINTF(2, 3) int strutils_appendf(char **s, const char *fmt, ...); |
4ff75060 | 48 | |
9c55c241 | 49 | #endif /* _STRING_UTILS_H */ |