From 6f940f7734c8209955d3c5acfa7f96fff4935938 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 23 Feb 2012 12:10:23 -0500 Subject: [PATCH] Reinstated the defunct 'whobbs' utility as a function of ctdlsh --- ctdlsh/src/Makefile.am | 6 +++--- ctdlsh/src/Makefile.in | 6 ++++-- ctdlsh/src/ctdlsh.h | 1 + ctdlsh/src/main.c | 1 + ctdlsh/src/who.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 ctdlsh/src/who.c diff --git a/ctdlsh/src/Makefile.am b/ctdlsh/src/Makefile.am index 4da8f1c95..5ceb21403 100644 --- a/ctdlsh/src/Makefile.am +++ b/ctdlsh/src/Makefile.am @@ -1,7 +1,7 @@ ## -## (c) 2009 by Art Cancro and citadel.org +## (c) 2009-2012 by Art Cancro and citadel.org ## This program is released under the terms of the GNU General Public License v3. -##/ +## bin_PROGRAMS = ctdlsh -ctdlsh_SOURCES = main.c sockets.c ctdlsh.h datetime.c passwd.c shutdown.c +ctdlsh_SOURCES = main.c sockets.c ctdlsh.h datetime.c passwd.c shutdown.c who.c diff --git a/ctdlsh/src/Makefile.in b/ctdlsh/src/Makefile.in index d0fb155bd..a00d16653 100644 --- a/ctdlsh/src/Makefile.in +++ b/ctdlsh/src/Makefile.in @@ -46,7 +46,8 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_ctdlsh_OBJECTS = main.$(OBJEXT) sockets.$(OBJEXT) \ - datetime.$(OBJEXT) passwd.$(OBJEXT) shutdown.$(OBJEXT) + datetime.$(OBJEXT) passwd.$(OBJEXT) shutdown.$(OBJEXT) \ + who.$(OBJEXT) ctdlsh_OBJECTS = $(am_ctdlsh_OBJECTS) ctdlsh_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -145,7 +146,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ctdlsh_SOURCES = main.c sockets.c ctdlsh.h datetime.c passwd.c shutdown.c +ctdlsh_SOURCES = main.c sockets.c ctdlsh.h datetime.c passwd.c shutdown.c who.c all: all-am .SUFFIXES: @@ -232,6 +233,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/who.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/ctdlsh/src/ctdlsh.h b/ctdlsh/src/ctdlsh.h index 77ca9e7e9..c06e2aa05 100644 --- a/ctdlsh/src/ctdlsh.h +++ b/ctdlsh/src/ctdlsh.h @@ -43,3 +43,4 @@ int cmd_quit(int, char *); int cmd_datetime(int, char *); int cmd_passwd(int, char *); int cmd_shutdown(int, char *); +int cmd_who(int, char *); diff --git a/ctdlsh/src/main.c b/ctdlsh/src/main.c index f996e68ec..7e18d2e6b 100644 --- a/ctdlsh/src/main.c +++ b/ctdlsh/src/main.c @@ -28,6 +28,7 @@ COMMAND commands[] = { { "date", cmd_datetime, "Print the server's date and time" }, { "time", cmd_datetime, "Print the server's date and time" }, { "passwd", cmd_passwd, "Set or change an account password" }, + { "who", cmd_who, "Display a list of online users" }, { "shutdown", cmd_shutdown, "Shut down the Citadel server" }, { NULL, NULL, NULL } }; diff --git a/ctdlsh/src/who.c b/ctdlsh/src/who.c new file mode 100644 index 000000000..5fd3cf9d9 --- /dev/null +++ b/ctdlsh/src/who.c @@ -0,0 +1,43 @@ +/* + * (c) 1987-2011 by Art Cancro and citadel.org + * This program is open source software, released under the terms of the GNU General Public License v3. + * It runs really well on the Linux operating system. + * We love open source software but reject Richard Stallman's linguistic fascism. + */ + +#include "ctdlsh.h" + + +int cmd_who(int server_socket, char *cmdbuf) { + char buf[1024]; + char *t = NULL; + + sock_puts(server_socket, "RWHO"); + sock_getln(server_socket, buf, sizeof buf); + printf("%s\n", &buf[4]); + if (buf[0] != '1') { + return(cmdret_error); + } + + printf( "Session User name Room From host\n"); + printf( "------- ------------------------- ------------------- ------------------------\n"); + + while (sock_getln(server_socket, buf, sizeof buf), strcmp(buf, "000")) { + +//7872|Dampfklon| |p5DE44943.dip.t-dialin.net||1330016445|CHEK|.||||1 + + t = strtok(buf, "|"); /* session number */ + printf("%-7d ", atoi(t)); + + t = strtok(NULL, "|"); + printf("%-26s", t); /* user name */ + + t = strtok(NULL, "|"); /* room name */ + printf("%-19s ", t); + + t = strtok(NULL, "|"); /* from host */ + printf("%-24s\n", t); + } + + return(cmdret_ok); +} -- 2.30.2