Header: <cwist/core/sstring/sstring.h>
Safe, dynamic string manipulation library.
cwist_sstring_create
cwist_sstring * cwist_sstring_create(void)
Create a new sstring instance.
Creates a dynamic string.
cwist_sstring_assign_len
cwist_error_t cwist_sstring_assign_len(cwist_sstring *str, const char *data, size_t len)
Assign raw bytes with length.
Integrated error structure used throughout the system.
Binary-safe assignment. Copies exactly len bytes (plus a trailing NUL for convenience) so HTTP handlers can store POST bodies that contain \0.
cwist_sstring_append
cwist_error_t cwist_sstring_append(cwist_sstring *str, const char *data)
Append a C string.
Safe concatenation. Returns cwist_error_t.
cwist_sstring_append_len
cwist_error_t cwist_sstring_append_len(cwist_sstring *str, const char *data, size_t len)
Append raw bytes with length.
Binary-safe append. Used by the HTTP response serializer to stream exact Content-Length bytes.
cwist_sstring_assign
cwist_error_t cwist_sstring_assign(cwist_sstring *str, const char *data)
Assign a C string.
Replaces the string contents with a NUL-terminated C string.
cwist_sstring_ltrim / cwist_sstring_rtrim / cwist_sstring_trim
cwist_error_t cwist_sstring_rtrim(cwist_sstring *str)
Right-trim whitespace.
cwist_error_t cwist_sstring_trim(cwist_sstring *str)
Trim whitespace from both ends.
cwist_error_t cwist_sstring_ltrim(cwist_sstring *str)
Left-trim whitespace.
Remove leading whitespace (ltrim), trailing whitespace (rtrim), or both (trim) in place.
cwist_sstring_compare
int cwist_sstring_compare(cwist_sstring *str, const char *compare_to)
Compare with a C string.
Compares the string contents to a NUL-terminated C string. Returns 0 if equal, a negative value if str sorts before compare_to, or a positive value if after (same semantics as strcmp).
cwist_sstring_destroy
void cwist_sstring_destroy(cwist_sstring *str)
Destroy an sstring instance.
Frees the string memory.