string-util: add common implementation of function that converts sized character buffers to NUL terminated C strings

This commit is contained in:
Lennart Poettering
2023-01-21 10:45:25 +01:00
parent 9e2e3342ca
commit 7153213e40
9 changed files with 130 additions and 57 deletions
+10
View File
@@ -239,6 +239,16 @@ bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok);
char *string_replace_char(char *str, char old_char, char new_char);
typedef enum MakeCStringMode {
MAKE_CSTRING_REFUSE_TRAILING_NUL,
MAKE_CSTRING_ALLOW_TRAILING_NUL,
MAKE_CSTRING_REQUIRE_TRAILING_NUL,
_MAKE_CSTRING_MODE_MAX,
_MAKE_CSTRING_MODE_INVALID = -1,
} MakeCStringMode;
int make_cstring(const char *s, size_t n, MakeCStringMode mode, char **ret);
size_t strspn_from_end(const char *str, const char *accept);
char *strdupspn(const char *a, const char *accept);