The Samba-Bugzilla – Attachment 1257 Details for
Bug 2767
Allow testparm to limit it's scope
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch to add the described enhancement.
testparm.diff (text/plain), 6.82 KB, created by
Lars Müller
on 2005-06-03 06:15:11 UTC
(
hide
)
Description:
Proposed patch to add the described enhancement.
Filename:
MIME Type:
Creator:
Lars Müller
Created:
2005-06-03 06:15:11 UTC
Size:
6.82 KB
patch
obsolete
>Index: source/param/loadparm.c >=================================================================== >--- source/param/loadparm.c (revision 7225) >+++ source/param/loadparm.c (working copy) >@@ -2519,6 +2519,59 @@ > } > > /*************************************************************************** >+ Show all parameter's name, type, [values,] and flags. >+***************************************************************************/ >+ >+void show_parameter_list(void) >+{ >+ int classIndex, parmIndex, enumIndex, flagIndex; >+ BOOL hadFlag; >+ char *section_names[] = { "local", "global", NULL}; >+ char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER", >+ "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING", "P_GSTRING", >+ "P_UGSTRING", "P_ENUM", "P_SEP"}; >+ unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL, >+ FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED, >+ FLAG_HIDE, FLAG_DOS_STRING}; >+ char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT", >+ "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER", >+ "FLAG_DEPRECATED", "FLAG_HIDE", "FLAG_DOS_STRING", NULL}; >+ >+ for ( classIndex=0; section_names[classIndex]; classIndex++) { >+ printf("[%s]\n", section_names[classIndex]); >+ for (parmIndex = 0; parm_table[parmIndex].label; parmIndex++) { >+ if (parm_table[parmIndex].class == classIndex) { >+ printf("%s=%s", >+ parm_table[parmIndex].label, >+ type[parm_table[parmIndex].type]); >+ switch (parm_table[parmIndex].type) { >+ case P_ENUM: >+ printf(","); >+ for (enumIndex=0; parm_table[parmIndex].enum_list[enumIndex].name; enumIndex++) >+ printf("%s%s", >+ enumIndex ? "|" : "", >+ parm_table[parmIndex].enum_list[enumIndex].name); >+ break; >+ default: >+ break; >+ } >+ printf(","); >+ hadFlag = False; >+ for ( flagIndex=0; flag_names[flagIndex]; flagIndex++ ) { >+ if (parm_table[parmIndex].flags & flags[flagIndex]) { >+ printf("%s%s", >+ hadFlag ? "|" : "", >+ flag_names[flagIndex]); >+ hadFlag = True; >+ } >+ } >+ printf("\n"); >+ } >+ } >+ } >+} >+ >+/*************************************************************************** > Set a boolean variable from the text value stored in the passed string. > Returns True in success, False if the passed string does not correctly > represent a boolean. >@@ -3541,7 +3594,7 @@ > int i; > param_opt_struct *data; > >- fprintf(f, "# Global parameters\n[global]\n"); >+ fprintf(f, "[global]\n"); > > for (i = 0; parm_table[i].label; i++) > if (parm_table[i].class == P_GLOBAL && >@@ -3586,7 +3639,7 @@ > param_opt_struct *data; > > if (pService != &sDefault) >- fprintf(f, "\n[%s]\n", pService->szService); >+ fprintf(f, "[%s]\n", pService->szService); > > for (i = 0; parm_table[i].label; i++) { > >@@ -3626,7 +3679,50 @@ > } > } > >+/*************************************************************************** >+ Display the contents of a parameter of a single services record. >+***************************************************************************/ > >+BOOL dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal) >+{ >+ service * pService = ServicePtrs[snum]; >+ int i, result = False; >+ parm_class class; >+ unsigned flag = 0; >+ void *ptr; >+ >+ if (isGlobal) { >+ class = P_GLOBAL; >+ flag = FLAG_GLOBAL; >+ } else >+ class = P_LOCAL; >+ >+ for (i = 0; parm_table[i].label; i++) { >+ if (strwicmp(parm_table[i].label, parm_name) == 0 && >+ (parm_table[i].class == class || parm_table[i].flags & flag) && >+ parm_table[i].ptr && >+ (*parm_table[i].label != '-') && >+ (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) >+ { >+ void *ptr; >+ >+ if (isGlobal) >+ ptr = parm_table[i].ptr; >+ else >+ ptr = ((char *)pService) + >+ PTR_DIFF(parm_table[i].ptr, &sDefault); >+ >+ print_parameter(&parm_table[i], >+ ptr, f); >+ fprintf(f, "\n"); >+ result = True; >+ break; >+ } >+ } >+ >+ return result; >+} >+ > /*************************************************************************** > Return info about the next service in a service. snum==GLOBAL_SECTION_SNUM gives the globals. > Return NULL when out of parameters. >@@ -4058,8 +4154,10 @@ > > dump_a_service(&sDefault, f); > >- for (iService = 0; iService < maxtoprint; iService++) >+ for (iService = 0; iService < maxtoprint; iService++) { >+ fprintf(f,"\n"); > lp_dump_one(f, show_defaults, iService); >+ } > } > > /*************************************************************************** >Index: source/utils/testparm.c >=================================================================== >--- source/utils/testparm.c (revision 7225) >+++ source/utils/testparm.c (working copy) >@@ -201,9 +201,12 @@ > const char *config_file = dyn_CONFIGFILE; > int s; > static BOOL silent_mode = False; >+ static BOOL show_all_parameters = False; > int ret = 0; > poptContext pc; > static const char *term_code = ""; >+ static char *parameter_name = NULL; >+ static char *section_name = NULL; > static char *new_local_machine = NULL; > const char *cname; > const char *caddr; >@@ -215,6 +218,9 @@ > {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, > {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, > {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, >+ {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, >+ {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, >+ {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, > POPT_COMMON_VERSION > POPT_TABLEEND > }; >@@ -225,6 +231,11 @@ > > while(poptGetNextOpt(pc) != -1); > >+ if (show_all_parameters) { >+ show_parameter_list(); >+ exit(0); >+ } >+ > setup_logging(poptGetArg(pc), True); > > if (poptPeekArg(pc)) >@@ -331,7 +342,7 @@ > } > > >- if (!silent_mode) { >+ if (!silent_mode && !section_name && !parameter_name) { > fprintf(stderr,"Server role: "); > switch(lp_server_role()) { > case ROLE_STANDALONE: >@@ -358,6 +369,34 @@ > fflush(stdout); > getc(stdin); > } >+ if (parameter_name || section_name) { >+ BOOL isGlobal = False; >+ s = GLOBAL_SECTION_SNUM; >+ >+ 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 (parameter_name) { >+ if (!dump_a_parameter( s, parameter_name, stdout, isGlobal)) { >+ fprintf(stderr,"Parameter %s unknown for section %s\n", >+ parameter_name, section_name); >+ return(1); >+ } >+ } else { >+ if (isGlobal == True) >+ lp_dump(stdout, show_defaults, 0); >+ else >+ lp_dump_one(stdout, show_defaults, s); >+ } >+ return(ret); >+ } >+ > lp_dump(stdout, show_defaults, lp_numservices()); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 2767
: 1257