1 /* 2 * Copyright (c) 1986, 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)reply.c 5.7 (Berkeley) 05/11/89"; 20 #endif /* not lint */ 21 22 #include <bug.h> 23 #include <sys/file.h> 24 #include <stdio.h> 25 #include "pathnames.h" 26 27 /* 28 * reply -- 29 * tell the user we got their silly little bug report 30 */ 31 reply() 32 { 33 register char *C, /* traveling pointer */ 34 *to; /* who we're replying to */ 35 register int afd, /* ack file descriptor */ 36 rval; /* return value */ 37 FILE *pf, /* pipe pointer */ 38 *popen(); 39 char *index(); 40 41 if (mailhead[RPLY_TAG].found) { 42 for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 43 if (*C) 44 goto gotone; 45 } 46 if (mailhead[FROM_TAG].found) { 47 for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 48 if (*C) 49 goto gotone; 50 } 51 if (mailhead[CFROM_TAG].found) { 52 for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 53 if (*C) 54 goto gotone; 55 } 56 return; 57 58 /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 59 gotone: if (to = index(C, '<')) 60 for (C = ++to;*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", BUGS_HOME, BUGS_HOME, to); 71 if (mailhead[SUBJ_TAG].found) 72 fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 73 else 74 fputs("Subject: Bug report acknowledgement.\n", pf); 75 if (mailhead[DATE_TAG].found) 76 fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 77 if (mailhead[MSG_TAG].found) 78 fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 79 fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ 80 fflush(pf); 81 82 (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); 83 if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { 84 while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 85 (void)write(fileno(pf), bfr, rval); 86 (void)close(afd); 87 } 88 pclose(pf); 89 } 90