[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-967-g6447bae

Michael Adam obnox at samba.org
Sun Dec 30 01:30:03 GMT 2007


The branch, v3-2-test has been updated
       via  6447bae71c99407485307dd508603c73d5bb9823 (commit)
       via  8e87dd79ba4e3aeceb26c7b4e131053172f077cd (commit)
       via  ac7baa17e89d2363b5b3db85de9c842b596dea25 (commit)
       via  95d9981d59fe69ee1ed98f21475bd1ba72930c1b (commit)
       via  94e97a72548a7f76a5273346d472e3ba5b24795a (commit)
       via  4842438c396b93007fc4f4dded437567e562a2dc (commit)
      from  a5df44f5b7887d10c1e1a0b7a3dd05bcf31015e1 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 6447bae71c99407485307dd508603c73d5bb9823
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 22:29:33 2007 +0100

    Make libnet_smbconf_reg_open_path() static.
    
    Michael

commit 8e87dd79ba4e3aeceb26c7b4e131053172f077cd
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 22:29:00 2007 +0100

    Make libnet_smbconf_reg_open_basepath() static.
    
    Michael

commit ac7baa17e89d2363b5b3db85de9c842b596dea25
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 22:11:09 2007 +0100

    Remove list_values() from net_conf.c - it is not needed any more.
    
    Also make libnet.c:libnet_smbconf_format_registry_value() static.
    (There are nor more external callers.)
    
    Michael

commit 95d9981d59fe69ee1ed98f21475bd1ba72930c1b
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 22:09:51 2007 +0100

    Use libnet_smbconf_get_config() in net_conf_list().
    
    This leaves only output logic in net_conf_list().
    
    Michael

commit 94e97a72548a7f76a5273346d472e3ba5b24795a
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 22:08:11 2007 +0100

    Add a function libnet_smbconf_get_config() to libnet_conf.c
    
    This gets the whole config as a set of lists (of share names
    and corresponding lists of parameter names and values). The function
    is an aggregate of libnet_smbconf_get_share_names() and
    libnet_smbconf_getshare().
    
    Michael

commit 4842438c396b93007fc4f4dded437567e562a2dc
Author: Michael Adam <obnox at samba.org>
Date:   Sat Dec 29 21:59:28 2007 +0100

    Include libnet/libnet.h in libnet_conf.c to have prototypes available.
    
    Michael

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

Summary of changes:
 source/libnet/libnet_conf.c |  102 +++++++++++++++++++++++++++++++++++++++---
 source/utils/net_conf.c     |   90 ++++++++------------------------------
 2 files changed, 113 insertions(+), 79 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libnet/libnet_conf.c b/source/libnet/libnet_conf.c
index 3f5265a..1069abc 100644
--- a/source/libnet/libnet_conf.c
+++ b/source/libnet/libnet_conf.c
@@ -19,6 +19,7 @@
  */
 
 #include "includes.h"
+#include "libnet/libnet.h"
 
 /**********************************************************************
  *
@@ -57,10 +58,10 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
 /*
  * Open a subkey of KEY_SMBCONF (i.e a service)
  */
-WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx,
-				    const char *subkeyname,
-				    uint32 desired_access,
-				    struct registry_key **key)
+static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx,
+					   const char *subkeyname,
+					   uint32 desired_access,
+					   struct registry_key **key)
 {
 	WERROR werr = WERR_OK;
 	char *path = NULL;
@@ -93,8 +94,9 @@ done:
 /*
  * open the base key KEY_SMBCONF
  */
-WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, uint32 desired_access,
-					struct registry_key **key)
+static WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx,
+					       uint32 desired_access,
+					       struct registry_key **key)
 {
 	return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key);
 }
@@ -256,8 +258,8 @@ done:
  * which are ar stored as REG_SZ values, so the incomplete
  * handling should be ok.
  */
-char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
-					   struct registry_value *value)
+static char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
+						  struct registry_value *value)
 {
 	char *result = NULL;
 
@@ -421,6 +423,90 @@ done:
 }
 
 /**
+ * Get the whole configuration as lists of strings with counts:
+ *
+ *  num_shares   : number of shares
+ *  share_names  : list of length num_shares of share names
+ *  num_params   : list of length num_shares of parameter counts for each share
+ *  param_names  : list of lists of parameter names for each share
+ *  param_values : list of lists of parameter values for each share
+ */
+WERROR libnet_smbconf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
+				 char ***share_names, uint32_t **num_params,
+				 char ****param_names, char ****param_values)
+{
+	WERROR werr = WERR_OK;
+	TALLOC_CTX *tmp_ctx = NULL;
+	uint32_t tmp_num_shares;
+	char **tmp_share_names;
+	uint32_t *tmp_num_params;
+	char ***tmp_param_names;
+	char ***tmp_param_values;
+	uint32_t count;
+
+	if ((num_shares == NULL) || (share_names == NULL) ||
+	    (num_params == NULL) || (param_names == NULL) ||
+	    (param_values == NULL))
+	{
+		werr = WERR_INVALID_PARAM;
+		goto done;
+	}
+
+	tmp_ctx = talloc_new(mem_ctx);
+	if (tmp_ctx == NULL) {
+		werr = WERR_NOMEM;
+		goto done;
+	}
+
+	werr = libnet_smbconf_get_share_names(tmp_ctx, &tmp_num_shares,
+					      &tmp_share_names);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	tmp_num_params   = TALLOC_ARRAY(tmp_ctx, uint32_t, tmp_num_shares);
+	tmp_param_names  = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares);
+	tmp_param_values = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares);
+
+	if ((tmp_num_params == NULL) || (tmp_param_names == NULL) ||
+	    (tmp_param_values == NULL))
+	{
+		werr = WERR_NOMEM;
+		goto done;
+	}
+
+	for (count = 0; count < tmp_num_shares; count++) {
+		werr = libnet_smbconf_getshare(mem_ctx, tmp_share_names[count],
+					       &tmp_num_params[count],
+					       &tmp_param_names[count],
+					       &tmp_param_values[count]);
+		if (!W_ERROR_IS_OK(werr)) {
+			goto done;
+		}
+	}
+
+	werr = WERR_OK;
+
+	*num_shares = tmp_num_shares;
+	if (tmp_num_shares > 0) {
+		*share_names = talloc_move(mem_ctx, &tmp_share_names);
+		*num_params = talloc_move(mem_ctx, &tmp_num_params);
+		*param_names = talloc_move(mem_ctx, &tmp_param_names);
+		*param_values = talloc_move(mem_ctx, &tmp_param_values);
+	} else {
+		*share_names = NULL;
+		*num_params = NULL;
+		*param_names = NULL;
+		*param_values = NULL;
+	}
+
+done:
+	TALLOC_FREE(tmp_ctx);
+	return werr;
+}
+
+
+/**
  * get the list of share names defined in the configuration.
  */
 WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
