From d833633660502d0209f3d49f91707253ee5ab041 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sat, 11 Apr 1987 22:38:46 -0800 Subject: [PATCH] version #2; -f flag, remove home_dir, redist per folder SCCS-vsn: libexec/bugfiler/Makefile 5.8 SCCS-vsn: libexec/bugfiler/bugfiler.c 5.7 SCCS-vsn: libexec/bugfiler/error.c 5.2 SCCS-vsn: libexec/bugfiler/gethead.c 5.2 SCCS-vsn: libexec/bugfiler/process.c 5.3 SCCS-vsn: libexec/bugfiler/redist.c 5.2 SCCS-vsn: libexec/bugfiler/reply.c 5.2 --- usr/src/libexec/bugfiler/Makefile | 9 ++- usr/src/libexec/bugfiler/bugfiler.c | 114 ++++++++++++++-------------- usr/src/libexec/bugfiler/error.c | 33 ++++---- usr/src/libexec/bugfiler/gethead.c | 63 ++++++++------- usr/src/libexec/bugfiler/process.c | 78 +++++++++---------- usr/src/libexec/bugfiler/redist.c | 58 +++++++------- usr/src/libexec/bugfiler/reply.c | 35 ++++----- 7 files changed, 188 insertions(+), 202 deletions(-) diff --git a/usr/src/libexec/bugfiler/Makefile b/usr/src/libexec/bugfiler/Makefile index 9ed5eb7313..c176d28474 100644 --- a/usr/src/libexec/bugfiler/Makefile +++ b/usr/src/libexec/bugfiler/Makefile @@ -3,13 +3,14 @@ # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # -# @(#)Makefile 5.7 (Berkeley) %G% +# @(#)Makefile 5.8 (Berkeley) %G% # # Bug report processor and associated programs # CFLAGS = -O -I. DESTDIR= +SRCS= bugfiler.c error.c gethead.c process.c redist.c reply.c OBJS= bugfiler.o error.o gethead.o process.o redist.o reply.o all: bugfiler @@ -25,4 +26,10 @@ install: bugfiler sendbug.sh bugformat clean: rm -f ${OBJS} core bugfiler +tags: + ctags ${SRCS} + +lint: + lint ${CFLAGS} -chapbx ${SRCS} + ${OBJS}: bug.h diff --git a/usr/src/libexec/bugfiler/bugfiler.c b/usr/src/libexec/bugfiler/bugfiler.c index 0c215b7d59..158b852726 100644 --- a/usr/src/libexec/bugfiler/bugfiler.c +++ b/usr/src/libexec/bugfiler/bugfiler.c @@ -11,7 +11,7 @@ char copyright[] = #endif not lint #ifndef lint -static char sccsid[] = "@(#)bugfiler.c 5.6 (Berkeley) 86/11/25"; +static char sccsid[] = "@(#)bugfiler.c 5.7 (Berkeley) 87/04/11"; #endif not lint /* @@ -20,96 +20,93 @@ static char sccsid[] = "@(#)bugfiler.c 5.6 (Berkeley) 86/11/25"; */ #include #include -#include +#include #include +#include -extern char *optarg; /* getopt arguments */ -extern int optind; - -int lfd; /* lock file descriptor */ -short do_redist = YES; /* redistribut BR */ char bfr[MAXBSIZE], /* general I/O buffer */ tmpname[sizeof(TMP_BUG) + 5]; /* temp bug file */ -main(argc,argv) -int argc; -char **argv; +main(argc, argv) + int argc; + char **argv; { + extern char *optarg; /* getopt arguments */ register struct passwd *pwd; /* bugs password entry */ register int ch; /* getopts char */ - register short do_ack = YES; /* acknowledge bug report */ + int do_ack, /* acknowledge bug report */ + do_redist; /* redistribut BR */ + char *argfolder, /* folder name provided */ + *strcpy(); struct passwd *getpwnam(); - while ((ch = getopt(argc,argv,"ar")) != EOF) + do_ack = do_redist = YES; + argfolder = NULL; + while ((ch = getopt(argc, argv, "af:r")) != EOF) switch((char)ch) { - case 'a': - do_ack = NO; - break; - case 'r': - do_redist = NO; - break; - case '?': - default: - error("usage: bugfiler [-ar] [maildir]",CHN); + case 'a': + do_ack = NO; + break; + case 'f': + argfolder = optarg; + break; + case 'r': + do_redist = NO; + break; + case '?': + default: + error("usage: bugfiler [-ar] [-f folder]", CHN); } if (!(pwd = getpwnam(BUGS_ID))) - error("bugs person %s is unknown",BUGS_ID); + error("can't find bugs login.", BUGS_ID); - argv += optind; - if (*argv) { /* change to argument directory */ - if (chdir(*argv)) - error("can't move to %s.",*argv); - } /* change to bugs home directory */ - else if (chdir(pwd->pw_dir)) - error("can't move to %s.",pwd->pw_dir); + if (chdir(pwd->pw_dir)) /* change to bugs home directory */ + error("can't chdir to %s.", pwd->pw_dir); - if (setreuid(0,pwd->pw_uid)) - error("can't set id to %s.",BUGS_ID); + if (setreuid(0, pwd->pw_uid)) + error("can't set id to %s.", BUGS_ID); - umask(2); /* everything is 664 */ - seterr(); - logit(); - make_copy(); + (void)umask(2); /* everything is 664 */ + seterr(); /* redirect to log file */ + logit(); /* log report arrival */ + make_copy(); /* save copy in case */ + gethead(do_redist); - if (access(LOCK_FILE,R_OK) || (lfd = open(LOCK_FILE,O_RDONLY,0)) < 0) - error("can't read lock file %s.",LOCK_FILE); + if (argfolder) /* specific folder requested */ + (void)strcpy(dir, argfolder); - gethead(); process(); - if (setuid(0,0)) - error("can't set id to root.",CHN); - + if (setuid(0, 0)) + error("can't set id to root.", CHN); if (do_ack) reply(); if (do_redist) redist(); - - unlink(tmpname); + (void)unlink(tmpname); exit(OK); } /* * make_copy -- - * make a copy of the bug report + * make a copy of bug report in error folder */ static make_copy() { register int cnt, /* read return value */ tfd; /* temp file descriptor */ - char *mktemp(), *strcpy(); - - /* use O_EXCL, since may not be able to get a lock file */ - for (cnt = 0;cnt < 20;++cnt) - if ((tfd = open(mktemp(strcpy(tmpname,TMP_BUG)),O_WRONLY | O_CREAT | O_EXCL,0664)) >= 0) { - while ((cnt = read(fileno(stdin),bfr,sizeof(bfr))) != ERR && cnt) - write(tfd,bfr,cnt); - close(tfd); - return; - } - error("unable to make copy using %s.\n",tmpname); + char *strcpy(); + + (void)strcpy(tmpname, TMP_BUG); + if (tfd = mkstemp(tmpname)) { + while ((cnt = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && cnt) + write(tfd, bfr, cnt); + (void)close(tfd); + return; + } + error("can't make copy using %s.\n", tmpname); } /* @@ -120,10 +117,9 @@ static logit() { struct timeval tp; - struct timezone tzp; char *ctime(); - if (gettimeofday(&tp,&tzp)) - error("unable to get time of day.",CHN); - fprintf(stderr,"\n>>> BUGFILER <<<\n\t%s",ctime(&tp.tv_sec)); + if (gettimeofday(&tp, (struct timezone *)NULL)) + error("can't get time of day.", CHN); + fprintf(stderr, "\n>>> BUGFILER <<<\n\t%s", ctime(&tp.tv_sec)); } diff --git a/usr/src/libexec/bugfiler/error.c b/usr/src/libexec/bugfiler/error.c index 69f6095b04..ac61d3cb77 100644 --- a/usr/src/libexec/bugfiler/error.c +++ b/usr/src/libexec/bugfiler/error.c @@ -8,14 +8,9 @@ static char sccsid[] = "@(#)error.c 5.1 (Berkeley) 86/11/25"; #endif not lint +#include #include #include -#include - -extern char *distf, /* redist temp file */ - tmpname[]; /* temporary file used */ - -short made_dist; /* if dist file made */ static short err_redir; /* stderr redirected */ @@ -25,8 +20,8 @@ static short err_redir; /* stderr redirected */ */ seterr() { - if (!freopen(ERROR_FILE,"a",stderr)) - error("unable to open error file %s.\n",ERROR_FILE); + if (!freopen(ERROR_FILE, "a", stderr)) + error("can't open error file %s.\n", ERROR_FILE); err_redir = YES; } @@ -34,28 +29,26 @@ seterr() * error -- * write errors to log file and die */ -error(fmt,arg) -register char *fmt, - *arg; +error(fmt, arg) + register char *fmt, + *arg; { static char logmsg[MAXLINELEN]; /* syslog message */ char *strcpy(), *strcat(); if (err_redir) { /* don't combine these, "fmt" may not require "arg" */ - fputc('\t',stderr); - fprintf(stderr,fmt,arg); - fprintf(stderr,"\n\ttemporary file is %s.\n",tmpname); + fputc('\t', stderr); + fprintf(stderr, fmt, arg); + fprintf(stderr, "\n\ttemporary file is %s.\n", tmpname); } else { - strcat(strcpy(logmsg,"bugfiler: "),fmt); - syslog(LOG_ERR,logmsg,arg); + sprintf(logmsg, "bugfiler: %s", fmt); + syslog(LOG_ERR, logmsg, arg); } - if (made_dist) /* unlink redist file if necessary */ - unlink(distf); #ifdef METOO exit(ERR); -#else !METOO +#else exit(OK); -#endif METOO +#endif } diff --git a/usr/src/libexec/bugfiler/gethead.c b/usr/src/libexec/bugfiler/gethead.c index 3b92581b29..cef12a0b37 100644 --- a/usr/src/libexec/bugfiler/gethead.c +++ b/usr/src/libexec/bugfiler/gethead.c @@ -5,12 +5,11 @@ */ #ifndef lint -static char sccsid[] = "@(#)gethead.c 5.1 (Berkeley) 86/11/25"; +static char sccsid[] = "@(#)gethead.c 5.2 (Berkeley) 87/04/11"; #endif not lint #include #include -#include #include static int chk1(); @@ -29,50 +28,51 @@ HEADER mailhead[] = { /* mail headers */ { ERR, } }; -extern short do_redist, /* if redistributing report */ - made_dist; /* if dist file needs removing */ -extern char tmpname[]; /* temp bug report file */ - -char *distf = TMP_FILE, /* redist temp file */ - dir[MAXNAMLEN], /* subject and folder */ +FILE *dfp; /* distf file pointer */ +char dir[MAXNAMLEN], /* subject and folder */ folder[MAXNAMLEN]; /* * gethead -- * read mail and bug headers from bug report, construct redist headers */ -gethead() +gethead(redist) + int redist; { register HEADER *hp; /* mail header pointer */ - register FILE *dfp; /* distf file pointer */ - char *strcpy(), *malloc(), *mktemp(); + char *strcpy(), *malloc(); + + if (redist) { + int fd; + char *distf; - if (do_redist && (!mktemp(distf) || !(dfp = fopen(distf,"w")))) - error("unable to create redistribution file %s.",distf); - made_dist = YES; - if (!freopen(tmpname,"r",stdin)) - error("unable to read temporary bug file %s.",tmpname); + distf = "/tmp/BUG_XXXXXX"; + if (!(fd = mkstemp(distf)) || !(dfp = fdopen(fd, "w+"))) + error("can't create redistribution file %s.", distf); + /* disappear after last reference is closed */ + (void)unlink(distf); + } + if (!freopen(tmpname, "r", stdin)) + error("can't read temporary bug file %s.", tmpname); - while (fgets(bfr,sizeof(bfr),stdin)) { - for (hp = mailhead;hp->found != ERR;++hp) + while (fgets(bfr, sizeof(bfr), stdin)) { + for (hp = mailhead; hp->found != ERR; ++hp) if (!hp->found) - if (!strncmp(hp->tag,bfr,hp->len)) { + if (!strncmp(hp->tag, bfr, hp->len)) { if (hp->valid && !((*(hp->valid))(bfr))) break; if (!(hp->line = malloc((u_int)(strlen(bfr) + 1)))) - error("unable to allocate space for header search.",CHN); - strcpy(hp->line,bfr); + error("malloc failed.", CHN); + (void)strcpy(hp->line, bfr); hp->found = YES; break; } - if ((hp->found == ERR || hp->redist) && do_redist) - fputs(bfr,dfp); + if ((hp->found == ERR || hp->redist) && redist) + fputs(bfr, dfp); } if (!mailhead[INDX_TAG].found) - error("no readable \"Index:\" header in bug report.",CHN); - if (do_redist) - fclose(dfp); + error("no readable \"Index:\" header in bug report.", CHN); } /* @@ -81,23 +81,20 @@ gethead() */ static chk1(line) -char *line; + char *line; { register char *C; /* tmp pointer */ struct stat sbuf; /* existence check */ char *index(); - if (sscanf(line," Index: %s %s ",folder,dir) != 2) + if (sscanf(line, " Index: %s %s ", folder, dir) != 2) return(NO); - - /* backward compatible, deal with "bin/from.c" */ - if (C = index(folder,'/')) { + if (C = index(folder, '/')) { /* deal with "bin/from.c" */ if (C == folder) return(NO); *C = EOS; } - - if (stat(dir,&sbuf) || (sbuf.st_mode & S_IFMT) != S_IFDIR) + if (stat(dir, &sbuf) || (sbuf.st_mode & S_IFMT) != S_IFDIR) return(NO); return(YES); } diff --git a/usr/src/libexec/bugfiler/process.c b/usr/src/libexec/bugfiler/process.c index 8a60051792..73fc9b7952 100644 --- a/usr/src/libexec/bugfiler/process.c +++ b/usr/src/libexec/bugfiler/process.c @@ -5,55 +5,51 @@ */ #ifndef lint -static char sccsid[] = "@(#)process.c 5.2 (Berkeley) 87/01/28"; +static char sccsid[] = "@(#)process.c 5.3 (Berkeley) 87/04/11"; #endif not lint #include #include -#include #include #include - -extern HEADER mailhead[]; /* mail headers */ -extern int lfd; /* lock file descriptor */ -extern char dir[], /* directory */ - folder[]; /* sub-directory */ +#include char pfile[MAXPATHLEN]; /* permanent file name */ /* * process -- - * process a bug report + * copy report to permanent file, + * update summary file. */ process() { register int rval; /* read return value */ struct timeval tp; /* time of day */ - struct timezone tzp; + int lfd; /* lock file descriptor */ char *ctime(); - /* copy report to permanent file */ - sprintf(pfile,"%s/%s/%d",dir,folder,getnext()); - fprintf(stderr,"\t%s\n",pfile); - if (!(freopen(pfile,"w",stdout))) - error("unable to create permanent bug file %s.",pfile); + if (access(LOCK_FILE, R_OK) || (lfd = open(LOCK_FILE, O_RDONLY, 0)) < 0) + error("can't find lock file %s.", LOCK_FILE); + if (flock(lfd, LOCK_EX)) + error("can't get lock.", CHN); + sprintf(pfile, "%s/%s/%d", dir, folder, getnext()); + fprintf(stderr, "\t%s\n", pfile); + if (!(freopen(pfile, "w", stdout))) + error("can't create %s.", pfile); rewind(stdin); - while ((rval = read(fileno(stdin),bfr,sizeof(bfr))) != ERR && rval) - write(fileno(stdout),bfr,rval); - REL_LOCK; + while ((rval = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && rval) + if (write(fileno(stdout), bfr, rval) != rval) + error("write to %s failed.", pfile); /* append information to the summary file */ - sprintf(bfr,"%s/%s",dir,SUMMARY_FILE); - GET_LOCK; - if (!(freopen(bfr,"a",stdout))) - error("unable to append to summary file %s.",bfr); - else { - if (gettimeofday(&tp,&tzp)) - error("unable to get time of day.",CHN); - printf("\n%s\t\t%s\t%s\t%s\tOwner: Bugs Bunny\n\tComment: Received\n",pfile,ctime(&tp.tv_sec),mailhead[INDX_TAG].line,mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n"); - } - REL_LOCK; - fclose(stdout); + sprintf(bfr, "%s/%s", dir, SUMMARY_FILE); + if (!(freopen(bfr, "a", stdout))) + error("can't append to summary file %s.", bfr); + if (gettimeofday(&tp, (struct timezone *)NULL)) + error("can't get time of day.", CHN); + printf("\n%s\t\t%s\t%s\t%s\tOwner: Bugs Bunny\n\tComment: Received\n", pfile, ctime(&tp.tv_sec), mailhead[INDX_TAG].line, mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n"); + (void)flock(lfd, LOCK_UN); + (void)fclose(stdout); } /* @@ -65,16 +61,22 @@ getnext() { register struct direct *d; /* directory structure */ register DIR *dirp; /* directory pointer */ - register int n; /* number values */ + register int highval, + newval; + register char *C; - GET_LOCK; - sprintf(bfr,"%s/%s",dir,folder); - if (!(dirp = opendir(bfr))) { - REL_LOCK; - error("unable to read folder directory %s.",bfr); - } - for (n = 0;d = readdir(dirp);) - n = MAX(n,atoi(d->d_name)); + sprintf(bfr, "%s/%s", dir, folder); + if (!(dirp = opendir(bfr))) + error("can't read folder directory %s.", bfr); + for (highval = 0;d = readdir(dirp);) + for (C = d->d_name;;++C) + if (!*C) { + if ((newval = atoi(d->d_name)) > highval) + highval = newval; + break; + } + else if (!isdigit(*C)) + break; closedir(dirp); - return(++n); + return(++highval); } diff --git a/usr/src/libexec/bugfiler/redist.c b/usr/src/libexec/bugfiler/redist.c index 45f8f8ec96..1dc49c41d7 100644 --- a/usr/src/libexec/bugfiler/redist.c +++ b/usr/src/libexec/bugfiler/redist.c @@ -5,18 +5,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)redist.c 5.1 (Berkeley) 86/11/25"; +static char sccsid[] = "@(#)redist.c 5.2 (Berkeley) 87/04/11"; #endif not lint #include #include #include -extern HEADER mailhead[]; /* mail headers */ -extern char *distf, /* redist temp file */ - pfile[], /* permanent bug file */ - folder[]; /* system name */ - /* * redist -- * Redistribute a bug report to those people indicated in the @@ -24,64 +19,63 @@ extern char *distf, /* redist temp file */ */ redist() { - register char *C1, /* traveling chars */ + extern FILE *dfp; /* dist file fp */ + extern char pfile[]; /* permanent bug file */ + register char *C1, *C2; - register int first = YES; /* if first blank line */ - FILE *pf, /* pipe pointer */ - *dfp, /* dist file fp */ + register int first; /* if first blank line */ + FILE *pf, *popen(); - char *index(), *mktemp(); + char *index(); - if (!freopen(DIST_FILE,"r",stdin)) + sprintf(bfr, "%s/%s", dir, DIST_FILE); + if (!freopen(bfr, "r", stdin)) return; - for (;;) { /* get first part of entry */ if (!gets(bfr)) return; - if (*bfr == COMMENT || *bfr == ' ' || *bfr == '\t' || !(C1 = index(bfr,':'))) + if (*bfr == COMMENT || *bfr == ' ' || *bfr == '\t' || !(C1 = index(bfr, ':'))) continue; *C1 = EOS; - if (!strcmp(bfr,folder)) + if (!strcmp(bfr, folder)) break; } for (++C1;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); if (!*C1) /* if empty */ return; - if (!(pf = popen(MAIL_CMD,"w"))) - error("sendmail pipe failed.",CHN); + if (!(pf = popen(MAIL_CMD, "w"))) + error("sendmail pipe failed.", CHN); - fprintf(pf,"Reply-To: %s\n",BUGS_HOME); + fprintf(pf, "Reply-To: %s\n", BUGS_HOME); if (mailhead[SUBJ_TAG].found) - fprintf(pf,"%s",mailhead[SUBJ_TAG].line); + fprintf(pf, "%s", mailhead[SUBJ_TAG].line); else - fputs("Subject: Untitled Bug Report\n",pf); - fputs("Resent-To: ",pf); + fputs("Subject: Untitled Bug Report\n", pf); + fputs("Resent-To: ", pf); /* * write out first entry, then succeeding entries * backward compatible, handles back slashes at end of line */ for (;;) { - if (C2 = index(C1,'\\')) + if (C2 = index(C1, '\\')) *C2 = EOS; - fputs(C1,pf); + fputs(C1, pf); if (!gets(bfr) || (*bfr != ' ' && *bfr != '\t')) break; for (C1 = bfr;*C1 && (*C1 == ' ' || *C1 == '\t');++C1); } - fputs("\n",pf); + putc('\n', pf); - if (!(dfp = fopen(distf,"r"))) - error("unable to read temporary file %s.",distf); - while (fgets(bfr,sizeof(bfr),dfp)) + rewind(dfp); + for (first = YES;fgets(bfr, sizeof(bfr), dfp);) if (*bfr == '\n' && first) { first = NO; - fprintf(pf,"\n%sReference: %s\n",mailhead[INDX_TAG].line,pfile); + fprintf(pf, "\n%sReference: %s\n", mailhead[INDX_TAG].line, pfile); } else - fputs(bfr,pf); - fclose(dfp); - pclose(pf); - unlink(distf); + fputs(bfr, pf); + (void)pclose(pf); + (void)fclose(dfp); } diff --git a/usr/src/libexec/bugfiler/reply.c b/usr/src/libexec/bugfiler/reply.c index 041b954216..0417a74e11 100644 --- a/usr/src/libexec/bugfiler/reply.c +++ b/usr/src/libexec/bugfiler/reply.c @@ -5,18 +5,16 @@ */ #ifndef lint -static char sccsid[] = "@(#)reply.c 5.1 (Berkeley) 86/11/25"; +static char sccsid[] = "@(#)reply.c 5.2 (Berkeley) 87/04/11"; #endif not lint #include #include #include -extern HEADER mailhead[]; /* mail headers */ - /* * reply -- - * tell the user we got their bug report + * tell the user we got their silly little bug report */ reply() { @@ -26,7 +24,7 @@ reply() rval; /* return value */ FILE *pf, /* pipe pointer */ *popen(); - char *mktemp(), *strcpy(), *index(); + char *index(); if (mailhead[RPLY_TAG].found) { for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); @@ -46,7 +44,7 @@ reply() return; /* if it's a foo , get the XXX, else get foo (first string) */ -gotone: if (to = index(C,'<')) +gotone: if (to = index(C, '<')) for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); else { to = C; @@ -54,26 +52,25 @@ gotone: if (to = index(C,'<')) } *C = EOS; - if (!(pf = popen(MAIL_CMD,"w"))) - error("sendmail pipe failed.",CHN); + if (!(pf = popen(MAIL_CMD, "w"))) + error("sendmail pipe failed.", CHN); - fprintf(pf,"Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n",BUGS_HOME,BUGS_HOME,to); + fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); if (mailhead[SUBJ_TAG].found) - fprintf(pf,"Subject: Re:%s",mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); + fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); else - fputs("Subject: Bug report acknowledgement.\n",pf); + fputs("Subject: Bug report acknowledgement.\n", pf); if (mailhead[DATE_TAG].found) - fprintf(pf,"In-Acknowledgement-Of: Your message of %s",mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); + fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); if (mailhead[MSG_TAG].found) - fprintf(pf,"\t\t%s",mailhead[MSG_TAG].line); - putc('\n',pf); + fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); + putc('\n', pf); fflush(pf); - if ((afd = open(ACK_FILE,O_RDONLY,0)) >= 0) { - while ((rval = read(afd,bfr,sizeof(bfr))) != ERR && rval) - write(fileno(pf),bfr,rval); - close(afd); + if ((afd = open(ACK_FILE, O_RDONLY, 0)) >= 0) { + while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) + (void)write(fileno(pf), bfr, rval); + (void)close(afd); } - pclose(pf); } -- 2.20.1