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
date and time created 83/02/11 15:44:29 by rrh
[unix-history]
/
usr
/
src
/
usr.bin
/
mail
/
fio.c
diff --git
a/usr/src/usr.bin/mail/fio.c
b/usr/src/usr.bin/mail/fio.c
index
d5e3bb2
..
41c677c
100644
(file)
--- a/
usr/src/usr.bin/mail/fio.c
+++ b/
usr/src/usr.bin/mail/fio.c
@@
-10,7
+10,7
@@
* File I/O.
*/
* File I/O.
*/
-static char *SccsId = "@(#)fio.c
1
.12 %G%";
+static char *SccsId = "@(#)fio.c
2
.12 %G%";
/*
* Set up the input pointers while copying the mail file into
/*
* Set up the input pointers while copying the mail file into
@@
-22,7
+22,8
@@
setptr(ibuf)
{
register int c;
register char *cp, *cp2;
{
register int c;
register char *cp, *cp2;
- register int count, s, l;
+ register int count, l;
+ long s;
off_t offset;
char linebuf[LINESIZE];
char wbuf[LINESIZE];
off_t offset;
char linebuf[LINESIZE];
char wbuf[LINESIZE];
@@
-34,7
+35,7
@@
setptr(ibuf)
exit(1);
msgCount = 0;
offset = 0;
exit(1);
msgCount = 0;
offset = 0;
- s = 0;
+ s = 0
L
;
l = 0;
maybe = 1;
flag = MUSED|MNEW;
l = 0;
maybe = 1;
flag = MUSED|MNEW;
@@
-42,7
+43,7
@@
setptr(ibuf)
cp = linebuf;
c = getc(ibuf);
while (c != EOF && c != '\n') {
cp = linebuf;
c = getc(ibuf);
while (c != EOF && c != '\n') {
- if (cp - linebuf >=
BUFSIZ
- 1) {
+ if (cp - linebuf >=
LINESIZE
- 1) {
ungetc(c, ibuf);
*cp = 0;
break;
ungetc(c, ibuf);
*cp = 0;
break;
@@
-84,7
+85,7
@@
setptr(ibuf)
this.m_offset = offsetof(offset);
this.m_size = s;
this.m_lines = l;
this.m_offset = offsetof(offset);
this.m_size = s;
this.m_lines = l;
- s = 0;
+ s = 0
L
;
l = 0;
if (append(&this, mestmp)) {
perror(tempSet);
l = 0;
if (append(&this, mestmp)) {
perror(tempSet);
@@
-109,7
+110,7
@@
setptr(ibuf)
}
}
offset += count;
}
}
offset += count;
- s += count;
+ s +=
(long)
count;
l++;
maybe = 0;
if (linebuf[0] == 0)
l++;
maybe = 0;
if (linebuf[0] == 0)
@@
-248,7
+249,7
@@
makemessage(f)
m->m_lines = (m+1)->m_lines;
m->m_flag = (m+1)->m_flag;
}
m->m_lines = (m+1)->m_lines;
m->m_flag = (m+1)->m_flag;
}
- message[msgCount].m_size = 0;
+ message[msgCount].m_size = 0
L
;
message[msgCount].m_lines = 0;
}
message[msgCount].m_lines = 0;
}
@@
-292,25
+293,33
@@
edstop()
{
register int gotcha, c;
register struct message *mp;
{
register int gotcha, c;
register struct message *mp;
- FILE *obuf, *ibuf;
+ FILE *obuf, *ibuf
, *readstat
;
struct stat statb;
struct stat statb;
- char tempname[30];
+ char tempname[30]
, *id
;
int (*sigs[3])();
if (readonly)
return;
holdsigs();
int (*sigs[3])();
if (readonly)
return;
holdsigs();
+ if (Tflag != NOSTR) {
+ if ((readstat = fopen(Tflag, "w")) == NULL)
+ Tflag = NOSTR;
+ }
for (mp = &message[0], gotcha = 0; mp < &message[msgCount]; mp++) {
if (mp->m_flag & MNEW) {
mp->m_flag &= ~MNEW;
mp->m_flag |= MSTATUS;
}
for (mp = &message[0], gotcha = 0; mp < &message[msgCount]; mp++) {
if (mp->m_flag & MNEW) {
mp->m_flag &= ~MNEW;
mp->m_flag |= MSTATUS;
}
- if (mp->m_flag & (MODIFY|MDELETED|MSTATUS))
{
+ if (mp->m_flag & (MODIFY|MDELETED|MSTATUS))
gotcha++;
gotcha++;
- break;
+ if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
+ if ((id = hfield("article-id", mp)) != NOSTR)
+ fprintf(readstat, "%s\n", id);
}
}
}
}
- if (!gotcha)
+ if (Tflag != NOSTR)
+ fclose(readstat);
+ if (!gotcha || Tflag != NOSTR)
goto done;
ibuf = NULL;
if (stat(editfile, &statb) >= 0 && statb.st_size > mailsize) {
goto done;
ibuf = NULL;
if (stat(editfile, &statb) >= 0 && statb.st_size > mailsize) {
@@
-353,7
+362,7
@@
edstop()
if ((mp->m_flag & MDELETED) != 0)
continue;
c++;
if ((mp->m_flag & MDELETED) != 0)
continue;
c++;
- if (send(mp, obuf) < 0) {
+ if (send(mp, obuf
, 0
) < 0) {
perror(editfile);
relsesigs();
reset(0);
perror(editfile);
relsesigs();
reset(0);
@@
-392,7
+401,13
@@
holdsigs()
register int i;
for (i = SIGHUP; i <= SIGQUIT; i++)
register int i;
for (i = SIGHUP; i <= SIGQUIT; i++)
- sighold(i);
+ /*
+ * This cannot be changed to ``sighold(i)'' because
+ * of a bug in the jobs library. Sighold does not
+ * record that one is using the new signal mechanisms
+ * so an eventual sigrelse() will fail.
+ */
+ sigset(i, SIG_HOLD);
}
/*
}
/*
@@
-488,6
+503,10
@@
expand(name)
int s, pivec[2], (*sigint)();
struct stat sbuf;
int s, pivec[2], (*sigint)();
struct stat sbuf;
+ if (name[0] == '+' && getfold(cmdbuf) >= 0) {
+ sprintf(xname, "%s/%s", cmdbuf, name + 1);
+ return(expand(savestr(xname)));
+ }
if (!anyof(name, "~{[*?$`'\"\\"))
return(name);
if (pipe(pivec) < 0) {
if (!anyof(name, "~{[*?$`'\"\\"))
return(name);
if (pipe(pivec) < 0) {
@@
-496,6
+515,7
@@
expand(name)
}
sprintf(cmdbuf, "echo %s", name);
if ((pid = vfork()) == 0) {
}
sprintf(cmdbuf, "echo %s", name);
if ((pid = vfork()) == 0) {
+ sigchild();
Shell = value("SHELL");
if (Shell == NOSTR)
Shell = SHELL;
Shell = value("SHELL");
if (Shell == NOSTR)
Shell = SHELL;
@@
-549,6
+569,23
@@
err:
return(NOSTR);
}
return(NOSTR);
}
+/*
+ * Determine the current folder directory name.
+ */
+getfold(name)
+ char *name;
+{
+ char *folder;
+
+ if ((folder = value("folder")) == NOSTR)
+ return(-1);
+ if (*folder == '/')
+ strcpy(name, folder);
+ else
+ sprintf(name, "%s/%s", homedir, folder);
+ return(0);
+}
+
/*
* A nicer version of Fdopen, which allows us to fclose
* without losing the open file.
/*
* A nicer version of Fdopen, which allows us to fclose
* without losing the open file.