]> granicus.if.org Git - neomutt/commitdiff
add typedef for CopyHeaderFlags
authorRichard Russon <rich@flatcap.org>
Wed, 27 Feb 2019 00:51:16 +0000 (00:51 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 1 Mar 2019 13:11:20 +0000 (13:11 +0000)
commands.c
copy.c
copy.h
editmsg.c
mutt_attach.c
ncrypt/crypt.c
recvcmd.c
send.c
sendlib.c
sendlib.h

index 80d21841098bd11bc90c776bf3b9fa0cf9cbe17a..22069fe5f15970e514fa0d5848cfd709809adfcf 100644 (file)
@@ -178,7 +178,7 @@ int mutt_display_message(struct Email *cur)
   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;
@@ -471,9 +471,9 @@ void ci_bounce_message(struct Mailbox *m, struct EmailList *el)
  * @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)
   {
@@ -502,7 +502,7 @@ static void pipe_set_flags(bool decode, bool print, int *cmflags, int *chflags)
 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);
 
@@ -882,10 +882,10 @@ void mutt_display_address(struct Envelope *env)
  * @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;
@@ -941,7 +941,8 @@ static void set_copy_flags(struct Email *e, bool decode, bool decrypt,
 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);
diff --git a/copy.c b/copy.c
index 52c1a5ebc70b349e90816a08d893c75d406c7924..3c6caed774d26db4201cb12b4c68a3f10941002d 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -60,7 +60,7 @@ static int copy_delete_attach(struct Body *b, FILE *fpin, FILE *fpout, char *dat
  * @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
@@ -70,7 +70,7 @@ static int copy_delete_attach(struct Body *b, FILE *fpin, FILE *fpout, char *dat
  * 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;
@@ -348,7 +348,8 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
       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;
@@ -381,21 +382,22 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
  * @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)
@@ -583,11 +585,11 @@ static int count_delete_lines(FILE *fp, struct Body *b, LOFF_T *length, size_t d
  * @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];
@@ -786,7 +788,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags,
  * @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
  *
@@ -794,7 +796,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int cmflags,
  * 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)
@@ -818,12 +820,12 @@ int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e,
  * @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;
@@ -858,13 +860,13 @@ static int append_message(struct Mailbox *dest, FILE *fpin, struct Mailbox *src,
  * @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)
diff --git a/copy.h b/copy.h
index 6f01078aacf3555d6ad7455f17e26aab0b7b6162..7d71f33860c3a9e74cb640f5d3aed28a80e16f5f 100644 (file)
--- a/copy.h
+++ b/copy.h
@@ -43,7 +43,8 @@ struct Mailbox;
 #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
@@ -67,14 +68,13 @@ struct Mailbox;
 #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 */
index 40067e6e22b07ca050e14fe8c1eee8266dd6e86a..a29219e0a6af4b8034ac2d3f41b0efcb08080c1f 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -81,7 +81,7 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e)
     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;
@@ -184,9 +184,10 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e)
   }
 
   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))
   {
index 7aac87d3bcec651046a61076d35ee22274bfbc54..58cb774a0520203e426bd1d412fb44312d9898e1 100644 (file)
@@ -803,7 +803,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
 
       char buf[8192];
       struct Message *msg = NULL;
-      int chflags = 0;
+      CopyHeaderFlags chflags = CH_NO_FLAGS;
       int r = -1;
 
       struct Email *en = m->email;
index 165094aae9012a052dd7c0607691c7413aa9cf82..967b3a2c1acaebb98e0042df8873e8666e23fb56 100644 (file)
@@ -1069,7 +1069,7 @@ int mutt_protected_headers_handler(struct Body *a, struct State *s)
       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);
     }
   }
index 18e82e749cf81483c2714f8332e6ce946f5d6b77..c9fca85d4b19e69a35bb8377967ee5b621f642ff 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -399,7 +399,7 @@ static struct AttachPtr *find_parent(struct AttachCtx *actx, struct Body *cur, 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)
@@ -642,7 +642,7 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx,
   char tmpbody[PATH_MAX];
   FILE *tmpfp = NULL;
 
-  int chflags = CH_XMIT;
+  CopyHeaderFlags chflags = CH_XMIT;
 
   if (cur)
     e_cur = cur->email;
@@ -878,7 +878,7 @@ static int attach_reply_envelope_defaults(struct Envelope *env, struct AttachCtx
 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);
 
diff --git a/send.c b/send.c
index 0c9c82e8cfd477af9f24f3ac8099e4466a39ca46..c3e9bce95a2dee509d97fd74f797e98c8b8cdcc5 100644 (file)
--- a/send.c
+++ b/send.c
@@ -495,7 +495,8 @@ void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp)
  */
 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);
@@ -577,7 +578,7 @@ void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *out)
 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))
   {
index a5187f5fa904172481489fa62ceed9c0abf6c9ed..d2cb750d3242262fa3609795e98df2a8e387221c 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1465,7 +1465,7 @@ struct Body *mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool a
   char buf[1024];
   struct Body *body = NULL;
   FILE *fp = NULL;
-  int cmflags, chflags;
+  int cmflags;
   int pgp = WithCrypto ? e->security : 0;
 
   if (WithCrypto)
@@ -1493,7 +1493,7 @@ struct Body *mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool a
 
   mutt_parse_mime_message(m, e);
 
-  chflags = CH_XMIT;
+  CopyHeaderFlags chflags = CH_XMIT;
   cmflags = 0;
 
   /* If we are attaching a message, ignore C_MimeForwardDecode */
@@ -1827,12 +1827,13 @@ void mutt_write_references(const struct ListHead *r, FILE *f, size_t trim)
  * @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)
   {
@@ -1873,19 +1874,20 @@ static int print_val(FILE *fp, const char *pfx, const char *value, int chflags,
  * @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;
@@ -2013,12 +2015,12 @@ static char *unfold_header(char *s)
  * @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);
@@ -2101,7 +2103,7 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char
  * @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
  *
@@ -2109,7 +2111,7 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char
  * 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;
@@ -2968,7 +2970,7 @@ static int bounce_message(FILE *fp, struct Email *e, struct Address *to,
   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;
index 0c99dc8770c45c4b55ab50fb7d9566db84dd1d91..de9b9b92c61818d8f8eba5b59c34772bf64c9efc 100644 (file)
--- a/sendlib.h
+++ b/sendlib.h
@@ -25,6 +25,7 @@
 
 #include <stdbool.h>
 #include <stdio.h>
+#include "copy.h"
 
 struct Address;
 struct Body;
@@ -87,7 +88,7 @@ int             mutt_write_fcc(const char *path, struct Email *e, const char *ms
 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 */