From: Florian Forster Date: Sun, 20 Jun 2010 19:39:05 +0000 (+0200) Subject: src/common.[ch]: Implement "strtolower" and "strtolower_copy". X-Git-Tag: v4.0.0~221 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=96c41b0aed8e2b9f6a5fa70dbba77465a2da4173;p=collection4.git src/common.[ch]: Implement "strtolower" and "strtolower_copy". --- diff --git a/src/common.c b/src/common.c index 2b6b5eb..4916b3c 100644 --- a/src/common.c +++ b/src/common.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -190,4 +191,25 @@ int print_debug (const char *format, ...) /* {{{ */ return (status); } /* }}} int print_debug */ +char *strtolower (char *str) /* {{{ */ +{ + unsigned int i; + + if (str == NULL) + return (NULL); + + for (i = 0; str[i] != 0; i++) + str[i] = (char) tolower ((int) str[i]); + + return (str); +} /* }}} char *strtolower */ + +char *strtolower_copy (const char *str) +{ + if (str == NULL) + return (NULL); + + return (strdup (str)); +} + /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/common.h b/src/common.h index 2b5662f..ad589e7 100644 --- a/src/common.h +++ b/src/common.h @@ -20,5 +20,8 @@ int ds_list_from_rrd_file (char *file, uint32_t get_random_color (void); +char *strtolower (char *str); +char *strtolower_copy (const char *str); + #endif /* COMMON_H */ /* vim: set sw=2 sts=2 et fdm=marker : */