X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=attach.c;h=c695e346e130374a24843da38028112dbf66e9a7;hp=a644784ad02b27ffe7a987547b0d801c30fe8d99;hb=abcb4c00cbb9994087487573aa3bddd02a64ff5e;hpb=84336b1f31f4acefd0bf8500b8571c33669fd99f diff --git a/attach.c b/attach.c index a644784..c695e34 100644 --- 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"); + goto bailout; } else { mutt_endwin (NULL); - if (mutt_system (command) == -1) + if (mutt_system (command) == -1) { mutt_error (_("Error running \"%s\"!"), command); + goto bailout; + } } } } @@ -1013,3 +1016,30 @@ int mutt_print_attachment (FILE * fp, BODY * a) 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); +}