s3-param: Make dump_a_parameter use lp_paramater() rather than an open-coded loop
authorAndrew Bartlett <abartlet@samba.org>
Wed, 15 Jan 2014 00:42:55 +0000 (13:42 +1300)
committerMichael Adam <obnox@samba.org>
Wed, 29 Jan 2014 23:46:14 +0000 (00:46 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/param/loadparm.c

index 0264b1ddbd4459434828c595bda92f661bb80678..180f7c836b8472f03946cf85152de3471631f385 100644 (file)
@@ -3683,13 +3683,12 @@ static void dump_a_service(struct loadparm_service *pService, FILE * f)
 
 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
 {
-       int i;
        bool result = false;
-       parm_class p_class;
-       unsigned flag = 0;
+       struct parm_struct *p_struct;
        fstring local_parm_name;
        char *parm_opt;
        const char *parm_opt_value;
+       void *ptr;
 
        /* check for parametrical option */
        fstrcpy( local_parm_name, parm_name);
@@ -3709,36 +3708,24 @@ bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
                return result;
        }
 
-       /* check for a key and print the value */
-       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].p_class == p_class || parm_table[i].flags & flag))
-               {
-                       void *ptr;
+       p_struct = lp_get_parameter(parm_name);
 
-                       if (isGlobal) {
-                               ptr = lp_parm_ptr(NULL, 
-                                                 &parm_table[i]);
-                       } else {
-                               ptr = lp_parm_ptr(ServicePtrs[snum], 
-                                                 &parm_table[i]);
-                       }
+       if (p_struct == NULL) {
+               return false;
+       }
 
-                       lpcfg_print_parameter(&parm_table[i],
-                                       ptr, f);
-                       fprintf(f, "\n");
-                       result = true;
-                       break;
-               }
+       if (isGlobal) {
+               ptr = lp_parm_ptr(NULL,
+                                 p_struct);
+       } else {
+               ptr = lp_parm_ptr(ServicePtrs[snum],
+                                 p_struct);
        }
 
-       return result;
+       lpcfg_print_parameter(p_struct,
+                             ptr, f);
+       fprintf(f, "\n");
+       return true;
 }
 
 /***************************************************************************