net: Make "net status" use functable3
authorKai Blin <kai@samba.org>
Mon, 19 May 2008 13:30:30 +0000 (15:30 +0200)
committerKai Blin <kai@samba.org>
Tue, 10 Jun 2008 07:46:12 +0000 (09:46 +0200)
(This used to be commit e4b4fb4c39f251b0675b1c1dcec14f20135f876b)

source3/utils/net_status.c

index 2835b2084d92af3503ccbc176e424ba07017a078..0bd698a8e7e10b1179779d691346d3f4057c2f1c 100644 (file)
@@ -63,6 +63,15 @@ static int net_status_sessions(struct net_context *c, int argc, const char **arg
        TDB_CONTEXT *tdb;
        bool parseable;
 
+       if (c->display_usage) {
+               d_printf("Usage:\n"
+                        "net status sessions [parseable]\n"
+                        "    Display open user sessions.\n"
+                        "    If parseable is specified, output is machine-"
+                        "readable.\n");
+               return 0;
+       }
+
        if (argc == 0) {
                parseable = false;
        } else if ((argc == 1) && strequal(argv[0], "parseable")) {
@@ -205,6 +214,15 @@ static int net_status_shares_parseable(struct net_context *c, int argc, const ch
 
 static int net_status_shares(struct net_context *c, int argc, const char **argv)
 {
+       if (c->display_usage) {
+               d_printf("Usage:\n"
+                        "net status shares [parseable]\n"
+                        "    Display open user shares.\n"
+                        "    If parseable is specified, output is machine-"
+                        "readable.\n");
+               return 0;
+       }
+
        if (argc == 0) {
 
                d_printf("\nService      pid     machine       "
@@ -226,11 +244,26 @@ static int net_status_shares(struct net_context *c, int argc, const char **argv)
 
 int net_status(struct net_context *c, int argc, const char **argv)
 {
-       struct functable func[] = {
-               {"sessions", net_status_sessions},
-               {"shares", net_status_shares},
-               {"help", net_status_usage},
-               {NULL, NULL}
+       struct functable3 func[] = {
+               {
+                       "sessions",
+                       net_status_sessions,
+                       NET_TRANSPORT_LOCAL,
+                       "Show list of open sessions",
+                       "net status sessions [parseable]\n"
+                       "    If parseable is specified, output is presented "
+                       "in a machine-parseable fashion."
+               },
+               {
+                       "shares",
+                       net_status_shares,
+                       NET_TRANSPORT_LOCAL,
+                       "Show list of open shares",
+                       "net status shares [parseable]\n"
+                       "    If parseable is specified, output is presented "
+                       "in a machine-parseable fashion."
+               },
+               {NULL, NULL, 0, NULL, NULL}
        };
-       return net_run_function(c, argc, argv, func, net_status_usage);
+       return net_run_function3(c, argc, argv, "net status", func);
 }