diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
| commit | 06950aab233de6a2f47293d59575bb42f6131660 (patch) | |
| tree | 62f6eed4a6d35414f656d22b9ac7420849018a11 /src/strutil.h | |
| parent | 1ef9c463f1efc1adfb62e42ab3dd17e8c6394373 (diff) | |
Complete rewrite using C++ and with shared state support
Diffstat (limited to 'src/strutil.h')
| -rw-r--r-- | src/strutil.h | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/strutil.h b/src/strutil.h deleted file mode 100644 index f4dea54..0000000 --- a/src/strutil.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * \file strutil.h - * A collection of string utilities. - */ - -#ifndef STRUTIL_H -#define STRUTIL_H - -#include "dynstr.h" - -#include <string.h> - -/** - * Allocate a string initialized with the len first bytes of src. - * Similar to strndup but it doesn't check for '\0' in src. - * Returns NULL in case of allocation errors. - * @param src string to copy len bytes from, may not be NULL - * @param len bytes to copy from src - * @return newly allocate null-terminated string - */ -MALLOC NONULL char* strdup_len(const char* src, size_t len); - -/** - * Unescape (remove backslashes from) a null-terminated string inline. - * Does not have any special handling for sequences like \\n, \\t or \\0. - * @param str null-terminated string to remove backslashes from, may not be NULL - */ -NONULL void unescape(char* str); - -/** - * Escape all listed characters if they appear in string with backslash. - * Also escapes backslash. - * Returns NULL in case of allocation errors. - * @param str null-terminated string to escape characters in if needed, - * may not be NULL - * @param chars null-terminated string containing all characters that need to - * be escaped, may not be NULL - * @return newly allocated null-terminated copy of string with - * characters escaped - */ -MALLOC NONULL char* escape(const char* str, const char* chars); - -/** - * Escape all listed characters if they appear in the dynamic string with - * backslash inline. Also escapes backslash. - * @param str dynamic string to escape characters in if needed, - * may not be NULL - * @param chars null-terminated string containing all characters that need to - * be escaped, may not be NULL - * @return false in case of allocation errors - */ -NONULL bool dynstr_escape(dynstr_t* str, const char* chars); - -/** - * Split string by delimiter. - * Returned list will always contain at least one item and will be - * null-terminated. - * Returns NULL in case of allocation errors. - * @param start start of string to split by delimiter - * @param end end of string to split by delimiter - * @param delim delimiter to use - * @return null-terminated list of strings or NULL - */ -NONULL char** split_len(const char* start, const char* end, char delim); - -/** - * Split string by delimiter. - * Returned list will always contain at least one item and will be - * null-terminated. - * Returns NULL in case of allocation errors. - * @param str string to split by delimiter - * @param delim delimiter to use - * @return null-terminated list of strings or NULL - */ -NONULL static inline char** split(const char* str, char delim) -{ - assert(str); - return split_len(str, str + strlen(str), delim); -} - -#endif /* STRUTIL_H */ |
