summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-12 00:56:56 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-12 00:56:56 +0200
commit218f482fbfe96b2cddec8c05f6b8f174481d2e27 (patch)
treef54c33f277840e089793fff8547b05875546eac5 /source3
parentcb78d4593b5ac4eaa0cbead6f86027d040a9e88a (diff)
downloadsamba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.tar.gz
samba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.tar.bz2
samba-218f482fbfe96b2cddec8c05f6b8f174481d2e27.zip
Use common strlist implementation in Samba 3 and Samba 4.
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in4
-rw-r--r--source3/auth/auth.c4
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/lib/util_str.c107
-rw-r--r--source3/libads/ldap.c4
-rw-r--r--source3/rpc_server/srv_svcctl_nt.c2
-rw-r--r--source3/smbd/password.c4
7 files changed, 11 insertions, 118 deletions
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<num; i++) {
- list[i] = talloc_strdup(list, src[i]);
- if (list[i] == NULL) {
- TALLOC_FREE(list);
- return false;
- }
- }
- list[i] = NULL;
- *dest = list;
- return true;
-}
-
/**
* Return true if all the elements of the list match exactly.
**/
@@ -1956,22 +1865,6 @@ bool str_list_compare(char **list1, char **list2)
return true;
}
-/******************************************************************************
- *****************************************************************************/
-
-int str_list_count( const char **list )
-{
- int i = 0;
-
- if ( ! list )
- return 0;
-
- /* count the number of list members */
-
- for ( i=0; *list; i++, list++ );
-
- return i;
-}
/******************************************************************************
version of standard_sub_basic() for string lists; uses talloc_sub_basic()
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 40f052281d..e78465f7da 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -832,7 +832,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) {
+ if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) {
rc = LDAP_NO_MEMORY;
goto done;
}
@@ -1144,7 +1144,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(talloc_tos(), &search_attrs, attrs)))
+ if (!(search_attrs = str_list_copy(talloc_tos(), attrs)))
{
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
rc = LDAP_NO_MEMORY;
diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c
index a57d0ff4a4..1caf4941a4 100644
--- a/source3/rpc_server/srv_svcctl_nt.c
+++ b/source3/rpc_server/srv_svcctl_nt.c
@@ -61,7 +61,7 @@ static const struct generic_mapping svc_generic_map =
bool init_service_op_table( void )
{
const char **service_list = lp_svcctl_list();
- int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list );
+ int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_length( service_list );
int i;
if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) {
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 1d3514429f..88e7b766be 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -545,7 +545,7 @@ static bool user_ok(const char *user, int snum)
ret = True;
if (lp_invalid_users(snum)) {
- str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum));
+ invalid = str_list_copy(talloc_tos(), lp_invalid_users(snum));
if (invalid &&
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
@@ -561,7 +561,7 @@ static bool user_ok(const char *user, int snum)
TALLOC_FREE(invalid);
if (ret && lp_valid_users(snum)) {
- str_list_copy(talloc_tos(), &valid, lp_valid_users(snum));
+ valid = str_list_copy(talloc_tos(), lp_valid_users(snum));
if ( valid &&
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {