130159Sbostic /* 233416Sbostic * Copyright (c) 1986, 1987 Regents of the University of California. 333416Sbostic * All rights reserved. 433416Sbostic * 542663Sbostic * %sccs.include.redist.c% 630159Sbostic */ 730159Sbostic 830159Sbostic #ifndef lint 9*60083Sbostic static char sccsid[] = "@(#)reply.c 5.10 (Berkeley) 05/17/93"; 1033416Sbostic #endif /* not lint */ 1130159Sbostic 1246667Sbostic #include <sys/param.h> 13*60083Sbostic 14*60083Sbostic #include <dirent.h> 1546667Sbostic #include <fcntl.h> 1630159Sbostic #include <stdio.h> 1746667Sbostic #include <string.h> 18*60083Sbostic #include <unistd.h> 19*60083Sbostic 2046667Sbostic #include "bug.h" 21*60083Sbostic #include "extern.h" 2237887Sbostic #include "pathnames.h" 2330159Sbostic 2430159Sbostic /* 2530159Sbostic * reply -- 2630890Sbostic * tell the user we got their silly little bug report 2730159Sbostic */ 28*60083Sbostic void 2930159Sbostic reply() 3030159Sbostic { 3130159Sbostic register char *C, /* traveling pointer */ 3230159Sbostic *to; /* who we're replying to */ 3330159Sbostic register int afd, /* ack file descriptor */ 3430159Sbostic rval; /* return value */ 35*60083Sbostic FILE *pf; /* pipe pointer */ 3630159Sbostic 3730159Sbostic if (mailhead[RPLY_TAG].found) { 38*60083Sbostic for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len; 39*60083Sbostic *C != '\n' && (*C == ' ' || *C == '\t');++C); 4030159Sbostic if (*C) 4130159Sbostic goto gotone; 4230159Sbostic } 4330159Sbostic if (mailhead[FROM_TAG].found) { 44*60083Sbostic for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len; 45*60083Sbostic *C != '\n' && (*C == ' ' || *C == '\t');++C); 4630159Sbostic if (*C) 4730159Sbostic goto gotone; 4830159Sbostic } 4930159Sbostic if (mailhead[CFROM_TAG].found) { 50*60083Sbostic for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len; 51*60083Sbostic *C != '\n' && (*C == ' ' || *C == '\t');++C); 5230159Sbostic if (*C) 5330159Sbostic goto gotone; 5430159Sbostic } 5530159Sbostic return; 5630159Sbostic 5730159Sbostic /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 58*60083Sbostic gotone: if (to = strchr(C, '<')) 59*60083Sbostic for (C = ++to; 60*60083Sbostic *C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); 6130159Sbostic else { 6230159Sbostic to = C; 6330159Sbostic for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); 6430159Sbostic } 6530159Sbostic *C = EOS; 6630159Sbostic 6730890Sbostic if (!(pf = popen(MAIL_CMD, "w"))) 6830890Sbostic error("sendmail pipe failed.", CHN); 6930159Sbostic 70*60083Sbostic fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", 71*60083Sbostic BUGS_HOME, BUGS_HOME, to); 7230159Sbostic if (mailhead[SUBJ_TAG].found) 73*60083Sbostic fprintf(pf, "Subject: Re:%s", 74*60083Sbostic mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 7530159Sbostic else 7630890Sbostic fputs("Subject: Bug report acknowledgement.\n", pf); 7730159Sbostic if (mailhead[DATE_TAG].found) 78*60083Sbostic fprintf(pf, "In-Acknowledgement-Of: Your message of %s", 79*60083Sbostic mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 8030159Sbostic if (mailhead[MSG_TAG].found) 8130890Sbostic fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 8231910Sbostic fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ 8330159Sbostic fflush(pf); 8430159Sbostic 8532654Sbostic (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); 8632654Sbostic if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { 8730890Sbostic while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 8830890Sbostic (void)write(fileno(pf), bfr, rval); 8930890Sbostic (void)close(afd); 9030159Sbostic } 9130159Sbostic pclose(pf); 9230159Sbostic } 93