1 /* 2 * Copyright (c) 1986, 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)redist.c 5.11 (Berkeley) 02/25/91"; 10 #endif /* not lint */ 11 12 #include <sys/param.h> 13 #include <dirent.h> 14 #include <stdio.h> 15 #include <ctype.h> 16 #include <string.h> 17 #include "bug.h" 18 #include "pathnames.h" 19 20 /* 21 * redist -- 22 * Redistribute a bug report to those people indicated in the 23 * redistribution list file. 24 */ 25 redist() 26 { 27 extern FILE *dfp; /* dist file fp */ 28 extern char pfile[]; /* permanent bug file */ 29 register char *C1, *C2; 30 FILE *pf, *popen(); 31 int group; 32 char *index(); 33 34 (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); 35 if (!freopen(bfr, "r", stdin)) 36 return; 37 for (pf = NULL, group = 0; gets(bfr);) { 38 if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) 39 continue; 40 *C1 = EOS; 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); 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 } 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 } 78 } 79 if (!pf) 80 return; 81 82 putc('\n', pf); 83 84 rewind(dfp); 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); 91 (void)pclose(pf); 92 } 93