* @param fp File to write to
* @param env Envelope of email
* @param attach Attachment
- * @param mode Mode, see notes below
+ * @param mode Mode, see #MuttWriteHeaderMode
* @param privacy If true, remove headers that might identify the user
* @retval 0 Success
* @retval -1 Failure
*
* Likewise, all IDN processing should happen outside of this routine.
*
- * mode == 1 => "light" mode (used for edit_headers)
- * mode == 0 => normal mode. write full header + MIME headers
- * mode == -1 => write just the envelope info (used for postponing messages)
- *
* privacy true => will omit any headers which may identify the user.
* Output generated is suitable for being sent through
* anonymous remailer chains.
*/
-int mutt_rfc822_write_header(FILE *fp, struct Envelope *env,
- struct Body *attach, int mode, bool privacy)
+int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach,
+ enum MuttWriteHeaderMode mode, bool privacy)
{
char buf[LONG_STRING];
char *p = NULL, *q = NULL;
bool has_agent = false; /* user defined user-agent header field exists */
- if (mode == 0 && !privacy)
+ if (mode == MUTT_WRITE_HEADER_NORMAL && !privacy)
fputs(mutt_date_make_date(buf, sizeof(buf)), fp);
/* UseFrom is not consulted here so that we can still write a From:
fputs("To: ", fp);
mutt_write_address_list(env->to, fp, 4, 0);
}
- else if (mode > 0)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
#ifdef USE_NNTP
if (!OptNewsSend)
#endif
fputs("Cc: ", fp);
mutt_write_address_list(env->cc, fp, 4, 0);
}
- else if (mode > 0)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
#ifdef USE_NNTP
if (!OptNewsSend)
#endif
if (env->bcc)
{
- if (mode != 0 || WriteBcc)
+ if (mode == MUTT_WRITE_HEADER_POSTPONE || mode == MUTT_WRITE_HEADER_EDITHDRS ||
+ (mode == MUTT_WRITE_HEADER_NORMAL && WriteBcc))
{
fputs("Bcc: ", fp);
mutt_write_address_list(env->bcc, fp, 5, 0);
}
}
- else if (mode > 0)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
#ifdef USE_NNTP
if (!OptNewsSend)
#endif
#ifdef USE_NNTP
if (env->newsgroups)
fprintf(fp, "Newsgroups: %s\n", env->newsgroups);
- else if (mode == 1 && OptNewsSend)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS && OptNewsSend)
fputs("Newsgroups:\n", fp);
if (env->followup_to)
fprintf(fp, "Followup-To: %s\n", env->followup_to);
- else if (mode == 1 && OptNewsSend)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS && OptNewsSend)
fputs("Followup-To:\n", fp);
if (env->x_comment_to)
fprintf(fp, "X-Comment-To: %s\n", env->x_comment_to);
- else if (mode == 1 && OptNewsSend && XCommentTo)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS && OptNewsSend && XCommentTo)
fputs("X-Comment-To:\n", fp);
#endif
if (env->subject)
mutt_write_one_header(fp, "Subject", env->subject, NULL, 0, 0);
- else if (mode == 1)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
fputs("Subject:\n", fp);
/* save message id if the user has set it */
fputs("Reply-To: ", fp);
mutt_write_address_list(env->reply_to, fp, 10, 0);
}
- else if (mode > 0)
+ else if (mode == MUTT_WRITE_HEADER_EDITHDRS)
fputs("Reply-To:\n", fp);
if (env->mail_followup_to)
mutt_write_address_list(env->mail_followup_to, fp, 18, 0);
}
- if (mode <= 0)
+ if (mode == MUTT_WRITE_HEADER_NORMAL || mode == MUTT_WRITE_HEADER_POSTPONE)
{
if (!STAILQ_EMPTY(&env->references))
{
}
}
- if (mode == 0 && !privacy && UserAgent && !has_agent)
+ if (mode == MUTT_WRITE_HEADER_NORMAL && !privacy && UserAgent && !has_agent)
{
/* Add a vanity header */
fprintf(fp, "User-Agent: NeoMutt/%s%s\n", PACKAGE_VERSION, GitVer);
goto done;
}
- /* post == 1 => postpone message. Set mode = -1 in mutt_rfc822_write_header()
- * post == 0 => Normal mode. Set mode = 0 in mutt_rfc822_write_header()
+ /* post == 1 => postpone message.
+ * post == 0 => Normal mode.
*/
- mutt_rfc822_write_header(msg->fp, e->env, e->content, post ? -1 : 0, false);
+ mutt_rfc822_write_header(msg->fp, e->env, e->content,
+ post ? MUTT_WRITE_HEADER_POSTPONE : MUTT_WRITE_HEADER_NORMAL,
+ false);
/* (postponement) if this was a reply of some sort, <msgid> contains the
* Message-ID: of message replied to. Save it using a special X-Mutt-
extern bool UserAgent;
extern short WrapHeaders;
+/**
+ * enum MuttWriteHeaderMode - Modes for mutt_rfc822_write_header()
+ */
+enum MuttWriteHeaderMode
+{
+ MUTT_WRITE_HEADER_NORMAL, ///< A normal Email, write full header + MIME headers
+ MUTT_WRITE_HEADER_POSTPONE, ///< A postponed Email, just the envelope info
+ MUTT_WRITE_HEADER_EDITHDRS, ///< "light" mode (used for edit_hdrs)
+ MUTT_WRITE_HEADER_MIME, ///< Write protected headers
+};
+
char * mutt_body_get_charset(struct Body *b, char *buf, size_t buflen);
int mutt_bounce_message(FILE *fp, struct Email *e, struct Address *to);
const char * mutt_fqdn(bool may_hide_host);
void mutt_prepare_envelope(struct Envelope *env, bool final);
struct Address *mutt_addrlist_dedupe(struct Address *addr);
struct Body * mutt_remove_multipart(struct Body *b);
-int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach, int mode, bool privacy);
+int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach, enum MuttWriteHeaderMode mode, bool privacy);
void mutt_stamp_attachment(struct Body *a);
void mutt_unprepare_envelope(struct Envelope *env);
void mutt_update_encoding(struct Body *a);