Commit | Line | Data |
---|---|---|
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 | |
8 | static char sccsid[] = "@(#)reply.c 5.1 (Berkeley) 86/11/25"; | |
9 | #endif not lint | |
10 | ||
11 | #include <bug.h> | |
12 | #include <sys/file.h> | |
13 | #include <stdio.h> | |
14 | ||
15 | extern HEADER mailhead[]; /* mail headers */ | |
16 | ||
17 | /* | |
18 | * reply -- | |
19 | * tell the user we got their bug report | |
20 | */ | |
21 | reply() | |
22 | { | |
23 | register char *C, /* traveling pointer */ | |
24 | *to; /* who we're replying to */ | |
25 | register int afd, /* ack file descriptor */ | |
26 | rval; /* return value */ | |
27 | FILE *pf, /* pipe pointer */ | |
28 | *popen(); | |
29 | char *mktemp(), *strcpy(), *index(); | |
30 | ||
31 | if (mailhead[RPLY_TAG].found) { | |
32 | for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
33 | if (*C) | |
34 | goto gotone; | |
35 | } | |
36 | if (mailhead[FROM_TAG].found) { | |
37 | for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
38 | if (*C) | |
39 | goto gotone; | |
40 | } | |
41 | if (mailhead[CFROM_TAG].found) { | |
42 | for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); | |
43 | if (*C) | |
44 | goto gotone; | |
45 | } | |
46 | return; | |
47 | ||
48 | /* if it's a foo <XXX>, get the XXX, else get foo (first string) */ | |
49 | gotone: if (to = index(C,'<')) | |
50 | for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); | |
51 | else { | |
52 | to = C; | |
53 | for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); | |
54 | } | |
55 | *C = EOS; | |
56 | ||
57 | if (!(pf = popen(MAIL_CMD,"w"))) | |
58 | error("sendmail pipe failed.",CHN); | |
59 | ||
60 | fprintf(pf,"Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n",BUGS_HOME,BUGS_HOME,to); | |
61 | if (mailhead[SUBJ_TAG].found) | |
62 | fprintf(pf,"Subject: Re:%s",mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); | |
63 | else | |
64 | fputs("Subject: Bug report acknowledgement.\n",pf); | |
65 | if (mailhead[DATE_TAG].found) | |
66 | fprintf(pf,"In-Acknowledgement-Of: Your message of %s",mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); | |
67 | if (mailhead[MSG_TAG].found) | |
68 | fprintf(pf,"\t\t%s",mailhead[MSG_TAG].line); | |
69 | putc('\n',pf); | |
70 | fflush(pf); | |
71 | ||
72 | if ((afd = open(ACK_FILE,O_RDONLY,0)) >= 0) { | |
73 | while ((rval = read(afd,bfr,sizeof(bfr))) != ERR && rval) | |
74 | write(fileno(pf),bfr,rval); | |
75 | close(afd); | |
76 | } | |
77 | ||
78 | pclose(pf); | |
79 | } |