130158Sbostic /* 2*33416Sbostic * Copyright (c) 1986, 1987 Regents of the University of California. 3*33416Sbostic * All rights reserved. 4*33416Sbostic * 5*33416Sbostic * Redistribution and use in source and binary forms are permitted 6*33416Sbostic * provided that this notice is preserved and that due credit is given 7*33416Sbostic * to the University of California at Berkeley. The name of the University 8*33416Sbostic * may not be used to endorse or promote products derived from this 9*33416Sbostic * software without specific prior written permission. This software 10*33416Sbostic * is provided ``as is'' without express or implied warranty. 1130158Sbostic */ 1230158Sbostic 1330158Sbostic #ifndef lint 14*33416Sbostic static char sccsid[] = "@(#)redist.c 5.6 (Berkeley) 02/01/88"; 15*33416Sbostic #endif /* not lint */ 1630158Sbostic 1730158Sbostic #include <sys/file.h> 1830158Sbostic #include <stdio.h> 1933024Sbostic #include <ctype.h> 2030158Sbostic #include <bug.h> 2130158Sbostic 2230158Sbostic /* 2330158Sbostic * redist -- 2430158Sbostic * Redistribute a bug report to those people indicated in the 2530158Sbostic * redistribution list file. 2630158Sbostic */ 2730158Sbostic redist() 2830158Sbostic { 2930890Sbostic extern FILE *dfp; /* dist file fp */ 3030890Sbostic extern char pfile[]; /* permanent bug file */ 3133024Sbostic register char *C1, *C2; 3233024Sbostic FILE *pf, *popen(); 3333024Sbostic int group; 3430890Sbostic char *index(); 3530158Sbostic 3633024Sbostic (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); 3730890Sbostic if (!freopen(bfr, "r", stdin)) 3830158Sbostic return; 3933024Sbostic for (pf = NULL, group = 0; gets(bfr);) { 4033024Sbostic if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) 4130158Sbostic continue; 4230158Sbostic *C1 = EOS; 4333024Sbostic if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { 4433024Sbostic for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 4533024Sbostic if (!*C1) /* if empty list */ 4633024Sbostic continue; 4733024Sbostic if (!pf) { 4833024Sbostic if (!(pf = popen(MAIL_CMD, "w"))) 4933024Sbostic error("sendmail pipe failed.", CHN); 5033024Sbostic if (mailhead[SUBJ_TAG].found) 5133024Sbostic fprintf(pf, "%s", mailhead[SUBJ_TAG].line); 5233024Sbostic else 5333024Sbostic fputs("Subject: Untitled Bug Report\n", pf); 5433024Sbostic if (!mailhead[TO_TAG].line && mailhead[APPAR_TO_TAG].line) 5533024Sbostic fprintf(pf, "To%s", index(mailhead[APPAR_TO_TAG].line, ':')); 5633024Sbostic fputs("Resent-To: ", pf); 5733024Sbostic } 5833024Sbostic /* 5933024Sbostic * write out first entry, then succeeding entries 6033024Sbostic * backward compatible, handles back slashes at end 6133024Sbostic * of line 6233024Sbostic */ 6333024Sbostic if (group++) 6433024Sbostic fputs(", ", pf); 6533024Sbostic for (;;) { 6633024Sbostic if (C2 = index(C1, '\\')) 6733024Sbostic *C2 = EOS; 6833024Sbostic fputs(C1, pf); 6933024Sbostic if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') 7033024Sbostic break; 7133024Sbostic for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 7233024Sbostic } 7333024Sbostic } 7430158Sbostic } 7533024Sbostic if (!pf) 7630158Sbostic return; 7730158Sbostic 7830890Sbostic putc('\n', pf); 7930158Sbostic 8030890Sbostic rewind(dfp); 8133024Sbostic /* add Reference header and copy bug report out */ 8233024Sbostic while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') 8333024Sbostic fputs(bfr, pf); 8433024Sbostic fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); 8533024Sbostic while (fgets(bfr, sizeof(bfr), dfp)) 8633024Sbostic fputs(bfr, pf); 8730890Sbostic (void)pclose(pf); 8830158Sbostic } 89