X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Ftextclient%2Froutines2.c;h=caf7c9e17d097670224224dbe736b1cda4e7263c;hb=686a8267f3ad753143303673e21dfed5cb314447;hp=3aab13d830ec30e7a2e07ac5e99ab1613b930a19;hpb=6106c1da54f0923550c7bdceb45246fb88e9ea19;p=citadel.git diff --git a/citadel/textclient/routines2.c b/citadel/textclient/routines2.c index 3aab13d83..caf7c9e17 100644 --- a/citadel/textclient/routines2.c +++ b/citadel/textclient/routines2.c @@ -62,7 +62,7 @@ int eopen(char *name, int mode) int ret; ret = open(name, mode); if (ret < 0) { - err_printf("Cannot open file '%s', mode=%d, errno=%d\n", + scr_printf("Cannot open file '%s', mode=%d, errno=%d\n", name, mode, errno); interr(errno); } @@ -287,15 +287,15 @@ void cli_image_upload(CtdlIPC *ipc, char *keyname) /* Can we upload this image? */ r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf); if (r / 100 != 2) { - err_printf("%s\n", buf); + scr_printf("%s\n", buf); return; } newprompt("Image file to be uploaded: ", flnm, 55); r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf); if (r / 100 == 5) { - err_printf("%s\n", buf); + scr_printf("%s\n", buf); } else if (r < 0) { - err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno)); + scr_printf("Cannot upload '%s': %s\n", flnm, strerror(errno)); } /* else upload succeeded */ } @@ -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,21 +517,19 @@ void subshell(void) { int a, b; - screen_reset(); stty_ctdl(SB_RESTORE); a = fork(); if (a == 0) { signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); execlp(getenv("SHELL"), getenv("SHELL"), NULL); - err_printf("Could not open a shell: %s\n", strerror(errno)); + scr_printf("Could not open a shell: %s\n", strerror(errno)); exit(errno); } do { b = ka_wait(NULL); } while ((a != b) && (a != (-1))); stty_ctdl(0); - screen_set(); } /* @@ -544,7 +544,7 @@ void deletefile(CtdlIPC *ipc) if (IsEmptyStr(filename)) return; CtdlIPCDeleteFile(ipc, filename, buf); - err_printf("%s\n", buf); + scr_printf("%s\n", buf); } @@ -562,7 +562,7 @@ void movefile(CtdlIPC *ipc) return; newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1); CtdlIPCMoveFile(ipc, filename, newroom, buf); - err_printf("%s\n", buf); + scr_printf("%s\n", buf); } @@ -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); }