]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r23010: Make the output of "smbcontrol --help" match that of "smbcontrol help".
authorJames Peach <jpeach@samba.org>
Sat, 19 May 2007 04:59:00 +0000 (04:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:22:15 +0000 (12:22 -0500)
Bug #3181.
(This used to be commit 94b0997ef1bd993587dfeef4e0a8d366c5371e9f)

source3/utils/smbcontrol.c

index 5d06576825b2ab986ecabea321d2b49887e818b0..637cdacffa433f92b733e52a8d2c8a52754fa748 100644 (file)
@@ -1062,11 +1062,11 @@ static const struct {
 
 /* Display usage information */
 
-static void usage(poptContext *pc)
+static void usage(poptContext pc)
 {
        int i;
 
-       poptPrintHelp(*pc, stderr, 0);
+       poptPrintHelp(pc, stderr, 0);
 
        fprintf(stderr, "\n");
        fprintf(stderr, "<destination> is one of \"nmbd\", \"smbd\", \"winbindd\" or a "
@@ -1160,6 +1160,29 @@ static BOOL do_command(struct messaging_context *msg_ctx,
        return False;
 }
 
+static void smbcontrol_help(poptContext pc,
+                   enum poptCallbackReason preason,
+                   struct poptOption * poption,
+                   const char * parg,
+                   void * pdata)
+{
+       if (poption->shortName != '?') {
+               poptPrintUsage(pc, stdout, 0);
+       } else {
+               usage(pc);
+       }
+
+       exit(0);
+}
+
+struct poptOption help_options[] = {
+       { NULL, '\0', POPT_ARG_CALLBACK, (void *)&smbcontrol_help, '\0',
+         NULL, NULL },
+       { "help", '?', 0, NULL, '?', "Show this help message", NULL },
+       { "usage", '\0', 0, NULL, 'u', "Display brief usage message", NULL },
+       { NULL }
+} ;
+
 /* Main program */
 
 int main(int argc, const char **argv)
@@ -1170,7 +1193,9 @@ int main(int argc, const char **argv)
        struct messaging_context *msg_ctx;
 
        static struct poptOption long_options[] = {
-               POPT_AUTOHELP
+               /* POPT_AUTOHELP */
+               { NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options,
+                                       0, "Help options:", NULL },
                { "timeout", 't', POPT_ARG_INT, &timeout, 't', 
                  "Set timeout value in seconds", "TIMEOUT" },
 
@@ -1191,7 +1216,7 @@ int main(int argc, const char **argv)
                               "<parameters>");
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch(opt) {
@@ -1215,7 +1240,7 @@ int main(int argc, const char **argv)
        }
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        lp_load(dyn_CONFIGFILE,False,False,False,True);