Commit | Line | Data |
---|---|---|
85ca7091 KB |
1 | /* |
2 | * Copyright (c) 1986 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
7 | #ifndef lint | |
3fa5a997 | 8 | static char sccsid[] = "@(#)reply.c 5.3 (Berkeley) 87/07/20"; |
85ca7091 KB |
9 | #endif not lint |
10 | ||
11 | #include <bug.h> | |
12 | #include <sys/file.h> | |
13 | #include <stdio.h> | |
14 | ||
85ca7091 KB |
15 | /* |
16 | * reply -- | |
d8336336 | 17 | * tell the user we got their silly little bug report |
85ca7091 KB |
18 | */ |
19 | reply() | |
20 | { | |
21 | register char *C, /* traveling pointer */ | |
22 | *to; /* who we're replying to */ | |
23 | register int afd, /* ack file descriptor */ | |
24 | rval; /* return value */ | |
25 | FILE *pf, /* pipe pointer */ | |
26 | *popen(); | |
d8336336 | 27 | char *index(); |
85ca7091 KB |
28 | |
29 | if (mailhead[RPLY_TAG].found) { | |
30 | for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
31 | if (*C) | |
32 | goto gotone; | |
33 | } | |
34 | if (mailhead[FROM_TAG].found) { | |
35 | for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
36 | if (*C) | |
37 | goto gotone; | |
38 | } | |
39 | if (mailhead[CFROM_TAG].found) { | |
40 | for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
41 | if (*C) | |
42 | goto gotone; | |
43 | } | |
44 | return; | |
45 | ||
46 | /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ | |
d8336336 | 47 | gotone: if (to = index(C, '<')) |
85ca7091 KB |
48 | for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); |
49 | else { | |
50 | to = C; | |
51 | for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); | |
52 | } | |
53 | *C = EOS; | |
54 | ||
d8336336 KB |
55 | if (!(pf = popen(MAIL_CMD, "w"))) |
56 | error("sendmail pipe failed.", CHN); | |
85ca7091 | 57 | |
d8336336 | 58 | fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); |
85ca7091 | 59 | if (mailhead[SUBJ_TAG].found) |
d8336336 | 60 | fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); |
85ca7091 | 61 | else |
d8336336 | 62 | fputs("Subject: Bug report acknowledgement.\n", pf); |
85ca7091 | 63 | if (mailhead[DATE_TAG].found) |
d8336336 | 64 | fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); |
85ca7091 | 65 | if (mailhead[MSG_TAG].found) |
d8336336 | 66 | fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); |
3fa5a997 | 67 | fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ |
85ca7091 KB |
68 | fflush(pf); |
69 | ||
d8336336 KB |
70 | if ((afd = open(ACK_FILE, O_RDONLY, 0)) >= 0) { |
71 | while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) | |
72 | (void)write(fileno(pf), bfr, rval); | |
73 | (void)close(afd); | |
85ca7091 | 74 | } |
85ca7091 KB |
75 | pclose(pf); |
76 | } |