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[] = "@(#)redist.c 5.12 (Berkeley) 4/1/91"; | |
36 | #endif /* not lint */ | |
37 | ||
38 | #include <sys/param.h> | |
39 | #include <dirent.h> | |
40 | #include <stdio.h> | |
41 | #include <ctype.h> | |
42 | #include <string.h> | |
43 | #include "bug.h" | |
44 | #include "pathnames.h" | |
45 | ||
46 | /* | |
47 | * redist -- | |
48 | * Redistribute a bug report to those people indicated in the | |
49 | * redistribution list file. | |
50 | */ | |
51 | redist() | |
52 | { | |
53 | extern FILE *dfp; /* dist file fp */ | |
54 | extern char pfile[]; /* permanent bug file */ | |
55 | register char *C1, *C2; | |
56 | FILE *pf, *popen(); | |
57 | int group; | |
58 | char *p, *index(); | |
59 | ||
60 | (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); | |
61 | if (!freopen(bfr, "r", stdin)) | |
62 | return; | |
63 | for (pf = NULL, group = 0; fgets(bfr, sizeof(bfr), stdin);) { | |
64 | if (C1 = index(bfr, '\n')) | |
65 | *C1 = '\0'; | |
66 | nextline: if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) | |
67 | continue; | |
68 | *C1 = EOS; | |
69 | if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { | |
70 | for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
71 | if (!*C1) /* if empty list */ | |
72 | continue; | |
73 | if (!pf) { | |
74 | if (!(pf = popen(MAIL_CMD, "w"))) | |
75 | error("sendmail pipe failed.", CHN); | |
76 | if (mailhead[SUBJ_TAG].found) | |
77 | fprintf(pf, | |
78 | "%s", mailhead[SUBJ_TAG].line); | |
79 | else | |
80 | fprintf(pf, | |
81 | "Subject: Untitled Bug Report\n"); | |
82 | if (!mailhead[TO_TAG].line) { | |
83 | if (mailhead[APPAR_TO_TAG].line) | |
84 | fprintf(pf, "To%s", | |
85 | index(mailhead[APPAR_TO_TAG].line, | |
86 | ':')); | |
87 | else | |
88 | fprintf(pf, "To: %s\n", BUGS_ID); | |
89 | } | |
90 | fputs("Resent-To: ", pf); | |
91 | } | |
92 | /* | |
93 | * write out first entry, then succeeding entries | |
94 | * backward compatible, handles back slashes at end | |
95 | * of line | |
96 | */ | |
97 | if (group++) | |
98 | fputs(", ", pf); | |
99 | for (;;) { | |
100 | if (C2 = index(C1, '\\')) | |
101 | *C2 = EOS; | |
102 | fputs(C1, pf); | |
103 | if (!fgets(bfr, sizeof(bfr), stdin)) | |
104 | break; | |
105 | if (C1 = index(bfr, '\n')) | |
106 | *C1 = '\0'; | |
107 | if (*bfr != ' ' && *bfr != '\t') | |
108 | goto nextline; | |
109 | for (C1 = bfr; | |
110 | *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
111 | } | |
112 | } | |
113 | } | |
114 | if (!pf) | |
115 | return; | |
116 | ||
117 | putc('\n', pf); | |
118 | ||
119 | rewind(dfp); | |
120 | /* add Reference header and copy bug report out */ | |
121 | while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') | |
122 | fputs(bfr, pf); | |
123 | fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); | |
124 | while (fgets(bfr, sizeof(bfr), dfp)) | |
125 | fputs(bfr, pf); | |
126 | (void)pclose(pf); | |
127 | } |