projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history]
/
usr
/
src
/
usr.bin
/
mail
/
collect.c
diff --git
a/usr/src/usr.bin/mail/collect.c
b/usr/src/usr.bin/mail/collect.c
index
ade3e43
..
73a0d98
100644
(file)
--- a/
usr/src/usr.bin/mail/collect.c
+++ b/
usr/src/usr.bin/mail/collect.c
@@
-1,12
+1,12
@@
/*
/*
- * Copyright (c) 1980
Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980
, 1993
+ *
The Regents of the University of California.
All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
*
* %sccs.include.redist.c%
*/
#ifndef lint
-static char sccsid[] = "@(#)collect.c
5.2
1 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c
8.
1 (Berkeley) %G%";
#endif /* not lint */
/*
#endif /* not lint */
/*
@@
-17,7
+17,7
@@
static char sccsid[] = "@(#)collect.c 5.21 (Berkeley) %G%";
*/
#include "rcv.h"
*/
#include "rcv.h"
-#include
<sys/stat.h>
+#include
"extern.h"
/*
* Read a message from standard output and return a read file to it
/*
* Read a message from standard output and return a read file to it
@@
-45,15
+45,16
@@
static jmp_buf collabort; /* To end collection with error */
FILE *
collect(hp, printheaders)
struct header *hp;
FILE *
collect(hp, printheaders)
struct header *hp;
+ int printheaders;
{
FILE *fbuf;
int lc, cc, escape, eofcount;
{
FILE *fbuf;
int lc, cc, escape, eofcount;
- int collint(), collhup(), collstop();
register int c, t;
char linebuf[LINESIZE], *cp;
extern char tempMail[];
char getsub;
int omask;
register int c, t;
char linebuf[LINESIZE], *cp;
extern char tempMail[];
char getsub;
int omask;
+ void collint(), collhup(), collstop();
collf = NULL;
/*
collf = NULL;
/*
@@
-69,13
+70,13
@@
collect(hp, printheaders)
savettou = signal(SIGTTOU, collstop);
savettin = signal(SIGTTIN, collstop);
if (setjmp(collabort) || setjmp(colljmp)) {
savettou = signal(SIGTTOU, collstop);
savettin = signal(SIGTTIN, collstop);
if (setjmp(collabort) || setjmp(colljmp)) {
- r
emove
(tempMail);
+ r
m
(tempMail);
goto err;
}
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
noreset++;
goto err;
}
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
noreset++;
- if ((collf =
f
open(tempMail, "w+")) == NULL) {
+ if ((collf =
F
open(tempMail, "w+")) == NULL) {
perror(tempMail);
goto err;
}
perror(tempMail);
goto err;
}
@@
-247,7
+248,7
@@
cont:
printf("%s: Directory\n", cp);
break;
}
printf("%s: Directory\n", cp);
break;
}
- if ((fbuf =
f
open(cp, "r")) == NULL) {
+ if ((fbuf =
F
open(cp, "r")) == NULL) {
perror(cp);
break;
}
perror(cp);
break;
}
@@
-258,12
+259,12
@@
cont:
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) {
-
f
close(fbuf);
+
F
close(fbuf);
goto err;
}
cc += t;
}
goto err;
}
cc += t;
}
-
f
close(fbuf);
+
F
close(fbuf);
printf("%d/%d\n", lc, cc);
break;
case 'w':
printf("%d/%d\n", lc, cc);
break;
case 'w':
@@
-296,13
+297,13
@@
cont:
goto err;
goto cont;
case '?':
goto err;
goto cont;
case '?':
- if ((fbuf =
f
open(_PATH_TILDE, "r")) == NULL) {
+ if ((fbuf =
F
open(_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);
-
f
close(fbuf);
+
F
close(fbuf);
break;
case 'p':
/*
break;
case 'p':
/*
@@
-338,7
+339,7
@@
cont:
goto out;
err:
if (collf != NULL) {
goto out;
err:
if (collf != NULL) {
-
f
close(collf);
+
F
close(collf);
collf = NULL;
}
out:
collf = NULL;
}
out:
@@
-358,10
+359,11
@@
out:
/*
* Write a file, ex-like if f set.
*/
/*
* Write a file, ex-like if f set.
*/
-
+int
exwrite(name, fp, f)
char name[];
FILE *fp;
exwrite(name, fp, f)
char name[];
FILE *fp;
+ int f;
{
register FILE *of;
register int c;
{
register FILE *of;
register int c;
@@
-379,7
+381,7
@@
exwrite(name, fp, f)
fprintf(stderr, "File exists\n");
return(-1);
}
fprintf(stderr, "File exists\n");
return(-1);
}
- if ((of =
f
open(name, "w")) == NULL) {
+ if ((of =
F
open(name, "w")) == NULL) {
perror(NOSTR);
return(-1);
}
perror(NOSTR);
return(-1);
}
@@
-392,11
+394,11
@@
exwrite(name, fp, f)
(void) putc(c, of);
if (ferror(of)) {
perror(name);
(void) putc(c, of);
if (ferror(of)) {
perror(name);
-
f
close(of);
+
F
close(of);
return(-1);
}
}
return(-1);
}
}
-
f
close(of);
+
F
close(of);
printf("%d/%ld\n", lc, cc);
fflush(stdout);
return(0);
printf("%d/%ld\n", lc, cc);
fflush(stdout);
return(0);
@@
-406,16
+408,18
@@
exwrite(name, fp, f)
* Edit the message being collected on fp.
* On return, make the edit file the new temp file.
*/
* Edit the message being collected on fp.
* On return, make the edit file the new temp file.
*/
+void
mesedit(fp, c)
FILE *fp;
mesedit(fp, c)
FILE *fp;
+ int c;
{
sig_t sigint = signal(SIGINT, SIG_IGN);
FILE *nf = run_editor(fp, (off_t)-1, c, 0);
if (nf != NULL) {
{
sig_t sigint = signal(SIGINT, SIG_IGN);
FILE *nf = run_editor(fp, (off_t)-1, c, 0);
if (nf != NULL) {
- fseek(nf,
(off_t)0
, 2);
+ fseek(nf,
0L
, 2);
collf = nf;
collf = nf;
-
f
close(fp);
+
F
close(fp);
}
(void) signal(SIGINT, sigint);
}
}
(void) signal(SIGINT, sigint);
}
@@
-426,6
+430,7
@@
mesedit(fp, c)
* New message collected from stdout.
* Sh -c must return 0 to accept the new message.
*/
* New message collected from stdout.
* Sh -c must return 0 to accept the new message.
*/
+void
mespipe(fp, cmd)
FILE *fp;
char cmd[];
mespipe(fp, cmd)
FILE *fp;
char cmd[];
@@
-434,7
+439,7
@@
mespipe(fp, cmd)
sig_t sigint = signal(SIGINT, SIG_IGN);
extern char tempEdit[];
sig_t sigint = signal(SIGINT, SIG_IGN);
extern char tempEdit[];
- if ((nf =
f
open(tempEdit, "w+")) == NULL) {
+ if ((nf =
F
open(tempEdit, "w+")) == NULL) {
perror(tempEdit);
goto out;
}
perror(tempEdit);
goto out;
}
@@
-443,13
+448,14
@@
mespipe(fp, cmd)
* stdin = current message.
* stdout = new message.
*/
* stdin = current message.
* stdout = new message.
*/
- if (run_command(cmd, 0, fileno(fp), fileno(nf), NOSTR) < 0) {
- (void) fclose(nf);
+ if (run_command(cmd,
+ 0, fileno(fp), fileno(nf), NOSTR, NOSTR, NOSTR) < 0) {
+ (void) Fclose(nf);
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)
f
close(nf);
+ (void)
F
close(nf);
goto out;
}
/*
goto out;
}
/*
@@
-457,7
+463,7
@@
mespipe(fp, cmd)
*/
(void) fseek(nf, 0L, 2);
collf = nf;
*/
(void) fseek(nf, 0L, 2);
collf = nf;
- (void)
f
close(fp);
+ (void)
F
close(fp);
out:
(void) signal(SIGINT, sigint);
}
out:
(void) signal(SIGINT, sigint);
}
@@
-470,9
+476,11
@@
out:
* the message temporary. The flag argument is 'm' if we
* should shift over and 'f' if not.
*/
* the message temporary. The flag argument is 'm' if we
* should shift over and 'f' if not.
*/
+int
forward(ms, fp, f)
char ms[];
FILE *fp;
forward(ms, fp, f)
char ms[];
FILE *fp;
+ int f;
{
register int *msgvec;
extern char tempMail[];
{
register int *msgvec;
extern char tempMail[];
@@
-516,7
+524,9
@@
forward(ms, fp, f)
* Print (continue) when continued after ^Z.
*/
/*ARGSUSED*/
* Print (continue) when continued after ^Z.
*/
/*ARGSUSED*/
+void
collstop(s)
collstop(s)
+ int s;
{
sig_t old_action = signal(s, SIG_DFL);
{
sig_t old_action = signal(s, SIG_DFL);
@@
-536,7
+546,9
@@
collstop(s)
* Then jump out of the collection loop.
*/
/*ARGSUSED*/
* Then jump out of the collection loop.
*/
/*ARGSUSED*/
+void
collint(s)
collint(s)
+ int s;
{
/*
* the control flow is subtle, because we can be called from ~q.
{
/*
* the control flow is subtle, because we can be called from ~q.
@@
-558,7
+570,9
@@
collint(s)
}
/*ARGSUSED*/
}
/*ARGSUSED*/
+void
collhup(s)
collhup(s)
+ int s;
{
rewind(collf);
savedeadletter(collf);
{
rewind(collf);
savedeadletter(collf);
@@
-569,6
+583,7
@@
collhup(s)
exit(1);
}
exit(1);
}
+void
savedeadletter(fp)
register FILE *fp;
{
savedeadletter(fp)
register FILE *fp;
{
@@
-580,12
+595,12
@@
savedeadletter(fp)
return;
cp = getdeadletter();
c = umask(077);
return;
cp = getdeadletter();
c = umask(077);
- dbuf =
f
open(cp, "a");
+ dbuf =
F
open(cp, "a");
(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);
-
f
close(dbuf);
+
F
close(dbuf);
rewind(fp);
}
rewind(fp);
}