svn commit: samba r12729 - in branches/SAMBA_4_0/source: param utils

abartlet at samba.org abartlet at samba.org
Fri Jan 6 02:13:01 GMT 2006


Author: abartlet
Date: 2006-01-06 02:13:01 +0000 (Fri, 06 Jan 2006)
New Revision: 12729

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

Log:
Implement the --section-name option, for dumping only one section.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/param/loadparm.h
   branches/SAMBA_4_0/source/utils/testparm.c


Changeset:
Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2006-01-06 00:46:35 UTC (rev 12728)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2006-01-06 02:13:01 UTC (rev 12729)
@@ -66,18 +66,6 @@
 
 static BOOL bLoaded = False;
 
-#ifndef GLOBAL_NAME
-#define GLOBAL_NAME "global"
-#endif
-
-#ifndef PRINTERS_NAME
-#define PRINTERS_NAME "printers"
-#endif
-
-#ifndef HOMES_NAME
-#define HOMES_NAME "homes"
-#endif
-
 /* some helpful bits */
 #define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
 #define VALID(i) ServicePtrs[i]->valid
@@ -706,6 +694,12 @@
 	do_parameter("tls cafile", "tls/ca.pem", NULL);
 	do_parameter_var("js include", "%s/js", dyn_LIBDIR);
 	do_parameter_var("setup directory", "%s/setup", dyn_LIBDIR);
+
+	for (i = 0; parm_table[i].label; i++) {
+		if (!(parm_table[i].flags & FLAG_CMDLINE)) {
+			parm_table[i].flags |= FLAG_DEFAULT;
+		}
+	}
 }
 
 static TALLOC_CTX *lp_talloc;
@@ -1886,6 +1880,17 @@
 			break;
 	}
 
+	if (parm_table[parmnum].flags & FLAG_DEFAULT) {
+		parm_table[parmnum].flags &= ~FLAG_DEFAULT;
+		/* we have to also unset FLAG_DEFAULT on aliases */
+		for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) {
+			parm_table[i].flags &= ~FLAG_DEFAULT;
+		}
+		for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) {
+			parm_table[i].flags &= ~FLAG_DEFAULT;
+		}
+	}
+
 	return (True);
 }
 
@@ -2151,7 +2156,7 @@
 Display the contents of the global structure.
 ***************************************************************************/
 
-static void dump_globals(FILE *f)
+static void dump_globals(FILE *f, BOOL show_defaults)
 {
 	int i;
 	struct param_opt *data;
@@ -2162,7 +2167,7 @@
 		if (parm_table[i].class == P_GLOBAL &&
 		    parm_table[i].ptr &&
 		    (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
-			if (defaults_saved && is_default(i))
+			if (!show_defaults && (parm_table[i].flags & FLAG_DEFAULT)) 
 				continue;
 			fprintf(f, "\t%s = ", parm_table[i].label);
 			print_parameter(&parm_table[i], parm_table[i].ptr, f);
@@ -2441,7 +2446,7 @@
 	if (show_defaults)
 		defaults_saved = False;
 
-	dump_globals(f);
+	dump_globals(f, show_defaults);
 
 	dump_a_service(&sDefault, f);
 

Modified: branches/SAMBA_4_0/source/param/loadparm.h
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.h	2006-01-06 00:46:35 UTC (rev 12728)
+++ branches/SAMBA_4_0/source/param/loadparm.h	2006-01-06 02:13:01 UTC (rev 12729)
@@ -68,6 +68,18 @@
 #define FLAG_DEVELOPER 	0x0040 /* Parameters that the wizard will operate on */
 #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
 #define FLAG_HIDE  	0x2000 /* options that should be hidden in SWAT */
-#define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
+#define FLAG_DEFAULT    0x4000 /* this option was a default */
 #define FLAG_CMDLINE    0x8000 /* this option was set from the command line */
 
+#ifndef GLOBAL_NAME
+#define GLOBAL_NAME "global"
+#endif
+
+#ifndef PRINTERS_NAME
+#define PRINTERS_NAME "printers"
+#endif
+
+#ifndef HOMES_NAME
+#define HOMES_NAME "homes"
+#endif
+

Modified: branches/SAMBA_4_0/source/utils/testparm.c
===================================================================
--- branches/SAMBA_4_0/source/utils/testparm.c	2006-01-06 00:46:35 UTC (rev 12728)
+++ branches/SAMBA_4_0/source/utils/testparm.c	2006-01-06 02:13:01 UTC (rev 12729)
@@ -82,9 +82,9 @@
 /*
 	static BOOL show_all_parameters = False;
 	static char *parameter_name = NULL;
-	static const char *section_name = NULL;
 	static char *new_local_machine = NULL;
 */
+	static const char *section_name = NULL;
 	static const char *cname;
 	static const char *caddr;
 	static int show_defaults;
@@ -101,8 +101,8 @@
   These are harder to do with the new code structure
 		{"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" },
 		{"parameter-name", '\0', POPT_ARG_STRING, &parameter_name, 0, "Limit testparm to a named parameter" },
+*/
 		{"section-name", '\0', POPT_ARG_STRING, &section_name, 0, "Limit testparm to a named section" },
-*/
 		{"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"},
 		{"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"},
 		POPT_COMMON_VERSION
@@ -196,7 +196,26 @@
 			fflush(stdout);
 			getc(stdin);
 		}
-		lp_dump(stdout, show_defaults, lp_numservices());
+		if (section_name) {
+			BOOL isGlobal = False;
+			if (!section_name) {
+				section_name = GLOBAL_NAME;
+				isGlobal = True;
+			} else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
+				 (s=lp_servicenumber(section_name)) == -1) {
+					fprintf(stderr,"Unknown section %s\n",
+						section_name);
+					return(1);
+			}
+			if (isGlobal == True) {
+				lp_dump(stdout, show_defaults, 0);
+			} else {
+				lp_dump_one(stdout, show_defaults, s);
+			}
+		} else {
+			lp_dump(stdout, show_defaults, lp_numservices());
+		}
+		return(ret);
 	}
 
 	if(cname && caddr){



More information about the samba-cvs mailing list