Commit | Line | Data |
---|---|---|
0c4713c9 | 1 | /* |
aec2eff2 KB |
2 | * Copyright (c) 1986, 1987 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
1343342a | 5 | * %sccs.include.redist.c% |
0c4713c9 KB |
6 | */ |
7 | ||
8 | #ifndef lint | |
d0ef4a0d | 9 | static char sccsid[] = "@(#)redist.c 5.11 (Berkeley) %G%"; |
aec2eff2 | 10 | #endif /* not lint */ |
0c4713c9 | 11 | |
d0ef4a0d KB |
12 | #include <sys/param.h> |
13 | #include <dirent.h> | |
0c4713c9 | 14 | #include <stdio.h> |
defca596 | 15 | #include <ctype.h> |
d0ef4a0d KB |
16 | #include <string.h> |
17 | #include "bug.h" | |
435e8dff | 18 | #include "pathnames.h" |
0c4713c9 | 19 | |
0c4713c9 KB |
20 | /* |
21 | * redist -- | |
22 | * Redistribute a bug report to those people indicated in the | |
23 | * redistribution list file. | |
24 | */ | |
25 | redist() | |
26 | { | |
d8336336 KB |
27 | extern FILE *dfp; /* dist file fp */ |
28 | extern char pfile[]; /* permanent bug file */ | |
defca596 KB |
29 | register char *C1, *C2; |
30 | FILE *pf, *popen(); | |
31 | int group; | |
d8336336 | 32 | char *index(); |
0c4713c9 | 33 | |
defca596 | 34 | (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); |
d8336336 | 35 | if (!freopen(bfr, "r", stdin)) |
0c4713c9 | 36 | return; |
defca596 KB |
37 | for (pf = NULL, group = 0; gets(bfr);) { |
38 | if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) | |
0c4713c9 KB |
39 | continue; |
40 | *C1 = EOS; | |
defca596 KB |
41 | if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { |
42 | for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
43 | if (!*C1) /* if empty list */ | |
44 | continue; | |
45 | if (!pf) { | |
46 | if (!(pf = popen(MAIL_CMD, "w"))) | |
47 | error("sendmail pipe failed.", CHN); | |
48 | if (mailhead[SUBJ_TAG].found) | |
49 | fprintf(pf, "%s", mailhead[SUBJ_TAG].line); | |
50 | else | |
51 | fputs("Subject: Untitled Bug Report\n", pf); | |
194c0a19 MK |
52 | if (!mailhead[TO_TAG].line) { |
53 | if (mailhead[APPAR_TO_TAG].line) | |
54 | fprintf(pf, "To%s", | |
55 | index(mailhead[APPAR_TO_TAG].line, | |
56 | ':')); | |
57 | else | |
58 | fprintf(pf, "To: %s\n", BUGS_ID); | |
59 | } | |
defca596 KB |
60 | fputs("Resent-To: ", pf); |
61 | } | |
62 | /* | |
63 | * write out first entry, then succeeding entries | |
64 | * backward compatible, handles back slashes at end | |
65 | * of line | |
66 | */ | |
67 | if (group++) | |
68 | fputs(", ", pf); | |
69 | for (;;) { | |
70 | if (C2 = index(C1, '\\')) | |
71 | *C2 = EOS; | |
72 | fputs(C1, pf); | |
73 | if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') | |
74 | break; | |
75 | for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
76 | } | |
77 | } | |
0c4713c9 | 78 | } |
defca596 | 79 | if (!pf) |
0c4713c9 KB |
80 | return; |
81 | ||
d8336336 | 82 | putc('\n', pf); |
0c4713c9 | 83 | |
d8336336 | 84 | rewind(dfp); |
defca596 KB |
85 | /* add Reference header and copy bug report out */ |
86 | while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') | |
87 | fputs(bfr, pf); | |
88 | fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); | |
89 | while (fgets(bfr, sizeof(bfr), dfp)) | |
90 | fputs(bfr, pf); | |
d8336336 | 91 | (void)pclose(pf); |
0c4713c9 | 92 | } |