From d864c5533606bc789809567c2719fb835a2507ca Mon Sep 17 00:00:00 2001 From: Bjoern Walk Date: Tue, 15 Oct 2024 16:23:57 +0200 Subject: [PATCH] libutil: Introduce util_str_tolower() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Mete Durlu Reviewed-by: Jan Höppner Reviewed-by: Steffen Eiden Signed-off-by: Bjoern Walk Signed-off-by: Jan Höppner --- include/lib/util_libc.h | 1 + libutil/util_libc.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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 */