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;
newprompt("Display name for this message: ", message.author, 40);
}
+ if (is_reply) {
+
+ if (!IsEmptyStr(reply_subject)) {
+ if (!strncasecmp(reply_subject,
+ "Re: ", 3)) {
+ strcpy(message.subject, reply_subject);
+ }
+ else {
+ snprintf(message.subject,
+ sizeof message.subject,
+ "Re: %s",
+ reply_subject);
+ }
+ }
+
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ int rrtok = num_tokens(reply_references, '|');
+ int rrlen = strlen(reply_references);
+ if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ remove_token(reply_references, 1, '|');
+ }
+
+ snprintf(message.references, sizeof message.references, "%s%s%s",
+ reply_references,
+ (IsEmptyStr(reply_references) ? "" : "|"),
+ reply_inreplyto
+ );
+ }
+
r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
if (r / 100 != 2 && r / 10 != 57) {
}
strcpy(message.recipient, buf);
- if (is_reply) {
-
- if (!IsEmptyStr(reply_subject)) {
- if (!strncasecmp(reply_subject,
- "Re: ", 3)) {
- strcpy(message.subject, reply_subject);
- }
- else {
- snprintf(message.subject,
- sizeof message.subject,
- "Re: %s",
- reply_subject);
- }
- }
-
- /* Trim down excessively long lists of thread references. We eliminate the
- * second one in the list so that the thread root remains intact.
- */
- int rrtok = num_tokens(reply_references, '|');
- int rrlen = strlen(reply_references);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
- remove_token(reply_references, 1, '|');
- }
-
- snprintf(message.references, sizeof message.references, "%s%s%s",
- reply_references,
- (IsEmptyStr(reply_references) ? "" : "|"),
- reply_inreplyto
- );
- }
-
if (room_flags & QR_ANONOPT) {
scr_printf("Anonymous (Y/N)? ");
if (yesno() == 1)
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) {
if ((quotflag) || (arcflag)) {
screenwidth = hold_sw;
}
-RMSGREAD: scr_flush();
+RMSGREAD:
highest_msg_read = msg_arr[a];
if (quotflag) {
fclose(dest);
scr_printf("\r%79s\r", "");
else
scr_printf("\n");
- scr_flush();
}
DONE_QUOTING: switch (e) {
case '?':
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);