summaryrefslogtreecommitdiff
path: root/source/utils/net_status.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/utils/net_status.c')
-rw-r--r--source/utils/net_status.c89
1 files changed, 23 insertions, 66 deletions
diff --git a/source/utils/net_status.c b/source/utils/net_status.c
index 4e355e48b3..4a3c5895a7 100644
--- a/source/utils/net_status.c
+++ b/source/utils/net_status.c
@@ -1,5 +1,5 @@
-/*
- Samba Unix/Linux SMB client library
+/*
+ Samba Unix/Linux SMB client library
net status command -- possible replacement for smbstatus
Copyright (C) 2003 Volker Lendecke (vl@samba.org)
@@ -7,27 +7,18 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "includes.h"
#include "utils/net.h"
-int net_status_usage(struct net_context *c, int argc, const char **argv)
-{
- d_printf(" net status sessions [parseable] "
- "Show list of open sessions\n");
- d_printf(" net status shares [parseable] "
- "Show list of open shares\n");
- return -1;
-}
-
static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *state)
{
@@ -46,38 +37,29 @@ static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
if (*parseable) {
d_printf("%s\\%s\\%s\\%s\\%s\n",
procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
- gidtoname(sessionid.gid),
+ gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);
} else {
d_printf("%7s %-12s %-12s %-12s (%s)\n",
procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
- gidtoname(sessionid.gid),
+ gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);
}
return 0;
}
-static int net_status_sessions(struct net_context *c, int argc, const char **argv)
+static int net_status_sessions(int argc, const char **argv)
{
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;
+ parseable = False;
} else if ((argc == 1) && strequal(argv[0], "parseable")) {
- parseable = true;
+ parseable = True;
} else {
- return net_status_usage(c, argc, argv);
+ return net_help_status(argc, argv);
}
if (!parseable) {
@@ -137,7 +119,7 @@ static int collect_pid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
- if (!process_exists(sessionid.pid))
+ if (!process_exists(sessionid.pid))
return 0;
ids->num_entries += 1;
@@ -158,7 +140,7 @@ static int show_share_parseable(struct db_record *rec,
{
struct sessionids *ids = (struct sessionids *)state;
int i;
- bool guest = true;
+ bool guest = True;
if (crec->cnum == -1)
return 0;
@@ -170,7 +152,7 @@ static int show_share_parseable(struct db_record *rec,
for (i=0; i<ids->num_entries; i++) {
struct server_id id = ids->entries[i].pid;
if (procid_equal(&id, &crec->pid)) {
- guest = false;
+ guest = False;
break;
}
}
@@ -179,14 +161,14 @@ static int show_share_parseable(struct db_record *rec,
crec->servicename,procid_str_static(&crec->pid),
guest ? "" : uidtoname(ids->entries[i].uid),
guest ? "" : gidtoname(ids->entries[i].gid),
- crec->machine,
+ crec->machine,
guest ? "" : ids->entries[i].hostname,
time_to_asc(crec->start));
return 0;
}
-static int net_status_shares_parseable(struct net_context *c, int argc, const char **argv)
+static int net_status_shares_parseable(int argc, const char **argv)
{
struct sessionids ids;
TDB_CONTEXT *tdb;
@@ -212,17 +194,8 @@ static int net_status_shares_parseable(struct net_context *c, int argc, const ch
return 0;
}
-static int net_status_shares(struct net_context *c, int argc, const char **argv)
+static int net_status_shares(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 "
@@ -236,34 +209,18 @@ static int net_status_shares(struct net_context *c, int argc, const char **argv)
}
if ((argc != 1) || !strequal(argv[0], "parseable")) {
- return net_status_usage(c, argc, argv);
+ return net_help_status(argc, argv);
}
- return net_status_shares_parseable(c, argc, argv);
+ return net_status_shares_parseable(argc, argv);
}
-int net_status(struct net_context *c, int argc, const char **argv)
+int net_status(int argc, const char **argv)
{
struct functable 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}
+ {"sessions", net_status_sessions},
+ {"shares", net_status_shares},
+ {NULL, NULL}
};
- return net_run_function(c, argc, argv, "net status", func);
+ return net_run_function(argc, argv, func, net_help_status);
}