Fixed bug with aborting F)wd

This commit is contained in:
Bobbi Webber-Manners 2020-07-08 00:50:20 -04:00
parent 42a92f2fa5
commit 5493171d14

View File

@ -1235,9 +1235,11 @@ done:
* fp2 - File handle of the destination mail message * fp2 - File handle of the destination mail message
* h - headers of the message being replied/forwarded * h - headers of the message being replied/forwarded
* mode - 'R' for reply, 'F' for forward * mode - 'R' for reply, 'F' for forward
* fwd_to - Recipient (used for mode=='F' only)
* Returns 0 if okay, 1 on error * Returns 0 if okay, 1 on error
*/ */
uint8_t write_email_headers(FILE *fp1, FILE *fp2, struct emailhdrs *h, char mode) { uint8_t write_email_headers(FILE *fp1, FILE *fp2, struct emailhdrs *h,
char mode, char *fwd_to) {
struct datetime dt; struct datetime dt;
fprintf(fp2, "From: %s\r", cfg_emailaddr); fprintf(fp2, "From: %s\r", cfg_emailaddr);
truncate_header(h->subject, buf, 80); truncate_header(h->subject, buf, 80);
@ -1250,12 +1252,8 @@ uint8_t write_email_headers(FILE *fp1, FILE *fp2, struct emailhdrs *h, char mode
if (parse_from_addr(filename, buf)) if (parse_from_addr(filename, buf))
return 1; return 1;
fprintf(fp2, "To: %s\r", buf); fprintf(fp2, "To: %s\r", buf);
} else { } else
prompt_for_name("Fwd to", 0); fprintf(fp2, "To: %s\r", fwd_to);
if (strlen(userentry) == 0)
return 0;
fprintf(fp2, "To: %s\r", userentry);
}
prompt_for_name("cc", 0); prompt_for_name("cc", 0);
if (strlen(userentry) > 0) if (strlen(userentry) > 0)
fprintf(fp2, "cc: %s\r", userentry); fprintf(fp2, "cc: %s\r", userentry);
@ -1294,6 +1292,12 @@ void copy_to_mailbox(struct emailhdrs *h, uint16_t idx,
uint16_t num, buflen, written, l; uint16_t num, buflen, written, l;
FILE *fp2; FILE *fp2;
if (mode == 'F') {
prompt_for_name("Fwd to", 0);
if (strlen(userentry) == 0)
return;
}
// Read next number from dest/NEXT.EMAIL // Read next number from dest/NEXT.EMAIL
if (get_next_email(mbox, &num)) if (get_next_email(mbox, &num))
return; return;
@ -1318,7 +1322,7 @@ void copy_to_mailbox(struct emailhdrs *h, uint16_t idx,
} }
if (mode != ' ') if (mode != ' ')
if (write_email_headers(fp, fp2, h, mode)) { if (write_email_headers(fp, fp2, h, mode, userentry)) {
error(ERR_NONFATAL, "Invalid email header"); error(ERR_NONFATAL, "Invalid email header");
fclose(fp); fclose(fp);
fclose(fp2); fclose(fp2);
@ -1512,7 +1516,8 @@ void create_blank_outgoing() {
datetimelong(&dt, userentry); datetimelong(&dt, userentry);
fprintf(fp, "Date: %s\r", userentry); fprintf(fp, "Date: %s\r", userentry);
prompt_for_name("cc", 0); prompt_for_name("cc", 0);
fprintf(fp, "cc: %s\r", userentry); if (strlen(userentry) > 0)
fprintf(fp, "cc: %s\r", userentry);
fprintf(fp, "X-Mailer: %s - Apple II Forever!\r\r", PROGNAME); fprintf(fp, "X-Mailer: %s - Apple II Forever!\r\r", PROGNAME);
fclose(fp); fclose(fp);