-/*
- 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)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 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)
{
- BOOL *parseable = (BOOL *)state;
+ bool *parseable = (bool *)state;
struct sessionid sessionid;
if (dbuf.dsize != sizeof(sessionid))
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(int argc, const char **argv)
+static int net_status_sessions(struct net_context *c, int argc, const char **argv)
{
TDB_CONTEXT *tdb;
- BOOL parseable;
+ bool parseable;
if (argc == 0) {
- parseable = False;
+ parseable = false;
} else if ((argc == 1) && strequal(argv[0], "parseable")) {
- parseable = True;
+ parseable = true;
} else {
- return net_help_status(argc, argv);
+ return net_status_usage(c, argc, argv);
}
if (!parseable) {
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
- if (!process_exists(sessionid.pid))
+ if (!process_exists(sessionid.pid))
return 0;
ids->num_entries += 1;
{
struct sessionids *ids = (struct sessionids *)state;
int i;
- BOOL guest = True;
+ bool guest = true;
if (crec->cnum == -1)
return 0;
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;
}
}
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(int argc, const char **argv)
+static int net_status_shares_parseable(struct net_context *c, int argc, const char **argv)
{
struct sessionids ids;
TDB_CONTEXT *tdb;
return 0;
}
-static int net_status_shares(int argc, const char **argv)
+static int net_status_shares(struct net_context *c, int argc, const char **argv)
{
if (argc == 0) {
}
if ((argc != 1) || !strequal(argv[0], "parseable")) {
- return net_help_status(argc, argv);
+ return net_status_usage(c, argc, argv);
}
- return net_status_shares_parseable(argc, argv);
+ return net_status_shares_parseable(c, argc, argv);
}
-int net_status(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}
};
- return net_run_function(argc, argv, func, net_help_status);
+ return net_run_function(c, argc, argv, func, net_status_usage);
}