libutil: Introduce util_str_tolower()

Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Bjoern Walk
2024-10-15 16:23:57 +02:00
committed by Jan Höppner
parent 1b18ba3a03
commit d864c55336
2 changed files with 16 additions and 0 deletions

View File

@@ -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);

View File

@@ -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
*/