]> code.citadel.org Git - citadel.git/blobdiff - citadel/rooms.c
* The size constant "256" which shows up everywhere as a buffer size has now
[citadel.git] / citadel / rooms.c
index dd17496890ffb5e3f2c404666742f17c549f722e..3e276edc2bd42010752dc3b134a4ce9bb4e06e51 100644 (file)
@@ -1,5 +1,10 @@
-/* Citadel/UX room-oriented routines */
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * 
+ * Client-side functions which perform room operations
+ *
+ */
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -31,7 +36,6 @@ void hit_any_key(void);
 int yesno(void);
 void strprompt(char *prompt, char *str, int len);
 void newprompt(char *prompt, char *str, int len);
-int struncmp(char *lstr, char *rstr, int len);
 void dotgoto(char *towhere, int display_name);
 void serv_read(char *buf, int bytes);
 void formout(char *name);
@@ -41,7 +45,6 @@ void progress(long int curr, long int cmax);
 int pattern(char *search, char *patn);
 int file_checksum(char *filename);
 int nukedir(char *dirname);
-int checkpagin(int lp, int pagin, int height); 
 
 extern unsigned room_flags;
 extern char room_name[];
@@ -62,14 +65,12 @@ extern int ugnum;
 extern long uglsn;
 extern char ugname[];
 
-extern char floorlist[128][256];
-
-int knlinecount;
+extern char floorlist[128][SIZ];
 
 
 void load_floorlist(void) {
        int a;
-       char buf[256];
+       char buf[SIZ];
 
        for (a=0; a<128; ++a) floorlist[a][0] = 0;
 
@@ -105,12 +106,7 @@ void room_tree_list(struct roomlisting *rp) {
                if ((c + strlen(rmname) + 4) > screenwidth) {
 
                        /* line break, check the paginator */
-                       printf("\n");
-                       knlinecount = knlinecount + 1;
-                       knlinecount = checkpagin(knlinecount,
-                                   ((userflags & US_PAGINATOR) ? 1 : 0),
-                                              screenheight);
-
+                       pprintf("\n");
                        c = 1;
                        }
                        if (f & QR_MAILBOX) {
@@ -122,11 +118,11 @@ void room_tree_list(struct roomlisting *rp) {
                else {
                        color(DIM_WHITE);
                        }
-               printf("%s",rmname);
-               if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) printf("}  ");
-               else if (f & QR_DIRECTORY) printf("]  ");
-               else if (f & QR_NETWORK) printf(")  ");
-               else printf(">  ");
+               pprintf("%s",rmname);
+               if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) pprintf("}  ");
+               else if (f & QR_DIRECTORY) pprintf("]  ");
+               else if (f & QR_NETWORK) pprintf(")  ");
+               else pprintf(">  ");
                c = c + strlen(rmname) + 3;
                }
 
@@ -159,7 +155,7 @@ int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
  */
 void listrms(char *variety)
 {
-       char buf[256];
+       char buf[SIZ];
 
        struct roomlisting *rl = NULL;
        struct roomlisting *rp;
@@ -205,13 +201,10 @@ void listrms(char *variety)
                        }
                }
 
-       sigcaught = 0;
-       sttybbs(SB_YES_INTR);
        room_tree_list(NULL);
        room_tree_list(rl);
        color(DIM_WHITE);
