[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-3261-g0207f99

Volker Lendecke vlendec at samba.org
Wed Jul 16 16:19:54 GMT 2008


The branch, v3-3-test has been updated
       via  0207f99d3f02bd8ff5dadc1574fe13b46c3e09a3 (commit)
       via  37dba0c192ec7d4105465beae0d6e8598c7dbb7a (commit)
       via  78801431c896f1e2007d652b611c2ce1108e1023 (commit)
      from  b731447ec539d454002300fd755dddcad2351d6c (commit)

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


- Log -----------------------------------------------------------------
commit 0207f99d3f02bd8ff5dadc1574fe13b46c3e09a3
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jul 16 16:08:28 2008 +0200

    Sequel to c10aad9f13: Ignore whitespaces in parametric options
    
    It's a bit difficult to explain why
    
    idmap config backend:FOO = rid
    
    should work while
    
    idmap config backend : FOO = rid
    
    should not. And I doubt we will ever see domain names with whitespaces...

commit 37dba0c192ec7d4105465beae0d6e8598c7dbb7a
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jul 16 16:05:46 2008 +0200

    Tiny logic simplification: Remove an indentation by using an early return;

commit 78801431c896f1e2007d652b611c2ce1108e1023
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jul 16 15:49:28 2008 +0200

    Remove a silly "typedef struct _param_opt_struct param_opt_struct"

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

Summary of changes:
 source/param/loadparm.c |  147 +++++++++++++++++++++++------------------------
 1 files changed, 71 insertions(+), 76 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 18ca495..0935181 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -97,9 +97,8 @@ extern int extra_time_offset;
 
 static bool defaults_saved = False;
 
-typedef struct _param_opt_struct param_opt_struct;
-struct _param_opt_struct {
-	param_opt_struct *prev, *next;
+struct param_opt_struct {
+	struct param_opt_struct *prev, *next;
 	char *key;
 	char *value;
 	char **list;
@@ -338,7 +337,7 @@ struct global {
 	bool bResetOnZeroVC;
 	int iKeepalive;
 	int iminreceivefile;
-	param_opt_struct *param_opt;
+	struct param_opt_struct *param_opt;
 };
 
 static struct global Globals;
@@ -482,7 +481,7 @@ struct service {
 	int iMap_readonly;
 	int iDirectoryNameCacheSize;
 	int ismb_encrypt;
-	param_opt_struct *param_opt;
+	struct param_opt_struct *param_opt;
 
 	char dummy[3];		/* for alignment */
 };
@@ -5356,14 +5355,17 @@ static char * canonicalize_servicename(const char *name);
 static void show_parameter(int parmIndex);
 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
 
-/* This is a helper function for parametrical options support. */
-/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
-/* Actual parametrical functions are quite simple */
-static param_opt_struct *get_parametrics(int snum, const char *type, const char *option)
+/*
+ * This is a helper function for parametrical options support.  It returns a
+ * pointer to parametrical option value if it exists or NULL otherwise. Actual
+ * parametrical functions are quite simple
+ */
+static struct param_opt_struct *get_parametrics(int snum, const char *type,
+						const char *option)
 {
 	bool global_section = False;
 	char* param_key;
-        param_opt_struct *data;
+        struct param_opt_struct *data;
 	
 	if (snum >= iNumServices) return NULL;
 	
@@ -5380,7 +5382,7 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
 	}
 
 	while (data) {
-		if (StrCaseCmp(data->key, param_key) == 0) {
+		if (strwicmp(data->key, param_key) == 0) {
 			string_free(&param_key);
 			return data;
 		}
@@ -5392,7 +5394,7 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
 		/* but only if we are not already working with Globals */
 		data = Globals.param_opt;
 		while (data) {
-		        if (strcmp(data->key, param_key) == 0) {
+		        if (strwicmp(data->key, param_key) == 0) {
 			        string_free(&param_key);
 				return data;
 			}
@@ -5497,7 +5499,7 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
 /* the returned value is talloced on the talloc_tos() */
 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data == NULL||data->value==NULL) {
 		if (def) {
@@ -5514,7 +5516,7 @@ char *lp_parm_talloc_string(int snum, const char *type, const char *option, cons
 /* Parametric option has following syntax: 'Type: option = value' */
 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data == NULL||data->value==NULL)
 		return def;
@@ -5527,7 +5529,7 @@ const char *lp_parm_const_string(int snum, const char *type, const char *option,
 
 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 
 	if (data == NULL||data->value==NULL)
 		return (const char **)def;
@@ -5544,7 +5546,7 @@ const char **lp_parm_string_list(int snum, const char *type, const char *option,
 
 int lp_parm_int(int snum, const char *type, const char *option, int def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data && data->value && *data->value)
 		return lp_int(data->value);
@@ -5557,7 +5559,7 @@ int lp_parm_int(int snum, const char *type, const char *option, int def)
 
 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data && data->value && *data->value)
 		return lp_ulong(data->value);
@@ -5570,7 +5572,7 @@ unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsi
 
 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data && data->value && *data->value)
 		return lp_bool(data->value);
@@ -5584,7 +5586,7 @@ bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
 int lp_parm_enum(int snum, const char *type, const char *option,
 		 const struct enum_list *_enum, int def)
 {
-	param_opt_struct *data = get_parametrics(snum, type, option);
+	struct param_opt_struct *data = get_parametrics(snum, type, option);
 	
 	if (data && data->value && *data->value && _enum)
 		return lp_enum(data->value, _enum);
@@ -5610,7 +5612,7 @@ static void init_service(struct service *pservice)
 static void free_service(struct service *pservice)
 {
 	int i;
-        param_opt_struct *data, *pdata;
+	struct param_opt_struct *data, *pdata;
 	if (!pservice)
 		return;
 
@@ -5689,7 +5691,7 @@ static int add_a_service(const struct service *pservice, const char *name)
 	int i;
 	struct service tservice;
 	int num_to_alloc = iNumServices + 1;
-	param_opt_struct *data, *pdata;
+	struct param_opt_struct *data, *pdata;
 
 	tservice = *pservice;
 
@@ -6372,7 +6374,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS
 {
 	int i;
 	bool bcopyall = (pcopymapDest == NULL);
-	param_opt_struct *data, *pdata, *paramo;
+	struct param_opt_struct *data, *pdata, *paramo;
 	bool not_added;
 
 	for (i = 0; parm_table[i].label; i++)
@@ -6436,7 +6438,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS
 		/* Traverse destination */
 		while (pdata) {
 			/* If we already have same option, override it */
-			if (strcmp(pdata->key, data->key) == 0) {
+			if (strwicmp(pdata->key, data->key) == 0) {
 				string_free(&pdata->value);
 				TALLOC_FREE(data->list);
 				pdata->value = SMB_STRDUP(data->value);
@@ -6446,7 +6448,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS
 			pdata = pdata->next;
 		}
 		if (not_added) {
-		    paramo = SMB_XMALLOC_P(param_opt_struct);
+		    paramo = SMB_XMALLOC_P(struct param_opt_struct);
 		    paramo->key = SMB_STRDUP(data->key);
 		    paramo->value = SMB_STRDUP(data->value);
 		    paramo->list = NULL;
@@ -7111,65 +7113,58 @@ void *lp_local_ptr(int snum, void *ptr)
 
 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
 {
-	int parmnum, i, slen;
+	int parmnum, i;
 	void *parm_ptr = NULL;	/* where we are going to store the result */
 	void *def_ptr = NULL;
-	char *param_key = NULL;
-	char *sep;
-	param_opt_struct *paramo, *data;
+	struct param_opt_struct *paramo, *data;
 	bool not_added;
 
 	parmnum = map_parameter(pszParmName);
 
 	if (parmnum < 0) {
-		if ((sep=strchr(pszParmName, ':')) != NULL) {
-			TALLOC_CTX *frame = talloc_stackframe();
-
-			*sep = '\0';
-			param_key = talloc_asprintf(frame, "%s:", pszParmName);
-			if (!param_key) {
-				TALLOC_FREE(frame);
-				return false;
-			}
-			slen = strlen(param_key);
-			param_key = talloc_asprintf_append(param_key, sep+1);
-			if (!param_key) {
-				TALLOC_FREE(frame);
-				return false;
-			}
-			trim_char(param_key+slen, ' ', ' ');
-			not_added = True;
-			data = (snum < 0) ? Globals.param_opt :
-				ServicePtrs[snum]->param_opt;
-			/* Traverse destination */
-			while (data) {
-				/* If we already have same option, override it */
-				if (strcmp(data->key, param_key) == 0) {
-					string_free(&data->value);
-					TALLOC_FREE(data->list);
-					data->value = SMB_STRDUP(pszParmValue);
-					not_added = False;
-					break;
-				}
-				data = data->next;
-			}
-			if (not_added) {
-				paramo = SMB_XMALLOC_P(param_opt_struct);
-				paramo->key = SMB_STRDUP(param_key);
-				paramo->value = SMB_STRDUP(pszParmValue);
-				paramo->list = NULL;
-				if (snum < 0) {
-					DLIST_ADD(Globals.param_opt, paramo);
-				} else {
-					DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
-				}
-			}
+		TALLOC_CTX *frame;
 
-			*sep = ':';
-			TALLOC_FREE(frame);
+		if (strchr(pszParmName, ':') == NULL) {
+			DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",
+				  pszParmName));
 			return (True);
 		}
-		DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+
+		/*
+		 * We've got a parametric option
+		 */
+
+		frame = talloc_stackframe();
+
+		not_added = True;
+		data = (snum < 0)
+			? Globals.param_opt : ServicePtrs[snum]->param_opt;
+		/* Traverse destination */
+		while (data) {
+			/* If we already have same option, override it */
+			if (strwicmp(data->key, pszParmName) == 0) {
+				string_free(&data->value);
+				TALLOC_FREE(data->list);
+				data->value = SMB_STRDUP(pszParmValue);
+				not_added = False;
+				break;
+			}
+			data = data->next;
+		}
+		if (not_added) {
+			paramo = SMB_XMALLOC_P(struct param_opt_struct);
+			paramo->key = SMB_STRDUP(pszParmName);
+			paramo->value = SMB_STRDUP(pszParmValue);
+			paramo->list = NULL;
+			if (snum < 0) {
+				DLIST_ADD(Globals.param_opt, paramo);
+			} else {
+				DLIST_ADD(ServicePtrs[snum]->param_opt,
+					  paramo);
+			}
+		}
+
+		TALLOC_FREE(frame);
 		return (True);
 	}
 
@@ -7485,7 +7480,7 @@ Display the contents of the global structure.
 static void dump_globals(FILE *f)
 {
 	int i;
-	param_opt_struct *data;
+	struct param_opt_struct *data;
 	
 	fprintf(f, "[global]\n");
 
@@ -7529,7 +7524,7 @@ bool lp_is_default(int snum, struct parm_struct *parm)
 static void dump_a_service(struct service *pService, FILE * f)
 {
 	int i;
-	param_opt_struct *data;
+	struct param_opt_struct *data;
 	
 	if (pService != &sDefault)
 		fprintf(f, "[%s]\n", pService->szService);
@@ -8746,7 +8741,7 @@ bool lp_load_ex(const char *pszFname,
 {
 	char *n2 = NULL;
 	bool bRetval;
-	param_opt_struct *data, *pdata;
+	struct param_opt_struct *data, *pdata;
 
 	bRetval = False;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list