MXS-1450 Add more string trimming functions

- trim_leading
- trim_trailing

Implemented trim in terms of trim_leading and trim_trailing
This commit is contained in:
Johan Wikman
2017-09-26 13:34:11 +03:00
parent bb95074e88
commit 4220e3ca6a
3 changed files with 121 additions and 33 deletions

View File

@ -81,7 +81,41 @@ void gw_sha1_2_str(const uint8_t *in, int in_len, const uint8_t *in2, int in2_le
int gw_getsockerrno(int fd);
char *create_hex_sha1_sha1_passwd(char *passwd);
/**
* Trim leading whitespace from a string.
*
* @param str String to trim.
* @return @c str
*
* @note If there is leading whitespace, the string is moved so that
* the returned pointer is always the same as the one given as
* argument.
*/
char* trim_leading(char* str);
/**
* Trim trailing whitespace from a string.
*
* @param str String to trim.
* @return @c str
*
* @note The returned pointer is always the same the one given as
* argument.
*/
char* trim_trailing(char* str);
/**
* Trim leading and trailing whitespace from a string.
*
* @param str String to trim.
* @return @c str
*
* @note If there is leading whitespace, the string is moved so that
* the returned pointer is always the same the one given as
* argument.
*/
char* trim(char *str);
char* squeeze_whitespace(char* str);
bool strip_escape_chars(char*);