From: Richard Russon Date: Thu, 5 May 2016 23:36:57 +0000 (+0100) Subject: feature: multiple-fcc X-Git-Tag: neomutt-20160822~20^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=334099e43282d69ba8df2fb0af1a97725498b1fb;p=neomutt feature: multiple-fcc --- diff --git a/protos.h b/protos.h index 19d640032..4b80e63b5 100644 --- a/protos.h +++ b/protos.h @@ -368,6 +368,7 @@ void mutt_update_num_postponed (void); int mutt_wait_filter (pid_t); int mutt_which_case (const char *); int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *); +int mutt_write_multiple_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *); int mutt_write_mime_body (BODY *, FILE *); int mutt_write_mime_header (BODY *, FILE *); int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, int flags); diff --git a/send.c b/send.c index d54d4951d..dddd6c9c0 100644 --- a/send.c +++ b/send.c @@ -1831,7 +1831,7 @@ full_fcc: * message was first postponed. */ msg->received = time (NULL); - if (mutt_write_fcc (fcc, msg, NULL, 0, NULL) == -1) + if (mutt_write_multiple_fcc (fcc, msg, NULL, 0, NULL) == -1) { /* * Error writing FCC, we should abort sending. diff --git a/sendlib.c b/sendlib.c index 771eae2d6..7a88a37ad 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2690,6 +2690,42 @@ static void set_noconv_flags (BODY *b, short flag) } } +/* Handle a Fcc with multiple, comma separated entries. */ +int mutt_write_multiple_fcc (const char *path, HEADER *hdr, const char *msgid, + int post, char *fcc) +{ + char fcc_tok[_POSIX_PATH_MAX]; + char fcc_expanded[_POSIX_PATH_MAX]; + char *tok = NULL; + int status; + + strfcpy(fcc_tok, path, sizeof (fcc_tok)); + + tok = strtok(fcc_tok, ","); + dprint(1, (debugfile, "Fcc: initial mailbox = '%s'\n", tok)); + /* mutt_expand_path already called above for the first token */ + status = mutt_write_fcc (tok, hdr, msgid, post, fcc); + if (status != 0) + return status; + + while ((tok = strtok (NULL, ",")) != NULL) + { + if (!*tok) + continue; + + /* Only call mutt_expand_path iff tok has some data */ + dprint (1, (debugfile, "Fcc: additional mailbox token = '%s'\n", tok)); + strfcpy (fcc_expanded, tok, sizeof (fcc_expanded)); + mutt_expand_path (fcc_expanded, sizeof (fcc_expanded)); + dprint (1, (debugfile, " Additional mailbox expanded = '%s'\n", fcc_expanded)); + status = mutt_write_fcc (fcc_expanded, hdr, msgid, post, fcc); + if (status != 0) + return status; + } + + return 0; +} + int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc) { CONTEXT f;