130159Sbostic /* 230159Sbostic * Copyright (c) 1986 Regents of the University of California. 330159Sbostic * All rights reserved. The Berkeley software License Agreement 430159Sbostic * specifies the terms and conditions for redistribution. 530159Sbostic */ 630159Sbostic 730159Sbostic #ifndef lint 8*30890Sbostic static char sccsid[] = "@(#)reply.c 5.2 (Berkeley) 87/04/11"; 930159Sbostic #endif not lint 1030159Sbostic 1130159Sbostic #include <bug.h> 1230159Sbostic #include <sys/file.h> 1330159Sbostic #include <stdio.h> 1430159Sbostic 1530159Sbostic /* 1630159Sbostic * reply -- 17*30890Sbostic * tell the user we got their silly little bug report 1830159Sbostic */ 1930159Sbostic reply() 2030159Sbostic { 2130159Sbostic register char *C, /* traveling pointer */ 2230159Sbostic *to; /* who we're replying to */ 2330159Sbostic register int afd, /* ack file descriptor */ 2430159Sbostic rval; /* return value */ 2530159Sbostic FILE *pf, /* pipe pointer */ 2630159Sbostic *popen(); 27*30890Sbostic char *index(); 2830159Sbostic 2930159Sbostic if (mailhead[RPLY_TAG].found) { 3030159Sbostic for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 3130159Sbostic if (*C) 3230159Sbostic goto gotone; 3330159Sbostic } 3430159Sbostic if (mailhead[FROM_TAG].found) { 3530159Sbostic for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 3630159Sbostic if (*C) 3730159Sbostic goto gotone; 3830159Sbostic } 3930159Sbostic if (mailhead[CFROM_TAG].found) { 4030159Sbostic for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 4130159Sbostic if (*C) 4230159Sbostic goto gotone; 4330159Sbostic } 4430159Sbostic return; 4530159Sbostic 4630159Sbostic /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 47*30890Sbostic gotone: if (to = index(C, '<')) 4830159Sbostic for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); 4930159Sbostic else { 5030159Sbostic to = C; 5130159Sbostic for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); 5230159Sbostic } 5330159Sbostic *C = EOS; 5430159Sbostic 55*30890Sbostic if (!(pf = popen(MAIL_CMD, "w"))) 56*30890Sbostic error("sendmail pipe failed.", CHN); 5730159Sbostic 58*30890Sbostic fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); 5930159Sbostic if (mailhead[SUBJ_TAG].found) 60*30890Sbostic fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 6130159Sbostic else 62*30890Sbostic fputs("Subject: Bug report acknowledgement.\n", pf); 6330159Sbostic if (mailhead[DATE_TAG].found) 64*30890Sbostic fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 6530159Sbostic if (mailhead[MSG_TAG].found) 66*30890Sbostic fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 67*30890Sbostic putc('\n', pf); 6830159Sbostic fflush(pf); 6930159Sbostic 70*30890Sbostic if ((afd = open(ACK_FILE, O_RDONLY, 0)) >= 0) { 71*30890Sbostic while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 72*30890Sbostic (void)write(fileno(pf), bfr, rval); 73*30890Sbostic (void)close(afd); 7430159Sbostic } 7530159Sbostic pclose(pf); 7630159Sbostic } 77