tv.tv_usec = 0;
retval = select(1, &rfds, NULL, NULL, &tv);
+ if (retval < 0) {
+ color(BRIGHT_WHITE);
+ scr_printf("Server gone Exiting chat mode\n");
+ scr_flush();
+ return;
+ }
+
/* If there's data from the keyboard... */
if (FD_ISSET(0, &rfds)) {
ch = scr_getc(SCR_BLOCK);
* in the middle of a data transfer from the server, in which case
* sending a NOOP would throw the client protocol out of sync.
*/
- if (FD_ISSET(0, &rfds)) {
+ if ((retval > 0) && FD_ISSET(0, &rfds)) {
set_keepalives(KA_NO);
the_character = inkey();
set_keepalives(KA_YES);
static time_t idlet = 0;
static void really_do_keepalive(void) {
- int r; /* IPC response code */
time(&idlet);
* wait for a response.
*/
if (keepalives_enabled == KA_YES) {
- r = CtdlIPCNoop(ipc_for_signal_handlers);
+ CtdlIPCNoop(ipc_for_signal_handlers);
if (instant_msgs > 0) {
if (ok_to_interrupt == 1) {
scr_printf("\r%64s\r", "");
if (FD_ISSET(0, &rfds)) {
abuf[strlen(abuf) + 1] = 0;
rv = read(0, &abuf[strlen(abuf)], 1);
+ if (rv < 0) {
+ scr_printf("failed to read after select: %s",
+ strerror(errno));
+ break;
+ }
}
} while (FD_ISSET(0, &rfds));
putc(10, fp);
fflush(fp);
rv = ftruncate(fileno(fp), ftell(fp));
+ if (rv < 0)
+ scr_printf("failed to set message buffer: %s\n", strerror(errno));
+
/* and deallocate the memory we used */
while (textlist != NULL) {
ptr = textlist->next;
rpos = ftell(fp);
fseek(fp, wpos, 0);
rv = fwrite((char *) buf, 128, 1, fp);
+ if (rv < 0) {
+ scr_printf("failed to replace string: %s\n", strerror(errno));
+ break; /*whoopsi! */
+ }
strcpy(buf, &buf[128]);
wpos = ftell(fp);
fseek(fp, rpos, 0);
newprompt("Subject: ", subject, 70);
}
- beg = 0L;
-
if (mode == 1) {
scr_printf("(Press ctrl-d when finished)\n");
}
if (fp != NULL) {
fmout(screenwidth, fp, NULL, NULL, 0);
beg = ftell(fp);
+ if (beg < 0)
+ scr_printf("failed to get stream position %s\n",
+ strerror(errno));
fclose(fp);
} else {
fp = fopen(filename, "w");
fp = fopen(filename, "r");
if (fp != NULL) {
fmout(screenwidth, fp, NULL, NULL, 0);
+ /* TODO: why ftell if we ignore the result? */
beg = ftell(fp);
+ if (beg < 0)
+ scr_printf("failed to get stream position %s\n",
+ strerror(errno));
fclose(fp);
}
goto MECR;
snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
rv = system(cmd);
+ if (rv != 0)
+ scr_printf("failed to '%s' by %d\n", cmd, rv);
scr_printf("\n");
}
enum MessageDirection rdir, /* 1=Forward (-1)=Reverse */
int q /* Number of msgs to read (if c==3) */
) {
- int a, b, e, f, g, start;
+ int a, e, f, g, start;
int savedpos;
int hold_sw = 0;
char arcflag = 0;
static int att_seq = 0; /* Attachment download sequence number */
int rv = 0; /* silence the stupid warn_unused_result warnings */
- if (c < 0)
- b = (num_msgs - 1);
- else
- b = 0;
-
CtdlMakeTempFileName(prtfile, sizeof prtfile);
if (msg_arr) {
save_buffer(attachment, extract_unsigned_long(cmd, 0), save_to);
snprintf(cmd, sizeof cmd, rc_open_cmd, save_to);
rv = system(cmd);
+ if (rv != 0)
+ scr_printf("failed to save %s Reason %d\n", cmd, rv);
}
else { /* save attachment to disk */
destination_directory(save_to, filename);
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 */
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);
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);
/* clean up the temporary directory */
{
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);
}
{
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);
}
{
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",
}
/* 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);
}
int xfer_pid;
int a, b;
FILE *fp, *lsfp;
- int r;
int rv;
if ((room_flags & QR_UPLOAD) == 0) {
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);
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);
int num_recs = 0;
char **recs = NULL;
char ch;
- int badkey;
int i, j;
int quitting = 0;
int modified = 0;
"Quit without saving", 0);
break;
default:
- badkey = 1;
+ break;
}
} while (!quitting);
int num_recs = 0;
char **recs = NULL;
char ch;
- int badkey;
int i, j;
int quitting = 0;
int modified = 0;
"Quit without saving", 0);
break;
default:
- badkey = 1;
+ break;
}
} while (!quitting);
int num_recs = 0;
char **recs = NULL;
char ch;
- int badkey;
int i, j;
int quitting = 0;
int modified = 0;
"Quit without saving", 0);
break;
default:
- badkey = 1;
+ break;
}
} while (!quitting);
int num_recs = 0;
char **recs = NULL;
char ch;
- int badkey;
int i, j;
int quitting = 0;
int modified = 0;
"Quit without saving", 0);
break;
default:
- badkey = 1;
+ break;
}
} while (!quitting);
int num_recs = 0;
char **recs = NULL;
char ch;
- int badkey;
int i, j;
int quitting = 0;
int modified = 0;
"Quit without saving", 0);
break;
default:
- badkey = 1;
+ break;
}
} while (!quitting);