1 /* 2 * Copyright (c) 1986, 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)reply.c 5.9 (Berkeley) 02/25/91"; 10 #endif /* not lint */ 11 12 #include <sys/param.h> 13 #include <fcntl.h> 14 #include <dirent.h> 15 #include <stdio.h> 16 #include <string.h> 17 #include "bug.h" 18 #include "pathnames.h" 19 20 /* 21 * reply -- 22 * tell the user we got their silly little bug report 23 */ 24 reply() 25 { 26 register char *C, /* traveling pointer */ 27 *to; /* who we're replying to */ 28 register int afd, /* ack file descriptor */ 29 rval; /* return value */ 30 FILE *pf, /* pipe pointer */ 31 *popen(); 32 char *index(); 33 34 if (mailhead[RPLY_TAG].found) { 35 for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 36 if (*C) 37 goto gotone; 38 } 39 if (mailhead[FROM_TAG].found) { 40 for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 41 if (*C) 42 goto gotone; 43 } 44 if (mailhead[CFROM_TAG].found) { 45 for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 46 if (*C) 47 goto gotone; 48 } 49 return; 50 51 /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 52 gotone: if (to = index(C, '<')) 53 for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); 54 else { 55 to = C; 56 for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); 57 } 58 *C = EOS; 59 60 if (!(pf = popen(MAIL_CMD, "w"))) 61 error("sendmail pipe failed.", CHN); 62 63 fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); 64 if (mailhead[SUBJ_TAG].found) 65 fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 66 else 67 fputs("Subject: Bug report acknowledgement.\n", pf); 68 if (mailhead[DATE_TAG].found) 69 fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 70 if (mailhead[MSG_TAG].found) 71 fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 72 fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ 73 fflush(pf); 74 75 (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); 76 if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { 77 while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 78 (void)write(fileno(pf), bfr, rval); 79 (void)close(afd); 80 } 81 pclose(pf); 82 } 83