| 1 | #include "stralloc.h" |
| 2 | #include "str.h" |
| 3 | #include "byte.h" |
| 4 | #include "readwrite.h" |
| 5 | #include "substdio.h" |
| 6 | #include "getln.h" |
| 7 | #include "strerr.h" |
| 8 | |
| 9 | char buf0[256]; |
| 10 | substdio ss0 = SUBSTDIO_FDBUF(read,0,buf0,sizeof(buf0)); |
| 11 | |
| 12 | #define FATAL "ezmlm-weed: fatal: " |
| 13 | |
| 14 | void get(sa) |
| 15 | stralloc *sa; |
| 16 | { |
| 17 | int match; |
| 18 | if (getln(&ss0,sa,&match,'\n') == -1) |
| 19 | strerr_die2sys(111,FATAL,"unable to read input: "); |
| 20 | if (!match) _exit(0); |
| 21 | } |
| 22 | |
| 23 | stralloc line = {0}; |
| 24 | stralloc line1 = {0}; |
| 25 | stralloc line2 = {0}; |
| 26 | stralloc line3 = {0}; |
| 27 | stralloc line4 = {0}; |
| 28 | stralloc line5 = {0}; |
| 29 | stralloc line6 = {0}; |
| 30 | stralloc line7 = {0}; |
| 31 | stralloc line8 = {0}; |
| 32 | |
| 33 | char warn1[] = " **********************************************"; |
| 34 | char warn2[] = " ** THIS IS A WARNING MESSAGE ONLY **"; |
| 35 | char warn3[] = " ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **"; |
| 36 | char warn4[] = " **********************************************"; |
| 37 | |
| 38 | int flagmds = 0; |
| 39 | int flagsw = 0; |
| 40 | int flagsr = 0; |
| 41 | int flagas = 0; |
| 42 | int flagbw = 0; |
| 43 | |
| 44 | void main() |
| 45 | { |
| 46 | int match; |
| 47 | |
| 48 | for (;;) { |
| 49 | get(&line); |
| 50 | if (line.len == 1) break; |
| 51 | |
| 52 | if (stralloc_starts(&line,"Subject: success notice")) |
| 53 | _exit(99); |
| 54 | if (stralloc_starts(&line,"Subject: deferral notice")) |
| 55 | _exit(99); |
| 56 | |
| 57 | if (stralloc_starts(&line,"From: Mail Delivery Subsystem <MAILER-DAEMON@")) |
| 58 | flagmds = 1; |
| 59 | if (stralloc_starts(&line,"Subject: Warning: could not send message")) |
| 60 | flagsw = 1; |
| 61 | if (stralloc_starts(&line,"Subject: Returned mail: warning: cannot send message")) |
| 62 | flagsr = 1; |
| 63 | if (stralloc_starts(&line,"Auto-Submitted: auto-generated (warning")) |
| 64 | flagas = 1; |
| 65 | } |
| 66 | |
| 67 | get(&line1); |
| 68 | get(&line2); |
| 69 | get(&line3); |
| 70 | get(&line4); |
| 71 | get(&line5); |
| 72 | get(&line6); |
| 73 | get(&line7); |
| 74 | get(&line8); |
| 75 | |
| 76 | if (stralloc_starts(&line1,"This is a MIME-encapsulated message")) |
| 77 | if (stralloc_starts(&line3,"--")) |
| 78 | if (stralloc_starts(&line5,warn1)) |
| 79 | if (stralloc_starts(&line6,warn2)) |
| 80 | if (stralloc_starts(&line7,warn3)) |
| 81 | if (stralloc_starts(&line8,warn4)) |
| 82 | flagbw = 1; |
| 83 | |
| 84 | if (stralloc_starts(&line1,warn1)) |
| 85 | if (stralloc_starts(&line2,warn2)) |
| 86 | if (stralloc_starts(&line3,warn3)) |
| 87 | if (stralloc_starts(&line4,warn4)) |
| 88 | flagbw = 1; |
| 89 | |
| 90 | if (flagmds && flagsw && flagas && flagbw) _exit(99); |
| 91 | if (flagmds && flagsr && flagbw) _exit(99); |
| 92 | |
| 93 | _exit(0); |
| 94 | } |