update testparm with -s option so it doesn't require a carriage return
authorHerb Lewis <herb@samba.org>
Thu, 19 Nov 1998 21:17:58 +0000 (21:17 +0000)
committerHerb Lewis <herb@samba.org>
Thu, 19 Nov 1998 21:17:58 +0000 (21:17 +0000)
also allow specifying [host hostip] without [configfile]
updated man page
(This used to be commit 85fbd401026e7f1464c9a125cbaa505b768f8a10)

docs/htmldocs/testparm.1.html
docs/manpages/testparm.1
docs/yodldocs/testparm.1.yo
source3/utils/testparm.c

index cd7b08232a78410ad1429538a617d02aae7c170a..6d2c2c92c565e118171d9cfacc8c352fcfac207e 100644 (file)
@@ -24,7 +24,7 @@
 <p><br><a name="SYNOPSIS"></a>
 <h2>SYNOPSIS</h2>
      
-<p><br><strong>testparm</strong> [<a href="testparm.1.html#configfilename">configfilename</a> [<a href="testparm.1.html#hostname">hostname</a> <a href="testparm.1.html#hostIP">hostIP</a>] ]
+<p><br><strong>testparm</strong> [<a href="testparm.1.html#minuss">-s</a>] [<a href="testparm.1.html#configfilename">configfilename</a>] [<a href="testparm.1.html#hostname">hostname</a> <a href="testparm.1.html#hostIP">hostIP</a>]
 <p><br><a name="DESCRIPTION"></a>
 <h2>DESCRIPTION</h2>
     
@@ -43,6 +43,10 @@ reporting whether the specified host has access to each service.
 <h2>OPTIONS</h2>
     
 <p><br><ul>
+<p><br><a name="minuss"></a>
+<li><strong><strong>-s</strong></strong> Without this option, <strong>testparm</strong> will prompt for a
+carriage return after printing the service names and before dumping
+the service definitions.
 <p><br><a name="configfilename"></a>
 <li><strong><strong>configfilename</strong></strong> This is the name of the configuration file to
 check. If this parameter is not present then the default
index 92ba093dedd3128ab916fb8e1ce9b2b81f13855b..725b5863b606cd2f4d499de7248c70216a9477df 100644 (file)
@@ -5,7 +5,7 @@ testparm \- check an smb\&.conf configuration file for internal correctness
 .PP 
 .SH "SYNOPSIS" 
 .PP 
-\fBtestparm\fP [configfilename [hostname hostIP] ]
+\fBtestparm\fP [-s] [configfilename] [hostname hostIP]
 .PP 
 .SH "DESCRIPTION" 
 .PP 
@@ -27,6 +27,11 @@ reporting whether the specified host has access to each service\&.
 .SH "OPTIONS" 
 .PP 
 .IP 
+.IP "\fB-s\fP" 
+Without this option, \fBtestparm\fP will prompt for a
+carriage return after printing the service names and before dumping
+the service definitions\&.
+.IP 
 .IP "\fBconfigfilename\fP" 
 This is the name of the configuration file to
 check\&. If this parameter is not present then the default
index ebb6120746989c2c1925913a18fbb2793be036d6..1c463a5ee4286481aa55ad8edb22578e0a602dcc 100644 (file)
@@ -8,7 +8,7 @@ manpagename(testparm)(check an smb.conf configuration file for internal correctn
 label(SYNOPSIS)
 manpagesynopsis() 
 
-bf(testparm) [link(configfilename)(configfilename) [link(hostname)(hostname) link(hostIP)(hostIP)] ]
+bf(testparm) [link(-s)(minuss)] [link(configfilename)(configfilename)] [link(hostname)(hostname) link(hostIP)(hostIP)]
 
 label(DESCRIPTION)
 manpagedescription()
@@ -33,6 +33,11 @@ manpageoptions()
 
 startdit()
 
+label(minuss)
+dit(bf(-s)) Without this option, bf(testparm) will prompt for a
+carriage return after printing the service names and before dumping
+the service definitions.
+
 label(configfilename)
 dit(bf(configfilename)) This is the name of the configuration file to
 check. If this parameter is not present then the default
index 92bf5cb3847ea324ca5a48d601e648d4cf7d4ee2..9bf741e24f14ae3df926ef7da22d69bf7814c9ae 100644 (file)
@@ -72,8 +72,12 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
 
  int main(int argc, char *argv[])
 {
+  extern char *optarg;
+  extern int optind;
   pstring configfile;
+  int opt;
   int s;
+  BOOL silent_mode = False;
 
   TimeInit();
 
@@ -81,10 +85,20 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
   
   charset_initialise();
 
-  if (argc < 2)
+  while ((opt = getopt(argc, argv,"s")) != EOF) {
+  switch (opt) {
+    case 's':
+      silent_mode = True;
+      break;
+    }
+  }
+
+  argc += (1 - optind);
+
+  if ((argc == 1) || (argc == 3))
     pstrcpy(configfile,CONFIGFILE);
-  else
-    pstrcpy(configfile,argv[1]);
+  else if ((argc == 2) || (argc == 4))
+    pstrcpy(configfile,argv[optind]);
 
   dbf = stdout;
   DEBUGLEVEL = 2;
@@ -116,19 +130,29 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
        break;
       }
 
-  if (argc < 4)
+  if (argc < 3)
     {
-      printf("Press enter to see a dump of your service definitions\n");
-      fflush(stdout);
-      getc(stdin);
+      if (!silent_mode) {
+       printf("Press enter to see a dump of your service definitions\n");
+       fflush(stdout);
+       getc(stdin);
+      }
       lp_dump(stdout,True);
     }
   
-  if (argc == 4)
+  if (argc >= 3)
     {
-      char *cname = argv[2];
-      char *caddr = argv[3];
+      char *cname;
+      char *caddr;
       
+      if (argc == 3) {
+       cname = argv[optind];
+       caddr = argv[optind+1];
+      } else if (argc == 4) {
+       cname = argv[optind+1];
+       caddr = argv[optind+2];
+      }
+
       /* this is totally ugly, a real `quick' hack */
       for (s=0;s<1000;s++)
        if (VALID_SNUM(s))