summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorCedric Duval <cedricduval+web@free.fr>2005-07-24 16:51:38 +0000
committerCedric Duval <cedricduval+web@free.fr>2005-07-24 16:51:38 +0000
commitd167711136fc1f8885bc5440fe5c4ce32fa82286 (patch)
tree0cb1e8f1c1c55240caa6cb85fa026d8e8ccbf7bb /copy.c
parent44e50eadda9f40b5b50fda8893ad6635c60b0d0a (diff)
Add thread editing commands.
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/copy.c b/copy.c
index d1b3f7c2..60ae50e9 100644
--- a/copy.c
+++ b/copy.c
@@ -99,6 +99,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
(ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
ascii_strncasecmp ("Lines:", buf, 6) == 0))
continue;
+ if ((flags & CH_UPDATE_REFS) &&
+ ascii_strncasecmp ("References:", buf, 11) == 0)
+ continue;
+ if ((flags & CH_UPDATE_IRT) &&
+ ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
+ continue;
ignore = 0;
}
@@ -197,6 +203,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
ascii_strncasecmp ("type:", buf + 8, 5) == 0)) ||
ascii_strncasecmp ("mime-version:", buf, 13) == 0))
continue;
+ if ((flags & CH_UPDATE_REFS) &&
+ ascii_strncasecmp ("References:", buf, 11) == 0)
+ continue;
+ if ((flags & CH_UPDATE_IRT) &&
+ ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
+ continue;
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER)
@@ -330,6 +342,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
CH_XMIT ignore Lines: and Content-Length:
CH_WEED do header weeding
CH_NOQFROM ignore ">From " line
+ CH_UPDATE_IRT update the In-Reply-To: header
+ CH_UPDATE_REFS update the References: header
prefix
string to use if CH_PREFIX is set
@@ -339,6 +353,9 @@ int
mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
{
char buffer[SHORT_STRING];
+
+ flags |= (h->irt_changed ? CH_UPDATE_IRT : 0)
+ | (h->refs_changed ? CH_UPDATE_REFS : 0);
if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
return (-1);
@@ -362,7 +379,56 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
if (flags & CH_UPDATE)
{
if ((flags & CH_NOSTATUS) == 0)
+#ifdef USE_IMAP
+#define NEW_ENV new_env
+#else
+#define NEW_ENV env
+#endif
{
+ if (h->irt_changed && h->NEW_ENV->in_reply_to)
+ {
+ LIST *listp = h->NEW_ENV->in_reply_to;
+
+ if (fputs ("In-Reply-To: ", out) == EOF)
+ return (-1);
+
+ for (; listp; listp = listp->next)
+ if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
+ return (-1);
+
+ if (fputc ('\n', out) == EOF)
+ return (-1);
+ }
+
+ if (h->refs_changed && h->NEW_ENV->references)
+ {
+ LIST *listp = h->NEW_ENV->references, *refs = NULL, *t;
+
+ if (fputs ("References: ", out) == EOF)
+ return (-1);
+
+ /* Mutt stores references in reverse order, thus we create
+ * a reordered refs list that we can put in the headers */
+ for (; listp; listp = listp->next, refs = t)
+ {
+ t = (LIST *)safe_malloc (sizeof (LIST));
+ t->data = listp->data;
+ t->next = refs;
+ }
+
+ for (; refs; refs = refs->next)
+ if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
+ return (-1);
+
+ /* clearing refs from memory */
+ for (t = refs; refs; refs = t->next, t = refs)
+ safe_free ((void **)&refs);
+
+ if (fputc ('\n', out) == EOF)
+ return (-1);
+ }
+#undef NEW_ENV
+
if (h->old || h->read)
{
if (fputs ("Status: ", out) == EOF)