Commit | Line | Data |
---|---|---|
0c4713c9 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 | |
8 | static char sccsid[] = "@(#)redist.c 5.1 (Berkeley) 86/11/25"; | |
9 | #endif not lint | |
10 | ||
11 | #include <sys/file.h> | |
12 | #include <stdio.h> | |
13 | #include <bug.h> | |
14 | ||
15 | extern HEADER mailhead[]; /* mail headers */ | |
16 | extern char *distf, /* redist temp file */ | |
17 | pfile[], /* permanent bug file */ | |
18 | folder[]; /* system name */ | |
19 | ||
20 | /* | |
21 | * redist -- | |
22 | * Redistribute a bug report to those people indicated in the | |
23 | * redistribution list file. | |
24 | */ | |
25 | redist() | |
26 | { | |
27 | register char *C1, /* traveling chars */ | |
28 | *C2; | |
29 | register int first = YES; /* if first blank line */ | |
30 | FILE *pf, /* pipe pointer */ | |
31 | *dfp, /* dist file fp */ | |
32 | *popen(); | |
33 | char *index(), *mktemp(); | |
34 | ||
35 | if (!freopen(DIST_FILE,"r",stdin)) | |
36 | return; | |
37 | ||
38 | for (;;) { /* get first part of entry */ | |
39 | if (!gets(bfr)) | |
40 | return; | |
41 | if (*bfr == COMMENT || *bfr == ' ' || *bfr == '\t' || !(C1 = index(bfr,':'))) | |
42 | continue; | |
43 | *C1 = EOS; | |
44 | if (!strcmp(bfr,folder)) | |
45 | break; | |
46 | } | |
47 | for (++C1;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); | |
48 | if (!*C1) /* if empty */ | |
49 | return; | |
50 | ||
51 | if (!(pf = popen(MAIL_CMD,"w"))) | |
52 | error("sendmail pipe failed.",CHN); | |
53 | ||
54 | fprintf(pf,"Reply-To: %s\n",BUGS_HOME); | |
55 | if (mailhead[SUBJ_TAG].found) | |
56 | fprintf(pf,"%s",mailhead[SUBJ_TAG].line); | |
57 | else | |
58 | fputs("Subject: Untitled Bug Report\n",pf); | |
59 | fputs("Resent-To: ",pf); | |
60 | ||
61 | /* | |
62 | * write out first entry, then succeeding entries | |
63 | * backward compatible, handles back slashes at end of line | |
64 | */ | |
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 | fputs("\n",pf); | |
74 | ||
75 | if (!(dfp = fopen(distf,"r"))) | |
76 | error("unable to read temporary file %s.",distf); | |
77 | while (fgets(bfr,sizeof(bfr),dfp)) | |
78 | if (*bfr == '\n' && first) { | |
79 | first = NO; | |
80 | fprintf(pf,"\n%sReference: %s\n",mailhead[INDX_TAG].line,pfile); | |
81 | } | |
82 | else | |
83 | fputs(bfr,pf); | |
84 | fclose(dfp); | |
85 | pclose(pf); | |
86 | unlink(distf); | |
87 | } |