From 4e07436b13fe15d88d0d40a1da4933585d013b58 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Fri, 27 Feb 2009 14:37:44 +0100 Subject: Add functions str_toupper() and str_casecmp_char() --- str.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'str.c') diff --git a/str.c b/str.c index ee406e3..82edf73 100644 --- a/str.c +++ b/str.c @@ -30,10 +30,12 @@ #include +#include #include #include #include #include +#include #include "str.h" #include "util.h" @@ -206,7 +208,7 @@ str_len(const ld_string_t *str) } /* - * Retrun a const char * type. + * Return a const char * type. */ const char * str_buf(const ld_string_t *src) @@ -369,6 +371,29 @@ cleanup: return result; } +void +str_toupper(ld_string_t *str) +{ + char *ptr; + + REQUIRE(str != NULL); + + if (str->data == NULL) + return; + + for (ptr = str->data; *ptr != '\0'; ptr++) + *ptr = toupper((unsigned char)*ptr); +} + +int +str_casecmp_char(const ld_string_t *s1, const char *s2) +{ + REQUIRE(s1 != NULL && s1->data != NULL); + REQUIRE(s2 != NULL); + + return strcasecmp(s1->data, s2); +} + /* * TODO: Review. */ -- cgit