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