From c66bc0dadbe7502f651fec53da488c838412f627 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jan 2006 02:50:46 +0000 Subject: r12731: Simplify and re-implemenet support for --parameter-name=foo --service-name=bar in testparm. Andrew Bartlett (This used to be commit be067e9a04a4dca02a9472ae7385dc0bf26735ea) --- source4/param/loadparm.c | 41 ++++++++++++++++------------------------- source4/utils/testparm.c | 2 +- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 3d079f3e3e..c79db6e584 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -2231,40 +2231,31 @@ 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; - + struct parm_struct *parm; + void *ptr; 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; - } + parm = lp_parm_struct(parm_name); + if (!parm) { + return False; } - - return result; + + if (isGlobal) + ptr = parm->ptr; + else + ptr = ((char *)pService) + + PTR_DIFF(parm->ptr, &sDefault); + + print_parameter(parm, + ptr, f); + fprintf(f, "\n"); + return True; } /*************************************************************************** diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index fd990221ed..d2f76960db 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -215,7 +215,7 @@ static int do_global_checks(void) lp_dump_one(stdout, show_defaults, s); } } else { - ret = lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); + ret = !lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); } } else { lp_dump(stdout, show_defaults, lp_numservices()); -- cgit