Import ezmlm 0.53
[ezmlm] / ezmlm-weed.c
CommitLineData
5b62e993
MW
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
9char buf0[256];
10substdio ss0 = SUBSTDIO_FDBUF(read,0,buf0,sizeof(buf0));
11
12#define FATAL "ezmlm-weed: fatal: "
13
14void get(sa)
15stralloc *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
23stralloc line = {0};
24stralloc line1 = {0};
25stralloc line2 = {0};
26stralloc line3 = {0};
27stralloc line4 = {0};
28stralloc line5 = {0};
29stralloc line6 = {0};
30stralloc line7 = {0};
31stralloc line8 = {0};
32
33char warn1[] = " **********************************************";
34char warn2[] = " ** THIS IS A WARNING MESSAGE ONLY **";
35char warn3[] = " ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **";
36char warn4[] = " **********************************************";
37
38int flagmds = 0;
39int flagsw = 0;
40int flagsr = 0;
41int flagas = 0;
42int flagbw = 0;
43
44void 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}