diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-12 00:56:56 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-12 00:56:56 +0200 |
commit | 218f482fbfe96b2cddec8c05f6b8f174481d2e27 (patch) | |
tree | f54c33f277840e089793fff8547b05875546eac5 /lib/util | |
parent | cb78d4593b5ac4eaa0cbead6f86027d040a9e88a (diff) | |
download | samba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.tar.gz samba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.tar.bz2 samba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.zip |
Use common strlist implementation in Samba 3 and Samba 4.
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/tests/strlist.c | 6 | ||||
-rw-r--r-- | lib/util/util.h | 9 | ||||
-rw-r--r-- | lib/util/util_strlist.c | 18 |
3 files changed, 17 insertions, 16 deletions
diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c index 9af26f9e71..8605102954 100644 --- a/lib/util/tests/strlist.c +++ b/lib/util/tests/strlist.c @@ -71,17 +71,17 @@ static bool test_list_copy(struct torture_context *tctx) const char *empty_list[] = { NULL }; const char **null_list = NULL; - result = str_list_copy(tctx, list); + result = (const char **)str_list_copy(tctx, list); torture_assert_int_equal(tctx, str_list_length(result), 2, "list length"); torture_assert_str_equal(tctx, result[0], "foo", "element 0"); torture_assert_str_equal(tctx, result[1], "bar", "element 1"); torture_assert_str_equal(tctx, result[2], NULL, "element 2"); - result = str_list_copy(tctx, empty_list); + result = (const char **)str_list_copy(tctx, empty_list); torture_assert_int_equal(tctx, str_list_length(result), 0, "list length"); torture_assert_str_equal(tctx, result[0], NULL, "element 0"); - result = str_list_copy(tctx, null_list); + result = (const char **)str_list_copy(tctx, null_list); torture_assert(tctx, result == NULL, "result NULL"); return true; diff --git a/lib/util/util.h b/lib/util/util.h index 861b6affe5..5cecad7350 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -21,10 +21,9 @@ #ifndef _SAMBA_UTIL_H_ #define _SAMBA_UTIL_H_ +#include "lib/charset/charset.h" #include "../lib/util/attr.h" -#include "charset/charset.h" - /* for TALLOC_CTX */ #include <talloc.h> @@ -452,7 +451,7 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2); separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); /** * build a null terminated list of strings from an argv-like input string @@ -473,12 +472,12 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char /** return the number of elements in a string list */ -_PUBLIC_ size_t str_list_length(const char **list); +_PUBLIC_ size_t str_list_length(const char * const *list); /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); /** Return true if all the elements of the list match exactly. diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c index 30de4b962d..f576024cd1 100644 --- a/lib/util/util_strlist.c +++ b/lib/util/util_strlist.c @@ -21,6 +21,8 @@ #include "includes.h" #include "system/locale.h" +#undef strcasecmp + /** * @file * @brief String list manipulation @@ -31,30 +33,30 @@ separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; - const char **ret = NULL; + char **ret = NULL; if (sep == NULL) { sep = LIST_SEP; } - ret = talloc_array(mem_ctx, const char *, 1); + ret = talloc_array(mem_ctx, char *, 1); if (ret == NULL) { return NULL; } while (string && *string) { size_t len = strcspn(string, sep); - const char **ret2; + char **ret2; if (len == 0) { string += strspn(string, sep); continue; } - ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2); + ret2 = talloc_realloc(mem_ctx, ret, char *, num_elements+2); if (ret2 == NULL) { talloc_free(ret); return NULL; @@ -196,15 +198,15 @@ _PUBLIC_ size_t str_list_length(const char **list) /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) { int i; - const char **ret; + char **ret; if (list == NULL) return NULL; - ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1); + ret = talloc_array(mem_ctx, char *, str_list_length(list)+1); if (ret == NULL) return NULL; |