]> code.citadel.org Git - citadel.git/blobdiff - citadel/routines.c
fix all the <time.h> vs. <sys/time.h> issues, hopefully
[citadel.git] / citadel / routines.c
index 6757a59f0d70e47e861b35e1d0cfadc22c14e752..6f3cd2106b62dbf391fb2b161238b540025d284c 100644 (file)
@@ -1,5 +1,9 @@
-/* Citadel/UX support routines */
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Client-side support functions.
+ *
+ */
 
 #include "sysdep.h"
 #include <stdlib.h>
 #include <signal.h>
 #include <dirent.h>
 #include <errno.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 <limits.h>
 #ifdef HAVE_UTMP_H
 #include <utmp.h>
@@ -54,26 +69,9 @@ extern struct CtdlServInfo serv_info;
 extern char rc_floor_mode;
 extern int rc_ansi_color;
 
-int struncmp(char *lstr, char *rstr, int len)
-{
-       int pos = 0;
-       char lc,rc;
-       while (pos<len) {
-               lc=tolower(lstr[pos]);
-               rc=tolower(rstr[pos]);
-               if ((lc==0)&&(rc==0)) return(0);
-               if (lc<rc) return(-1);
-               if (lc>rc) return(1);
-               pos=pos+1;
-               }
-       return(0);
-       }
-
-
-
 void back(int spaces) /* Destructive backspace */
             {
-int a;
+       int a;
        for (a=1; a<=spaces; ++a) {
                putc(8,stdout); putc(32,stdout); putc(8,stdout);
                }
@@ -94,16 +92,16 @@ void hit_any_key(void) {            /* hit any key to continue */
        sttybbs(1);
        if (b==NEXT_KEY) sigcaught = SIGINT;
        if (b==STOP_KEY) sigcaught = SIGQUIT;
-       }
+}
 
 /*
  * change a user's access level
  */
 void edituser(void)
 {
-       char buf[256];
-       char who[256];
-       char pass[256];
+       char buf[SIZ];
+       char who[SIZ];
+       char pass[SIZ];
        int flags;
        int timescalled;
        int posted;
@@ -131,7 +129,9 @@ void edituser(void)
        userpurge = extract_int(&buf[4], 8);
 
        val_user(who, 0); /* Display registration */
-       strprompt("Password", pass, 19);
+       if (boolprompt("Change password", 0)) {
+               strprompt("Password", pass, 19);
+       }
        axlevel = intprompt("Access level", axlevel, 0, 6);
        timescalled = intprompt("Times called", timescalled, 0, INT_MAX);
        posted = intprompt("Messages posted", posted, 0, INT_MAX);
@@ -178,7 +178,7 @@ int set_attr(int sval, char *prompt, unsigned int sbit)
  */
 void enter_config(int mode)
 {
-       int width,height,flags;
+       int width, height, flags, filter;
        char buf[128];
 
        sprintf(buf,"GETU");
@@ -192,6 +192,7 @@ void enter_config(int mode)
        width = extract_int(&buf[4],0);
        height = extract_int(&buf[4],1);
        flags = extract_int(&buf[4],2);
+       filter = extract_int(&buf[4],3);
 
        if ((mode==0)||(mode==1)) {
 
@@ -219,6 +220,9 @@ void enter_config(int mode)
          flags = set_attr(flags,
                "Enable color support",US_COLOR);
          }
+       
+        /* filter = intprompt("Moderation filter level", filter, -63, 63); */
+
         }
 
        if (mode==2) {
@@ -243,7 +247,7 @@ void enter_config(int mode)
                }
         }
 
-       sprintf(buf,"SETU %d|%d|%d",width,height,flags);
+       sprintf(buf,"SETU %d|%d|%d|%d",width,height,flags,filter);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') printf("%s\n",&buf[4]);
@@ -279,7 +283,7 @@ int pattern(char *search, char *patn)       /* Searches for patn in search string */
 {
        int a,b;
        for (a=0; a<strlen(search); ++a)
-       {       b=struncmp(&search[a],patn,strlen(patn));
+       {       b=strncasecmp(&search[a],patn,strlen(patn));
                if (b==0) return(b);
                }
        return(-1);
@@ -295,25 +299,6 @@ void interr(int errnum)    /* display internal error as defined in errmsgs */
 
 
 
-/*
- * Check to see if we need to pause at the end of a screen.
- * If we do, we have to disable server keepalives during the pause because
- * we are probably in the middle of a server operation and the NOOP command
- * would confuse everything.
- */
-int checkpagin(int lp, int pagin, int height)
-{
-       if (pagin!=1) return(0);
-       if (lp>=(height-1)) {
-               set_keepalives(KA_NO);
-               hit_any_key();
-               set_keepalives(KA_YES);
-               return(0);
-               }
-       return(lp);
-       }
-
-
 void strproc(char *string)
 {
        int a;
@@ -398,7 +383,7 @@ void progress(long int curr, long int cmax)
 void locate_host(char *hbuf)
 {
 #ifndef HAVE_UTMP_H
-       char buf[256];
+       char buf[SIZ];
        FILE *who;
        int a,b;
 
@@ -407,7 +392,7 @@ void locate_host(char *hbuf)
                strcpy(hbuf,serv_info.serv_fqdn);
                return; 
                }
-       fgets(buf,256,who);
+       fgets(buf,sizeof buf,who);
        pclose(who);
 
        b = 0;
@@ -476,7 +461,7 @@ void locate_host(char *hbuf)
  * miscellaneous server commands (testing, etc.)
  */
 void misc_server_cmd(char *cmd) {
-       char buf[256];
+       char buf[SIZ];
 
        serv_puts(cmd);
        serv_gets(buf);
@@ -529,7 +514,7 @@ int nukedir(char *dirname)
 {
        DIR *dp;
        struct dirent *d;
-       char filename[256];
+       char filename[SIZ];
 
        dp = opendir(dirname);
        if (dp == NULL) {