diff -r 96f643d30ff1 -r f1b2146d4805 src/ucx/string.h --- a/src/ucx/string.h Sun Mar 11 13:43:07 2018 +0100 +++ b/src/ucx/string.h Sun Apr 01 09:51:01 2018 +0200 @@ -264,6 +264,14 @@ */ sstr_t sstrrchr(sstr_t string, int chr); + +const char* ucx_strstr( + const char *str, + size_t length, + const char *match, + size_t matchlen, + size_t *newlen); + /** * Returns a substring starting at the location of the first occurrence of the * specified string. @@ -279,7 +287,11 @@ * match, or an empty string, if the sequence is not * present in string */ -sstr_t sstrstr(sstr_t string, sstr_t match); +sstr_t ucx_sstrstr(sstr_t string, scstr_t match); +#define sstrstr(string, match) ucx_sstrstr(string, SCSTR(match)) + +scstr_t ucx_scstrstr(scstr_t string, scstr_t match); +#define scstrstr(string, match) ucx_scstrstr(string, SCSTR(match)) /** * Splits a string into parts by using a delimiter string. @@ -328,7 +340,9 @@ * * @see sstrsplit_a() */ -sstr_t* sstrsplit(sstr_t string, sstr_t delim, ssize_t *count); +sstr_t* ucx_strsplit(scstr_t string, scstr_t delim, ssize_t *count); + +#define sstrsplit(s, delim, count) ucx_strsplit(SCSTR(s), SCSTR(delim), count) /** * Performing sstrsplit() using a UcxAllocator. @@ -352,9 +366,11 @@ * * @see sstrsplit() */ -sstr_t* sstrsplit_a(UcxAllocator *allocator, sstr_t string, sstr_t delim, +sstr_t* ucx_strsplit_a(UcxAllocator *allocator, scstr_t string, scstr_t delim, ssize_t *count); +#define sstrsplit_a(a, s, d, c) ucx_strsplit_a(a, SCSTR(s), SCSTR(d, c)) + /** * Compares two UCX strings with standard memcmp(). * @@ -367,7 +383,9 @@ * length of s1 is greater than the length of s2 or the result of * memcmp() otherwise (i.e. 0 if the strings match) */ -int sstrcmp(sstr_t s1, sstr_t s2); +int ucx_str_cmp(scstr_t s1, scstr_t s2); + +#define sstrcmp(s1, s2) ucx_str_cmp(SCSTR(s1), SCSTR(s2)) /** * Compares two UCX strings ignoring the case. @@ -383,7 +401,9 @@ * first two differing characters otherwise (i.e. 0 if the strings match and * no characters differ) */ -int sstrcasecmp(sstr_t s1, sstr_t s2); +int ucx_str_casecmp(scstr_t s1, scstr_t s2); + +#define sstrcasecmp(s1, s2) ucx_str_casecmp(SCSTR(s1), SCSTR(s2)) /** * Creates a duplicate of the specified string. @@ -423,6 +443,9 @@ #define sstrdup_a(allocator, s) scstrdup_a(allocator, SCSTR(s)) + +size_t ucx_strtrim(const char *str, size_t length, size_t *newlen); + /** * Omits leading and trailing spaces. * @@ -442,6 +465,8 @@ */ sstr_t sstrtrim(sstr_t string); +scstr_t scstrtrim(scstr_t string); + /** * Checks, if a string has a specific prefix. * @param string the string to check