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