11 substdio ss0
= SUBSTDIO_FDBUF(read
,0,buf0
,sizeof(buf0
));
13 #define FATAL "ezmlm-weed: fatal: "
17 strerr_die2x(111,FATAL
,ERR_NOMEM
);
24 if (getln(&ss0
,sa
,&match
,'\n') == -1)
25 strerr_die2sys(111,FATAL
,ERR_READ_INPUT
);
39 stralloc boundary
= {0};
40 stralloc dsnline
= {0};
42 char warn1
[] = " **********************************************";
43 char warn2
[] = " ** THIS IS A WARNING MESSAGE ONLY **";
44 char warn3
[] = " ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **";
45 char warn4
[] = " **********************************************";
55 /* returns 1 if line.len contains the mime bondary, 0 otherwise */
57 if (line
.s
[0] == '-' && line
.s
[1] == '-' && line
.len
>= boundary
.len
+ 3)
58 if (!byte_diff(line
.s
+ 2,boundary
.len
,boundary
.s
)) /* boundary */
69 if (line
.len
== 1) break;
70 if (line
.s
[0] == ' ' || line
.s
[0] == '\t') { /* continuation */
72 if (!stralloc_catb(&dsnline
,line
.s
,line
.len
- 1)) die_nomem();
77 if (stralloc_starts(&line
,"Subject: success notice"))
79 if (stralloc_starts(&line
,"Subject: deferral notice"))
81 if (stralloc_starts(&line
,"Precedence: bulk"))
83 if (stralloc_starts(&line
,"Precedence: junk"))
85 /* for Novell Groupwise */
86 if (stralloc_starts(&line
,"Subject: Message status - delivered"))
88 if (stralloc_starts(&line
,"Subject: Message status - opened"))
90 if (stralloc_starts(&line
,"Subject: Out of Office AutoReply:"))
93 if (stralloc_starts(&line
,"From: Mail Delivery Subsystem <MAILER-DAEMON@"))
95 if (stralloc_starts(&line
,"Subject: Warning: could not send message"))
97 if (stralloc_starts(&line
,"Subject: Returned mail: warning: cannot send message"))
99 if (stralloc_starts(&line
,"Auto-Submitted: auto-generated (warning"))
101 if (case_startb(line
.s
,line
.len
,"Content-type: multipart/report"))
102 if (!stralloc_copyb(&dsnline
,line
.s
,line
.len
- 1)) die_nomem();
104 } /* end of header */
106 if (flagdsn
) { /* always only one recipient/action */
107 flagdsn
= 0; /* will be set for correct report type */
108 for (i
=0; i
< dsnline
.len
; i
+= 1+byte_chr(dsnline
.s
+i
,dsnline
.len
-i
,';')) {
109 while (dsnline
.s
[i
] == ' ' || dsnline
.s
[i
] == '\t')
110 if (++i
>= dsnline
.len
) break;
111 if (case_startb(dsnline
.s
+ i
,dsnline
.len
- i
,"report-type=")) {
113 while (dsnline
.s
[i
] ==' ' || dsnline
.s
[i
] =='\t' || dsnline
.s
[i
] =='"')
114 if (++i
>= dsnline
.len
) break;
115 if (case_startb(dsnline
.s
+ i
,dsnline
.len
- i
,"delivery-status"))
117 } else if (case_startb(dsnline
.s
+ i
,dsnline
.len
- i
,"boundary=")) {
119 while (dsnline
.s
[i
] ==' ' || dsnline
.s
[i
] =='\t')
120 if (++i
>= dsnline
.len
) break;
121 if (dsnline
.s
[i
] == '"') {
122 if (++i
>= dsnline
.len
) break;
123 j
= i
+ byte_chr(dsnline
.s
+ i
,dsnline
.len
- i
,'"');
124 if (j
>= dsnline
.len
) break;
127 while (dsnline
.s
[j
] !=' ' && dsnline
.s
[j
] !='\t' &&
129 if (++j
>= dsnline
.len
) break;
131 if (!stralloc_copyb(&boundary
,dsnline
.s
+i
,j
-i
)) die_nomem();
135 if (flagdsn
&& boundary
.len
) { /* parse DSN message */
136 get(&line
); /* if bad format we exit(0) via get() */
139 if (line
.len
== boundary
.len
+ 5 && line
.s
[line
.len
- 1] == '-'
140 && line
.s
[line
.len
- 2] == '-')
141 _exit(99); /* end: not failure report */
142 get(&line
); /* Content-type */
143 if (case_startb(line
.s
,line
.len
,"content-type:")) {
145 while (line
.s
[i
] == ' ' || line
.s
[i
] == '\t')
146 if (++i
>= line
.len
) break;
147 if (case_startb(line
.s
+i
,line
.len
-i
,"message/delivery-status")) {
150 if (isboundary()) break;
151 if (case_startb(line
.s
,line
.len
,"action:")) {
153 while (line
.s
[i
] == ' ' || line
.s
[i
] == '\t')
154 if (++i
>= line
.len
) break;
155 if (case_startb(line
.s
+ i
, line
.len
- i
,"failed"))
156 _exit(0); /* failure notice */
158 _exit(99); /* there shouldn't be more than 1 action */
177 if (stralloc_starts(&line1
,"This is a MIME-encapsulated message"))
178 if (stralloc_starts(&line3
,"--"))
179 if (stralloc_starts(&line5
,warn1
))
180 if (stralloc_starts(&line6
,warn2
))
181 if (stralloc_starts(&line7
,warn3
))
182 if (stralloc_starts(&line8
,warn4
))
185 if (stralloc_starts(&line1
,warn1
))
186 if (stralloc_starts(&line2
,warn2
))
187 if (stralloc_starts(&line3
,warn3
))
188 if (stralloc_starts(&line4
,warn4
))
191 if (flagmds
&& flagsw
&& flagas
&& flagbw
) _exit(99);
192 if (flagmds
&& flagsr
&& flagbw
) _exit(99);