Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Copyright (c) 1986, 1987 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef lint | |
35 | static char sccsid[] = "@(#)reply.c 5.9 (Berkeley) 2/25/91"; | |
36 | #endif /* not lint */ | |
37 | ||
38 | #include <sys/param.h> | |
39 | #include <fcntl.h> | |
40 | #include <dirent.h> | |
41 | #include <stdio.h> | |
42 | #include <string.h> | |
43 | #include "bug.h" | |
44 | #include "pathnames.h" | |
45 | ||
46 | /* | |
47 | * reply -- | |
48 | * tell the user we got their silly little bug report | |
49 | */ | |
50 | reply() | |
51 | { | |
52 | register char *C, /* traveling pointer */ | |
53 | *to; /* who we're replying to */ | |
54 | register int afd, /* ack file descriptor */ | |
55 | rval; /* return value */ | |
56 | FILE *pf, /* pipe pointer */ | |
57 | *popen(); | |
58 | char *index(); | |
59 | ||
60 | if (mailhead[RPLY_TAG].found) { | |
61 | for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
62 | if (*C) | |
63 | goto gotone; | |
64 | } | |
65 | if (mailhead[FROM_TAG].found) { | |
66 | for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
67 | if (*C) | |
68 | goto gotone; | |
69 | } | |
70 | if (mailhead[CFROM_TAG].found) { | |
71 | for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
72 | if (*C) | |
73 | goto gotone; | |
74 | } | |
75 | return; | |
76 | ||
77 | /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ | |
78 | gotone: if (to = index(C, '<')) | |
79 | for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); | |
80 | else { | |
81 | to = C; | |
82 | for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); | |
83 | } | |
84 | *C = EOS; | |
85 | ||
86 | if (!(pf = popen(MAIL_CMD, "w"))) | |
87 | error("sendmail pipe failed.", CHN); | |
88 | ||
89 | fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); | |
90 | if (mailhead[SUBJ_TAG].found) | |
91 | fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); | |
92 | else | |
93 | fputs("Subject: Bug report acknowledgement.\n", pf); | |
94 | if (mailhead[DATE_TAG].found) | |
95 | fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); | |
96 | if (mailhead[MSG_TAG].found) | |
97 | fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); | |
98 | fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ | |
99 | fflush(pf); | |
100 | ||
101 | (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); | |
102 | if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { | |
103 | while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) | |
104 | (void)write(fileno(pf), bfr, rval); | |
105 | (void)close(afd); | |
106 | } | |
107 | pclose(pf); | |
108 | } |