- register char *p;
- char buf[MAXLINE],
- *malloc(), *strcpy();
-
- /* read the from line */
- if (!gets(buf) || strncmp(buf, "From ", 5)) {
- fputs("vacation: no initial From line.\n", stderr);
- exit(EX_DATAERR);
- }
-
- /* find the end of the sender address and terminate it */
- for (p = &buf[5]; *p && *p != ' '; ++p);
- if (!*p) {
- fprintf(stderr, "vacation: address terminated From line '%s'\n", buf);
+ register ALIAS *cur;
+ register char *p;
+ 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 (junkmail())
+ exit(EX_OK);
+ }
+ 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))
+ exit(EX_OK);
+ 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)
+ exit(EX_OK);
+ if (!*from) {
+ syslog(LOG_ERR, "vacation: no initial \"From\" line.\n");