Fix more warnings; output errors to the users.
[citadel.git] / citadel / textclient / rooms.c
index 34f1fea19a2f30029af5432af09d5be0d7955455..f88d82b34cfe433c7692ec5ccc414106afb99c92 100644 (file)
@@ -121,7 +121,7 @@ void room_tree_list(struct ctdlroomlisting *rp)
                if ((c + strlen(rmname) + 4) > screenwidth) {
 
                        /* line break, check the paginator */
-                       pprintf("\n");
+                       scr_printf("\n");
                        c = 1;
                }
                if (f & QR_MAILBOX) {
@@ -131,15 +131,15 @@ void room_tree_list(struct ctdlroomlisting *rp)
                } else {
                        color(DIM_WHITE);
                }
-               pprintf("%s", rmname);
+               scr_printf("%s", rmname);
                if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
-                       pprintf("}  ");
+                       scr_printf("}  ");
                else if (f & QR_DIRECTORY)
-                       pprintf("]  ");
+                       scr_printf("]  ");
                else if (f & QR_NETWORK)
-                       pprintf(")  ");
+                       scr_printf(")  ");
                else
-                       pprintf(">  ");
+                       scr_printf(">  ");
                c = c + strlen(rmname) + 3;
        }
 
@@ -254,10 +254,10 @@ void list_other_floors(void)
        for (a = 0; a < 128; ++a) {
                if ((strlen(floorlist[a]) > 0) && (a != curr_floor)) {
                        if ((c + strlen(floorlist[a]) + 4) > screenwidth) {
-                               pprintf("\n");
+                               scr_printf("\n");
                                c = 1;
                        }
-                       pprintf("%s:  ", floorlist[a]);
+                       scr_printf("%s:  ", floorlist[a]);
                        c = c + strlen(floorlist[a]) + 3;
                }
        }
@@ -288,37 +288,37 @@ void knrooms(CtdlIPC *ipc, int kn_floor_mode)
 
        if (kn_floor_mode == 0) {
                color(BRIGHT_CYAN);
-               pprintf("\n   Rooms with unread messages:\n");
+               scr_printf("\n   Rooms with unread messages:\n");
                listrms(listing, LISTRMS_NEW_ONLY, -1, 0, NULL);
                color(BRIGHT_CYAN);
-               pprintf("\n\n   No unseen messages in:\n");
+               scr_printf("\n\n   No unseen messages in:\n");
                listrms(listing, LISTRMS_OLD_ONLY, -1, 0, NULL);
-               pprintf("\n");
+               scr_printf("\n");
        }
 
        if (kn_floor_mode == 1) {
                color(BRIGHT_CYAN);
-               pprintf("\n   Rooms with unread messages on %s:\n",
+               scr_printf("\n   Rooms with unread messages on %s:\n",
                        floorlist[(int) curr_floor]);
                listrms(listing, LISTRMS_NEW_ONLY, curr_floor, 0, NULL);
                color(BRIGHT_CYAN);
-               pprintf("\n\n   Rooms with no new messages on %s:\n",
+               scr_printf("\n\n   Rooms with no new messages on %s:\n",
                        floorlist[(int) curr_floor]);
                listrms(listing, LISTRMS_OLD_ONLY, curr_floor, 0, NULL);
                color(BRIGHT_CYAN);
-               pprintf("\n\n   Other floors:\n");
+               scr_printf("\n\n   Other floors:\n");
                list_other_floors();
-               pprintf("\n");
+               scr_printf("\n");
        }
 
        if (kn_floor_mode == 2) {
                for (a = 0; a < 128; ++a) {
                        if (floorlist[a][0] != 0) {
                                color(BRIGHT_CYAN);
-                               pprintf("\n   Rooms on %s:\n",
+                               scr_printf("\n   Rooms on %s:\n",
                                        floorlist[a]);
                                listrms(listing, LISTRMS_ALL, a, 0, NULL);
-                               pprintf("\n");
+                               scr_printf("\n");
                        }
                }
        }
@@ -331,7 +331,6 @@ void knrooms(CtdlIPC *ipc, int kn_floor_mode)
        };
 
        color(DIM_WHITE);
-       IFNEXPERT hit_any_key(ipc);
 }
 
 
@@ -350,9 +349,9 @@ void listzrooms(CtdlIPC *ipc)
        }
 
        color(BRIGHT_CYAN);
