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 are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)redist.c 5.9 (Berkeley) 05/11/89"; 20 #endif /* not lint */ 21 22 #include <sys/file.h> 23 #include <stdio.h> 24 #include <ctype.h> 25 #include <bug.h> 26 #include "pathnames.h" 27 28 /* 29 * redist -- 30 * Redistribute a bug report to those people indicated in the 31 * redistribution list file. 32 */ 33 redist() 34 { 35 extern FILE *dfp; /* dist file fp */ 36 extern char pfile[]; /* permanent bug file */ 37 register char *C1, *C2; 38 FILE *pf, *popen(); 39 int group; 40 char *index(); 41 42 (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); 43 if (!freopen(bfr, "r", stdin)) 44 return; 45 for (pf = NULL, group = 0; gets(bfr);) { 46 if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) 47 continue; 48 *C1 = EOS; 49 if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { 50 for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 51 if (!*C1) /* if empty list */ 52 continue; 53 if (!pf) { 54 if (!(pf = popen(MAIL_CMD, "w"))) 55 error("sendmail pipe failed.", CHN); 56 if (mailhead[SUBJ_TAG].found) 57 fprintf(pf, "%s", mailhead[SUBJ_TAG].line); 58 else 59 fputs("Subject: Untitled Bug Report\n", pf); 60 if (!mailhead[TO_TAG].line) { 61 if (mailhead[APPAR_TO_TAG].line) 62 fprintf(pf, "To%s", 63 index(mailhead[APPAR_TO_TAG].line, 64 ':')); 65 else 66 fprintf(pf, "To: %s\n", BUGS_ID); 67 } 68 fputs("Resent-To: ", pf); 69 } 70 /* 71 * write out first entry, then succeeding entries 72 * backward compatible, handles back slashes at end 73 * of line 74 */ 75 if (group++) 76 fputs(", ", pf); 77 for (;;) { 78 if (C2 = index(C1, '\\')) 79 *C2 = EOS; 80 fputs(C1, pf); 81 if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') 82 break; 83 for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 84 } 85 } 86 } 87 if (!pf) 88 return; 89 90 putc('\n', pf); 91 92 rewind(dfp); 93 /* add Reference header and copy bug report out */ 94 while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') 95 fputs(bfr, pf); 96 fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); 97 while (fgets(bfr, sizeof(bfr), dfp)) 98 fputs(bfr, pf); 99 (void)pclose(pf); 100 } 101