SCCS-vsn: usr.bin/mail/lex.c 5.21
SCCS-vsn: usr.bin/mail/names.c 5.16
SCCS-vsn: usr.bin/mail/edit.c 5.15
SCCS-vsn: usr.bin/mail/collect.c 5.22
SCCS-vsn: usr.bin/mail/cmd2.c 5.14
SCCS-vsn: usr.bin/mail/quit.c 5.15
SCCS-vsn: usr.bin/mail/send.c 5.21
SCCS-vsn: usr.bin/mail/glob.h 5.20
SCCS-vsn: usr.bin/mail/cmd3.c 5.24
SCCS-vsn: usr.bin/mail/main.c 5.27
SCCS-vsn: usr.bin/mail/fio.c 5.23
SCCS-vsn: usr.bin/mail/cmd1.c 5.21
SCCS-vsn: usr.bin/mail/popen.c 5.15
SCCS-vsn: usr.bin/mail/def.h 5.22
SCCS-vsn: usr.bin/mail/aux.c 5.20
15 files changed:
-static char sccsid[] = "@(#)aux.c 5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)aux.c 5.20 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
fprintf(stderr, "panic: ");
fprintf(stderr, fmt, a, b);
putc('\n', stderr);
fprintf(stderr, "panic: ");
fprintf(stderr, fmt, a, b);
putc('\n', stderr);
+ fflush(stdout);
+ abort();
if ((cp = expand(*arglist)) == NOSTR)
return(1);
if ((cp = expand(*arglist)) == NOSTR)
return(1);
- if ((fi = fopen(cp, "r")) == NULL) {
+ if ((fi = Fopen(cp, "r")) == NULL) {
perror(cp);
return(1);
}
if (ssp >= NOFILE - 1) {
printf("Too much \"sourcing\" going on.\n");
perror(cp);
return(1);
}
if (ssp >= NOFILE - 1) {
printf("Too much \"sourcing\" going on.\n");
return(1);
}
sstack[ssp].s_file = input;
return(1);
}
sstack[ssp].s_file = input;
sourcing = 0;
return(1);
}
sourcing = 0;
return(1);
}
if (cond != CANY)
printf("Unmatched \"if\"\n");
ssp--;
if (cond != CANY)
printf("Unmatched \"if\"\n");
ssp--;
-static char sccsid[] = "@(#)cmd1.c 5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd1.c 5.21 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
FILE *obuf;
obuf = stdout;
FILE *obuf;
obuf = stdout;
- if (setjmp(pipestop)) {
- if (obuf != stdout) {
- pipef = NULL;
- Pclose(obuf);
- }
- signal(SIGPIPE, SIG_DFL);
- return(0);
- }
+ if (setjmp(pipestop))
+ goto close_pipe;
if (value("interactive") != NOSTR &&
(page || (cp = value("crt")) != NOSTR)) {
nlines = 0;
if (value("interactive") != NOSTR &&
(page || (cp = value("crt")) != NOSTR)) {
nlines = 0;
if (obuf == NULL) {
perror(cp);
obuf = stdout;
if (obuf == NULL) {
perror(cp);
obuf = stdout;
- } else {
- pipef = obuf;
signal(SIGPIPE, brokpipe);
signal(SIGPIPE, brokpipe);
}
}
for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
}
}
for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
fprintf(obuf, "Message %d:\n", *ip);
(void) send(mp, obuf, doign ? ignore : 0, NOSTR);
}
fprintf(obuf, "Message %d:\n", *ip);
(void) send(mp, obuf, doign ? ignore : 0, NOSTR);
}
+ /*
+ * Ignore SIGPIPE so it can't cause a duplicate close.
+ */
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_DFL);
- signal(SIGPIPE, SIG_DFL);
return(0);
}
/*
* Respond to a broken pipe signal --
return(0);
}
/*
* Respond to a broken pipe signal --
- * probably caused by using quitting more.
+ * probably caused by quitting more.
-static char sccsid[] = "@(#)cmd2.c 5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd2.c 5.14 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
disp = "[Appended]";
else
disp = "[New file]";
disp = "[Appended]";
else
disp = "[New file]";
- if ((obuf = fopen(file, "a")) == NULL) {
+ if ((obuf = Fopen(file, "a")) == NULL) {
perror(NOSTR);
return(1);
}
perror(NOSTR);
return(1);
}
touch(mp);
if (send(mp, obuf, ignore, NOSTR) < 0) {
perror(file);
touch(mp);
if (send(mp, obuf, ignore, NOSTR) < 0) {
perror(file);
fflush(obuf);
if (ferror(obuf))
perror(file);
fflush(obuf);
if (ferror(obuf))
perror(file);
printf("%s\n", disp);
return(0);
}
printf("%s\n", disp);
return(0);
}
-static char sccsid[] = "@(#)cmd3.c 5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd3.c 5.24 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
register c;
register FILE *f;
register c;
register FILE *f;
- if ((f = fopen(_PATH_HELP, "r")) == NULL) {
+ if ((f = Fopen(_PATH_HELP, "r")) == NULL) {
perror(_PATH_HELP);
return(1);
}
while ((c = getc(f)) != EOF)
putchar(c);
perror(_PATH_HELP);
return(1);
}
while ((c = getc(f)) != EOF)
putchar(c);
-static char sccsid[] = "@(#)collect.c 5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c 5.22 (Berkeley) %G%";
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
noreset++;
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
noreset++;
- if ((collf = fopen(tempMail, "w+")) == NULL) {
+ if ((collf = Fopen(tempMail, "w+")) == NULL) {
perror(tempMail);
goto err;
}
perror(tempMail);
goto err;
}
printf("%s: Directory\n", cp);
break;
}
printf("%s: Directory\n", cp);
break;
}
- if ((fbuf = fopen(cp, "r")) == NULL) {
+ if ((fbuf = Fopen(cp, "r")) == NULL) {
while (readline(fbuf, linebuf, LINESIZE) >= 0) {
lc++;
if ((t = putline(collf, linebuf)) < 0) {
while (readline(fbuf, linebuf, LINESIZE) >= 0) {
lc++;
if ((t = putline(collf, linebuf)) < 0) {
printf("%d/%d\n", lc, cc);
break;
case 'w':
printf("%d/%d\n", lc, cc);
break;
case 'w':
goto err;
goto cont;
case '?':
goto err;
goto cont;
case '?':
- if ((fbuf = fopen(_PATH_TILDE, "r")) == NULL) {
+ if ((fbuf = Fopen(_PATH_TILDE, "r")) == NULL) {
perror(_PATH_TILDE);
break;
}
while ((t = getc(fbuf)) != EOF)
(void) putchar(t);
perror(_PATH_TILDE);
break;
}
while ((t = getc(fbuf)) != EOF)
(void) putchar(t);
goto out;
err:
if (collf != NULL) {
goto out;
err:
if (collf != NULL) {
fprintf(stderr, "File exists\n");
return(-1);
}
fprintf(stderr, "File exists\n");
return(-1);
}
- if ((of = fopen(name, "w")) == NULL) {
+ if ((of = Fopen(name, "w")) == NULL) {
perror(NOSTR);
return(-1);
}
perror(NOSTR);
return(-1);
}
(void) putc(c, of);
if (ferror(of)) {
perror(name);
(void) putc(c, of);
if (ferror(of)) {
perror(name);
printf("%d/%ld\n", lc, cc);
fflush(stdout);
return(0);
printf("%d/%ld\n", lc, cc);
fflush(stdout);
return(0);
if (nf != NULL) {
fseek(nf, (off_t)0, 2);
collf = nf;
if (nf != NULL) {
fseek(nf, (off_t)0, 2);
collf = nf;
}
(void) signal(SIGINT, sigint);
}
}
(void) signal(SIGINT, sigint);
}
sig_t sigint = signal(SIGINT, SIG_IGN);
extern char tempEdit[];
sig_t sigint = signal(SIGINT, SIG_IGN);
extern char tempEdit[];
- if ((nf = fopen(tempEdit, "w+")) == NULL) {
+ if ((nf = Fopen(tempEdit, "w+")) == NULL) {
perror(tempEdit);
goto out;
}
perror(tempEdit);
goto out;
}
* stdout = new message.
*/
if (run_command(cmd, 0, fileno(fp), fileno(nf), NOSTR) < 0) {
* stdout = new message.
*/
if (run_command(cmd, 0, fileno(fp), fileno(nf), NOSTR) < 0) {
goto out;
}
if (fsize(nf) == 0) {
fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
goto out;
}
if (fsize(nf) == 0) {
fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
*/
(void) fseek(nf, 0L, 2);
collf = nf;
*/
(void) fseek(nf, 0L, 2);
collf = nf;
out:
(void) signal(SIGINT, sigint);
}
out:
(void) signal(SIGINT, sigint);
}
return;
cp = getdeadletter();
c = umask(077);
return;
cp = getdeadletter();
c = umask(077);
(void) umask(c);
if (dbuf == NULL)
return;
while ((c = getc(fp)) != EOF)
(void) putc(c, dbuf);
(void) umask(c);
if (dbuf == NULL)
return;
while ((c = getc(fp)) != EOF)
(void) putc(c, dbuf);
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)def.h 5.21 (Berkeley) %G%
+ * @(#)def.h 5.22 (Berkeley) %G%
*/
#include <sys/param.h> /* includes <sys/types.h> */
*/
#include <sys/param.h> /* includes <sys/types.h> */
* Forward declarations of routine types to keep lint and cc happy.
*/
* Forward declarations of routine types to keep lint and cc happy.
*/
FILE *Fdopen();
FILE *Popen();
FILE *collect();
FILE *Fdopen();
FILE *Popen();
FILE *collect();
-static char sccsid[] = "@(#)edit.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)edit.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
}
if (ferror(otf))
perror("/tmp");
}
if (ferror(otf))
perror("/tmp");
}
(void) signal(SIGINT, sigint);
}
}
(void) signal(SIGINT, sigint);
}
perror(tempEdit);
goto out;
}
perror(tempEdit);
goto out;
}
- if ((nf = fdopen(t, "w")) == NULL) {
+ if ((nf = Fdopen(t, "w")) == NULL) {
perror(tempEdit);
(void) unlink(tempEdit);
goto out;
perror(tempEdit);
(void) unlink(tempEdit);
goto out;
modtime = 0;
else
modtime = statb.st_mtime;
modtime = 0;
else
modtime = statb.st_mtime;
- if (ferror(nf) || fclose(nf) < 0) {
+ if (ferror(nf)) {
+ (void) Fclose(nf);
+ perror(tempEdit);
+ (void) unlink(tempEdit);
+ nf = NULL;
+ goto out;
+ }
+ if (Fclose(nf) < 0) {
perror(tempEdit);
(void) unlink(tempEdit);
nf = NULL;
perror(tempEdit);
(void) unlink(tempEdit);
nf = NULL;
/*
* Now switch to new file.
*/
/*
* Now switch to new file.
*/
- if ((nf = fopen(tempEdit, "a+")) == NULL) {
+ if ((nf = Fopen(tempEdit, "a+")) == NULL) {
perror(tempEdit);
(void) unlink(tempEdit);
goto out;
perror(tempEdit);
(void) unlink(tempEdit);
goto out;
-static char sccsid[] = "@(#)fio.c 5.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)fio.c 5.23 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
if ((c = opentemp(tempSet)) < 0)
exit(1);
if ((c = opentemp(tempSet)) < 0)
exit(1);
- if ((mestmp = fdopen(c, "r+")) == NULL)
+ if ((mestmp = Fdopen(c, "r+")) == NULL)
panic("Can't open temporary");
msgCount = 0;
maybe = 1;
panic("Can't open temporary");
msgCount = 0;
maybe = 1;
perror(tempSet);
exit(1);
}
perror(tempSet);
exit(1);
}
makemessage(mestmp);
return;
}
makemessage(mestmp);
return;
}
panic("Message temporary file corrupted");
message[msgCount].m_size = 0;
message[msgCount].m_lines = 0;
panic("Message temporary file corrupted");
message[msgCount].m_size = 0;
message[msgCount].m_lines = 0;
-
-/*
- * A nicer version of Fdopen, which allows us to fclose
- * without losing the open file.
- */
-FILE *
-Fdopen(fildes, mode)
- char *mode;
-{
- int f;
-
- if ((f = dup(fildes)) < 0) {
- perror("dup");
- return (NULL);
- }
- return fdopen(f, mode);
-}
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)glob.h 5.19 (Berkeley) %G%
+ * @(#)glob.h 5.20 (Berkeley) %G%
int cond; /* Current state of conditional exc. */
FILE *itf; /* Input temp file buffer */
FILE *otf; /* Output temp file buffer */
int cond; /* Current state of conditional exc. */
FILE *itf; /* Input temp file buffer */
FILE *otf; /* Output temp file buffer */
-FILE *pipef; /* Pipe file we have opened */
int image; /* File descriptor for image of msg */
FILE *input; /* Current command input file */
char mailname[PATHSIZE]; /* Name of current file */
int image; /* File descriptor for image of msg */
FILE *input; /* Current command input file */
char mailname[PATHSIZE]; /* Name of current file */
-static char sccsid[] = "@(#)lex.c 5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c 5.21 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
if ((name = expand(name)) == NOSTR)
return -1;
if ((name = expand(name)) == NOSTR)
return -1;
- if ((ibuf = fopen(name, "r")) == NULL) {
+ if ((ibuf = Fopen(name, "r")) == NULL) {
if (!isedit && errno == ENOENT)
goto nomail;
perror(name);
if (!isedit && errno == ENOENT)
goto nomail;
perror(name);
if (fstat(fileno(ibuf), &stb) < 0) {
perror("fstat");
if (fstat(fileno(ibuf), &stb) < 0) {
perror("fstat");
return (-1);
}
switch (stb.st_mode & S_IFMT) {
case S_IFDIR:
return (-1);
}
switch (stb.st_mode & S_IFMT) {
case S_IFDIR:
errno = EISDIR;
perror(name);
return (-1);
errno = EISDIR;
perror(name);
return (-1);
errno = EINVAL;
perror(name);
return (-1);
errno = EINVAL;
perror(name);
return (-1);
remove(tempMesg);
setptr(ibuf);
setmsize(msgCount);
remove(tempMesg);
setptr(ibuf);
setmsize(msgCount);
relsesigs();
sawcom = 0;
if (!edit && msgCount == 0) {
relsesigs();
sawcom = 0;
if (!edit && msgCount == 0) {
int inithdr; /* am printing startup headers */
int inithdr; /* am printing startup headers */
-#ifdef _NFILE
-static
-_fwalk(function)
- register int (*function)();
-{
- register FILE *iop;
-
- for (iop = _iob; iop < _iob + _NFILE; iop++)
- (*function)(iop);
-}
-#endif
-
-static
-xclose(iop)
- register FILE *iop;
-{
- if (iop == stdin || iop == stdout ||
- iop == stderr || iop == itf || iop == otf)
- return;
-
- if (iop != pipef)
- fclose(iop);
- else {
- Pclose(pipef);
- pipef = NULL;
- }
-}
-
while (sourcing)
unstack();
while (sourcing)
unstack();
- /*
- * Walk through all the open FILEs, applying xclose() to them
- */
- _fwalk(xclose);
if (image >= 0) {
close(image);
if (image >= 0) {
close(image);
{
register FILE *in, *oldin;
{
register FILE *in, *oldin;
- if ((in = fopen(name, "r")) == NULL)
+ if ((in = Fopen(name, "r")) == NULL)
return;
oldin = input;
input = in;
return;
oldin = input;
input = in;
loading = 0;
sourcing = 0;
input = oldin;
loading = 0;
sourcing = 0;
input = oldin;
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.26 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.27 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
load(_PATH_MASTER_RC);
/*
* Expand returns a savestr, but load only uses the file name
load(_PATH_MASTER_RC);
/*
* Expand returns a savestr, but load only uses the file name
- * for fopen, so it's save to do this.
+ * for fopen, so it's safe to do this.
*/
load(expand("~/.mailrc"));
if (!rcvmode) {
*/
load(expand("~/.mailrc"));
if (!rcvmode) {
-static char sccsid[] = "@(#)names.c 5.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)names.c 5.16 (Berkeley) %G%";
- if ((fout = fopen(tempEdit, "a")) == NULL) {
+ if ((fout = Fopen(tempEdit, "a")) == NULL) {
perror(tempEdit);
senderr++;
goto cant;
perror(tempEdit);
senderr++;
goto cant;
if (image < 0) {
perror(tempEdit);
senderr++;
if (image < 0) {
perror(tempEdit);
senderr++;
- else {
- fprintf(fout, "From %s %s", myname, date);
- puthead(hp, fout, GTO|GSUBJECT|GCC|GNL);
- while ((c = getc(fo)) != EOF)
- (void) putc(c, fout);
- rewind(fo);
- (void) putc('\n', fout);
- (void) fflush(fout);
- if (ferror(fout))
- perror(tempEdit);
- (void) fclose(fout);
- }
+ fprintf(fout, "From %s %s", myname, date);
+ puthead(hp, fout, GTO|GSUBJECT|GCC|GNL);
+ while ((c = getc(fo)) != EOF)
+ (void) putc(c, fout);
+ rewind(fo);
+ (void) putc('\n', fout);
+ (void) fflush(fout);
+ if (ferror(fout))
+ perror(tempEdit);
+ (void) Fclose(fout);
- /* XXX, can't really reuse the same image file */
+ /*
+ * XXX
+ * We can't really reuse the same image file,
+ * because multiple piped recipients will
+ * share the same lseek location and trample
+ * on one another.
+ */
if ((shell = value("SHELL")) == NOSTR)
shell = _PATH_CSHELL;
pid = start_command(shell, sigmask(SIGHUP)|
if ((shell = value("SHELL")) == NOSTR)
shell = _PATH_CSHELL;
pid = start_command(shell, sigmask(SIGHUP)|
}
free_child(pid);
} else {
}
free_child(pid);
} else {
- if ((fout = fopen(fname, "a")) == NULL) {
+ int f;
+ if ((fout = Fopen(fname, "a")) == NULL) {
perror(fname);
senderr++;
goto cant;
}
perror(fname);
senderr++;
goto cant;
}
- fin = Fdopen(image, "r");
+ if ((f = dup(image)) < 0) {
+ perror("dup");
+ fin = NULL;
+ } else
+ fin = Fdopen(f, "r");
if (fin == NULL) {
fprintf(stderr, "Can't reopen image\n");
if (fin == NULL) {
fprintf(stderr, "Can't reopen image\n");
(void) putc(c, fout);
if (ferror(fout))
senderr++, perror(fname);
(void) putc(c, fout);
if (ferror(fout))
senderr++, perror(fname);
- (void) fclose(fout);
- (void) fclose(fin);
+ (void) Fclose(fout);
+ (void) Fclose(fin);
-static char sccsid[] = "@(#)popen.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)popen.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
#define WRITE 1
static int *pid;
#define WRITE 1
static int *pid;
+struct fp {
+ FILE *fp;
+ int pipe;
+ struct fp *link;
+};
+static struct fp *fp_head;
+
+FILE *
+Fopen(file, mode)
+ char *file, *mode;
+{
+ FILE *fp;
+
+ if ((fp = fopen(file, mode)) != NULL)
+ register_file(fp, 0);
+ return fp;
+}
+
+FILE *
+Fdopen(fd, mode)
+ char *mode;
+{
+ FILE *fp;
+
+ if ((fp = fdopen(fd, mode)) != NULL)
+ register_file(fp, 0);
+ return fp;
+}
+
+Fclose(fp)
+ FILE *fp;
+{
+ unregister_file(fp);
+ return fclose(fp);
+}
+
FILE *
Popen(cmd, mode)
char *cmd;
FILE *
Popen(cmd, mode)
char *cmd;
{
int p[2];
int myside, hisside, fd0, fd1;
{
int p[2];
int myside, hisside, fd0, fd1;
if (pid == 0)
pid = (int *) malloc((unsigned) sizeof (int) * getdtablesize());
if (pid == 0)
pid = (int *) malloc((unsigned) sizeof (int) * getdtablesize());
close(p[WRITE]);
return NULL;
}
close(p[WRITE]);
return NULL;
}
- close(hisside);
- return fdopen(myside, mode);
+ (void) close(hisside);
+ if ((fp = fdopen(myside, mode)) != NULL)
+ register_file(fp, 1);
+ return fp;
int omask;
i = fileno(ptr);
int omask;
i = fileno(ptr);
+ unregister_file(ptr);
+ (void) fclose(ptr);
omask = sigblock(sigmask(SIGINT)|sigmask(SIGHUP));
i = wait_child(pid[i]);
sigsetmask(omask);
return i;
}
omask = sigblock(sigmask(SIGINT)|sigmask(SIGHUP));
i = wait_child(pid[i]);
sigsetmask(omask);
return i;
}
+close_all_files()
+{
+
+ while (fp_head)
+ if (fp_head->pipe)
+ (void) Pclose(fp_head->fp);
+ else
+ (void) Fclose(fp_head->fp);
+}
+
+register_file(fp, pipe)
+ FILE *fp;
+{
+ struct fp *fpp;
+
+ if ((fpp = (struct fp *) malloc(sizeof *fpp)) == NULL)
+ panic("Out of memory");
+ fpp->fp = fp;
+ fpp->pipe = pipe;
+ fpp->link = fp_head;
+ fp_head = fpp;
+}
+
+unregister_file(fp)
+ FILE *fp;
+{
+ struct fp **pp, *p;
+
+ for (pp = &fp_head; p = *pp; pp = &p->link)
+ if (p->fp == fp) {
+ *pp = p->link;
+ free((char *) p);
+ return;
+ }
+ /* XXX
+ * Ignore this for now; there may still be uncaught
+ * duplicate closes.
+ panic("Invalid file pointer");
+ */
+}
+
/*
* Run a command without a shell, with optional arguments and splicing
* of stdin and stdout. The command name can be a sequence of words.
/*
* Run a command without a shell, with optional arguments and splicing
* of stdin and stdout. The command name can be a sequence of words.
-static char sccsid[] = "@(#)quit.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)quit.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
- fbuf = fopen(mailname, "r");
+ fbuf = Fopen(mailname, "r");
if (fbuf == NULL)
goto newmail;
flock(fileno(fbuf), LOCK_EX);
rbuf = NULL;
if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
printf("New mail has arrived.\n");
if (fbuf == NULL)
goto newmail;
flock(fileno(fbuf), LOCK_EX);
rbuf = NULL;
if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
printf("New mail has arrived.\n");
- rbuf = fopen(tempResid, "w");
+ rbuf = Fopen(tempResid, "w");
if (rbuf == NULL || fbuf == NULL)
goto newmail;
#ifdef APPEND
if (rbuf == NULL || fbuf == NULL)
goto newmail;
#ifdef APPEND
(void) putc(c, rbuf);
}
#endif
(void) putc(c, rbuf);
}
#endif
- fclose(rbuf);
- if ((rbuf = fopen(tempResid, "r")) == NULL)
+ Fclose(rbuf);
+ if ((rbuf = Fopen(tempResid, "r")) == NULL)
goto newmail;
remove(tempResid);
}
goto newmail;
remove(tempResid);
}
}
modify = 0;
if (Tflag != NOSTR) {
}
modify = 0;
if (Tflag != NOSTR) {
- if ((readstat = fopen(Tflag, "w")) == NULL)
+ if ((readstat = Fopen(Tflag, "w")) == NULL)
Tflag = NOSTR;
}
for (c = 0, p = 0, mp = &message[0]; mp < &message[msgCount]; mp++) {
Tflag = NOSTR;
}
for (c = 0, p = 0, mp = &message[0]; mp < &message[msgCount]; mp++) {
if (p == msgCount && !modify && !anystat) {
printf("Held %d message%s in %s\n",
p, p == 1 ? "" : "s", mailname);
if (p == msgCount && !modify && !anystat) {
printf("Held %d message%s in %s\n",
p, p == 1 ? "" : "s", mailname);
return;
}
if (c == 0) {
if (p != 0) {
writeback(rbuf);
return;
}
if (c == 0) {
if (p != 0) {
writeback(rbuf);
mbox = expand("&");
mcount = c;
if (value("append") == NOSTR) {
mbox = expand("&");
mcount = c;
if (value("append") == NOSTR) {
- if ((obuf = fopen(tempQuit, "w")) == NULL) {
+ if ((obuf = Fopen(tempQuit, "w")) == NULL) {
- if ((ibuf = fopen(tempQuit, "r")) == NULL) {
+ if ((ibuf = Fopen(tempQuit, "r")) == NULL) {
perror(tempQuit);
remove(tempQuit);
perror(tempQuit);
remove(tempQuit);
- fclose(obuf);
- fclose(fbuf);
+ Fclose(obuf);
+ Fclose(fbuf);
return;
}
remove(tempQuit);
return;
}
remove(tempQuit);
- if ((abuf = fopen(mbox, "r")) != NULL) {
+ if ((abuf = Fopen(mbox, "r")) != NULL) {
while ((c = getc(abuf)) != EOF)
(void) putc(c, obuf);
while ((c = getc(abuf)) != EOF)
(void) putc(c, obuf);
}
if (ferror(obuf)) {
perror(tempQuit);
}
if (ferror(obuf)) {
perror(tempQuit);
- fclose(ibuf);
- fclose(obuf);
- fclose(fbuf);
+ Fclose(ibuf);
+ Fclose(obuf);
+ Fclose(fbuf);
close(creat(mbox, 0600));
close(creat(mbox, 0600));
- if ((obuf = fopen(mbox, "r+")) == NULL) {
+ if ((obuf = Fopen(mbox, "r+")) == NULL) {
- fclose(ibuf);
- fclose(fbuf);
+ Fclose(ibuf);
+ Fclose(fbuf);
return;
}
}
if (value("append") != NOSTR) {
return;
}
}
if (value("append") != NOSTR) {
- if ((obuf = fopen(mbox, "a")) == NULL) {
+ if ((obuf = Fopen(mbox, "a")) == NULL) {
return;
}
fchmod(fileno(obuf), 0600);
return;
}
fchmod(fileno(obuf), 0600);
if (mp->m_flag & MBOX)
if (send(mp, obuf, saveignore, NOSTR) < 0) {
perror(mbox);
if (mp->m_flag & MBOX)
if (send(mp, obuf, saveignore, NOSTR) < 0) {
perror(mbox);
- fclose(ibuf);
- fclose(obuf);
- fclose(fbuf);
+ Fclose(ibuf);
+ Fclose(obuf);
+ Fclose(fbuf);
fflush(obuf);
}
trunc(obuf);
if (ferror(obuf)) {
perror(mbox);
fflush(obuf);
}
trunc(obuf);
if (ferror(obuf)) {
perror(mbox);
- fclose(obuf);
- fclose(fbuf);
+ Fclose(obuf);
+ Fclose(fbuf);
if (mcount == 1)
printf("Saved 1 message in mbox\n");
else
if (mcount == 1)
printf("Saved 1 message in mbox\n");
else
if (p != 0) {
writeback(rbuf);
if (p != 0) {
writeback(rbuf);
cream:
if (rbuf != NULL) {
cream:
if (rbuf != NULL) {
- abuf = fopen(mailname, "r+");
+ abuf = Fopen(mailname, "r+");
if (abuf == NULL)
goto newmail;
while ((c = getc(rbuf)) != EOF)
(void) putc(c, abuf);
if (abuf == NULL)
goto newmail;
while ((c = getc(rbuf)) != EOF)
(void) putc(c, abuf);
return;
newmail:
printf("Thou hast new mail.\n");
if (fbuf != NULL)
return;
newmail:
printf("Thou hast new mail.\n");
if (fbuf != NULL)
- if ((obuf = fopen(mailname, "r+")) == NULL) {
+ if ((obuf = Fopen(mailname, "r+")) == NULL) {
perror(mailname);
return(-1);
}
perror(mailname);
return(-1);
}
p++;
if (send(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
perror(mailname);
p++;
if (send(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
perror(mailname);
trunc(obuf);
if (ferror(obuf)) {
perror(mailname);
trunc(obuf);
if (ferror(obuf)) {
perror(mailname);
return(-1);
}
if (res != NULL)
return(-1);
}
if (res != NULL)
- fclose(res);
- fclose(obuf);
+ Fclose(res);
+ Fclose(obuf);
alter(mailname);
if (p == 1)
printf("Held 1 message in %s\n", mailname);
alter(mailname);
if (p == 1)
printf("Held 1 message in %s\n", mailname);
return;
holdsigs();
if (Tflag != NOSTR) {
return;
holdsigs();
if (Tflag != NOSTR) {
- if ((readstat = fopen(Tflag, "w")) == NULL)
+ if ((readstat = Fopen(Tflag, "w")) == NULL)
Tflag = NOSTR;
}
for (mp = &message[0], gotcha = 0; mp < &message[msgCount]; mp++) {
Tflag = NOSTR;
}
for (mp = &message[0], gotcha = 0; mp < &message[msgCount]; mp++) {
if (!gotcha || Tflag != NOSTR)
goto done;
ibuf = NULL;
if (!gotcha || Tflag != NOSTR)
goto done;
ibuf = NULL;
strcpy(tempname, _PATH_TMP);
strcat(tempname, "mboxXXXXXX");
mktemp(tempname);
strcpy(tempname, _PATH_TMP);
strcat(tempname, "mboxXXXXXX");
mktemp(tempname);
- if ((obuf = fopen(tempname, "w")) == NULL) {
+ if ((obuf = Fopen(tempname, "w")) == NULL) {
perror(tempname);
relsesigs();
reset(0);
}
perror(tempname);
relsesigs();
reset(0);
}
- if ((ibuf = fopen(mailname, "r")) == NULL) {
+ if ((ibuf = Fopen(mailname, "r")) == NULL) {
remove(tempname);
relsesigs();
reset(0);
remove(tempname);
relsesigs();
reset(0);
fseek(ibuf, mailsize, 0);
while ((c = getc(ibuf)) != EOF)
(void) putc(c, obuf);
fseek(ibuf, mailsize, 0);
while ((c = getc(ibuf)) != EOF)
(void) putc(c, obuf);
- fclose(ibuf);
- fclose(obuf);
- if ((ibuf = fopen(tempname, "r")) == NULL) {
+ Fclose(ibuf);
+ Fclose(obuf);
+ if ((ibuf = Fopen(tempname, "r")) == NULL) {
perror(tempname);
remove(tempname);
relsesigs();
perror(tempname);
remove(tempname);
relsesigs();
}
printf("\"%s\" ", mailname);
fflush(stdout);
}
printf("\"%s\" ", mailname);
fflush(stdout);
- if ((obuf = fopen(mailname, "r+")) == NULL) {
+ if ((obuf = Fopen(mailname, "r+")) == NULL) {
perror(mailname);
relsesigs();
reset(0);
perror(mailname);
relsesigs();
reset(0);
if (ibuf != NULL) {
while ((c = getc(ibuf)) != EOF)
(void) putc(c, obuf);
if (ibuf != NULL) {
while ((c = getc(ibuf)) != EOF)
(void) putc(c, obuf);
}
fflush(obuf);
if (ferror(obuf)) {
}
fflush(obuf);
if (ferror(obuf)) {
if (gotcha) {
remove(mailname);
printf("removed\n");
if (gotcha) {
remove(mailname);
printf("removed\n");
-static char sccsid[] = "@(#)send.c 5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)send.c 5.21 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
if (access(_PATH_MAIL_LOG, 0) == 0) {
FILE *postage;
if (access(_PATH_MAIL_LOG, 0) == 0) {
FILE *postage;
- if ((postage = fopen(_PATH_MAIL_LOG, "a")) != NULL) {
+ if ((postage = Fopen(_PATH_MAIL_LOG, "a")) != NULL) {
fprintf(postage, "%s %d %ld\n", myname,
count(to), fsize(mtf));
fprintf(postage, "%s %d %ld\n", myname,
count(to), fsize(mtf));
- (void) fclose(postage);
+ (void) Fclose(postage);
}
}
prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)|
}
}
prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)|
else
free_child(pid);
out:
else
free_child(pid);
out:
register FILE *nfo, *nfi;
register int c;
register FILE *nfo, *nfi;
register int c;
- if ((nfo = fopen(tempMail, "w")) == NULL) {
+ if ((nfo = Fopen(tempMail, "w")) == NULL) {
perror(tempMail);
return(fi);
}
perror(tempMail);
return(fi);
}
- if ((nfi = fopen(tempMail, "r")) == NULL) {
+ if ((nfi = Fopen(tempMail, "r")) == NULL) {
return(fi);
}
(void) remove(tempMail);
return(fi);
}
(void) remove(tempMail);
(void) fflush(nfo);
if (ferror(nfo)) {
perror(tempMail);
(void) fflush(nfo);
if (ferror(nfo)) {
perror(tempMail);
- (void) fclose(nfo);
- (void) fclose(nfi);
+ (void) Fclose(nfo);
+ (void) Fclose(nfi);
rewind(fi);
return(fi);
}
rewind(fi);
return(fi);
}
- (void) fclose(nfo);
- (void) fclose(fi);
+ (void) Fclose(nfo);
+ (void) Fclose(fi);
rewind(nfi);
return(nfi);
}
rewind(nfi);
return(nfi);
}
time_t now, time();
char *ctime();
time_t now, time();
char *ctime();
- if ((fo = fopen(name, "a")) == NULL) {
+ if ((fo = Fopen(name, "a")) == NULL) {
perror(name);
return (-1);
}
perror(name);
return (-1);
}
(void) fflush(fo);
if (ferror(fo))
perror(name);
(void) fflush(fo);
if (ferror(fo))
perror(name);
rewind(fi);
return (0);
}
rewind(fi);
return (0);
}