[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Fri Feb 5 11:11:05 UTC 2016


The branch, master has been updated
       via  da2aae9 s3:utils/smbget set default blocksize
       via  6412147 s3:utils/smbget add a error message on allocation error
       via  3e30998 util: Move util_strlist.c into samba-util-core
       via  c1a75ab util: Make util_strlist.c standalone with its own header file
       via  c4c1592 util: Split str_list_make_v3() into separate file
      from  aec07b8 s3:smbd:open: Skip redundant call to file_set_dosmode when creating a new file.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit da2aae933e3964aafce05c74755244e0f2b4d982
Author: Christian Ambach <ambi at samba.org>
Date:   Thu Feb 4 21:39:47 2016 +0100

    s3:utils/smbget set default blocksize
    
    this got lost in the recent refactorings and causes problems
    when smbget attempts to use a zero byte read buffer
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Fri Feb  5 12:10:16 CET 2016 on sn-devel-144

commit 64121471f98cfeaf48b701b3b85614a7436d3da9
Author: Christian Ambach <ambi at samba.org>
Date:   Thu Feb 4 21:38:20 2016 +0100

    s3:utils/smbget add a error message on allocation error
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 3e30998ffbb09a947a2fb884bb56c4a0083a485d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Feb 4 20:03:49 2016 +1100

    util: Move util_strlist.c into samba-util-core
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit c1a75ab5a4ad44e35bf2c04e18bf7246eb901e66
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Feb 4 20:00:58 2016 +1100

    util: Make util_strlist.c standalone with its own header file
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit c4c15924081086eb4e735ca28e77eecf1ae48b93
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Feb 4 19:42:54 2016 +1100

    util: Split str_list_make_v3() into separate file
    
    str_list_make_v3() calls next_token_talloc(), which has deep
    dependencies, so can't be used without dragging in a lot of code.  The
    other functions in this file are generally useful and have minimal
    dependencies.
    
    So leave the easily reusable code and split out the more difficult
    stuff.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/samba_util.h      | 122 +-----------------------------------
 lib/util/util_strlist.c    |  90 ++-------------------------
 lib/util/util_strlist.h    | 150 +++++++++++++++++++++++++++++++++++++++++++++
 lib/util/util_strlist_v3.c | 112 +++++++++++++++++++++++++++++++++
 lib/util/wscript_build     |   5 +-
 source3/utils/smbget.c     |   4 +-
 6 files changed, 275 insertions(+), 208 deletions(-)
 create mode 100644 lib/util/util_strlist.h
 create mode 100644 lib/util/util_strlist_v3.c


Changeset truncated at 500 lines:

diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 1f265e8..56cde7b 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -224,15 +224,6 @@ _PUBLIC_ char *rfc1738_escape_unescaped(TALLOC_CTX *mem_ctx, const char *url);
 _PUBLIC_ char *rfc1738_escape_part(TALLOC_CTX *mem_ctx, const char *url);
 
 /**
- * Add a string to an array of strings.
- *
- * num should be a pointer to an integer that holds the current 
- * number of elements in strings. It will be updated by this function.
- */
-_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx,
-			 const char *str, const char ***strings, size_t *num);
-
-/**
   varient of strcmp() that handles NULL ptrs
 **/
 _PUBLIC_ int strcmp_safe(const char *s1, const char *s2);
@@ -326,118 +317,9 @@ _PUBLIC_ char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data);
  **/
 _PUBLIC_ bool strequal(const char *s1, const char *s2);
 
-/* The following definitions come from lib/util/util_strlist.c  */
-
-/* separators for lists */
-#ifndef LIST_SEP
-#define LIST_SEP " \t,\n\r"
-#endif
-
-/**
-  build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc)
-*/
-_PUBLIC_ char **str_list_make_empty(TALLOC_CTX *mem_ctx);
-
-/**
-  place the only element 'entry' into a new, NULL terminated string list
-*/
-_PUBLIC_ char **str_list_make_single(TALLOC_CTX *mem_ctx,
-	const char *entry);
-
-/**
-  build a null terminated list of strings from a input string and a
-  separator list. The separator list must contain characters less than
-  or equal to 0x2f for this to work correctly on multi-byte strings
-*/
-_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string,
-	const char *sep);
+#include "util_strlist.h"
 
