Since it is no longer possible for the utilities to access the data files
authorArt Cancro <ajc@citadel.org>
Mon, 13 Jul 1998 03:24:19 +0000 (03:24 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 13 Jul 1998 03:24:19 +0000 (03:24 +0000)
directly, they all have to be reworked to talk to the server instead.  This
version of userlist does that.

citadel/Makefile.in
citadel/userlist.c [new file with mode: 0644]
citadel/utils.txt

index 060cc911da954108d83e924558d1cb3355d69e7e..924353310b31f583fda4ab01422020cdf3b2702f 100644 (file)
@@ -15,7 +15,7 @@ client: citadel whobbs
 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
 
 #
 #
@@ -156,6 +156,9 @@ netsetup: netsetup.c config.o citadel.h
 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
diff --git a/citadel/userlist.c b/citadel/userlist.c
new file mode 100644 (file)
index 0000000..77c04ef
--- /dev/null
@@ -0,0 +1,156 @@
+#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
+
+
+
+
+
index 9ce507cee7956d2de3c0cf118be76d5f206cd196..7f44ee8221535a3e709b09861f7a59aaeb402dc4 100644 (file)
@@ -115,18 +115,11 @@ archives of certain rooms.
 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