server: citserver setup
utils: aidepost netmailer netproc netsetup useradmin msgform \
-readlog rcit stats sysoputil citmail netpoll mailinglist
+readlog rcit stats sysoputil citmail netpoll mailinglist userlist
#
#
whobbs: whobbs.c ipc_c_tcp.o
$(CC) -O $(CFLAGS) whobbs.c ipc_c_tcp.o $(LFLAGS) -o whobbs
+userlist: userlist.c ipc_c_tcp.o
+ $(CC) -O $(CFLAGS) userlist.c ipc_c_tcp.o $(LFLAGS) -o userlist
+
useradmin: useradmin.c config.o citadel.h axdefs.h
$(CC) -O $(CFLAGS) useradmin.c config.o $(CURSES) $(LFLAGS) -o useradmin
chmod 4750 useradmin
--- /dev/null
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include "citadel.h"
+#include <unistd.h>
+
+void attach_to_server();
+
+/*
+ * num_parms() - discover number of parameters...
+ */
+int num_parms(source)
+char source[]; {
+ int a;
+ int count = 1;
+
+ for (a=0; a<strlen(source); ++a)
+ if (source[a]=='|') ++count;
+ return(count);
+ }
+
+
+/*
+ * extract() - extract a parameter from a series of "|" separated...
+ */
+void extract(dest,source,parmnum)
+char dest[];
+char source[];
+int parmnum; {
+ char buf[256];
+ int count = 0;
+ int n;
+
+ n = num_parms(source);
+
+ if (parmnum >= n) {
+ strcpy(dest,"");
+ return;
+ }
+ strcpy(buf,source);
+ if ( (parmnum == 0) && (n == 1) ) {
+ strcpy(dest,buf);
+ return;
+ }
+
+ while (count++ < parmnum) do {
+ strcpy(buf,&buf[1]);
+ } while( (strlen(buf)>0) && (buf[0]!='|') );
+ if (buf[0]=='|') strcpy(buf,&buf[1]);
+ for (count = 0; count<strlen(buf); ++count)
+ if (buf[count] == '|') buf[count] = 0;
+ strcpy(dest,buf);
+ }
+
+/*
+ * extract_int() - extract an int parm w/o supplying a buffer
+ */
+int extract_int(source,parmnum)
+char *source;
+int parmnum; {
+ char buf[256];
+
+ extract(buf,source,parmnum);
+ return(atoi(buf));
+ }
+
+
+/*
+ * extract_long() - extract an long parm w/o supplying a buffer
+ */
+long extract_long(source,parmnum)
+char *source;
+int parmnum; {
+ char buf[256];
+
+ extract(buf,source,parmnum);
+ return(atol(buf));
+ }
+
+
+void logoff(code)
+int code; {
+ exit(code);
+ }
+
+void userlist() {
+ char buf[256];
+ char fl[256];
+ struct tm *tmbuf;
+ long lc;
+
+ serv_puts("LIST");
+ serv_gets(buf);
+ if (buf[0]!='1') {
+ printf("%s\n",&buf[4]);
+ return;
+ }
+ printf(" User Name Num L LastCall Calls Posts\n");
+ printf("------------------------- ----- - ---------- ----- -----\n");
+ while (serv_gets(buf), strcmp(buf,"000")) {
+ extract(fl,buf,0);
+ printf("%-25s ",fl);
+ printf("%5ld %d ",extract_long(buf,2),
+ extract_int(buf,1));
+ lc = extract_long(buf,3);
+ tmbuf = (struct tm *)localtime(&lc);
+ printf("%02d/%02d/%04d ",
+ (tmbuf->tm_mon+1),
+ tmbuf->tm_mday,
+ (tmbuf->tm_year + 1900));
+ printf("%5ld %5ld\n",
+ extract_long(buf,4),extract_long(buf,5));
+ }
+ printf("\n");
+ }
+
+
+void main(argc,argv)
+int argc;
+char *argv[]; {
+ char buf[256];
+
+ attach_to_server(argc,argv);
+ serv_gets(buf);
+ if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
+ fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
+ logoff(atoi(buf));
+ }
+
+ userlist();
+
+ serv_puts("QUIT");
+ serv_gets(buf);
+ exit(0);
+ }
+
+
+#ifdef NO_STRERROR
+/*
+ * replacement strerror() for systems that don't have it
+ */
+char *strerror(e)
+int e; {
+ static char buf[32];
+
+ sprintf(buf,"errno = %d",e);
+ return(buf);
+ }
+#endif
+
+
+
+
+
set when running this program. When called without any arguments, userlist
will display all users (except those who have chosen to be unlisted), their
user numbers, times called, messages posted, screen width, and date of their
-most recent call.
-
- Setting the -p option (only allowed by root as distributed; you may wish
-to change this) also displays passwords, and lists all users regardless of
-whether they are unlisted.
-
- Setting the -n option causes the next argument after -n to be a user
-number to search for.
+most recent call.
- You can also elect to sort the output by user name or user number by
-specifying the -su or -sn flags.
-
+ userlist is simply the same user listing code that is in the client, made
+into a standalone utility for convenience.
+
READLOG