[SCM] Samba Shared Repository - branch master updated - 51118b1974fd91d7f60ed1a68e1eb5717690362b

Michael Adam obnox at samba.org
Mon Dec 15 14:22:34 GMT 2008


The branch, master has been updated
       via  51118b1974fd91d7f60ed1a68e1eb5717690362b (commit)
       via  c2bd88f145d73e9a8613d32d313954e3ecdcacd2 (commit)
       via  03f19dad795c247878918de95a8c1f63ec259d13 (commit)
       via  0b0dc506d4b709b6373a19795276351285679eb3 (commit)
       via  6244194265f7f1027c16664b2701ce114435a59b (commit)
       via  91c543f0b5a539da4194f14dee8cad0f980a117e (commit)
       via  606abdceacfcad19735cd80f59aad975a9e97b7c (commit)
      from  07a21dbfa5b9dc3cc6fa7417b64e4963f111fe1a (commit)

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


- Log -----------------------------------------------------------------
commit 51118b1974fd91d7f60ed1a68e1eb5717690362b
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:42:13 2008 +0100

    s3:loadparm: fix copy service error (canonicalize_servicename: NULL source name)
    
    this was introduced by commit 3358a139d2dc77eb4c842d41722b1acc24bd2cb2.
    
    Michael

commit c2bd88f145d73e9a8613d32d313954e3ecdcacd2
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:38:51 2008 +0100

    s3:loadparm: add service-struct based variants of the free-parameter routines
    
    and use the abstracted free_one_parameter_common() in old
    free_one_parameter_by_snum() as well as in new free_one_parameter()
    
    Michael

commit 03f19dad795c247878918de95a8c1f63ec259d13
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:29:34 2008 +0100

    s3:loadparm: rename free_parameters() to free_parameters_by_snum()
    
    Michael

commit 0b0dc506d4b709b6373a19795276351285679eb3
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:28:03 2008 +0100

    s3:loadparm: rename free_parameter() to free_one_parameter_by_snum()
    
    Michael

commit 6244194265f7f1027c16664b2701ce114435a59b
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:20:16 2008 +0100

    s3:loadparm: add lp_local_ptr() that operates on a service struct
    
    and use this in lp_local_ptr_by_snum().
    
    Michael

commit 91c543f0b5a539da4194f14dee8cad0f980a117e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 14:16:06 2008 +0100

    s3:loadparm: rename lp_local_ptr() to lp_local_ptr_by_snum()
    
    Michael

commit 606abdceacfcad19735cd80f59aad975a9e97b7c
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 15 13:33:24 2008 +0100

    s3:loadparm: fix newly introduced leading whitespaces to tabs
    
    Michael

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

Summary of changes:
 source3/include/proto.h  |    2 +-
 source3/param/loadparm.c |   94 ++++++++++++++++++++++++++++++++++++----------
 source3/web/swat.c       |    4 +-
 3 files changed, 77 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2a8f838..9d86f16 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4260,7 +4260,7 @@ const char *lp_ldap_machine_suffix(void);
 const char *lp_ldap_user_suffix(void);
 const char *lp_ldap_group_suffix(void);
 const char *lp_ldap_idmap_suffix(void);
