]> code.citadel.org Git - citadel.git/blobdiff - citadel/routines.c
* Changed the comments at the beginning of each file to a consistent format
[citadel.git] / citadel / routines.c
index 8a0790923fcb73f0a409d17ea5216d10bee29749..0997942175aed98ab87b1ad61e8a01d542a1847a 100644 (file)
@@ -1,5 +1,9 @@
-/* Citadel/UX support routines */
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Client-side support functions.
+ *
+ */
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -19,6 +23,9 @@
 #ifdef HAVE_UTMP_H
 #include <utmp.h>
 #endif
+#ifdef HAVE_UTMPX_H
+#include <utmpx.h>
+#endif
 
 #ifndef HAVE_GETUTLINE
 struct utmp *getutline(struct utmp *ut);
@@ -51,37 +58,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);
-       }
-
-
-/* 
- * check for the presence of a character within a string (returns count)
- */
-int haschar(char *st, int ch)
-{
-       int a,b;
-       b=0;
-       for (a=0; a<strlen(st); ++a) if (st[a]==ch) ++b;
-       return(b);
-       }
-
-
 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);
                }
@@ -90,7 +69,10 @@ int a;
 void hit_any_key(void) {               /* hit any key to continue */
        int a,b;
 
+       color(COLOR_PUSH);
+       color(DIM_RED);
        printf("%s\r",serv_info.serv_moreprompt);
+       color(COLOR_POP);
        sttybbs(0);
        b=inkey();
        for (a=0; a<strlen(serv_info.serv_moreprompt); ++a)
@@ -146,7 +128,7 @@ void edituser(void)
 
        sprintf(buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
                who, pass, flags, timescalled, posted, axlevel, usernum,
-               lastcall, userpurge);
+               (long)lastcall, userpurge);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') {
@@ -161,15 +143,17 @@ int set_attr(int sval, char *prompt, unsigned int sbit)
        int temp;
 
        temp = sval;
-       color(3);
-       printf("%45s [", prompt);
-       color(1);
+       color(DIM_WHITE);
+       printf("%45s ", prompt);
+       color(DIM_MAGENTA);
+       printf("[");
+       color(BRIGHT_MAGENTA);
        printf("%3s", ((temp&sbit) ? "Yes":"No"));
-       color(3);
+       color(DIM_MAGENTA);
        printf("]? ");
-       color(2);
+       color(BRIGHT_CYAN);
        a=yesno_d(temp&sbit);
-       color(7);
+       color(DIM_WHITE);
        temp=(temp|sbit);
        if (!a) temp=(temp^sbit);
        return(temp);
@@ -181,7 +165,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");
@@ -195,6 +179,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)) {
 
@@ -222,6 +207,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) {
@@ -246,7 +234,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]);
@@ -282,7 +270,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);
@@ -298,25 +286,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;
@@ -435,7 +404,11 @@ void locate_host(char *hbuf)
        else strncpy(hbuf,buf,24);
 #else
        char *tty = ttyname(0);
+#ifdef HAVE_GETUTXLINE
+       struct utmpx ut, *put;
+#else
        struct utmp ut, *put;
+#endif
 
        if (tty == NULL) {
            fail:
@@ -448,17 +421,23 @@ void locate_host(char *hbuf)
 
        safestrncpy(ut.ut_line, &tty[5], sizeof ut.ut_line);
 
+#ifdef HAVE_GETUTXLINE /* Solaris uses this */
+       if ((put = getutxline(&ut)) == NULL)
+#else
        if ((put = getutline(&ut)) == NULL)
+#endif
                goto fail;
 
-#ifdef HAVE_UT_TYPE
+#if defined(HAVE_UT_TYPE) || defined(HAVE_GETUTXLINE)
        if (put->ut_type == USER_PROCESS) {
 #endif
+#if defined(HAVE_UT_HOST) || defined(HAVE_GETUTXLINE)
                if (*put->ut_host)
                        safestrncpy(hbuf, put->ut_host, 24);
                else
+#endif
                        safestrncpy(hbuf, put->ut_line, 24);
-#ifdef HAVE_UT_TYPE
+#if defined(HAVE_UT_TYPE) || defined(HAVE_GETUTXLINE)
                }
        else goto fail;
 #endif