-       pprintf("\n   Forgotten public rooms:\n");
+       scr_printf("\n   Forgotten public rooms:\n");
        listrms(listing, LISTRMS_ALL, -1, 0, NULL);
-       pprintf("\n");
+       scr_printf("\n");
 
        /* Free the room list */
        while (listing) {
@@ -362,7 +361,6 @@ void listzrooms(CtdlIPC *ipc)
        };
 
        color(DIM_WHITE);
-       IFNEXPERT hit_any_key(ipc);
 }
 
 void dotknown(CtdlIPC *ipc, int what, char *match)
@@ -382,39 +380,39 @@ void dotknown(CtdlIPC *ipc, int what, char *match)
 
        switch (what) {
     case 0:
-       pprintf("\n   Anonymous rooms:\n");
+       scr_printf("\n   Anonymous rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_ANONONLY|QR_ANONOPT, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 1:
-       pprintf("\n   Directory rooms:\n");
+       scr_printf("\n   Directory rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_DIRECTORY, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 2:
-       pprintf("\n   Matching \"%s\" rooms:\n", match);
+       scr_printf("\n   Matching \"%s\" rooms:\n", match);
            listrms(listing, LISTRMS_ALL, -1, 0, match);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 3:
-       pprintf("\n   Preferred only rooms:\n");
+       scr_printf("\n   Preferred only rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_PREFONLY, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 4:
-       pprintf("\n   Private rooms:\n");
+       scr_printf("\n   Private rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_PRIVATE, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 5:
-       pprintf("\n   Read only rooms:\n");
+       scr_printf("\n   Read only rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_READONLY, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
     case 6:
-       pprintf("\n   Shared rooms:\n");
+       scr_printf("\n   Shared rooms:\n");
            listrms(listing, LISTRMS_ALL, -1, QR_NETWORK, NULL);
-       pprintf("\n");
+       scr_printf("\n");
                break;
        }
 
@@ -426,7 +424,6 @@ void dotknown(CtdlIPC *ipc, int what, char *match)
        };
 
        color(DIM_WHITE);
-       IFNEXPERT hit_any_key(ipc);
 }
 
 
@@ -855,7 +852,7 @@ void download(CtdlIPC *ipc, int proto)
        char tempname[PATH_MAX];
        char transmit_cmd[SIZ];
        FILE *tpipe = NULL;
-       int broken = 0;
+/*     int broken = 0;*/
        int r;
        int rv = 0;
        void *file = NULL;      /* The downloaded file */
@@ -894,8 +891,8 @@ void download(CtdlIPC *ipc, int proto)
        snprintf(tempname, sizeof tempname, "%s/%s", tempdir, filename);
        tpipe = fopen(tempname, "wb");
        if (fwrite(file, filelen, 1, tpipe) < filelen) {
-               /* FIXME: restart syscall on EINTR */
-               broken = 1;
+               /* FIXME: restart syscall on EINTR 
+                  broken = 1;*/
        }
        fclose(tpipe);
        if (file) free(file);
@@ -916,11 +913,11 @@ void download(CtdlIPC *ipc, int proto)
                /* FIXME: display internally instead */
                snprintf(transmit_cmd, sizeof transmit_cmd, "exec cat %s", tempname);
 
-       screen_reset();
        stty_ctdl(SB_RESTORE);
        rv = system(transmit_cmd);
+       if (rv != 0)
+               scr_printf("failed to download '%s': %d\n", transmit_cmd, rv);
        stty_ctdl(SB_NO_INTR);
-       screen_set();
 
        /* clean up the temporary directory */
        nukedir(tempdir);
@@ -943,14 +940,14 @@ void roomdir(CtdlIPC *ipc)
 
        r = CtdlIPCReadDirectory(ipc, &listing, buf);
        if (r / 100 != 1) {
-               pprintf("%s\n", buf);
+               scr_printf("%s\n", buf);
                return;
        }
 
        extract_token(comment, buf, 0, '|', sizeof comment);
        extract_token(flnm, buf, 1, '|', sizeof flnm);
-       pprintf("\nDirectory of %s on %s\n", flnm, comment);
-       pprintf("-----------------------\n");
+       scr_printf("\nDirectory of %s on %s\n", flnm, comment);
+       scr_printf("-----------------------\n");
        while (listing && *listing && !IsEmptyStr(listing)) {
                extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
@@ -960,9 +957,9 @@ void roomdir(CtdlIPC *ipc)
                extract_token(mimetype, buf, 2, '|', sizeof mimetype);
                extract_token(comment, buf, 3, '|', sizeof comment);
                if (strlen(flnm) <= 14)
-                       pprintf("%-14s %8s %s [%s]\n", flnm, flsz, comment, mimetype);
+                       scr_printf("%-14s %8s %s [%s]\n", flnm, flsz, comment, mimetype);
                else
-                       pprintf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz,
+                       scr_printf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz,
                                comment, mimetype);
        }
        if (listing) free(listing);
@@ -976,13 +973,12 @@ void invite(CtdlIPC *ipc)
 {
        char username[USERNAME_SIZE];
        char buf[SIZ];
-       int r;                          /* IPC response code */
 
        newprompt("Name of user? ", username, USERNAME_SIZE);
        if (username[0] == 0)
                return;
 
-       r = CtdlIPCInviteUserToRoom(ipc, username, buf);
+       CtdlIPCInviteUserToRoom(ipc, username, buf);
        scr_printf("%s\n", buf);
 }
 
@@ -994,13 +990,12 @@ void kickout(CtdlIPC *ipc)
 {
        char username[USERNAME_SIZE];
        char buf[SIZ];
-       int r;                          /* IPC response code */
 
        newprompt("Name of user? ", username, USERNAME_SIZE);
        if (username[0] == 0)
                return;
 
-       r = CtdlIPCKickoutUserFromRoom(ipc, username, buf);
+       CtdlIPCKickoutUserFromRoom(ipc, username, buf);
        scr_printf("%s\n", buf);
 }
 
@@ -1162,9 +1157,7 @@ void readinfo(CtdlIPC *ipc)
                return;
 
        if (text) {
-               fmout(screenwidth, NULL, text, NULL,
-                     ((userflags & US_PAGINATOR) ? 1 : 0), screenheight, 
-                     (*raide) ? 2 : 0, 1);
+               fmout(screenwidth, NULL, text, NULL, 1);
                free(text);
        }
 }
@@ -1181,14 +1174,14 @@ void whoknows(CtdlIPC *ipc)
 
        r = CtdlIPCWhoKnowsRoom(ipc, &listing, buf);
        if (r / 100 != 1) {
-               pprintf("%s\n", buf);
+               scr_printf("%s\n", buf);
                return;
        }
        while (!IsEmptyStr(listing)) {
                extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
                if (sigcaught == 0)
-                       pprintf("%s\n", buf);
+                       scr_printf("%s\n", buf);
        }
        free(listing);
 }
