don't restart on non-fatal errors; use the error reporting counters
[unix-history] / usr / src / libexec / bugfiler / reply.c
CommitLineData
85ca7091
KB
1/*
2 * Copyright (c) 1986 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
d8336336 8static char sccsid[] = "@(#)reply.c 5.2 (Berkeley) 87/04/11";
85ca7091
KB
9#endif not lint
10
11#include <bug.h>
12#include <sys/file.h>
13#include <stdio.h>
14
85ca7091
KB
15/*
16 * reply --
d8336336 17 * tell the user we got their silly little bug report
85ca7091
KB
18 */
19reply()
20{
21 register char *C, /* traveling pointer */
22 *to; /* who we're replying to */
23 register int afd, /* ack file descriptor */
24 rval; /* return value */
25 FILE *pf, /* pipe pointer */
26 *popen();
d8336336 27 char *index();
85ca7091
KB
28
29 if (mailhead[RPLY_TAG].found) {
30 for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C);
31 if (*C)
32 goto gotone;
33 }
34 if (mailhead[FROM_TAG].found) {
35 for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C);
36 if (*C)
37 goto gotone;
38 }
39 if (mailhead[CFROM_TAG].found) {
40 for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C);
41 if (*C)
42 goto gotone;
43 }
44 return;
45
46 /* if it's a foo <XXX>, get the XXX, else get foo (first string) */
d8336336 47gotone: if (to = index(C, '<'))
85ca7091
KB
48 for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C);
49 else {
50 to = C;
51 for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C);
52 }
53 *C = EOS;
54
d8336336
KB
55 if (!(pf = popen(MAIL_CMD, "w")))
56 error("sendmail pipe failed.", CHN);
85ca7091 57
d8336336 58 fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to);
85ca7091 59 if (mailhead[SUBJ_TAG].found)
d8336336 60 fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len);
85ca7091 61 else
d8336336 62 fputs("Subject: Bug report acknowledgement.\n", pf);
85ca7091 63 if (mailhead[DATE_TAG].found)
d8336336 64 fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len);
85ca7091 65 if (mailhead[MSG_TAG].found)
d8336336
KB
66 fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line);
67 putc('\n', pf);
85ca7091
KB
68 fflush(pf);
69
d8336336
KB
70 if ((afd = open(ACK_FILE, O_RDONLY, 0)) >= 0) {
71 while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval)
72 (void)write(fileno(pf), bfr, rval);
73 (void)close(afd);
85ca7091 74 }
85ca7091
KB
75 pclose(pf);
76}