]> code.citadel.org Git - citadel.git/blobdiff - citadel/routines.c
* added RCS Id keyword strings to sources
[citadel.git] / citadel / routines.c
index 2d47c6b6d30299de52fdfcd0bd255f4a4ff7aea3..9cb387ef1d2c348c9bfd0f0bd1809e3caac5e85a 100644 (file)
@@ -1,4 +1,5 @@
 /* Citadel/UX support routines */
+/* $Id$ */
 
 #include "sysdep.h"
 #include <stdlib.h>
 #define ROUTINES_C
 
 #include "citadel.h"
-
-char inkey();
-void sttybbs();
-void newprompt();
-void val_user();
-int intprompt();
-void formout();
-void logoff();
-void set_keepalives();
-void strprompt();
-void newprompt();
-void color();
+#include "routines.h"
+
+char inkey(void);
+void sttybbs(int cmd);
+void newprompt(char *prompt, char *str, int len);
+void val_user(char *user);
+int intprompt(char *prompt, int ival, int imin, int imax);
+void formout(char *name);
+void logoff(int code);
+void set_keepalives(int s);
+void strprompt(char *prompt, char *str, int len);
+void newprompt(char *prompt, char *str, int len);
+void color(int colornum);
 
 #define IFAIDE if(axlevel>=6)
 #define IFNAIDE if (axlevel<6)
@@ -37,12 +39,11 @@ void color();
 extern unsigned userflags;
 extern char *axdefs[7];
 extern char sigcaught;
-extern struct serv_info serv_info;
+extern struct CtdlServInfo serv_info;
 extern char rc_floor_mode;
 
