From 218f482fbfe96b2cddec8c05f6b8f174481d2e27 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 12 Oct 2008 00:56:56 +0200 Subject: Use common strlist implementation in Samba 3 and Samba 4. --- source3/Makefile.in | 4 +- source3/auth/auth.c | 4 +- source3/include/proto.h | 4 +- source3/lib/util_str.c | 107 ------------------------------------- source3/libads/ldap.c | 4 +- source3/rpc_server/srv_svcctl_nt.c | 2 +- source3/smbd/password.c | 4 +- 7 files changed, 11 insertions(+), 118 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 52dcbfb939..65a9ca42e4 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -323,8 +323,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) \ ../lib/util/time.o \ lib/ufc.o lib/genrand.o lib/username.o \ lib/util_pw.o lib/access.o lib/smbrun.o \ - lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o \ - ../lib/util/xfile.o lib/wins_srv.o $(UTIL_REG_OBJ) \ + lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o $(UTIL_REG_OBJ) \ + ../lib/util/xfile.o ../lib/util/util_strlist.o lib/wins_srv.o \ lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \ lib/util_unistr.o lib/util_file.o lib/data_blob.o \ lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \ diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 754cb7a508..7f95656bef 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -459,8 +459,8 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) NTSTATUS nt_status; if (lp_auth_methods() - && !str_list_copy(talloc_tos(), &auth_method_list, - lp_auth_methods())) { + && !(auth_method_list = str_list_copy(talloc_tos(), + lp_auth_methods()))) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/include/proto.h b/source3/include/proto.h index d4b9e67caa..34db104905 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1672,9 +1672,9 @@ char *binary_string_rfc2254(char *buf, int len); char *binary_string(char *buf, int len); int fstr_sprintf(fstring s, const char *fmt, ...); char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); -bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src); +char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); bool str_list_compare(char **list1, char **list2); -int str_list_count( const char **list ); +size_t str_list_length( const char **list ); bool str_list_sub_basic( char **list, const char *smb_name, const char *domain_name ); bool str_list_substitute(char **list, const char *pattern, const char *insert); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 9f952abf10..b0a7cb072d 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1843,97 +1843,6 @@ int fstr_sprintf(fstring s, const char *fmt, ...) #define S_LIST_ABS 16 /* List Allocation Block Size */ -char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) -{ - char **list; - const char *str; - char *s; - int num, lsize; - char *tok; - - if (!string || !*string) - return NULL; - - list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1); - if (list == NULL) { - return NULL; - } - lsize = S_LIST_ABS; - - s = talloc_strdup(list, string); - if (s == NULL) { - DEBUG(0,("str_list_make: Unable to allocate memory")); - TALLOC_FREE(list); - return NULL; - } - if (!sep) sep = LIST_SEP; - - num = 0; - str = s; - - while (next_token_talloc(list, &str, &tok, sep)) { - - if (num == lsize) { - char **tmp; - - lsize += S_LIST_ABS; - - tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *, - lsize + 1); - if (tmp == NULL) { - DEBUG(0,("str_list_make: " - "Unable to allocate memory")); - TALLOC_FREE(list); - return NULL; - } - - list = tmp; - - memset (&list[num], 0, - ((sizeof(char**)) * (S_LIST_ABS +1))); - } - - list[num] = tok; - num += 1; - } - - list[num] = NULL; - - TALLOC_FREE(s); - return list; -} - -bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src) -{ - char **list; - int i, num; - - *dest = NULL; - if (!src) - return false; - - num = 0; - while (src[num] != NULL) { - num += 1; - } - - list = TALLOC_ARRAY(mem_ctx, char *, num+1); - if (list == NULL) { - return false; - } - - for (i=0; i