Author: abartlet
Date: 2006-01-06 02:28:36 +0000 (Fri, 06 Jan 2006)
New Revision: 12730

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

Log:
Reimplement --parameter-name, and bring in common samba options.

This changes -s from meaning 'suppress prompt' to 'services file'.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/param/loadparm.c
   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 02:13:01 UTC (rev 
12729)
+++ branches/SAMBA_4_0/source/param/loadparm.c  2006-01-06 02:28:36 UTC (rev 
12730)
@@ -2228,7 +2228,45 @@
         }
 }
 
+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.
  Return NULL when out of parameters.

Modified: branches/SAMBA_4_0/source/utils/testparm.c
===================================================================
--- branches/SAMBA_4_0/source/utils/testparm.c  2006-01-06 02:13:01 UTC (rev 
12729)
+++ branches/SAMBA_4_0/source/utils/testparm.c  2006-01-06 02:28:36 UTC (rev 
12730)
@@ -81,17 +81,17 @@
        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 @@
 /*
   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" },
+               {"parameter-name", '\0', POPT_ARG_STRING, &parameter_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 @@
                        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 @@
                                                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());

Reply via email to