-int struncmp(lstr,rstr,len)
-char lstr[],rstr[];
-int len; {
+int struncmp(char *lstr, char *rstr, int len)
+{
        int pos = 0;
        char lc,rc;
        while (pos<len) {
@@ -60,9 +61,8 @@ int len; {
 /* 
  * check for the presence of a character within a string (returns count)
  */
-int haschar(st,ch)
-char st[];
-int ch; {
+int haschar(char *st, int ch)
+{
        int a,b;
        b=0;
        for (a=0; a<strlen(st); ++a) if (st[a]==ch) ++b;
@@ -73,8 +73,8 @@ int ch; {
 /*
  * num_parms()  -  discover number of parameters...
  */
-int num_parms(source)
-char source[]; {
+int num_parms(char *source)
+{
        int a;
        int count = 1;
 
@@ -86,10 +86,8 @@ char source[]; {
 /*
  * extract()  -  extract a parameter from a series of "|" separated...
  */
-void extract(dest,source,parmnum)
-char dest[];
-char source[];
-int parmnum; {
+void extract(char *dest, char *source, int parmnum)
+{
        char buf[256];
        int count = 0;
        int n;
@@ -118,9 +116,8 @@ int parmnum; {
 /*
  * extract_int()  -  extract an int parm w/o supplying a buffer
  */
-int extract_int(source,parmnum)
-char *source;
-int parmnum; {
+int extract_int(char *source, int parmnum)
+{
        char buf[256];
        
        extract(buf,source,parmnum);
@@ -130,24 +127,23 @@ int parmnum; {
 /*
  * extract_long()  -  extract a long parm w/o supplying a buffer
  */
-long extract_long(source,parmnum)
-char *source;
-int parmnum; {
+long extract_long(char *source, int parmnum)
+{
        char buf[256];
        
        extract(buf,source,parmnum);
        return(atol(buf));
        }
 
-void back(spaces) /* Destructive backspace */
-int spaces; {
+void back(int spaces) /* Destructive backspace */
+            {
 int a;
        for (a=1; a<=spaces; ++a) {
                putc(8,stdout); putc(32,stdout); putc(8,stdout);
                }
        }
 
-int yesno() { /* Returns 1 for yes, 0 for no */
+int yesno(void) { /* Returns 1 for yes, 0 for no */
 int a;
        while (1) {
                a=inkey(); a=tolower(a);
@@ -156,8 +152,8 @@ int a;
                }
        }
 
-int yesno_d(d) /* Returns 1 for yes, 0 for no, arg is default value */
-int d; {
+int yesno_d(int d) /* Returns 1 for yes, 0 for no, arg is default value */
+       {
 int a;
        while (1) {
                a=inkey(); a=tolower(a);
@@ -168,7 +164,7 @@ int a;
        }
 
 
-void hit_any_key() {           /* hit any key to continue */
+void hit_any_key(void) {               /* hit any key to continue */
        int a,b;
 
        printf("%s\r",serv_info.serv_moreprompt);
@@ -185,8 +181,8 @@ void hit_any_key() {                /* hit any key to continue */
 /*
  * change a user's access level
  */
-void edituser(userbuf)
-struct usersupp *userbuf; {
+void edituser(void)
+{
        char who[256];
        char buf[256];
 
@@ -203,10 +199,8 @@ struct usersupp *userbuf; {
        }
 
 
-int set_attr(sval,prompt,sbit)
-int sval;
-char *prompt;
-unsigned sbit; {
+int set_attr(int sval, char *prompt, unsigned int sbit)
+{
        int a;
        int temp;
 
@@ -229,8 +223,8 @@ unsigned sbit; {
  * modes are:  0 - .EC command, 1 - .EC for new user,
  *             2 - toggle Xpert mode  3 - toggle floor mode
  */
-void enter_config(mode)
-int mode; {
+void enter_config(int mode)
+{
        int width,height,flags;
        char buf[128];
 
@@ -303,9 +297,8 @@ int mode; {
  * getstring()  -  get a line of text from a file
  *                ignores lines beginning with "#"
  */
-int getstring(fp,string)
-FILE *fp;              
-char string[]; {
+int getstring(FILE *fp, char *string)
+{
        int a,c;
        do {
                strcpy(string,"");
@@ -323,9 +316,9 @@ char string[]; {
        return(strlen(string));
        }
 
-int pattern(search,patn)       /* Searches for patn in search string */
-char search[];
-char patn[];
+int pattern(char *search, char *patn)  /* Searches for patn in search string */
+              
+            
 {
        int a,b;
        for (a=0; a<strlen(search); ++a)
@@ -335,8 +328,8 @@ char patn[];
        return(-1);
 }
 
-void interr(errnum)    /* display internal error as defined in errmsgs */
-int errnum; {
+void interr(int errnum)        /* display internal error as defined in errmsgs */
+            {
        printf("*** INTERNAL ERROR %d\n",errnum);
        printf("(Press any key to continue)\n");
        inkey();
@@ -351,9 +344,8 @@ int errnum; {
  * we are probably in the middle of a server operation and the NOOP command
  * would confuse everything.
  */
-int checkpagin(lp,pagin,height)
-int lp;
-int pagin; {
+int checkpagin(int lp, int pagin, int height)
+{
        if (pagin!=1) return(0);
        if (lp>=(height-1)) {
                set_keepalives(KA_NO);
@@ -365,8 +357,7 @@ int pagin; {
        }
 
 
-void strproc(string)
-char string[];
+void strproc(char *string)
 {
        int a;
 
@@ -403,124 +394,12 @@ char string[];
        }
 
 
-int hash(str)
-char str[]; {
-       int h = 0;
-       int i;
-
-       for (i=0; i<strlen(str); ++i) h=h+((i+1)*tolower(str[i]));
-       return(h);
-       }
-
-long finduser(file,name)
-int file;
-char *name; {
-       FILE *fp;
-       int uh,fh;
-       long pp=0L;
-       
-       uh=hash(name);
-       fp=fopen("hashtab","r");
-       while(fread((char *)&fh,sizeof(int),1,fp)>0) {
-               if (uh==fh) {
-                       lseek(file,pp,0);
-                       return(pp);
-                       }
-               pp = pp + (long)sizeof(struct usersupp);
-               }
-       fclose(fp);
-       return(-1L);
-       }
-
-
-int alias(name)                /* process alias and routing info for mail */
-char name[]; {
-       FILE *fp;
-       int a,b;
-       char aaa[300],bbb[300];
-       
-       fp=fopen("network/mail.aliases","r");
-       if (fp==NULL) return(2);
-GNA:   strcpy(aaa,""); strcpy(bbb,"");
-       do {
-               a=getc(fp);
-               if (a==',') a=0;
-               if (a>0) { b=strlen(aaa); aaa[b]=a; aaa[b+1]=0; }
-               } while(a>0);
-       do {
-               a=getc(fp);
-               if (a==10) a=0;
-               if (a>0) { b=strlen(bbb); bbb[b]=a; bbb[b+1]=0; }
-               } while(a>0);
-       if (a<0) {
-               fclose(fp);
-               goto DETYPE;
-               }
-       if (strucmp(name,aaa)) goto GNA;
-       fclose(fp);
-       strcpy(name,bbb);
-       printf("*** Mail is being forwarded to %s\n",name);
-
-DETYPE:        /* determine local or remote type, see citadel.h */
-       for (a=0; a<strlen(name); ++a) if (name[a]=='!') return(M_INTERNET);
-       for (a=0; a<strlen(name); ++a)
-               if (name[a]=='@')
-                       for (b=a; b<strlen(name); ++b)
-                               if (name[b]=='.') return(M_INTERNET);
-       b=0; for (a=0; a<strlen(name); ++a) if (name[a]=='@') ++b;
-       if (b>1) {
-               printf("Too many @'s in address\n");
-               return(M_ERROR);
-               }
-       if (b==1) {
-               for (a=0; a<strlen(name); ++a)
-                       if (name[a]=='@') strcpy(bbb,&name[a+1]);
-               while (bbb[0]==32) strcpy(bbb,&bbb[1]);
-               fp = fopen("network/mail.sysinfo","r");
-               if (fp==NULL) return(M_ERROR);
-GETSN:         do {
-                       a=getstring(fp,aaa);
-                       } while ((a>=0)&&(strucmp(aaa,bbb)));
-               a=getstring(fp,aaa);
-               if (!strncmp(aaa,"use ",4)) {
-                       strcpy(bbb,&aaa[4]);
-                       fseek(fp,0L,0);
-                       goto GETSN;
-                       }
-               fclose(fp);
-               if (!strncmp(aaa,"uum",3)) {
-                       strcpy(bbb,name);
-                       for (a=0; a<strlen(bbb); ++a) {
-                               if (bbb[a]=='@') bbb[a]=0;
-                               if (bbb[a]==' ') bbb[a]='_';
-                               }
-                       while(bbb[strlen(bbb)-1]=='_') bbb[strlen(bbb)-1]=0;
-                       sprintf(name,&aaa[4],bbb);
-                       return(M_INTERNET);
-                       }
-               if (!strncmp(aaa,"bin",3)) {
-                       strcpy(aaa,name); strcpy(bbb,name);
-                       while (aaa[strlen(aaa)-1]!='@') aaa[strlen(aaa)-1]=0;
-                       aaa[strlen(aaa)-1]=0;
-                       while (aaa[strlen(aaa)-1]==' ') aaa[strlen(aaa)-1]=0;
-                       while (bbb[0]!='@') strcpy(bbb,&bbb[1]);
-                       strcpy(bbb,&bbb[1]);
-                       while (bbb[0]==' ') strcpy(bbb,&bbb[1]);
-                       sprintf(name,"%s @%s",aaa,bbb);
-                       return(M_BINARY);
-                       }
-               return(M_ERROR);
-               }
-       return(M_LOCAL);
-       }
-
-
-#ifdef NO_STRERROR
+#ifndef HAVE_STRERROR
 /*
  * replacement strerror() for systems that don't have it
  */
-char *strerror(e)
-int e; {
+char *strerror(int e)
+{
        static char buf[32];
 
        sprintf(buf,"errno = %d",e);
@@ -529,9 +408,8 @@ int e; {
 #endif
 
 
-void progress(curr,cmax)
-long curr;
-long cmax; {
+void progress(long int curr, long int cmax)
+{
        static long dots_printed;
        long a;
 
@@ -560,8 +438,8 @@ long cmax; {
  * NOT the same locate_host() in locate_host.c.  This one just does a
  * 'who am i' to try to discover where the user is...
  */
-void locate_host(hbuf)
-char hbuf[]; {
+void locate_host(char *hbuf)
+{
        char buf[256];
        FILE *who;
        int a,b;
@@ -624,8 +502,8 @@ void misc_server_cmd(char *cmd) {
 /*
  * compute the checksum of a file
  */
-int file_checksum(filename)
-char *filename; {
+int file_checksum(char *filename)
+{
        int cksum = 0;
        int ch;
        FILE *fp;
@@ -647,8 +525,8 @@ char *filename; {
 /*
  * nuke a directory and its contents
  */
-int nukedir(dirname)
-char *dirname; {
+int nukedir(char *dirname)
+{
        DIR *dp;
        struct dirent *d;
        char filename[256];