diff --git a/source/utils/net_conf.c b/source/utils/net_conf.c
index 8957408..29bbc83 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -110,32 +110,6 @@ static int net_conf_delparm_usage(int argc, const char **argv)
  * Helper functions
  */
 
-static WERROR list_values(TALLOC_CTX *ctx, struct registry_key *key)
-{
-	WERROR werr = WERR_OK;
-	uint32 idx = 0;
-	struct registry_value *valvalue = NULL;
-	char *valname = NULL;
-
-	for (idx = 0;
-	     W_ERROR_IS_OK(werr = reg_enumvalue(ctx, key, idx, &valname,
-			                        &valvalue));
-	     idx++)
-	{
-		d_printf("\t%s = %s\n", valname,
-			 libnet_smbconf_format_registry_value(ctx, valvalue));
-	}
-	if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
-                d_fprintf(stderr, "Error enumerating values: %s\n",
-                          dos_errstr(werr));
-		goto done;
-        }
-	werr = WERR_OK;
-
-done:
-	return werr;
-}
-
 static char *parm_valstr(TALLOC_CTX *ctx, struct parm_struct *parm,
 			 struct share_params *share)
 {
@@ -301,10 +275,12 @@ static int net_conf_list(int argc, const char **argv)
 	WERROR werr = WERR_OK;
 	int ret = -1;
 	TALLOC_CTX *ctx;
-	struct registry_key *base_key = NULL;
-	struct registry_key *sub_key = NULL;
-	uint32 idx_key = 0;
-	char *subkey_name = NULL;
+	uint32_t num_shares;
+	char **share_names;
+	uint32_t *num_params;
+	char ***param_names;
+	char ***param_values;
+	uint32_t share_count, param_count;
 
 	ctx = talloc_init("list");
 
@@ -313,54 +289,26 @@ static int net_conf_list(int argc, const char **argv)
 		goto done;
 	}
 
-	werr = libnet_smbconf_reg_open_basepath(ctx, REG_KEY_READ, &base_key);
+	werr = libnet_smbconf_get_config(ctx, &num_shares, &share_names,
+					 &num_params, &param_names,
+					 &param_values);
 	if (!W_ERROR_IS_OK(werr)) {
+		d_fprintf(stderr, "Error getting config: %s\n",
+			  dos_errstr(werr));
 		goto done;
 	}
 
-	if (libnet_smbconf_key_exists(GLOBAL_NAME))  {
-		werr = reg_openkey(ctx, base_key, GLOBAL_NAME,
-				   REG_KEY_READ, &sub_key);
-		if (!W_ERROR_IS_OK(werr)) {
-			d_fprintf(stderr, "Error opening subkey '%s' : %s\n",
-				  subkey_name, dos_errstr(werr));
-			goto done;
-		}
-		d_printf("[%s]\n", GLOBAL_NAME);
-		if (!W_ERROR_IS_OK(list_values(ctx, sub_key))) {
-			goto done;
-		}
-		d_printf("\n");
-	}
-
-	for (idx_key = 0;
-	     W_ERROR_IS_OK(werr = reg_enumkey(ctx, base_key, idx_key,
-			     		      &subkey_name, NULL));
-	     idx_key++)
-	{
-		if (strequal(subkey_name, GLOBAL_NAME)) {
-			continue;
-		}
-		d_printf("[%s]\n", subkey_name);
-
-		werr = reg_openkey(ctx, base_key, subkey_name,
-				   REG_KEY_READ, &sub_key);
-		if (!W_ERROR_IS_OK(werr)) {
-			d_fprintf(stderr,
-				  "Error opening subkey '%s': %s\n",
-				  subkey_name, dos_errstr(werr));
-			goto done;
-		}
-		if (!W_ERROR_IS_OK(list_values(ctx, sub_key))) {
-			goto done;
+	for (share_count = 0; share_count < num_shares; share_count++) {
+		d_printf("[%s]\n", share_names[share_count]);
+		for (param_count = 0; param_count < num_params[share_count];
+		     param_count++)
+		{
+			d_printf("\t%s = %s\n",
+				 param_names[share_count][param_count],
+				 param_values[share_count][param_count]);
 		}
 		d_printf("\n");
 	}
-	if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
-		d_fprintf(stderr, "Error enumerating subkeys: %s\n",
-			  dos_errstr(werr));
-		goto done;
-	}
 
 	ret = 0;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list