file reorg, pathnames.h, paths.h
[unix-history] / usr / src / libexec / bugfiler / reply.c
CommitLineData
85ca7091 1/*
aec2eff2
KB
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
5e8b0e60
KB
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.
85ca7091
KB
16 */
17
18#ifndef lint
435e8dff 19static char sccsid[] = "@(#)reply.c 5.7 (Berkeley) %G%";
aec2eff2 20#endif /* not lint */
85ca7091
KB
21
22#include <bug.h>
23#include <sys/file.h>
24#include <stdio.h>
435e8dff 25#include "pathnames.h"
85ca7091 26
85ca7091
KB
27/*
28 * reply --
d8336336 29 * tell the user we got their silly little bug report
85ca7091
KB
30 */
31reply()
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();
d8336336 39 char *index();
85ca7091
KB
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) */
d8336336 59gotone: if (to = index(C, '<'))
85ca7091
KB
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
d8336336
KB
67 if (!(pf = popen(MAIL_CMD, "w")))
68 error("sendmail pipe failed.", CHN);
85ca7091 69
d8336336 70 fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to);
85ca7091 71 if (mailhead[SUBJ_TAG].found)
d8336336 72 fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len);
85ca7091 73 else
d8336336 74 fputs("Subject: Bug report acknowledgement.\n", pf);
85ca7091 75 if (mailhead[DATE_TAG].found)
d8336336 76 fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len);
85ca7091 77 if (mailhead[MSG_TAG].found)
d8336336 78 fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line);
3fa5a997 79 fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */
85ca7091
KB
80 fflush(pf);
81
9377830c
KB
82 (void)sprintf(bfr, "%s/%s", dir, ACK_FILE);
83 if ((afd = open(bfr, O_RDONLY, 0)) >= 0) {
d8336336
KB
84 while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval)
85 (void)write(fileno(pf), bfr, rval);
86 (void)close(afd);
85ca7091 87 }
85ca7091
KB
88 pclose(pf);
89}