@@ -1236,7 +1229,6 @@ void do_edit(CtdlIPC *ipc,
 
                snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc);
                putenv(tmp);
-               screen_reset();
                stty_ctdl(SB_RESTORE);
                editor_pid = fork();
                if (editor_pid == 0) {
@@ -1252,7 +1244,6 @@ void do_edit(CtdlIPC *ipc,
                editor_pid = (-1);
                scr_printf("Executed %s\n", editor_paths[0]);
                stty_ctdl(0);
-               screen_set();
        } else {
                scr_printf("Entering %s.  Press return twice when finished.\n", desc);
                fp = fopen(temp, "r+");
@@ -1333,14 +1324,13 @@ void edit_floor(CtdlIPC *ipc)
 {
        char buf[SIZ];
        struct ExpirePolicy *ep = NULL;
-       int r;                          /* IPC response code */
 
        load_floorlist(ipc);
 
        /* Fetch the expire policy (this will silently fail on old servers,
         * resulting in "default" policy)
         */
-       r = CtdlIPCGetMessageExpirationPolicy(ipc, 1, &ep, buf);
+       CtdlIPCGetMessageExpirationPolicy(ipc, 1, &ep, buf);
 
        /* Interact with the user */
        scr_printf("You are editing the floor called \"%s\"\n", 
@@ -1377,8 +1367,8 @@ void edit_floor(CtdlIPC *ipc)
        }
 
        /* Save it */
-       r = CtdlIPCSetMessageExpirationPolicy(ipc, 1, ep, buf);
-       r = CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int)curr_floor][0], buf);
+       CtdlIPCSetMessageExpirationPolicy(ipc, 1, ep, buf);
+       CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int)curr_floor][0], buf);
        scr_printf("%s\n", buf);
        load_floorlist(ipc);
 }