-/**
- * build a null terminated list of strings from an argv-like input string 
- * Entries are separated by spaces and can be enclosed by quotes.
- * Does NOT support escaping
- */
-_PUBLIC_ char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
-
-/**
- * join a list back to one string 
- */
-_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char separator);
-
-/** join a list back to one (shell-like) string; entries 
- * separated by spaces, using quotes where necessary */
-_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep);
-
-/**
-  return the number of elements in a string list
-*/
-_PUBLIC_ size_t str_list_length(const char * const *list);
-
-/**
-  copy a string list
-*/
-_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
-
-/**
-   Return true if all the elements of the list match exactly.
- */
-_PUBLIC_ bool str_list_equal(const char * const *list1, const char * const *list2);
-
-/**
-  add an entry to a string list
-*/
-_PUBLIC_ const char **str_list_add(const char **list, const char *s);
-
-/**
-  remove an entry from a string list
-*/
-_PUBLIC_ void str_list_remove(const char **list, const char *s);
-
-/**
-  return true if a string is in a list
-*/
-_PUBLIC_ bool str_list_check(const char **list, const char *s);
-
-/**
-  return true if a string is in a list, case insensitively
-*/
-_PUBLIC_ bool str_list_check_ci(const char **list, const char *s);
-/**
-  append one list to another - expanding list1
-*/
-_PUBLIC_ const char **str_list_append(const char **list1,
-	const char * const *list2);
-
-/**
- remove duplicate elements from a list 
-*/
-_PUBLIC_ const char **str_list_unique(const char **list);
-
-/*
-  very useful when debugging complex list related code
- */
-_PUBLIC_ void str_list_show(const char **list);
-
-
-/**
-  append one list to another - expanding list1
-  this assumes the elements of list2 are const pointers, so we can re-use them
-*/
-_PUBLIC_ const char **str_list_append_const(const char **list1,
-					    const char **list2);
-
-/**
-  add an entry to a string list
-  this assumes s will not change
-*/
-_PUBLIC_ const char **str_list_add_const(const char **list, const char *s);
-
-/**
-  copy a string list
-  this assumes list will not change
-*/
-_PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
-					  const char **list);
+/* The following definitions come from lib/util/util_strlist_v3.c  */
 
 /**
  * Needed for making an "unconst" list "const"
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 987fdfb..203a643 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -18,9 +18,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "system/locale.h"
-#include "lib/util/tsort.h"
+#include "replace.h"
+#include "debug.h"
+#include "tsort.h"
+
+#include "util_strlist.h"
 
 #undef strcasecmp
 
@@ -513,85 +515,3 @@ _PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
 	ret[i] = NULL;
 	return ret;
 }
-
-/**
- * Needed for making an "unconst" list "const"
- */
-_PUBLIC_ const char **const_str_list(char **list)
-{
-	return discard_const_p(const char *, list);
-}
-
-/**
- * str_list_make, v3 version. The v4 version does not
- * look at quoted strings with embedded blanks, so
- * do NOT merge this function please!
- */
-#define S_LIST_ABS 16 /* List Allocation Block Size */
-
-char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
-	const char *sep)
-{
-	char **list;
-	const char *str;
-	char *s, *tok;
-	int num, lsize;
-
-	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(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;
-}
-
-const char **str_list_make_v3_const(TALLOC_CTX *mem_ctx,
-				    const char *string,
-				    const char *sep)
-{
-	return const_str_list(str_list_make_v3(mem_ctx, string, sep));
-}
diff --git a/lib/util/util_strlist.h b/lib/util/util_strlist.h
new file mode 100644
index 0000000..1163034
--- /dev/null
+++ b/lib/util/util_strlist.h
@@ -0,0 +1,150 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Jelmer Vernooij 2005
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SAMBA_UTIL_STRLIST_H
+#define _SAMBA_UTIL_STRLIST_H
+
+#include <talloc.h>
+
+/* separators for lists */
+#ifndef LIST_SEP
+#define LIST_SEP " \t,\n\r"
+#endif
+
+/**
+  build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc)
+*/
+char **str_list_make_empty(TALLOC_CTX *mem_ctx);
+
+/**
+  place the only element 'entry' into a new, NULL terminated string list
+*/
+char **str_list_make_single(TALLOC_CTX *mem_ctx,
+			    const char *entry);
+
+/**
+  build a null terminated list of strings from a input string and a
+  separator list. The separator list must contain characters less than
+  or equal to 0x2f for this to work correctly on multi-byte strings
+*/
+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
+ * Entries are separated by spaces and can be enclosed by quotes.
+ * Does NOT support escaping
+ */
+char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string,
+			   const char *sep);
+
+/**
+ * join a list back to one string
+ */
+char *str_list_join(TALLOC_CTX *mem_ctx, const char **list,
+		    char separator);
+
+/** join a list back to one (shell-like) string; entries
+ * separated by spaces, using quotes where necessary */
+char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list,
+			  char sep);
+
+/**
+  return the number of elements in a string list
+*/
+size_t str_list_length(const char * const *list);
+
+/**
+  copy a string list
+*/
+char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
+
+/**
+   Return true if all the elements of the list match exactly.
+ */
+bool str_list_equal(const char * const *list1,
+		    const char * const *list2);
+
+/**
+  add an entry to a string list
+*/
+const char **str_list_add(const char **list, const char *s);
+
+/**
+  remove an entry from a string list
+*/
+void str_list_remove(const char **list, const char *s);
+
+/**
+  return true if a string is in a list
+*/
+bool str_list_check(const char **list, const char *s);
+
+/**
+  return true if a string is in a list, case insensitively
+*/
+bool str_list_check_ci(const char **list, const char *s);
+/**
+  append one list to another - expanding list1
+*/
+const char **str_list_append(const char **list1,
+			     const char * const *list2);
+
+/**
+ remove duplicate elements from a list
+*/
+const char **str_list_unique(const char **list);
+
+/*
+  very useful when debugging complex list related code
+ */
+void str_list_show(const char **list);
+
+
+/**
+  append one list to another - expanding list1
+  this assumes the elements of list2 are const pointers, so we can re-use them
+*/
+const char **str_list_append_const(const char **list1,
+				   const char **list2);
+
+/**
+   Add a string to an array of strings.
+
+   num should be a pointer to an integer that holds the current
+   number of elements in strings. It will be updated by this function.
+ */
+bool add_string_to_array(TALLOC_CTX *mem_ctx,
+			 const char *str, const char ***strings, size_t *num);
+
+/**
+  add an entry to a string list
+  this assumes s will not change
+*/
+const char **str_list_add_const(const char **list, const char *s);
+
+/**
+  copy a string list
+  this assumes list will not change
+*/
+const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
+				 const char **list);
+
+#endif /* _SAMBA_UTIL_STRLIST_H */
diff --git a/lib/util/util_strlist_v3.c b/lib/util/util_strlist_v3.c
new file mode 100644
index 0000000..e08edd4
--- /dev/null
+++ b/lib/util/util_strlist_v3.c
@@ -0,0 +1,112 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Jelmer Vernooij 2005
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "system/locale.h"
+#include "lib/util/tsort.h"
+
+#undef strcasecmp
+
+/**
+ * @file
+ * @brief String list manipulation v3
+ */
+
+/**
+ * Needed for making an "unconst" list "const"
+ */
+_PUBLIC_ const char **const_str_list(char **list)
+{
+	return discard_const_p(const char *, list);
+}
+
+/**
+ * str_list_make, v3 version. The v4 version does not
+ * look at quoted strings with embedded blanks, so
+ * do NOT merge this function please!
+ */
+#define S_LIST_ABS 16 /* List Allocation Block Size */
+
+char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
+	const char *sep)
+{
+	char **list;
+	const char *str;
+	char *s, *tok;
+	int num, lsize;
+
+	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(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;
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list