diff --git a/include/lib/util_libc.h b/include/lib/util_libc.h index 6b77876e..e5e2f982 100644 --- a/include/lib/util_libc.h +++ b/include/lib/util_libc.h @@ -129,6 +129,7 @@ int __util_vsprintf(const char *func, const char *file, int line, char *util_strcat_realloc(char *str1, const char *str2); void util_concatf(char **str1, const char *fmt, ...); void util_str_toupper(char *str); +void util_str_tolower(char *str); char *util_strstrip(char *s); size_t util_strlcpy(char *dest, const char *src, size_t size); diff --git a/libutil/util_libc.c b/libutil/util_libc.c index 8ffd1116..00b33ee3 100644 --- a/libutil/util_libc.c +++ b/libutil/util_libc.c @@ -174,6 +174,21 @@ void util_str_toupper(char *str) str[i] = toupper(str[i]); } +/** + * Convert string to lowercase + * + * String \a str is converted to lowercase + * + * @param[in,out] str String to convert + */ +void util_str_tolower(char *str) +{ + int i; + + for (i = 0; str[i] != '\0'; i++) + str[i] = tolower(str[i]); +} + /* * Print to newly allocated string or exit in case of failure */