-       sttybbs(SB_NO_INTR);
-       }
+}
 
 
 void list_other_floors(void) {
@@ -220,10 +213,10 @@ void list_other_floors(void) {
        c = 1;
        for (a=0; a<128; ++a) if ((strlen(floorlist[a])>0)&&(a!=curr_floor)) {
                if ((c + strlen(floorlist[a]) + 4) > screenwidth) {
-                       printf("\n");
+                       pprintf("\n");
                        c = 1;
                        }
-               printf("%s:  ",floorlist[a]);
+               pprintf("%s:  ",floorlist[a]);
                c = c + strlen(floorlist[a]) + 3;
                }
        }
@@ -235,55 +228,45 @@ void list_other_floors(void) {
  */
 void knrooms(int kn_floor_mode)
 {
-       char buf[256];
+       char buf[SIZ];
        int a;
 
        load_floorlist();
-       knlinecount = 0;
 
        if (kn_floor_mode == 0) {
                color(BRIGHT_CYAN);
-               printf("\n   Rooms with unread messages:\n");
-               knlinecount = knlinecount + 2;
+               pprintf("\n   Rooms with unread messages:\n");
                listrms("LKRN");
                color(BRIGHT_CYAN);
-               printf("\n\n   No unseen messages in:\n");
-               knlinecount = knlinecount + 3;
+               pprintf("\n\n   No unseen messages in:\n");
                listrms("LKRO");
-               printf("\n");
-               knlinecount = knlinecount + 1;
+               pprintf("\n");
                }
 
        if (kn_floor_mode == 1) {
                color(BRIGHT_CYAN);
-               printf("\n   Rooms with unread messages on %s:\n",
+               pprintf("\n   Rooms with unread messages on %s:\n",
                        floorlist[(int)curr_floor]);
-               knlinecount = knlinecount + 2;
-               sprintf(buf,"LKRN %d",curr_floor);
+               sprintf(buf,"LKRN %d", curr_floor);
                listrms(buf);
                color(BRIGHT_CYAN);
-               printf("\n\n   Rooms with no new messages on %s:\n",
+               pprintf("\n\n   Rooms with no new messages on %s:\n",
                        floorlist[(int)curr_floor]);
-               knlinecount = knlinecount + 3;
                sprintf(buf,"LKRO %d",curr_floor);
                listrms(buf);
                color(BRIGHT_CYAN);
-               printf("\n\n   Other floors:\n");
-               knlinecount = knlinecount + 3;
+               pprintf("\n\n   Other floors:\n");
                list_other_floors();
-               printf("\n");
-               knlinecount = knlinecount + 1;
+               pprintf("\n");
                }
 
        if (kn_floor_mode == 2) {
                for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
                        color(BRIGHT_CYAN);
-                       printf("\n   Rooms on %s:\n",floorlist[a]);
-                       knlinecount = knlinecount + 2;
+                       pprintf("\n   Rooms on %s:\n",floorlist[a]);
                        sprintf(buf,"LKRA %d",a);
                        listrms(buf);
-                       printf("\n");
-                       knlinecount = knlinecount + 1;
+                       pprintf("\n");
                        }
                }
        
@@ -294,9 +277,9 @@ void knrooms(int kn_floor_mode)
 
 void listzrooms(void) {                /* list public forgotten rooms */
        color(BRIGHT_CYAN);
-       printf("\n   Forgotten public rooms:\n");
+       pprintf("\n   Forgotten public rooms:\n");
        listrms("LZRM");
-       printf("\n");
+       pprintf("\n");
        color(DIM_WHITE);
        IFNEXPERT hit_any_key();
        }
@@ -322,7 +305,7 @@ int set_room_attr(int ibuf, char *prompt, unsigned int sbit)
 int select_floor(int rfloor)
 {
        int a, newfloor;
-       char floorstr[256];
+       char floorstr[SIZ];
 
        if (floor_mode == 1) {
                if (floorlist[(int)curr_floor][0]==0) load_floorlist();
@@ -330,11 +313,11 @@ int select_floor(int rfloor)
                do {
                        newfloor = (-1);
                        safestrncpy(floorstr,floorlist[rfloor],sizeof floorstr);
-                       strprompt("Which floor",floorstr,256);
+                       strprompt("Which floor",floorstr,SIZ);
                        for (a=0; a<128; ++a) {
-                               if (!strucmp(floorstr,&floorlist[a][0]))
+                               if (!strcasecmp(floorstr,&floorlist[a][0]))
                                        newfloor = a;
-                               if ((newfloor<0)&&(!struncmp(floorstr,
+                               if ((newfloor<0)&&(!strncasecmp(floorstr,
                                        &floorlist[a][0],strlen(floorstr))))
                                                newfloor = a;
                                if ((newfloor<0)&&(pattern(&floorlist[a][0],
@@ -366,7 +349,7 @@ void editthisroom(void) {
        unsigned rflags;
        int rbump;
        char raide[32];
-       char buf[256];
+       char buf[SIZ];
        int rfloor;
        int rorder;
        int expire_mode = 0;
@@ -459,7 +442,7 @@ void editthisroom(void) {
        /* Ask about the room aide */
        do {
                strprompt("Room aide (or 'none')",raide,29);
-               if (!strucmp(raide,"none")) {
+               if (!strcasecmp(raide,"none")) {
                        strcpy(raide,"");
                        strcpy(buf,"200");
                        }
@@ -471,7 +454,7 @@ void editthisroom(void) {
                        }
                } while(buf[0]!='2');
 
-       if (!strucmp(raide,"none")) strcpy(raide,"");
+       if (!strcasecmp(raide,"none")) strcpy(raide,"");
 
 
        /* Angels and demons dancing in my head... */
@@ -529,7 +512,7 @@ void editthisroom(void) {
  * un-goto the previous room
  */
 void ungoto(void) { 
-       char buf[256];
+       char buf[SIZ];
        
        if (!strcmp(ugname,"")) return;
        snprintf(buf,sizeof buf,"GOTO %s",ugname);
@@ -556,14 +539,14 @@ void ungoto(void) {
  */
 void download_to_local_disk(char *supplied_filename, long total_bytes)
 {
-       char buf[256];
+       char buf[SIZ];
        char dbuf[4096];
        long transmitted_bytes = 0L;
        long aa,bb;
        FILE *savefp;
        int broken = 0;
        int packet;
-       char filename[256];
+       char filename[SIZ];
 
        strcpy(filename, supplied_filename);
        if (strlen(filename)==0) {
@@ -573,7 +556,7 @@ void download_to_local_disk(char *supplied_filename, long total_bytes)
        printf("Enter the name of the directory to save '%s'\n",
                filename);
        printf("to, or press return for the current directory.\n");
-       newprompt("Directory: ",dbuf,256);
+       newprompt("Directory: ", dbuf, sizeof dbuf);
        if (strlen(dbuf)==0) strcpy(dbuf,".");
        strcat(dbuf,"/");
        strcat(dbuf,filename);
@@ -624,10 +607,10 @@ void download_to_local_disk(char *supplied_filename, long total_bytes)
  */
 void download(int proto)
 {
-       char buf[256];
-       char filename[256];
-       char tempname[256];
-       char transmit_cmd[256];
+       char buf[SIZ];
+       char filename[SIZ];
+       char tempname[SIZ];
+       char transmit_cmd[SIZ];
        long total_bytes = 0L;
        char dbuf[4096];
        long transmitted_bytes = 0L;
@@ -708,10 +691,10 @@ void download(int proto)
  * read directory of this room
  */
 void roomdir(void) {
-       char flnm[256];
+       char flnm[SIZ];
        char flsz[32];
-       char comment[256];
-       char buf[256];
+       char comment[SIZ];
+       char buf[SIZ];
 
        serv_puts("RDIR");
        serv_gets(buf);
@@ -740,7 +723,7 @@ void roomdir(void) {
  * add a user to a private room
  */
 void invite(void) {
-       char aaa[31],bbb[256];
+       char aaa[31],bbb[SIZ];
 
        if ((room_flags & QR_PRIVATE)==0) {
                printf("This is not a private room.\n");
@@ -761,7 +744,7 @@ void invite(void) {
  * kick a user out of a room
  */
 void kickout(void) {
-       char aaa[31],bbb[256];
+       char aaa[31],bbb[SIZ];
 
        newprompt("Name of user? ",aaa,30);
        if (aaa[0]==0) return;
@@ -797,7 +780,7 @@ void killroom(void) {
        }
 
 void forget(void) {    /* forget the current room */
-       char cmd[256];
+       char cmd[SIZ];
 
        printf("Are you sure you want to forget this room? ");
        if (yesno()==0) return;
@@ -818,7 +801,7 @@ void forget(void) { /* forget the current room */
  * create a new room
  */
 void entroom(void) {
-       char cmd[256];
+       char cmd[SIZ];
        char new_room_name[ROOMNAMELEN];
        int new_room_type;
        char new_room_pass[10];
@@ -890,7 +873,7 @@ void entroom(void) {
 
 
 void readinfo(void) {  /* read info file for current room */
-       char cmd[256];
+       char cmd[SIZ];
        
        sprintf(cmd,"RINF");
        serv_puts(cmd);
@@ -908,26 +891,23 @@ void readinfo(void) {     /* read info file for current room */
  * <W>ho knows room...
  */
 void whoknows(void) {
-       char buf[256];
+       char buf[SIZ];
        serv_puts("WHOK");
        serv_gets(buf);
        if (buf[0]!='1') {
-               printf("%s\n",&buf[5]);
+               pprintf("%s\n",&buf[5]);
                return;
-               }
-       sigcaught = 0;
-       sttybbs(SB_YES_INTR);
+       }
        while (serv_gets(buf), strncmp(buf,"000",3)) {
-               if (sigcaught==0) printf("%s\n",buf);
-               }
-       sttybbs(SB_NO_INTR);
+               if (sigcaught==0) pprintf("%s\n",buf);
        }
+}
 
 
 void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
 {
        FILE *fp;
-       char cmd[256];
+       char cmd[SIZ];
        int b,cksum,editor_exit;
 
 
@@ -1014,7 +994,7 @@ void enterinfo(void) {             /* edit info file for current room */
        }
 
 void enter_bio(void) {
-       char cmd[256];
+       char cmd[SIZ];
        snprintf(cmd,sizeof cmd,"RBIO %s",fullname);
        do_edit("your Bio",cmd,"NOOP","EBIO");
        }
@@ -1023,8 +1003,8 @@ void enter_bio(void) {
  * create a new floor
  */
 void create_floor(void) {
-       char buf[256];
-       char newfloorname[256];
+       char buf[SIZ];
+       char newfloorname[SIZ];
 
        serv_puts("CFLR xx|0");
        serv_gets(buf);
@@ -1049,7 +1029,7 @@ void create_floor(void) {
  * edit the current floor
  */
 void edit_floor(void) {
-       char buf[256];
+       char buf[SIZ];
        int expire_mode = 0;
        int expire_value = 0;
 
@@ -1118,7 +1098,7 @@ void edit_floor(void) {
  */
 void kill_floor(void) {
        int floornum_to_delete,a;
-       char buf[256];
+       char buf[SIZ];
 
        if (floorlist[(int)curr_floor][0]==0) load_floorlist();
        do {
@@ -1127,7 +1107,7 @@ void kill_floor(void) {
                newprompt("Delete which floor? ",buf,255);
                if (strlen(buf)==0) return;
                for (a=0; a<128; ++a)
-                       if (!strucmp(&floorlist[a][0],buf))
+                       if (!strcasecmp(&floorlist[a][0],buf))
                                floornum_to_delete = a;
                if (floornum_to_delete < 0) {
                        printf("No such floor.  Select one of:\n");