svn commit: samba r25460 - in branches/SAMBA_4_0: . source/param source/scripting/ejs

jelmer at samba.org jelmer at samba.org
Tue Oct 2 13:00:41 GMT 2007


Author: jelmer
Date: 2007-10-02 13:00:33 +0000 (Tue, 02 Oct 2007)
New Revision: 25460

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25460

Log:
use common structure in param/generic.c
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/param/generic.c
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/param/param.h
   branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/param/generic.c
===================================================================
--- branches/SAMBA_4_0/source/param/generic.c	2007-10-02 10:50:42 UTC (rev 25459)
+++ branches/SAMBA_4_0/source/param/generic.c	2007-10-02 13:00:33 UTC (rev 25460)
@@ -36,19 +36,20 @@
 	return NULL;
 }
 
-struct param *param_section_get (struct param_section *section, const char *name)
+struct param_opt *param_section_get(struct param_section *section, 
+				    const char *name)
 {
-	struct param *p;
+	struct param_opt *p;
 
 	for (p = section->parameters; p; p = p->next) {
-		if (strcasecmp_m(p->name, name) == 0) 
+		if (strcasecmp_m(p->key, name) == 0) 
 			return p;
 	}
 
 	return NULL;
 }
 
-struct param *param_get (struct param_context *ctx, const char *section_name, const char *name)
+struct param_opt *param_get (struct param_context *ctx, const char *section_name, const char *name)
 {
 	struct param_section *section = param_get_section(ctx, section_name);
 	if (section == NULL)
@@ -58,10 +59,10 @@
 }
 
 /* Look up parameter. If it is not found, add it */
