130158Sbostic /* 233416Sbostic * Copyright (c) 1986, 1987 Regents of the University of California. 333416Sbostic * All rights reserved. 433416Sbostic * 5*42663Sbostic * %sccs.include.redist.c% 630158Sbostic */ 730158Sbostic 830158Sbostic #ifndef lint 9*42663Sbostic static char sccsid[] = "@(#)redist.c 5.10 (Berkeley) 06/01/90"; 1033416Sbostic #endif /* not lint */ 1130158Sbostic 1230158Sbostic #include <sys/file.h> 1330158Sbostic #include <stdio.h> 1433024Sbostic #include <ctype.h> 1530158Sbostic #include <bug.h> 1637887Sbostic #include "pathnames.h" 1730158Sbostic 1830158Sbostic /* 1930158Sbostic * redist -- 2030158Sbostic * Redistribute a bug report to those people indicated in the 2130158Sbostic * redistribution list file. 2230158Sbostic */ 2330158Sbostic redist() 2430158Sbostic { 2530890Sbostic extern FILE *dfp; /* dist file fp */ 2630890Sbostic extern char pfile[]; /* permanent bug file */ 2733024Sbostic register char *C1, *C2; 2833024Sbostic FILE *pf, *popen(); 2933024Sbostic int group; 3030890Sbostic char *index(); 3130158Sbostic 3233024Sbostic (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); 3330890Sbostic if (!freopen(bfr, "r", stdin)) 3430158Sbostic return; 3533024Sbostic for (pf = NULL, group = 0; gets(bfr);) { 3633024Sbostic if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) 3730158Sbostic continue; 3830158Sbostic *C1 = EOS; 3933024Sbostic if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { 4033024Sbostic for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 4133024Sbostic if (!*C1) /* if empty list */ 4233024Sbostic continue; 4333024Sbostic if (!pf) { 4433024Sbostic if (!(pf = popen(MAIL_CMD, "w"))) 4533024Sbostic error("sendmail pipe failed.", CHN); 4633024Sbostic if (mailhead[SUBJ_TAG].found) 4733024Sbostic fprintf(pf, "%s", mailhead[SUBJ_TAG].line); 4833024Sbostic else 4933024Sbostic fputs("Subject: Untitled Bug Report\n", pf); 5033928Skarels if (!mailhead[TO_TAG].line) { 5133928Skarels if (mailhead[APPAR_TO_TAG].line) 5233928Skarels fprintf(pf, "To%s", 5333928Skarels index(mailhead[APPAR_TO_TAG].line, 5433928Skarels ':')); 5533928Skarels else 5633928Skarels fprintf(pf, "To: %s\n", BUGS_ID); 5733928Skarels } 5833024Sbostic fputs("Resent-To: ", pf); 5933024Sbostic } 6033024Sbostic /* 6133024Sbostic * write out first entry, then succeeding entries 6233024Sbostic * backward compatible, handles back slashes at end 6333024Sbostic * of line 6433024Sbostic */ 6533024Sbostic if (group++) 6633024Sbostic fputs(", ", pf); 6733024Sbostic for (;;) { 6833024Sbostic if (C2 = index(C1, '\\')) 6933024Sbostic *C2 = EOS; 7033024Sbostic fputs(C1, pf); 7133024Sbostic if (!gets(bfr) || *bfr != ' ' && *bfr != '\t') 7233024Sbostic break; 7333024Sbostic for (C1 = bfr; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); 7433024Sbostic } 7533024Sbostic } 7630158Sbostic } 7733024Sbostic if (!pf) 7830158Sbostic return; 7930158Sbostic 8030890Sbostic putc('\n', pf); 8130158Sbostic 8230890Sbostic rewind(dfp); 8333024Sbostic /* add Reference header and copy bug report out */ 8433024Sbostic while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') 8533024Sbostic fputs(bfr, pf); 8633024Sbostic fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); 8733024Sbostic while (fgets(bfr, sizeof(bfr), dfp)) 8833024Sbostic fputs(bfr, pf); 8930890Sbostic (void)pclose(pf); 9030158Sbostic } 91