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*46667Sbostic static char sccsid[] = "@(#)reply.c 5.9 (Berkeley) 02/25/91"; 1033416Sbostic #endif /* not lint */ 1130159Sbostic 12*46667Sbostic #include <sys/param.h> 13*46667Sbostic #include <fcntl.h> 14*46667Sbostic #include <dirent.h> 1530159Sbostic #include <stdio.h> 16*46667Sbostic #include <string.h> 17*46667Sbostic #include "bug.h" 1837887Sbostic #include "pathnames.h" 1930159Sbostic 2030159Sbostic /* 2130159Sbostic * reply -- 2230890Sbostic * tell the user we got their silly little bug report 2330159Sbostic */ 2430159Sbostic reply() 2530159Sbostic { 2630159Sbostic register char *C, /* traveling pointer */ 2730159Sbostic *to; /* who we're replying to */ 2830159Sbostic register int afd, /* ack file descriptor */ 2930159Sbostic rval; /* return value */ 3030159Sbostic FILE *pf, /* pipe pointer */ 3130159Sbostic *popen(); 3230890Sbostic char *index(); 3330159Sbostic 3430159Sbostic if (mailhead[RPLY_TAG].found) { 3530159Sbostic for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 3630159Sbostic if (*C) 3730159Sbostic goto gotone; 3830159Sbostic } 3930159Sbostic if (mailhead[FROM_TAG].found) { 4030159Sbostic for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 4130159Sbostic if (*C) 4230159Sbostic goto gotone; 4330159Sbostic } 4430159Sbostic if (mailhead[CFROM_TAG].found) { 4530159Sbostic for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 4630159Sbostic if (*C) 4730159Sbostic goto gotone; 4830159Sbostic } 4930159Sbostic return; 5030159Sbostic 5130159Sbostic /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 5230890Sbostic gotone: if (to = index(C, '<')) 5330159Sbostic for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); 5430159Sbostic else { 5530159Sbostic to = C; 5630159Sbostic for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); 5730159Sbostic } 5830159Sbostic *C = EOS; 5930159Sbostic 6030890Sbostic if (!(pf = popen(MAIL_CMD, "w"))) 6130890Sbostic error("sendmail pipe failed.", CHN); 6230159Sbostic 6330890Sbostic fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); 6430159Sbostic if (mailhead[SUBJ_TAG].found) 6530890Sbostic fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 6630159Sbostic else 6730890Sbostic fputs("Subject: Bug report acknowledgement.\n", pf); 6830159Sbostic if (mailhead[DATE_TAG].found) 6930890Sbostic fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 7030159Sbostic if (mailhead[MSG_TAG].found) 7130890Sbostic fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 7231910Sbostic fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ 7330159Sbostic fflush(pf); 7430159Sbostic 7532654Sbostic (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); 7632654Sbostic if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { 7730890Sbostic while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 7830890Sbostic (void)write(fileno(pf), bfr, rval); 7930890Sbostic (void)close(afd); 8030159Sbostic } 8130159Sbostic pclose(pf); 8230159Sbostic } 83