-void *lp_local_ptr(int snum, void *ptr);
+void *lp_local_ptr_by_snum(int snum, void *ptr);
 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
 void init_locals(void);
 bool lp_is_default(int snum, struct parm_struct *parm);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 7e7a1e5..9a55067 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -425,7 +425,7 @@ struct service {
 	bool bHideUnReadable;
 	bool bHideUnWriteableFiles;
 	bool bBrowseable;
-       bool bAccessBasedShareEnum;
+	bool bAccessBasedShareEnum;
 	bool bAvailable;
 	bool bRead_only;
 	bool bNo_set_dir;
@@ -569,7 +569,7 @@ static struct service sDefault = {
 	False,			/* bHideUnReadable */
 	False,			/* bHideUnWriteableFiles */
 	True,			/* bBrowseable */
-       False,                  /* bAccessBasedShareEnum */
+	False,			/* bAccessBasedShareEnum */
 	True,			/* bAvailable */
 	True,			/* bRead_only */
 	True,			/* bNo_set_dir */
@@ -671,6 +671,8 @@ static void set_server_role(void);
 static void set_default_server_announce_type(void);
 static void set_allowed_client_auth(void);
 
+static void *lp_local_ptr(struct service *service, void *ptr);
+
 static const struct enum_list enum_protocol[] = {
 	{PROTOCOL_NT1, "NT1"},
 	{PROTOCOL_LANMAN2, "LANMAN2"},
@@ -4584,9 +4586,56 @@ static void init_printer_values(struct service *pService)
 }
 
 /**
- * Free the allocated data for one parameter for a given share.
+ * Common part of freeing allocated data for one parameter.
+ */
+static void free_one_parameter_common(void *parm_ptr,
+				      struct parm_struct parm)
+{
+	if ((parm.type == P_STRING) ||
+	    (parm.type == P_USTRING))
+	{
+		string_free((char**)parm_ptr);
+	} else if (parm.type == P_LIST) {
+		TALLOC_FREE(*((char***)parm_ptr));
+	}
+}
+
+/**
+ * Free the allocated data for one parameter for a share
+ * given as a service struct.
  */
-static void free_parameter(int snum, struct parm_struct parm)
+static void free_one_parameter(struct service *service,
+			       struct parm_struct parm)
+{
+	void *parm_ptr;
+
+	if (parm.p_class != P_LOCAL) {
+		return;
+	}
+
+	parm_ptr = lp_local_ptr(service, parm.ptr);
+
+	free_one_parameter_common(parm_ptr, parm);
+}
+
+/**
+ * Free the allocated parameter data of a share given
+ * as a service struct.
+ */
+static void free_parameters(struct service *service)
+{
+	uint32_t i;
+
+	for (i=0; parm_table[i].label; i++) {
+		free_one_parameter(service, parm_table[i]);
+	}
+}
+
+/**
+ * Free the allocated data for one parameter for a given share
+ * specified by an snum.
+ */
+static void free_one_parameter_by_snum(int snum, struct parm_struct parm)
 {
 	void *parm_ptr;
 
@@ -4599,27 +4648,22 @@ static void free_parameter(int snum, struct parm_struct parm)
 	} else if (parm.p_class != P_LOCAL) {
 		return;
 	} else {
-		parm_ptr = lp_local_ptr(snum, parm.ptr);
+		parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr);
 	}
 
-	if ((parm.type == P_STRING) ||
-	    (parm.type == P_USTRING))
-	{
-		string_free((char**)parm_ptr);
-	} else if (parm.type == P_LIST) {
-		TALLOC_FREE(*((char***)parm_ptr));
-	}
+	free_one_parameter_common(parm_ptr, parm);
 }
 
 /**
- * Free the allocated parameter data for a share.
+ * Free the allocated parameter data for a share specified
+ * by an snum.
  */
-static void free_parameters(int snum)
+static void free_parameters_by_snum(int snum)
 {
 	uint32_t i;
 
 	for (i=0; parm_table[i].label; i++) {
-		free_parameter(snum, parm_table[i]);
+		free_one_parameter_by_snum(snum, parm_table[i]);
 	}
 }
 
@@ -4628,7 +4672,7 @@ static void free_parameters(int snum)
  */
 static void free_global_parameters(void)
 {
-	free_parameters(GLOBAL_SECTION_SNUM);
+	free_parameters_by_snum(GLOBAL_SECTION_SNUM);
 }
 
 /***************************************************************************
@@ -5739,7 +5783,7 @@ static void free_service(struct service *pservice)
 		DEBUG(5, ("free_service: Freeing service %s\n",
 		       pservice->szService));
 
-	free_parameters(getservicebyname(pservice->szService, NULL));
+	free_parameters(pservice);
 
 	string_free(&pservice->szService);
 	bitmap_free(pservice->copymap);
@@ -7167,13 +7211,23 @@ static void init_copymap(struct service *pservice)
 }
 
 /***************************************************************************
+ Return the local pointer to a parameter given a service struct and the
+ pointer into the default structure.
+***************************************************************************/
+
+static void *lp_local_ptr(struct service *service, void *ptr)
+{
+	return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
+}
+
+/***************************************************************************
  Return the local pointer to a parameter given the service number and the 
  pointer into the default structure.
 ***************************************************************************/
 
-void *lp_local_ptr(int snum, void *ptr)
+void *lp_local_ptr_by_snum(int snum, void *ptr)
 {
-	return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
+	return lp_local_ptr(ServicePtrs[snum], ptr);
 }
 
 /***************************************************************************
@@ -7225,7 +7279,7 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
 			       pszParmName));
 			return (True);
 		}
-		parm_ptr = lp_local_ptr(snum, def_ptr);
+		parm_ptr = lp_local_ptr_by_snum(snum, def_ptr);
 	}
 
 	if (snum >= 0) {
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 27c4b54..b729e3b 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -232,7 +232,7 @@ static void show_parameter(int snum, struct parm_struct *parm)
 	TALLOC_CTX *ctx = talloc_stackframe();
 
 	if (parm->p_class == P_LOCAL && snum >= 0) {
-		ptr = lp_local_ptr(snum, ptr);
+		ptr = lp_local_ptr_by_snum(snum, ptr);
 	}
 
 	printf("<tr><td>%s</td><td>", get_parm_translated(ctx,
@@ -375,7 +375,7 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte
 					void *ptr = parm->ptr;
 
 				if (parm->p_class == P_LOCAL && snum >= 0) {
-					ptr = lp_local_ptr(snum, ptr);
+					ptr = lp_local_ptr_by_snum(snum, ptr);
 				}
 
 				switch (parm->type) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list