- extern char *index();
-
- /* read the from line */
- if (fgets(line, sizeof line, stdin) == NULL ||
- strncmp(line, "From ", 5) != NULL)
- {
- usrerr("No initial From line");
- exit(EX_USAGE);
+ int tome, cont;
+ char buf[MAXLINE], *strcpy(), *index();
+
+ cont = tome = 0;
+ while (fgets(buf, sizeof(buf), stdin) && *buf != '\n')
+ switch(*buf) {
+ case 'F': /* "From " */
+ cont = 0;
+ if (!strncmp(buf, "From ", 5)) {
+ for (p = buf + 5; *p && *p != ' '; ++p);
+ *p = '\0';
+ (void)strcpy(from, buf + 5);
+ if (p = index(from, '\n'))
+ *p = '\0';
+ if (junkmail())
+ myexit(0);
+ }
+ break;
+ case 'P': /* "Precedence:" */
+ cont = 0;
+ if (strncasecmp(buf, "Precedence", 10) || buf[10] != ':' && buf[10] != ' ' && buf[10] != '\t')
+ break;
+ if (!(p = index(buf, ':')))
+ break;
+ while (*++p && isspace(*p));
+ if (!*p)
+ break;
+ if (!strncasecmp(p, "junk", 4) || !strncasecmp(p, "bulk", 4))
+ myexit(0);
+ break;
+ case 'C': /* "Cc:" */
+ if (strncmp(buf, "Cc:", 3))
+ break;
+ cont = 1;
+ goto findme;
+ case 'T': /* "To:" */
+ if (strncmp(buf, "To:", 3))
+ break;
+ cont = 1;
+ goto findme;
+ default:
+ if (!isspace(*buf) || !cont || tome) {
+ cont = 0;
+ break;
+ }
+findme: for (cur = names; !tome && cur; cur = cur->next)
+ tome += nsearch(cur->name, buf);
+ }
+ if (!tome)
+ myexit(0);
+ if (!*from) {
+ syslog(LOG_NOTICE, "vacation: no initial \"From\" line.\n");
+ myexit(1);