Commit | Line | Data |
---|---|---|
0c4713c9 | 1 | /* |
aec2eff2 KB |
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 are permitted | |
6 | * provided that this notice is preserved and that due credit is given | |
7 | * to the University of California at Berkeley. The name of the University | |
8 | * may not be used to endorse or promote products derived from this | |
9 | * software without specific prior written permission. This software | |
10 | * is provided ``as is'' without express or implied warranty. | |
0c4713c9 KB |
11 | */ |
12 | ||
13 | #ifndef lint | |
aec2eff2 KB |
14 | static char sccsid[] = "@(#)redist.c 5.6 (Berkeley) %G%"; |
15 | #endif /* not lint */ | |
0c4713c9 KB |
16 | |
17 | #include <sys/file.h> | |
18 | #include <stdio.h> | |
defca596 | 19 | #include <ctype.h> |
0c4713c9 KB |
20 | #include <bug.h> |
21 | ||
0c4713c9 KB |
22 | /* |
23 | * redist -- | |
24 | * Redistribute a bug report to those people indicated in the | |
25 | * redistribution list file. | |
26 | */ | |
27 | redist() | |
28 | { | |
d8336336 KB |
29 | extern FILE *dfp; /* dist file fp */ |
30 | extern char pfile[]; /* permanent bug file */ | |
defca596 KB |
31 | register char *C1, *C2; |
32 | FILE *pf, *popen(); | |
33 | int group; | |
d8336336 | 34 | char *index(); |
0c4713c9 | 35 | |
defca596 | 36 | (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); |
d8336336 | 37 | if (!freopen(bfr, "r", stdin)) |
0c4713c9 | 38 | return; |
defca596 KB |
39 | for (pf = NULL, group = 0; gets(bfr);) { |
40 | if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) | |
0c4713c9 KB |
41 | continue; |
42 | *C1 = EOS; | |
defca596 KB |
43 | if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { |
44 | for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
45 | if (!*C1) /* if empty list */ | |
46 | continue; | |
47 | if (!pf) { | |
48 | if (!(pf = popen(MAIL_CMD, "w"))) | |
49 | error("sendmail pipe failed.", CHN); | |
50 | if (mailhead[SUBJ_TAG].found) | |
51 | fprintf(pf, "%s", mailhead[SUBJ_TAG].line); | |
52 | else | |
53 | fputs("Subject: Untitled Bug Report\n", pf); | |
54 | if (!mailhead[TO_TAG].line && mailhead[APPAR_TO_TAG].line) | |
55 | fprintf(pf, "To%s", index(mailhead[APPAR_TO_TAG].line, ':')); | |
56 | fputs("Resent-To: ", pf); | |
57 | } | |
58 | /* | |
59 | * write out first entry, then succeeding entries | |
60 | * backward compatible, handles back slashes at end | |
61 | * of line | |
62 | */ | |
63 | if (group++) | |
64 | fputs(", ", pf); | |
65 | for (;;) { | |
66 | if (C2 = index(C1, '\\')) | |
67 | *C2 = EOS; | |
68 | fputs(C1, pf); | |
69 | if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') | |
70 | break; | |
71 | for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); | |
72 | } | |
73 | } | |
0c4713c9 | 74 | } |
defca596 | 75 | if (!pf) |
0c4713c9 KB |
76 | return; |
77 | ||
d8336336 | 78 | putc('\n', pf); |
0c4713c9 | 79 | |
d8336336 | 80 | rewind(dfp); |
defca596 KB |
81 | /* add Reference header and copy bug report out */ |
82 | while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') | |
83 | fputs(bfr, pf); | |
84 | fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); | |
85 | while (fgets(bfr, sizeof(bfr), dfp)) | |
86 | fputs(bfr, pf); | |
d8336336 | 87 | (void)pclose(pf); |
0c4713c9 | 88 | } |