int rc = 0;
bool builtin = false;
int cmflags = MUTT_CM_DECODE | MUTT_CM_DISPLAY | MUTT_CM_CHARCONV;
- int chflags;
+ CopyHeaderFlags chflags;
FILE *fpout = NULL;
FILE *fpfilterout = NULL;
pid_t filterpid = -1;
* @param[in] decode If true decode the message
* @param[in] print If true, mark the message for printing
* @param[out] cmflags Copy message flags, e.g. MUTT_CM_DECODE
- * @param[out] chflags Copy header flags, e.g. CH_DECODE
+ * @param[out] chflags Flags, see #CopyHeaderFlags
*/
-static void pipe_set_flags(bool decode, bool print, int *cmflags, int *chflags)
+static void pipe_set_flags(bool decode, bool print, int *cmflags, CopyHeaderFlags *chflags)
{
if (decode)
{
static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
{
int cmflags = 0;
- int chflags = CH_FROM;
+ CopyHeaderFlags chflags = CH_FROM;
pipe_set_flags(decode, print, &cmflags, &chflags);
* @param[in] decode If true, decode the message
* @param[in] decrypt If true, decrypt the message
* @param[out] cmflags Copy message flags, e.g. MUTT_CM_DECODE
- * @param[out] chflags Copy header flags, e.g. CH_DECODE
+ * @param[out] chflags Flags, see #CopyHeaderFlags
*/
static void set_copy_flags(struct Email *e, bool decode, bool decrypt,
- int *cmflags, int *chflags)
+ int *cmflags, CopyHeaderFlags *chflags)
{
*cmflags = 0;
*chflags = CH_UPDATE_LEN;
int mutt_save_message_ctx(struct Email *e, bool delete, bool decode,
bool decrypt, struct Mailbox *m)
{
- int cmflags, chflags;
+ int cmflags;
+ CopyHeaderFlags chflags;
int rc;
set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
* @param out FILE pointer to write to
* @param off_start Offset to start from
* @param off_end Offset to finish at
- * @param chflags Flags (see below)
+ * @param chflags Flags, see #CopyHeaderFlags
* @param prefix Prefix for quoting headers
* @retval 0 Success
* @retval -1 Failure
* wrap headers much more aggressively than the other one.
*/
int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
- int chflags, const char *prefix)
+ CopyHeaderFlags chflags, const char *prefix)
{
bool from = false;
bool this_is_from = false;
if (chflags & (CH_DECODE | CH_PREFIX))
{
if (mutt_write_one_header(out, 0, headers[x], (chflags & CH_PREFIX) ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
+ mutt_window_wrap_cols(MuttIndexWindow, C_Wrap),
+ chflags) == -1)
{
error = true;
break;
* @param in FILE pointer to read from
* @param e Email
* @param out FILE pointer to write to
- * @param chflags Flags, e.g. #CH_DECODE
+ * @param chflags See #CopyHeaderFlags
* @param prefix Prefix for quoting headers (if #CH_PREFIX is set)
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_copy_header(FILE *in, struct Email *e, FILE *out, int chflags, const char *prefix)
+int mutt_copy_header(FILE *in, struct Email *e, FILE *out,
+ CopyHeaderFlags chflags, const char *prefix)
{
char *temp_hdr = NULL;
if (e->env)
{
chflags |= ((e->env->changed & MUTT_ENV_CHANGED_IRT) ? CH_UPDATE_IRT : 0) |
- ((e->env->changed & MUTT_ENV_CHANGED_REFS) ? CH_UPDATE_REFS : 0) |
- ((e->env->changed & MUTT_ENV_CHANGED_XLABEL) ? CH_UPDATE_LABEL : 0) |
- ((e->env->changed & MUTT_ENV_CHANGED_SUBJECT) ? CH_UPDATE_SUBJECT : 0);
+ ((e->env->changed & MUTT_ENV_CHANGED_REFS) ? CH_UPDATE_REFS : 0) |
+ ((e->env->changed & MUTT_ENV_CHANGED_XLABEL) ? CH_UPDATE_LABEL : 0) |
+ ((e->env->changed & MUTT_ENV_CHANGED_SUBJECT) ? CH_UPDATE_SUBJECT : 0);
}
if (mutt_copy_hdr(in, out, e->offset, e->content->offset, chflags, prefix) == -1)
* @param fpin Where to get input
* @param e Email being copied
* @param cmflags Flags, e.g. #MUTT_CM_NOHEADER
- * @param chflags Flags to mutt_copy_header()
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags, int chflags)
+int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags, CopyHeaderFlags chflags)
{
struct Body *body = e->content;
char prefix[128];
* @param src Source mailbox
* @param e Email
* @param cmflags Flags, see: mutt_copy_message_fp()
- * @param chflags Header flags, see: mutt_copy_header()
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*
* like partial decode, where it is worth displaying as much as possible
*/
int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e,
- int cmflags, int chflags)
+ int cmflags, CopyHeaderFlags chflags)
{
struct Message *msg = mx_msg_open(src, e->msgno);
if (!msg)
* @param src source mailbox
* @param e Email being copied
* @param cmflags mutt_open_copy_message() flags
- * @param chflags mutt_copy_header() flags
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Error
*/
static int append_message(struct Mailbox *dest, FILE *fpin, struct Mailbox *src,
- struct Email *e, int cmflags, int chflags)
+ struct Email *e, int cmflags, CopyHeaderFlags chflags)
{
char buf[256];
struct Message *msg = NULL;
* @param dest Destination Mailbox
* @param src Source Mailbox
* @param e Email
- * @param cmflags mutt_open_copy_message() cmflags
- * @param chflags mutt_copy_header() cmflags
+ * @param cmflags mutt_open_copy_message() flags
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*/
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src,
- struct Email *e, int cmflags, int chflags)
+ struct Email *e, int cmflags, CopyHeaderFlags chflags)
{
struct Message *msg = mx_msg_open(src, e->msgno);
if (!msg)
#define MUTT_CM_VERIFY (1 << 11) ///< Do signature verification
#define MUTT_CM_DECODE_CRYPT (MUTT_CM_DECODE_PGP | MUTT_CM_DECODE_SMIME)
-/* flags for mutt_copy_header() */
+typedef uint32_t CopyHeaderFlags; ///< Flags for mutt_copy_header(), e.g. #CH_UPDATE
+#define CH_NO_FLAGS 0 ///< No flags are set
#define CH_UPDATE (1 << 0) ///< Update the status and x-status fields?
#define CH_WEED (1 << 1) ///< Weed the headers?
#define CH_DECODE (1 << 2) ///< Do RFC2047 header decoding
#define CH_UPDATE_SUBJECT (1 << 20) ///< Update Subject: protected header update
#define CH_VIRTUAL (1 << 21) ///< Write virtual header lines too
-int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
- int chflags, const char *prefix);
+int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix);
-int mutt_copy_header(FILE *in, struct Email *e, FILE *out, int chflags, const char *prefix);
+int mutt_copy_header(FILE *in, struct Email *e, FILE *out, CopyHeaderFlags chflags, const char *prefix);
-int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags, int chflags);
-int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e, int cmflags, int chflags);
+int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags, CopyHeaderFlags chflags);
+int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e, int cmflags, CopyHeaderFlags chflags);
-int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, int cmflags, int chflags);
+int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, int cmflags, CopyHeaderFlags chflags);
#endif /* MUTT_COPY_H */
return -1;
}
- const int chflags =
+ const CopyHeaderFlags chflags =
CH_NOLEN | ((m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS);
rc = mutt_append_message(tmpctx->mailbox, m, e, 0, chflags);
int oerrno = errno;
}
MsgOpenFlags of = MUTT_MSG_NO_FLAGS;
- int cf = (((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF)) ?
- 0 :
- CH_NOSTATUS);
+ CopyHeaderFlags cf =
+ (((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF)) ?
+ CH_NO_FLAGS :
+ CH_NOSTATUS);
if (fgets(buf, sizeof(buf), fp) && is_from(buf, NULL, 0, NULL))
{
char buf[8192];
struct Message *msg = NULL;
- int chflags = 0;
+ CopyHeaderFlags chflags = CH_NO_FLAGS;
int r = -1;
struct Email *en = m->email;
state_mark_protected_header(s);
mutt_write_one_header(s->fp_out, "Subject", a->mime_headers->subject,
s->prefix, mutt_window_wrap_cols(MuttIndexWindow, C_Wrap),
- (s->flags & MUTT_DISPLAY) ? CH_DISPLAY : 0);
+ (s->flags & MUTT_DISPLAY) ? CH_DISPLAY : CH_NO_FLAGS);
state_puts("\n", s);
}
}
*/
static void include_header(bool quote, FILE *ifp, struct Email *e, FILE *ofp, char *prefix)
{
- int chflags = CH_DECODE;
+ CopyHeaderFlags chflags = CH_DECODE;
char prefix2[128];
if (C_Weed)
char tmpbody[PATH_MAX];
FILE *tmpfp = NULL;
- int chflags = CH_XMIT;
+ CopyHeaderFlags chflags = CH_XMIT;
if (cur)
e_cur = cur->email;
static void attach_include_reply(FILE *fp, FILE *tmpfp, struct Email *cur)
{
int cmflags = MUTT_CM_PREFIX | MUTT_CM_DECODE | MUTT_CM_CHARCONV;
- int chflags = CH_DECODE;
+ CopyHeaderFlags chflags = CH_DECODE;
mutt_make_attribution(Context->mailbox, cur, tmpfp);
*/
static int include_forward(struct Mailbox *m, struct Email *e, FILE *out)
{
- int chflags = CH_DECODE, cmflags = 0;
+ CopyHeaderFlags chflags = CH_DECODE;
+ int cmflags = 0;
mutt_parse_mime_message(m, e);
mutt_message_hook(m, e, MUTT_MESSAGE_HOOK);
static int include_reply(struct Mailbox *m, struct Email *e, FILE *out)
{
int cmflags = MUTT_CM_PREFIX | MUTT_CM_DECODE | MUTT_CM_CHARCONV | MUTT_CM_REPLYING;
- int chflags = CH_DECODE;
+ CopyHeaderFlags chflags = CH_DECODE;
if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT))
{
char buf[1024];
struct Body *body = NULL;
FILE *fp = NULL;
- int cmflags, chflags;
+ int cmflags;
int pgp = WithCrypto ? e->security : 0;
if (WithCrypto)
mutt_parse_mime_message(m, e);
- chflags = CH_XMIT;
+ CopyHeaderFlags chflags = CH_XMIT;
cmflags = 0;
/* If we are attaching a message, ignore C_MimeForwardDecode */
* @param fp File to write to
* @param pfx Prefix for headers
* @param value Text to be added
- * @param chflags Flags, e.g. #CH_DISPLAY
+ * @param chflags Flags, see #CopyHeaderFlags
* @param col Column that this text starts at
* @retval 0 Success
* @retval -1 Failure
*/
-static int print_val(FILE *fp, const char *pfx, const char *value, int chflags, size_t col)
+static int print_val(FILE *fp, const char *pfx, const char *value,
+ CopyHeaderFlags chflags, size_t col)
{
while (value && *value)
{
* @param value Header value
* @param pfx Prefix for header
* @param wraplen Column to wrap at
- * @param chflags Flags, e.g. #CH_DISPLAY
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*/
static int fold_one_header(FILE *fp, const char *tag, const char *value,
- const char *pfx, int wraplen, int chflags)
+ const char *pfx, int wraplen, CopyHeaderFlags chflags)
{
const char *p = value;
char buf[8192] = "";
int first = 1, col = 0, l = 0;
const bool display = (chflags & CH_DISPLAY);
- mutt_debug(5, "pfx=[%s], tag=[%s], flags=%d value=[%s]\n", pfx, tag, chflags, NONULL(value));
+ mutt_debug(5, "pfx=[%s], tag=[%s], flags=%d value=[%s]\n", pfx, tag, chflags,
+ NONULL(value));
if (tag && *tag && fprintf(fp, "%s%s: ", NONULL(pfx), tag) < 0)
return -1;
* @param pfx Prefix for header
* @param start Start of header line
* @param end End of header line
- * @param chflags Flags, e.g. #CH_DISPLAY
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*/
static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char *pfx,
- const char *start, const char *end, int chflags)
+ const char *start, const char *end, CopyHeaderFlags chflags)
{
char *tagbuf = NULL, *valbuf = NULL, *t = NULL;
int is_from = (end - start) > 5 && mutt_str_startswith(start, "from ", CASE_IGNORE);
* @param value Header value
* @param pfx Prefix for header
* @param wraplen Column to wrap at
- * @param chflags Flags, e.g. #CH_DISPLAY
+ * @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*
* for each one
*/
int mutt_write_one_header(FILE *fp, const char *tag, const char *value,
- const char *pfx, int wraplen, int chflags)
+ const char *pfx, int wraplen, CopyHeaderFlags chflags)
{
char *p = (char *) value, *last = NULL, *line = NULL;
int max = 0, w, rc = -1;
if (f)
{
char date[128];
- int chflags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
+ CopyHeaderFlags chflags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
if (!C_BounceDelivered)
chflags |= CH_WEED_DELIVERED;
#include <stdbool.h>
#include <stdio.h>
+#include "copy.h"
struct Address;
struct Body;
int mutt_write_mime_body(struct Body *a, FILE *f);
int mutt_write_mime_header(struct Body *a, FILE *f);
int mutt_write_multiple_fcc(const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath);
-int mutt_write_one_header(FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, int chflags);
+int mutt_write_one_header(FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, CopyHeaderFlags chflags);
void mutt_write_references(const struct ListHead *r, FILE *f, size_t trim);
#endif /* MUTT_SENDLIB_H */