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.8 (Berkeley) 06/29/88"; 20 #endif /* not lint */ 21 22 #include <sys/file.h> 23 #include <stdio.h> 24 #include <ctype.h> 25 #include <bug.h> 26 27 /* 28 * redist -- 29 * Redistribute a bug report to those people indicated in the 30 * redistribution list file. 31 */ 32 redist() 33 { 34 extern FILE *dfp; /* dist file fp */ 35 extern char pfile[]; /* permanent bug file */ 36 register char *C1, *C2; 37 FILE *pf, *popen(); 38 int group; 39 char *index(); 40 41 (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); 42 if (!freopen(bfr, "r", stdin)) 43 return; 44 for (pf = NULL, group = 0; gets(bfr);) { 45 if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) 46 continue; 47 *C1 = EOS; 48 if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { 49 for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 50 if (!*C1) /* if empty list */ 51 continue; 52 if (!pf) { 53 if (!(pf = popen(MAIL_CMD, "w"))) 54 error("sendmail pipe failed.", CHN); 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 if (!mailhead[TO_TAG].line) { 60 if (mailhead[APPAR_TO_TAG].line) 61 fprintf(pf, "To%s", 62 index(mailhead[APPAR_TO_TAG].line, 63 ':')); 64 else 65 fprintf(pf, "To: %s\n", BUGS_ID); 66 } 67 fputs("Resent-To: ", pf); 68 } 69 /* 70 * write out first entry, then succeeding entries 71 * backward compatible, handles back slashes at end 72 * of line 73 */ 74 if (group++) 75 fputs(", ", pf); 76 for (;;) { 77 if (C2 = index(C1, '\\')) 78 *C2 = EOS; 79 fputs(C1, pf); 80 if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') 81 break; 82 for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 83 } 84 } 85 } 86 if (!pf) 87 return; 88 89 putc('\n', pf); 90 91 rewind(dfp); 92 /* add Reference header and copy bug report out */ 93 while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') 94 fputs(bfr, pf); 95 fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); 96 while (fgets(bfr, sizeof(bfr), dfp)) 97 fputs(bfr, pf); 98 (void)pclose(pf); 99 } 100