+stralloc to = {0};
+stralloc outhost = {0};
+stralloc outlocal = {0};
+stralloc content = {0};
+stralloc subject = {0};
+stralloc boundary = {0};
+stralloc precd = {0};
+stralloc mydtline = {0};
+
+void die_nomem()
+{
+ strerr_die2x(100,FATAL,ERR_NOMEM);
+}
+
+void die_usage()
+{
+ strerr_die2x(100,FATAL,"usage: ezmlm-reject [-bBcCfFhHqQsStT] [dir]");
+}
+
+unsigned int findlocal(sa,n)
+ /* n is index of '@' within sa. Returns index to last postition */
+ /* of local, n otherwise. */
+stralloc *sa; /* line */
+unsigned int n;
+{
+ char *first;
+ register char *s;
+ register int level = 0;
+
+ first = sa->s;
+ s = sa->s + n;
+ if (s <= first) return n;
+ while (--s >= first) {
+ switch (*s) {
+ case ' ': case '\t': case '\n': break;
+ case ')':
+ if (--s <= first) return n;
+ if (*s == '\\') break;
+ ++level; ++s;
+ while (level && --s > first) {
+ if (*s == ')') if (*(s-1) != '\\') ++level;
+ if (*s == '(') if (*(s-1) != '\\') --level;
+ }
+ break;
+ case '"':
+ --s;
+ if (s < first) return n;
+ return (unsigned int) (s - first);
+ default:
+ return (unsigned int) (s - first);
+ }
+#include "env.h"
+ }
+}
+
+unsigned int findhost(sa,n)
+ /* s in index to a '@' within sa. Returns index to first pos of */
+ /* host part if there is one, n otherwise. */
+stralloc *sa; /* line */
+unsigned int n;
+{
+ char *last;
+ register char *s;
+ register int level = 0;
+
+ last = sa->s + sa->len - 1;
+ s = sa->s + n;
+ if (s >= last) return n;
+ while (++s <= last) {
+ switch (*s) {
+ case ' ': case '\t': case '\n': break;
+ case '(':
+ ++level;
+ while (level && (++s < last)) {
+ if (*s == ')') --level; if (!level) break;
+ if (*s == '(') ++level;
+ if (*s == '\\') ++s;
+ }
+ break;
+ case '"':
+ while (++s < last) {
+ if (*s == '"') break;
+ if (*s == '\\') ++s;
+ }
+ break;
+ default:
+ return (unsigned int) (s - sa->s);
+ }
+ }
+}
+
+int getto(sa)
+ /* find list address in line. If found, return 1, else return 0. */
+ stralloc *sa;
+{
+ unsigned int pos = 0;
+ unsigned int pos1;
+
+ if (!sa->len) return 0; /* no To: or Cc: line */
+ while ((pos += 1 + byte_chr(sa->s+pos+1,sa->len-pos-1,'@')) != sa->len) {
+ pos1 = findhost(sa,pos);
+ if (pos1 == pos) break;
+ if (pos1 + outhost.len <= sa->len)
+ if (!case_diffb(sa->s+pos1,outhost.len,outhost.s)) { /* got host */
+ pos1 = findlocal(sa,pos);
+ if (pos1 == pos) break;
+ ++pos1; /* avoids 1 x 2 below */
+ if (pos1 >= outlocal.len)
+ if (!case_diffb(sa->s+pos1-outlocal.len,outlocal.len,outlocal.s))
+ return 1; /* got local as well */
+ }
+ }
+ return 0;
+}