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 this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #ifndef lint 14 static char sccsid[] = "@(#)reply.c 5.5 (Berkeley) 02/01/88"; 15 #endif /* not lint */ 16 17 #include <bug.h> 18 #include <sys/file.h> 19 #include <stdio.h> 20 21 /* 22 * reply -- 23 * tell the user we got their silly little bug report 24 */ 25 reply() 26 { 27 register char *C, /* traveling pointer */ 28 *to; /* who we're replying to */ 29 register int afd, /* ack file descriptor */ 30 rval; /* return value */ 31 FILE *pf, /* pipe pointer */ 32 *popen(); 33 char *index(); 34 35 if (mailhead[RPLY_TAG].found) { 36 for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 37 if (*C) 38 goto gotone; 39 } 40 if (mailhead[FROM_TAG].found) { 41 for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 42 if (*C) 43 goto gotone; 44 } 45 if (mailhead[CFROM_TAG].found) { 46 for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); 47 if (*C) 48 goto gotone; 49 } 50 return; 51 52 /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ 53 gotone: if (to = index(C, '<')) 54 for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); 55 else { 56 to = C; 57 for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); 58 } 59 *C = EOS; 60 61 if (!(pf = popen(MAIL_CMD, "w"))) 62 error("sendmail pipe failed.", CHN); 63 64 fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); 65 if (mailhead[SUBJ_TAG].found) 66 fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); 67 else 68 fputs("Subject: Bug report acknowledgement.\n", pf); 69 if (mailhead[DATE_TAG].found) 70 fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); 71 if (mailhead[MSG_TAG].found) 72 fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); 73 fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ 74 fflush(pf); 75 76 (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); 77 if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { 78 while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) 79 (void)write(fileno(pf), bfr, rval); 80 (void)close(afd); 81 } 82 pclose(pf); 83 } 84