Create some directories to hold the source files for the utility
[citadel.git] / citadel / userlist.c
index 9c23f189133d0bc3a1cd970c5e87a7ff7f99e41e..3f78cea6fb0e03b61aa2c852984de2864838a2d8 100644 (file)
 # endif
 #endif
 
+#include <libcitadel.h>
 #include "citadel.h"
 #include <unistd.h>
 #include "citadel_ipc.h"
-#include "tools.h"
+#include "citadel_dirs.h"
 
 void logoff(int code)
 {
@@ -34,32 +35,32 @@ void logoff(int code)
 void userlist(CtdlIPC *ipc) { 
        char buf[SIZ];
        char fl[SIZ];
-       struct tm *tmbuf;
+       struct tm tmbuf;
        time_t lc;
        char *listing = NULL;
        int r;
 
-       r = CtdlIPCUserListing(ipc, &listing, buf);
+       r = CtdlIPCUserListing(ipc, "", &listing, buf);
        if (r / 100 != 1) {
                printf("%s\n", buf);
                return;
        }
-       printf("       User Name           Num  L  LastCall  Calls Posts\n");
-       printf("------------------------- ----- - ---------- ----- -----\n");
+       printf("       User Name           Num  L Last Visit Logins Messages\n");
+       printf("------------------------- ----- - ---------- ------ --------\n");
        while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
-               extract(fl,buf,0);
+               extract_token(fl, buf, 0, '|', sizeof fl);
                printf("%-25s ",fl);
-               printf("%5ld %d ",extract_long(buf,2),
+               printf("%5ld %d ", extract_long(buf,2),
                        extract_int(buf,1));
                lc = extract_long(buf,3);
-               tmbuf = (struct tm *)localtime(&lc);
+               localtime_r(&lc, &tmbuf);
                printf("%02d/%02d/%04d ",
-                       (tmbuf->tm_mon+1),
-                       tmbuf->tm_mday,
-                       (tmbuf->tm_year + 1900));
-               printf("%5ld %5ld\n",
+                       (tmbuf.tm_mon+1),
+                       tmbuf.tm_mday,
+                       (tmbuf.tm_year + 1900));
+               printf("%6ld %8ld\n",
                        extract_long(buf,4),extract_long(buf,5));
        }
        printf("\n");
@@ -71,6 +72,12 @@ int main(int argc, char **argv)
        char buf[SIZ];
        char hostbuf[SIZ], portbuf[SIZ];
        CtdlIPC *ipc = NULL;
+       int relh=0;
+       int home=0;
+       char relhome[PATH_MAX]="";
+       char ctdldir[PATH_MAX]=CTDLDIR;
+
+       calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
 
        ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
        CtdlIPC_chat_recv(ipc, buf);
@@ -98,3 +105,11 @@ char *strerror(int e)
        return(buf);
 }
 #endif
+
+
+/*
+ * Stub function
+ */
+void stty_ctdl(int cmd) {
+}
+