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.2 (Berkeley) 87/04/11"; 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 fprintf(pf, "Reply-To: %s\n", BUGS_HOME); 51 if (mailhead[SUBJ_TAG].found) 52 fprintf(pf, "%s", mailhead[SUBJ_TAG].line); 53 else 54 fputs("Subject: Untitled Bug Report\n", pf); 55 fputs("Resent-To: ", pf); 56 57 /* 58 * write out first entry, then succeeding entries 59 * backward compatible, handles back slashes at end of line 60 */ 61 for (;;) { 62 if (C2 = index(C1, '\\')) 63 *C2 = EOS; 64 fputs(C1, pf); 65 if (!gets(bfr) || (*bfr != ' ' && *bfr != '\t')) 66 break; 67 for (C1 = bfr;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); 68 } 69 putc('\n', pf); 70 71 rewind(dfp); 72 for (first = YES;fgets(bfr, sizeof(bfr), dfp);) 73 if (*bfr == '\n' && first) { 74 first = NO; 75 fprintf(pf, "\n%sReference: %s\n", mailhead[INDX_TAG].line, pfile); 76 } 77 else 78 fputs(bfr, pf); 79 (void)pclose(pf); 80 (void)fclose(dfp); 81 } 82