Rocco Rutte:
[apps/madmutt.git] / attach.c
index c32eb79..c695e34 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -238,11 +238,14 @@ int mutt_edit_attachment (BODY * a)
                                   command, sizeof (command))) {
         /* For now, editing requires a file, no piping */
         mutt_error _("Mailcap Edit entry requires %%s");
                                   command, sizeof (command))) {
         /* For now, editing requires a file, no piping */
         mutt_error _("Mailcap Edit entry requires %%s");
+        goto bailout;
       }
       else {
         mutt_endwin (NULL);
       }
       else {
         mutt_endwin (NULL);
-        if (mutt_system (command) == -1)
+        if (mutt_system (command) == -1) {
           mutt_error (_("Error running \"%s\"!"), command);
           mutt_error (_("Error running \"%s\"!"), command);
+          goto bailout;
+        }
       }
     }
   }
       }
     }
   }
@@ -463,7 +466,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr,
     if (fp && !use_mailcap && a->filename) {
       /* recv case */
       strfcpy (pagerfile, a->filename, sizeof (pagerfile));
     if (fp && !use_mailcap && a->filename) {
       /* recv case */
       strfcpy (pagerfile, a->filename, sizeof (pagerfile));
-      mutt_adv_mktemp (pagerfile, sizeof (pagerfile));
+      mutt_adv_mktemp (NULL, pagerfile, sizeof (pagerfile));
     }
     else
       mutt_mktemp (pagerfile);
     }
     else
       mutt_mktemp (pagerfile);
@@ -1013,3 +1016,30 @@ int mutt_print_attachment (FILE * fp, BODY * a)
     return 0;
   }
 }
     return 0;
   }
 }
+
+int mutt_attach_check (HEADER* hdr) {
+  int found = 0;
+  char buf[LONG_STRING];
+  char *p = NULL;
+  FILE* fp = NULL;
+  regmatch_t pmatch[1];
+
+  if (!hdr || !hdr->content || !((regex_t*) AttachRemindRegexp.rx) ||
+      (fp = safe_fopen (hdr->content->filename, "r")) == NULL)
+    return (0);
+
+  while (!found && fgets (buf, sizeof (buf), fp)) {
+    p = buf;
+    while (p && *p) {
+      if (regexec ((regex_t*) AttachRemindRegexp.rx, p, 1,
+                  pmatch, 0) == 0) {
+        found = 1;
+        break;
+      }
+      p++;
+    }
+  }
+  fclose (fp);
+
+  return (found);
+}