Fix more warnings; output errors to the users.
[citadel.git] / citadel / textclient / routines2.c
index 89c0acf927560eddaa4c0933c2cd4e999a983b5d..caf7c9e17d097670224224dbe736b1cda4e7263c 100644 (file)
@@ -313,7 +313,6 @@ void upload(CtdlIPC *ipc, int c)
        int xfer_pid;
        int a, b;
        FILE *fp, *lsfp;
-       int r;
        int rv;
 
        if ((room_flags & QR_UPLOAD) == 0) {
@@ -342,6 +341,13 @@ void upload(CtdlIPC *ipc, int c)
        xfer_pid = fork();
        if (xfer_pid == 0) {
                rv = chdir(tempdir);
+               if (rv < 0) {
+                       scr_printf("failed to change into %s Reason %s\nAborting now.\n", 
+                                  tempdir, 
+                                  strerror(errno));
+                       nukedir(tempdir);
+                       return;
+               }
                switch (c) {
                case 0:
                        stty_ctdl(0);
@@ -360,17 +366,14 @@ void upload(CtdlIPC *ipc, int c)
                        fclose(fp);
                        exit(0);
                case 1:
-                       screen_reset();
                        stty_ctdl(3);
                        execlp("rx", "rx", flnm, NULL);
                        exit(1);
                case 2:
-                       screen_reset();
                        stty_ctdl(3);
                        execlp("rb", "rb", NULL);
                        exit(1);
                case 3:
-                       screen_reset();
                        stty_ctdl(3);
                        execlp("rz", "rz", NULL);
                        exit(1);
@@ -380,7 +383,6 @@ void upload(CtdlIPC *ipc, int c)
                        b = ka_wait(&a);
                } while ((b != xfer_pid) && (b != (-1)));
        stty_ctdl(0);
-       screen_set();
 
        if (a != 0) {
                scr_printf("\r*** Transfer unsuccessful.\n");
@@ -398,7 +400,7 @@ void upload(CtdlIPC *ipc, int c)
                                 flnm);
                        newprompt(buf, desc, 150);
                        snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
-                       r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
+                       CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
                        scr_printf("%s\n", tbuf);
                }
                pclose(lsfp);
@@ -515,7 +517,6 @@ void subshell(void)
 {
        int a, b;
 
-       screen_reset();
        stty_ctdl(SB_RESTORE);
        a = fork();
        if (a == 0) {
@@ -529,7 +530,6 @@ void subshell(void)
                b = ka_wait(NULL);
        } while ((a != b) && (a != (-1)));
        stty_ctdl(0);
-       screen_set();
 }
 
 /*
@@ -578,20 +578,20 @@ void list_bio(CtdlIPC *ipc)
 
        r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
        if (r / 100 != 1) {
-               pprintf("%s\n", buf);
+               scr_printf("%s\n", buf);
                return;
        }
        while (resp && !IsEmptyStr(resp)) {
                extract_token(buf, resp, 0, '\n', sizeof buf);
                remove_token(resp, 0, '\n');
                if ((pos + strlen(buf) + 5) > screenwidth) {
-                       pprintf("\n");
+                       scr_printf("\n");
                        pos = 1;
                }
-               pprintf("%s, ", buf);
+               scr_printf("%s, ", buf);
                pos = pos + strlen(buf) + 2;
        }
-       pprintf("%c%c  \n\n", 8, 8);
+       scr_printf("%c%c  \n\n", 8, 8);
        if (resp) free(resp);
 }
 
@@ -608,20 +608,20 @@ void read_bio(CtdlIPC *ipc)
 
        do {
                newprompt("Read bio for who ('?' for list) : ", who, 25);
-               pprintf("\n");
+               scr_printf("\n");
                if (!strcmp(who, "?"))
                        list_bio(ipc);
        } while (!strcmp(who, "?"));
 
        r = CtdlIPCGetBio(ipc, who, &resp, buf);
        if (r / 100 != 1) {
-               pprintf("%s\n", buf);
+               scr_printf("%s\n", buf);
                return;
        }
        while (!IsEmptyStr(resp)) {
                extract_token(buf, resp, 0, '\n', sizeof buf);
                remove_token(resp, 0, '\n');
-               pprintf("%s\n", buf);
+               scr_printf("%s\n", buf);
        }
        if (resp) free(resp);
 }