make mutt_match_spam_list a generic rx function: rx_list_match2 that does
[apps/madmutt.git] / lib-mime / rfc822parse.c
index 31b5d88..b03a17a 100644 (file)
  * please see the file GPL in the top level source directory.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/ascii.h>
-#include <lib-lib/macros.h>
-#include <lib-lib/buffer.h>
-#include <lib-lib/date.h>
-#include <lib-lib/url.h>
+#include <lib-lib/lib-lib.h>
 
 #include "recvattach.h"
 
@@ -384,7 +372,7 @@ static void parse_content_disposition(const char *s, BODY *ct)
  */
 BODY *mutt_read_mime_header(FILE *fp, int digest)
 {
-    BODY *body = mutt_new_body ();
+    BODY *body = body_new();
     char *line = p_new(char, LONG_STRING);
     ssize_t linelen = LONG_STRING;
     char *p;
@@ -573,7 +561,7 @@ mutt_parse_multipart(FILE *fp, const char *bound, off_t end_off, int digest)
                  */
 
                 if (new->offset > end_off) {
-                    mutt_free_body(&new);
+                    body_list_wipe(&new);
                     break;
                 }
 
@@ -1018,7 +1006,7 @@ mutt_read_rfc822_header(FILE *f, HEADER *hdr, short user_hdrs, short weed)
     off_t loc;
 
     if (hdr && !hdr->content) {
-        hdr->content = mutt_new_body ();
+        hdr->content = body_new();
 
         /* set the defaults from RFC1521 */
         hdr->content->type     = TYPETEXT;
@@ -1056,29 +1044,25 @@ mutt_read_rfc822_header(FILE *f, HEADER *hdr, short user_hdrs, short weed)
             break;                    /* end of header */
         }
 
-        if (mutt_match_spam_list(line, SpamList, buf, sizeof(buf))) {
-            if (!rx_list_match(NoSpamList, line)) {
-                /* if spam tag already exists, figure out how to amend it */
-                if (e->spam && *buf) {
-                    if (SpamSep) {
-                        /* If SpamSep defined, append with separator */
-                        mutt_buffer_addstr(e->spam, SpamSep);
-                        mutt_buffer_addstr(e->spam, buf);
-                    } else {
-                        /* else overwrite */
-                        mutt_buffer_reset(e->spam);
-                        mutt_buffer_addstr(e->spam, buf);
-                    }
-                }
-                else if (!e->spam && *buf) {
-                    /* spam tag is new, and match expr is non-empty; copy */
-                    e->spam = mutt_buffer_from(NULL, buf);
-                }
-                else if (!e->spam) {
-                    /* match expr is empty; plug in null string if no existing tag */
-                    e->spam = mutt_buffer_from(NULL, "");
+        if (rx_list_match2(SpamList, line, buf, sizeof(buf))
+        && !rx_list_match(NoSpamList, line))
+        {
+            /* if spam tag already exists, figure out how to amend it */
+            if (e->spam && *buf) {
+                if (SpamSep) {
+                    /* If SpamSep defined, append with separator */
+                    mutt_buffer_addstr(e->spam, SpamSep);
+                    mutt_buffer_addstr(e->spam, buf);
+                } else {
+                    /* else overwrite */
+                    mutt_buffer_reset(e->spam);
+                    mutt_buffer_addstr(e->spam, buf);
                 }
             }
+
+            if (!e->spam) {
+                e->spam = mutt_buffer_from(NULL, buf);
+            }
         }
 
         *p++ = '\0';