-static struct param *param_get_add(struct param_context *ctx, const char *section_name, const char *name)
+static struct param_opt *param_get_add(struct param_context *ctx, const char *section_name, const char *name)
 {
 	struct param_section *section;
-	struct param *p;
+	struct param_opt *p;
 
 	section = param_get_section(ctx, section_name);
 
@@ -76,11 +77,11 @@
 
 	p = param_section_get(section, name);
 	if (p == NULL) {
-		p = talloc_zero(section, struct param);
+		p = talloc_zero(section, struct param_opt);
 		if (p == NULL)
 			return NULL;
 
-		p->name = talloc_strdup(p, name);
+		p->key = talloc_strdup(p, name);
 		DLIST_ADD(section->parameters, p);
 	}
 	
@@ -89,7 +90,7 @@
 
 const char *param_get_string(struct param_context *ctx, const char *section, const char *param)
 {
-	struct param *p = param_get(ctx, section, param);
+	struct param_opt *p = param_get(ctx, section, param);
 
 	if (p == NULL)
 		return NULL;
@@ -99,7 +100,7 @@
 
 int param_set_string(struct param_context *ctx, const char *section, const char *param, const char *value)
 {
-	struct param *p = param_get_add(ctx, section, param);
+	struct param_opt *p = param_get_add(ctx, section, param);
 
 	if (p == NULL)
 		return -1;
@@ -112,7 +113,7 @@
 const char **param_get_string_list(struct param_context *ctx, const char *section, const char *param,
 				 const char *separator)
 {
-	struct param *p = param_get(ctx, section, param);
+	struct param_opt *p = param_get(ctx, section, param);
 	
 	if (p == NULL)
 		return NULL;
@@ -120,19 +121,14 @@
 	if (separator == NULL)
 		separator = LIST_SEP;
 	
-	if (p->list_value == NULL) {
-		p->list_value = str_list_make(ctx, p->value, separator);
-	}
-
-	return p->list_value;
+	return str_list_make(ctx, p->value, separator);
 }
 
 int param_set_string_list(struct param_context *ctx, const char *section, const char *param, const char **list)
 {
-	struct param *p = param_get_add(ctx, section, param);	
+	struct param_opt *p = param_get_add(ctx, section, param);	
 
 	p->value = str_list_join(p, list, ' ');
-	p->list_value = str_list_copy(p, list);
 
 	return 0;
 }
@@ -149,7 +145,7 @@
 
 void param_set_int(struct param_context *ctx, const char *section, const char *param, int value)
 {
-	struct param *p = param_get_add(ctx, section, param);
+	struct param_opt *p = param_get_add(ctx, section, param);
 
 	if (!p) 
 		return;
@@ -169,7 +165,7 @@
 
 void param_set_ulong(struct param_context *ctx, const char *section, const char *name, unsigned long value)
 {
-	struct param *p = param_get_add(ctx, section, name);
+	struct param_opt *p = param_get_add(ctx, section, name);
 
 	if (!p)
 		return;
@@ -201,14 +197,14 @@
 static bool param_pfunc (const char *name, const char *value, void *_ctx)
 {
 	struct param_context *ctx = (struct param_context *)_ctx;
-	struct param *p = param_section_get(ctx->sections, name);
+	struct param_opt *p = param_section_get(ctx->sections, name);
 
 	if (!p) {
-		p = talloc_zero(ctx->sections, struct param);
+		p = talloc_zero(ctx->sections, struct param_opt);
 		if (p == NULL)
 			return False;
 
-		p->name = talloc_strdup(p, name);
+		p->key = talloc_strdup(p, name);
 		p->value = talloc_strdup(p, value);
 		DLIST_ADD(ctx->sections->parameters, p);
 	} else { /* Replace current value */
@@ -253,11 +249,11 @@
 		return -1;
 	
 	for (section = ctx->sections; section; section = section->next) {
-		struct param *param;
+		struct param_opt *param;
 		
 		fdprintf(file, "[%s]\n", section->name);
 		for (param = section->parameters; param; param = param->next) {
-			fdprintf(file, "\t%s = %s\n", param->name, param->value);
+			fdprintf(file, "\t%s = %s\n", param->key, param->value);
 		}
 		fdprintf(file, "\n");
 	}

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2007-10-02 10:50:42 UTC (rev 25459)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2007-10-02 13:00:33 UTC (rev 25460)
@@ -71,13 +71,6 @@
 static bool do_parameter(const char *, const char *, void *);
 static bool defaults_saved = false;
 
-struct param_opt {
-	struct param_opt *prev, *next;
-	char *key;
-	char *value;
-	int flags;
-};
-
 /* 
  * This structure describes global (ie., server-wide) parameters.
  */

Modified: branches/SAMBA_4_0/source/param/param.h
===================================================================
--- branches/SAMBA_4_0/source/param/param.h	2007-10-02 10:50:42 UTC (rev 25459)
+++ branches/SAMBA_4_0/source/param/param.h	2007-10-02 13:00:33 UTC (rev 25460)
@@ -20,21 +20,21 @@
 #ifndef _PARAM_H /* _PARAM_H */
 #define _PARAM_H 
 
+struct param_opt {
+	struct param_opt *prev, *next;
+	char *key;
+	char *value;
+	int flags;
+};
+
 struct param_context {
 	struct param_section *sections;
 };
 
-struct param {
-	const char *name;
-	char *value;
-	const char **list_value;
-	struct param *prev, *next;
-};
-
 struct param_section {
 	const char *name;
 	struct param_section *prev, *next;
-	struct param *parameters;
+	struct param_opt *parameters;
 };
 
 struct param_context;

Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c	2007-10-02 10:50:42 UTC (rev 25459)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c	2007-10-02 13:00:33 UTC (rev 25460)
@@ -155,10 +155,10 @@
 
 	for (sec = ctx->sections; sec; sec = sec->next) {
 		struct MprVar ps = mprObject("array");
-		struct param *p;
+		struct param_opt *p;
 
 		for (p = sec->parameters; p; p = p->next) {
-			mprSetVar(&ps, p->name, mprString(p->value));
+			mprSetVar(&ps, p->key, mprString(p->value));
 		}
 		
 		mprSetVar(&ret, sec->name, ps);



More information about the samba-cvs mailing list