diff options
author | Martin Nagy <mnagy@redhat.com> | 2009-02-27 14:37:44 +0100 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2009-03-16 15:45:47 +0100 |
commit | 4e07436b13fe15d88d0d40a1da4933585d013b58 (patch) | |
tree | 9532417f789b460a75867745a43405ff927fe5a5 | |
parent | a832ae4bb0fcc62a9c6fa6155ab67d2ea1c3f754 (diff) | |
download | ldap_driver_testing-4e07436b13fe15d88d0d40a1da4933585d013b58.tar.gz ldap_driver_testing-4e07436b13fe15d88d0d40a1da4933585d013b58.tar.xz ldap_driver_testing-4e07436b13fe15d88d0d40a1da4933585d013b58.zip |
Add functions str_toupper() and str_casecmp_char()
-rw-r--r-- | str.c | 27 | ||||
-rw-r--r-- | str.h | 3 |
2 files changed, 29 insertions, 1 deletions
@@ -30,10 +30,12 @@ #include <dns/result.h> +#include <ctype.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #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. */ @@ -54,6 +54,9 @@ isc_result_t str_cat_char(ld_string_t *dest, const char *src); isc_result_t str_cat(ld_string_t *dest, const ld_string_t *src); isc_result_t str_sprintf(ld_string_t *dest, const char *format, ...); isc_result_t str_vsprintf(ld_string_t *dest, const char *format, va_list ap); +void str_toupper(ld_string_t *str); + +int str_casecmp_char(const ld_string_t *s1, const char *s2); isc_result_t str_new_split(isc_mem_t *mctx, ld_split_t **splitp); void str_destroy_split(ld_split_t **splitp); |