diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-01-06 02:28:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:46 -0500 |
commit | 1b29552e70a78116337cf08a8d629170097427ad (patch) | |
tree | 1791a697f4755a7f7b2f87edb0d7e1f846b7226e | |
parent | 03ab3429090a9fccc8778d949cd9d92042575558 (diff) | |
download | samba-1b29552e70a78116337cf08a8d629170097427ad.tar.gz samba-1b29552e70a78116337cf08a8d629170097427ad.tar.bz2 samba-1b29552e70a78116337cf08a8d629170097427ad.zip |
r12730: Reimplement --parameter-name, and bring in common samba options.
This changes -s from meaning 'suppress prompt' to 'services file'.
Andrew Bartlett
(This used to be commit 0f78bd743b8bc415e47006a683c53bfdff1bc1e1)
-rw-r--r-- | source4/param/loadparm.c | 38 | ||||
-rw-r--r-- | source4/utils/testparm.c | 19 |
2 files changed, 50 insertions, 7 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 6e7716b1f2..3d079f3e3e 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -2228,6 +2228,44 @@ static void dump_a_service(service * pService, FILE * f) } } +BOOL lp_dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal) +{ + service * pService = ServicePtrs[snum]; + int i, result = False; + parm_class p_class; + unsigned flag = 0; + + if (isGlobal) { + p_class = P_GLOBAL; + flag = FLAG_GLOBAL; + } else + p_class = P_LOCAL; + + for (i = 0; parm_table[i].label; i++) { + if (strwicmp(parm_table[i].label, parm_name) == 0 && + (parm_table[i].class == p_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==-1 gives the globals. diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index c4b7dd38d8..fd990221ed 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -81,17 +81,17 @@ static int do_global_checks(void) static const char *term_code = ""; /* static BOOL show_all_parameters = False; - static char *parameter_name = NULL; static char *new_local_machine = NULL; */ static const char *section_name = NULL; + static char *parameter_name = NULL; static const char *cname; static const char *caddr; static int show_defaults; struct poptOption long_options[] = { POPT_AUTOHELP - {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, + {"suppress-prompt", '\0', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, /* We need support for smb.conf macros before this will work again @@ -100,11 +100,12 @@ static int do_global_checks(void) /* 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, ¶meter_name, 0, "Limit testparm to a named parameter" }, */ {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, + {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, {"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_SAMBA POPT_COMMON_VERSION POPT_TABLEEND }; @@ -196,7 +197,7 @@ static int do_global_checks(void) fflush(stdout); getc(stdin); } - if (section_name) { + if (section_name || parameter_name) { BOOL isGlobal = False; if (!section_name) { section_name = GLOBAL_NAME; @@ -207,10 +208,14 @@ static int do_global_checks(void) section_name); return(1); } - if (isGlobal == True) { - lp_dump(stdout, show_defaults, 0); + if (!parameter_name) { + if (isGlobal == True) { + lp_dump(stdout, show_defaults, 0); + } else { + lp_dump_one(stdout, show_defaults, s); + } } else { - lp_dump_one(stdout, show_defaults, s); + ret = lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); } } else { lp_dump(stdout, show_defaults, lp_numservices()); |