move str_list_make_v3 out of s3 code
authorGarming Sam <garming@catalyst.net.nz>
Mon, 24 Feb 2014 04:33:57 +0000 (17:33 +1300)
committerJeremy Allison <jra@samba.org>
Wed, 7 May 2014 17:49:16 +0000 (19:49 +0200)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/samba_util.h
lib/util/util_strlist.c
source3/include/proto.h
source3/lib/util_str.c

index e3fe6a6079229053fed063d7c84c88be430b551b..73cab66c35138ca505bf9ee74cbcd4d8f7252c84 100644 (file)
@@ -530,6 +530,14 @@ _PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
  */
 _PUBLIC_ const char **const_str_list(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!
+ */
+char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
+       const char *sep);
+
 
 /* The following definitions come from lib/util/util_file.c  */
 
index 8397589d747282e3f0b3bd4ea37190aec883c2f0..d542e6f74f5eba2d3cdb07e94bf227fbd1363c3b 100644 (file)
@@ -522,3 +522,69 @@ _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;
+}
index 9cdd0df2c003f6dc964f74627dfdb48e9418d40f..356bf91dd89cb80b944b389a8303d55f6d63fa5f 100644 (file)
@@ -725,7 +725,6 @@ bool validate_net_name( const char *name,
                const char *invalid_chars,
                int max_len);
 char *escape_shell_string(const char *src);
-char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
 ssize_t full_path_tos(const char *dir, const char *name,
                      char *tmpbuf, size_t tmpbuf_len,
                      char **pdst, char **to_free);
index 908f23aaa9df3405c159f8d956c3e587280b6d64..cfc495d67021ec3543a45c92a83b9f74938e0907 100644 (file)
@@ -1227,74 +1227,6 @@ char *escape_shell_string(const char *src)
        return ret;
 }
 
-/***************************************************
- 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;
-}
-
 /*
  * This routine improves performance for operations temporarily acting on a
  * full path. It is equivalent to the much more expensive