]> code.citadel.org Git - citadel.git/blobdiff - citadel/userlist.c
fix all the <time.h> vs. <sys/time.h> issues, hopefully
[citadel.git] / citadel / userlist.c
index 2bf663c05a76376f31d66cce133a7912590a8db0..bd59f04a582cf1f4cef04f742065eafa7740339a 100644 (file)
@@ -1,79 +1,30 @@
+/*
+ * $Id$
+ *
+ * Command-line user list utility.
+ *
+ */
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include "citadel.h"
 #include <unistd.h>
 #include "ipc.h"
-
-/*
- * num_parms()  -  discover number of parameters...
- */
-int num_parms(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(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(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(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atol(buf));
-       }
-
+#include "tools.h"
 
 void logoff(int code)
 {
@@ -81,10 +32,10 @@ void logoff(int code)
        }
 
 void userlist(void) { 
-       char buf[256];
-       char fl[256];
+       char buf[SIZ];
+       char fl[SIZ];
        struct tm *tmbuf;
-       long lc;
+       time_t lc;
 
        serv_puts("LIST");
        serv_gets(buf);
@@ -114,9 +65,10 @@ void userlist(void) {
 
 int main(int argc, char **argv)
 {
-       char buf[256];
+       char buf[SIZ];
+       char hostbuf[SIZ], portbuf[SIZ];
 
-       attach_to_server(argc,argv);
+       attach_to_server(argc, argv, hostbuf, portbuf);
        serv_gets(buf);
        if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
                fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);