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.4 (Berkeley) 87/09/01"; 9 #endif not lint 10 11 #include <sys/file.h> 12 #include <stdio.h> 13 #include <bug.h> 14 15 /* 16 * redist -- 17 * Redistribute a bug report to those people indicated in the 18 * redistribution list file. 19 */ 20 redist() 21 { 22 extern FILE *dfp; /* dist file fp */ 23 extern char pfile[]; /* permanent bug file */ 24 register char *C1, 25 *C2; 26 register int first; /* if first blank line */ 27 FILE *pf, 28 *popen(); 29 char *index(); 30 31 sprintf(bfr, "%s/%s", dir, DIST_FILE); 32 if (!freopen(bfr, "r", stdin)) 33 return; 34 for (;;) { /* get first part of entry */ 35 if (!gets(bfr)) 36 return; 37 if (*bfr == COMMENT || *bfr == ' ' || *bfr == '\t' || !(C1 = index(bfr, ':'))) 38 continue; 39 *C1 = EOS; 40 if (!strcmp(bfr, folder)) 41 break; 42 } 43 for (++C1;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); 44 if (!*C1) /* if empty */ 45 return; 46 47 if (!(pf = popen(MAIL_CMD, "w"))) 48 error("sendmail pipe failed.", CHN); 49 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 == 0 && mailhead[APPAR_TO_TAG].line != 0) 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 of line 61 */ 62 for (;;) { 63 if (C2 = index(C1, '\\')) 64 *C2 = EOS; 65 fputs(C1, pf); 66 if (!gets(bfr) || (*bfr != ' ' && *bfr != '\t')) 67 break; 68 for (C1 = bfr;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); 69 } 70 putc('\n', pf); 71 72 rewind(dfp); 73 for (first = YES;fgets(bfr, sizeof(bfr), dfp);) 74 if (*bfr == '\n' && first) { 75 first = NO; 76 fprintf(pf, "\n%sReference: %s\n", mailhead[INDX_TAG].line, pfile); 77 } 78 else 79 fputs(bfr, pf); 80 (void)pclose(pf); 81 } 82