Author: jpeach
Date: 2007-05-19 04:59:00 +0000 (Sat, 19 May 2007)
New Revision: 23010

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

Log:
Make the output of "smbcontrol --help" match that of "smbcontrol help".
Bug #3181.

Modified:
   branches/SAMBA_3_0/source/utils/smbcontrol.c
   branches/SAMBA_3_0_26/source/utils/smbcontrol.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/smbcontrol.c
===================================================================
--- branches/SAMBA_3_0/source/utils/smbcontrol.c        2007-05-19 04:23:04 UTC 
(rev 23009)
+++ branches/SAMBA_3_0/source/utils/smbcontrol.c        2007-05-19 04:59:00 UTC 
(rev 23010)
@@ -1062,11 +1062,11 @@
 
 /* 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 @@
        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 @@
        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 @@
                               "<parameters>");
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch(opt) {
@@ -1215,7 +1240,7 @@
        }
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        lp_load(dyn_CONFIGFILE,False,False,False,True);
 

Modified: branches/SAMBA_3_0_26/source/utils/smbcontrol.c
===================================================================
--- branches/SAMBA_3_0_26/source/utils/smbcontrol.c     2007-05-19 04:23:04 UTC 
(rev 23009)
+++ branches/SAMBA_3_0_26/source/utils/smbcontrol.c     2007-05-19 04:59:00 UTC 
(rev 23010)
@@ -1062,11 +1062,11 @@
 
 /* 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 @@
        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 @@
        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 @@
                               "<parameters>");
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch(opt) {
@@ -1215,7 +1240,7 @@
        }
 
        if (argc == 1)
-               usage(&pc);
+               usage(pc);
 
        lp_load(dyn_CONFIGFILE,False,False,False,True);
 

Reply via email to