Cleanup mail(1)'s varying styles by converting to using style(9).
Also take a stab at cleaning up BDECFLAGS and convert all uses of NOSTR, NIL, NONE, NOVAR, NOGRP, NOGE to NULL. Also kill 'register' to get diffs somewhat closer to OpenBSD/NetBSD. There are no functional changes however. Reviewed by: nra (visual inspection)
This commit is contained in:
parent
9dfe98e24e
commit
9ce73e9018
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77274
@ -48,6 +48,8 @@ static const char rcsid[] =
|
||||
* Auxiliary functions.
|
||||
*/
|
||||
|
||||
static char *save2str __P((char *, char *));
|
||||
|
||||
/*
|
||||
* Return a pointer to a dynamic copy of the argument.
|
||||
*/
|
||||
@ -58,9 +60,9 @@ savestr(str)
|
||||
char *new;
|
||||
int size = strlen(str) + 1;
|
||||
|
||||
if ((new = salloc(size)) != NOSTR)
|
||||
if ((new = salloc(size)) != NULL)
|
||||
bcopy(str, new, size);
|
||||
return new;
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -74,14 +76,14 @@ save2str(str, old)
|
||||
int newsize = strlen(str) + 1;
|
||||
int oldsize = old ? strlen(old) + 1 : 0;
|
||||
|
||||
if ((new = salloc(newsize + oldsize)) != NOSTR) {
|
||||
if ((new = salloc(newsize + oldsize)) != NULL) {
|
||||
if (oldsize) {
|
||||
bcopy(old, new, oldsize);
|
||||
new[oldsize - 1] = ' ';
|
||||
}
|
||||
bcopy(str, new + oldsize, newsize);
|
||||
}
|
||||
return new;
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -91,7 +93,7 @@ save2str(str, old)
|
||||
*/
|
||||
void
|
||||
touch(mp)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
{
|
||||
|
||||
mp->m_flag |= MTOUCH;
|
||||
@ -110,8 +112,8 @@ isdir(name)
|
||||
struct stat sbuf;
|
||||
|
||||
if (stat(name, &sbuf) < 0)
|
||||
return(0);
|
||||
return(S_ISDIR(sbuf.st_mode));
|
||||
return (0);
|
||||
return (S_ISDIR(sbuf.st_mode));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -121,40 +123,40 @@ int
|
||||
argcount(argv)
|
||||
char **argv;
|
||||
{
|
||||
register char **ap;
|
||||
char **ap;
|
||||
|
||||
for (ap = argv; *ap++ != NOSTR;)
|
||||
for (ap = argv; *ap++ != NULL;)
|
||||
;
|
||||
return ap - argv - 1;
|
||||
return (ap - argv - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the desired header line from the passed message
|
||||
* pointer (or NOSTR if the desired header field is not available).
|
||||
* pointer (or NULL if the desired header field is not available).
|
||||
*/
|
||||
char *
|
||||
hfield(field, mp)
|
||||
char field[];
|
||||
const char *field;
|
||||
struct message *mp;
|
||||
{
|
||||
register FILE *ibuf;
|
||||
FILE *ibuf;
|
||||
char linebuf[LINESIZE];
|
||||
register int lc;
|
||||
register char *hfield;
|
||||
char *colon, *oldhfield = NOSTR;
|
||||
int lc;
|
||||
char *hfield;
|
||||
char *colon, *oldhfield = NULL;
|
||||
|
||||
ibuf = setinput(mp);
|
||||
if ((lc = mp->m_lines - 1) < 0)
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
if (readline(ibuf, linebuf, LINESIZE) < 0)
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
while (lc > 0) {
|
||||
if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0)
|
||||
return oldhfield;
|
||||
return (oldhfield);
|
||||
if ((hfield = ishfield(linebuf, colon, field)) != NULL)
|
||||
oldhfield = save2str(hfield, oldhfield);
|
||||
}
|
||||
return oldhfield;
|
||||
return (oldhfield);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -165,22 +167,22 @@ hfield(field, mp)
|
||||
*/
|
||||
int
|
||||
gethfield(f, linebuf, rem, colon)
|
||||
register FILE *f;
|
||||
FILE *f;
|
||||
char linebuf[];
|
||||
register int rem;
|
||||
int rem;
|
||||
char **colon;
|
||||
{
|
||||
char line2[LINESIZE];
|
||||
register char *cp, *cp2;
|
||||
register int c;
|
||||
char *cp, *cp2;
|
||||
int c;
|
||||
|
||||
for (;;) {
|
||||
if (--rem < 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if ((c = readline(f, linebuf, LINESIZE)) <= 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':';
|
||||
cp++)
|
||||
cp++)
|
||||
;
|
||||
if (*cp != ':' || cp == linebuf)
|
||||
continue;
|
||||
@ -212,7 +214,7 @@ gethfield(f, linebuf, rem, colon)
|
||||
cp += c;
|
||||
}
|
||||
*cp = 0;
|
||||
return rem;
|
||||
return (rem);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@ -224,20 +226,21 @@ gethfield(f, linebuf, rem, colon)
|
||||
|
||||
char*
|
||||
ishfield(linebuf, colon, field)
|
||||
char linebuf[], field[];
|
||||
char linebuf[];
|
||||
char *colon;
|
||||
const char *field;
|
||||
{
|
||||
register char *cp = colon;
|
||||
char *cp = colon;
|
||||
|
||||
*cp = 0;
|
||||
if (strcasecmp(linebuf, field) != 0) {
|
||||
*cp = ':';
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
*cp = ':';
|
||||
for (cp++; *cp == ' ' || *cp == '\t'; cp++)
|
||||
;
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -246,7 +249,8 @@ ishfield(linebuf, colon, field)
|
||||
*/
|
||||
void
|
||||
istrncpy(dest, src, dsize)
|
||||
register char *dest, *src;
|
||||
char *dest;
|
||||
const char *src;
|
||||
size_t dsize;
|
||||
{
|
||||
|
||||
@ -282,16 +286,16 @@ source(arglist)
|
||||
FILE *fi;
|
||||
char *cp;
|
||||
|
||||
if ((cp = expand(*arglist)) == NOSTR)
|
||||
return(1);
|
||||
if ((cp = expand(*arglist)) == NULL)
|
||||
return (1);
|
||||
if ((fi = Fopen(cp, "r")) == NULL) {
|
||||
warn("%s", cp);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
if (ssp >= SSTACK_SIZE - 1) {
|
||||
printf("Too much \"sourcing\" going on.\n");
|
||||
Fclose(fi);
|
||||
return(1);
|
||||
(void)Fclose(fi);
|
||||
return (1);
|
||||
}
|
||||
sstack[ssp].s_file = input;
|
||||
sstack[ssp].s_cond = cond;
|
||||
@ -301,7 +305,7 @@ source(arglist)
|
||||
cond = CANY;
|
||||
input = fi;
|
||||
sourcing++;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -314,9 +318,9 @@ unstack()
|
||||
if (ssp <= 0) {
|
||||
printf("\"Source\" stack over-pop.\n");
|
||||
sourcing = 0;
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
Fclose(input);
|
||||
(void)Fclose(input);
|
||||
if (cond != CANY)
|
||||
printf("Unmatched \"if\"\n");
|
||||
ssp--;
|
||||
@ -325,7 +329,7 @@ unstack()
|
||||
input = sstack[ssp].s_file;
|
||||
if (ssp == 0)
|
||||
sourcing = loading;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -338,7 +342,6 @@ alter(name)
|
||||
{
|
||||
struct stat sb;
|
||||
struct timeval tv[2];
|
||||
time_t time();
|
||||
|
||||
if (stat(name, &sb))
|
||||
return;
|
||||
@ -355,21 +358,21 @@ alter(name)
|
||||
*/
|
||||
char *
|
||||
nameof(mp, reptype)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
int reptype;
|
||||
{
|
||||
register char *cp, *cp2;
|
||||
char *cp, *cp2;
|
||||
|
||||
cp = skin(name1(mp, reptype));
|
||||
if (reptype != 0 || charcount(cp, '!') < 2)
|
||||
return(cp);
|
||||
return (cp);
|
||||
cp2 = strrchr(cp, '!');
|
||||
cp2--;
|
||||
while (cp2 > cp && *cp2 != '!')
|
||||
cp2--;
|
||||
if (*cp2 == '!')
|
||||
return(cp2 + 1);
|
||||
return(cp);
|
||||
return (cp2 + 1);
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -378,9 +381,9 @@ nameof(mp, reptype)
|
||||
*/
|
||||
char *
|
||||
skip_comment(cp)
|
||||
register char *cp;
|
||||
char *cp;
|
||||
{
|
||||
register nesting = 1;
|
||||
int nesting = 1;
|
||||
|
||||
for (; nesting > 0 && *cp; cp++) {
|
||||
switch (*cp) {
|
||||
@ -396,7 +399,7 @@ skip_comment(cp)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -407,24 +410,22 @@ char *
|
||||
skin(name)
|
||||
char *name;
|
||||
{
|
||||
register int c;
|
||||
register char *cp, *cp2;
|
||||
char *bufend, *nbuf;
|
||||
int gotlt, lastsp;
|
||||
char *nbuf, *bufend, *cp, *cp2;
|
||||
int c, gotlt, lastsp;
|
||||
|
||||
if (name == NOSTR)
|
||||
return(NOSTR);
|
||||
if (strchr(name, '(') == NOSTR && strchr(name, '<') == NOSTR
|
||||
&& strchr(name, ' ') == NOSTR)
|
||||
return(name);
|
||||
if (name == NULL)
|
||||
return (NULL);
|
||||
if (strchr(name, '(') == NULL && strchr(name, '<') == NULL
|
||||
&& strchr(name, ' ') == NULL)
|
||||
return (name);
|
||||
|
||||
/* We assume that length(input) <= length(output) */
|
||||
if ((nbuf = (char *)malloc(strlen(name) + 1)) == NULL)
|
||||
if ((nbuf = malloc(strlen(name) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
gotlt = 0;
|
||||
lastsp = 0;
|
||||
bufend = nbuf;
|
||||
for (cp = name, cp2 = bufend; c = *cp++; ) {
|
||||
for (cp = name, cp2 = bufend; (c = *cp++) != '\0'; ) {
|
||||
switch (c) {
|
||||
case '(':
|
||||
cp = skip_comment(cp);
|
||||
@ -436,13 +437,13 @@ skin(name)
|
||||
* Start of a "quoted-string".
|
||||
* Copy it in its entirety.
|
||||
*/
|
||||
while (c = *cp) {
|
||||
while ((c = *cp) != '\0') {
|
||||
cp++;
|
||||
if (c == '"')
|
||||
break;
|
||||
if (c != '\\')
|
||||
*cp2++ = c;
|
||||
else if (c = *cp) {
|
||||
else if ((c = *cp) != '\0') {
|
||||
*cp2++ = c;
|
||||
cp++;
|
||||
}
|
||||
@ -469,16 +470,16 @@ skin(name)
|
||||
case '>':
|
||||
if (gotlt) {
|
||||
gotlt = 0;
|
||||
while ((c = *cp) && c != ',') {
|
||||
while ((c = *cp) != '\0' && c != ',') {
|
||||
cp++;
|
||||
if (c == '(')
|
||||
cp = skip_comment(cp);
|
||||
else if (c == '"')
|
||||
while (c = *cp) {
|
||||
while ((c = *cp) != '\0') {
|
||||
cp++;
|
||||
if (c == '"')
|
||||
break;
|
||||
if (c == '\\' && *cp)
|
||||
if (c == '\\' && *cp != '\0')
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
@ -502,11 +503,11 @@ skin(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
*cp2 = 0;
|
||||
*cp2 = '\0';
|
||||
|
||||
if ((nbuf = (char *)realloc(nbuf, strlen(nbuf) + 1)) == NULL)
|
||||
if ((nbuf = realloc(nbuf, strlen(nbuf) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
return(nbuf);
|
||||
return (nbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -518,38 +519,39 @@ skin(name)
|
||||
*/
|
||||
char *
|
||||
name1(mp, reptype)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
int reptype;
|
||||
{
|
||||
char namebuf[LINESIZE];
|
||||
char linebuf[LINESIZE];
|
||||
register char *cp, *cp2;
|
||||
register FILE *ibuf;
|
||||
char *cp, *cp2;
|
||||
FILE *ibuf;
|
||||
int first = 1;
|
||||
|
||||
if ((cp = hfield("from", mp)) != NOSTR)
|
||||
return cp;
|
||||
if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR)
|
||||
return cp;
|
||||
if ((cp = hfield("from", mp)) != NULL)
|
||||
return (cp);
|
||||
if (reptype == 0 && (cp = hfield("sender", mp)) != NULL)
|
||||
return (cp);
|
||||
ibuf = setinput(mp);
|
||||
namebuf[0] = '\0';
|
||||
if (readline(ibuf, linebuf, LINESIZE) < 0)
|
||||
return(savestr(namebuf));
|
||||
return (savestr(namebuf));
|
||||
newname:
|
||||
for (cp = linebuf; *cp && *cp != ' '; cp++)
|
||||
for (cp = linebuf; *cp != '\0' && *cp != ' '; cp++)
|
||||
;
|
||||
for (; *cp == ' ' || *cp == '\t'; cp++)
|
||||
;
|
||||
for (cp2 = &namebuf[strlen(namebuf)];
|
||||
*cp && *cp != ' ' && *cp != '\t' && cp2 < namebuf + LINESIZE - 1;)
|
||||
*cp != '\0' && *cp != ' ' && *cp != '\t' &&
|
||||
cp2 < namebuf + LINESIZE - 1;)
|
||||
*cp2++ = *cp++;
|
||||
*cp2 = '\0';
|
||||
if (readline(ibuf, linebuf, LINESIZE) < 0)
|
||||
return(savestr(namebuf));
|
||||
return (savestr(namebuf));
|
||||
if ((cp = strchr(linebuf, 'F')) == NULL)
|
||||
return(savestr(namebuf));
|
||||
return (savestr(namebuf));
|
||||
if (strncmp(cp, "From", 4) != 0)
|
||||
return(savestr(namebuf));
|
||||
return (savestr(namebuf));
|
||||
while ((cp = strchr(cp, 'r')) != NULL) {
|
||||
if (strncmp(cp, "remote", 6) == 0) {
|
||||
if ((cp = strchr(cp, 'f')) == NULL)
|
||||
@ -570,7 +572,7 @@ name1(mp, reptype)
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
return(savestr(namebuf));
|
||||
return (savestr(namebuf));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -581,13 +583,13 @@ charcount(str, c)
|
||||
char *str;
|
||||
int c;
|
||||
{
|
||||
register char *cp;
|
||||
register int i;
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
for (i = 0, cp = str; *cp; cp++)
|
||||
for (i = 0, cp = str; *cp != '\0'; cp++)
|
||||
if (*cp == c)
|
||||
i++;
|
||||
return(i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -595,13 +597,13 @@ charcount(str, c)
|
||||
*/
|
||||
int
|
||||
isign(field, ignore)
|
||||
char *field;
|
||||
const char *field;
|
||||
struct ignoretab ignore[2];
|
||||
{
|
||||
char realfld[LINESIZE];
|
||||
|
||||
if (ignore == ignoreall)
|
||||
return 1;
|
||||
return (1);
|
||||
/*
|
||||
* Lower-case the string, so that "Status" and "status"
|
||||
* will hash to the same place.
|
||||
@ -615,12 +617,12 @@ isign(field, ignore)
|
||||
|
||||
int
|
||||
member(realfield, table)
|
||||
register char *realfield;
|
||||
char *realfield;
|
||||
struct ignoretab *table;
|
||||
{
|
||||
register struct ignore *igp;
|
||||
struct ignore *igp;
|
||||
|
||||
for (igp = table->i_head[hash(realfield)]; igp != 0; igp = igp->i_link)
|
||||
for (igp = table->i_head[hash(realfield)]; igp != NULL; igp = igp->i_link)
|
||||
if (*igp->i_field == *realfield &&
|
||||
equal(igp->i_field, realfield))
|
||||
return (1);
|
||||
|
@ -48,6 +48,8 @@ static const char rcsid[] =
|
||||
* User commands.
|
||||
*/
|
||||
|
||||
extern const struct cmd cmdtab[];
|
||||
|
||||
/*
|
||||
* Print the current active headings.
|
||||
* Don't change dot if invoker didn't give an argument.
|
||||
@ -59,9 +61,8 @@ int
|
||||
headers(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register int n, mesg, flag;
|
||||
register struct message *mp;
|
||||
int size;
|
||||
int n, mesg, flag, size;
|
||||
struct message *mp;
|
||||
|
||||
size = screensize();
|
||||
n = msgvec[0];
|
||||
@ -88,9 +89,9 @@ headers(msgvec)
|
||||
}
|
||||
if (flag == 0) {
|
||||
printf("No more mail.\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -100,7 +101,7 @@ int
|
||||
scroll(arg)
|
||||
char arg[];
|
||||
{
|
||||
register int s, size;
|
||||
int s, size;
|
||||
int cur[1];
|
||||
|
||||
cur[0] = 0;
|
||||
@ -112,7 +113,7 @@ scroll(arg)
|
||||
s++;
|
||||
if (s * size > msgCount) {
|
||||
printf("On last screenful of messages\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
screen = s;
|
||||
break;
|
||||
@ -120,16 +121,16 @@ scroll(arg)
|
||||
case '-':
|
||||
if (--s < 0) {
|
||||
printf("On first screenful of messages\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
screen = s;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unrecognized scrolling command \"%s\"\n", arg);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
return(headers(cur));
|
||||
return (headers(cur));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -141,9 +142,9 @@ screensize()
|
||||
int s;
|
||||
char *cp;
|
||||
|
||||
if ((cp = value("screen")) != NOSTR && (s = atoi(cp)) > 0)
|
||||
return s;
|
||||
return screenheight - 4;
|
||||
if ((cp = value("screen")) != NULL && (s = atoi(cp)) > 0)
|
||||
return (s);
|
||||
return (screenheight - 4);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -154,13 +155,13 @@ int
|
||||
from(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register int *ip;
|
||||
int *ip;
|
||||
|
||||
for (ip = msgvec; *ip != 0; ip++)
|
||||
printhead(*ip);
|
||||
if (--ip >= msgvec)
|
||||
dot = &message[*ip - 1];
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -179,8 +180,8 @@ printhead(mesg)
|
||||
char *name;
|
||||
|
||||
mp = &message[mesg-1];
|
||||
(void) readline(setinput(mp), headline, LINESIZE);
|
||||
if ((subjline = hfield("subject", mp)) == NOSTR)
|
||||
(void)readline(setinput(mp), headline, LINESIZE);
|
||||
if ((subjline = hfield("subject", mp)) == NULL)
|
||||
subjline = hfield("subj", mp);
|
||||
/*
|
||||
* Bletch!
|
||||
@ -200,9 +201,9 @@ printhead(mesg)
|
||||
parse(headline, &hl, pbuf);
|
||||
sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size);
|
||||
subjlen = screenwidth - 50 - strlen(wcount);
|
||||
name = value("show-rcpt") != NOSTR ?
|
||||
name = value("show-rcpt") != NULL ?
|
||||
skin(hfield("to", mp)) : nameof(mp, 0);
|
||||
if (subjline == NOSTR || subjlen < 0) /* pretty pathetic */
|
||||
if (subjline == NULL || subjlen < 0) /* pretty pathetic */
|
||||
printf("%c%c%3d %-20.20s %16.16s %s\n",
|
||||
curind, dispc, mesg, name, hl.l_date, wcount);
|
||||
else
|
||||
@ -218,7 +219,7 @@ int
|
||||
pdot()
|
||||
{
|
||||
printf("%d\n", dot - &message[0] + 1);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -227,9 +228,8 @@ pdot()
|
||||
int
|
||||
pcmdlist()
|
||||
{
|
||||
register struct cmd *cp;
|
||||
register int cc;
|
||||
extern struct cmd cmdtab[];
|
||||
const struct cmd *cp;
|
||||
int cc;
|
||||
|
||||
printf("Commands are:\n");
|
||||
for (cc = 0, cp = cmdtab; cp->c_name != NULL; cp++) {
|
||||
@ -238,12 +238,12 @@ pcmdlist()
|
||||
printf("\n");
|
||||
cc = strlen(cp->c_name) + 2;
|
||||
}
|
||||
if ((cp+1)->c_name != NOSTR)
|
||||
if ((cp+1)->c_name != NULL)
|
||||
printf("%s, ", cp->c_name);
|
||||
else
|
||||
printf("%s\n", cp->c_name);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -253,6 +253,7 @@ int
|
||||
more(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
|
||||
return (type1(msgvec, 1, 1));
|
||||
}
|
||||
|
||||
@ -275,7 +276,7 @@ type(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
|
||||
return(type1(msgvec, 1, 0));
|
||||
return (type1(msgvec, 1, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -286,7 +287,7 @@ Type(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
|
||||
return(type1(msgvec, 0, 0));
|
||||
return (type1(msgvec, 0, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -298,17 +299,16 @@ type1(msgvec, doign, page)
|
||||
int *msgvec;
|
||||
int doign, page;
|
||||
{
|
||||
register *ip;
|
||||
register struct message *mp;
|
||||
register char *cp;
|
||||
int nlines;
|
||||
int nlines, *ip;
|
||||
struct message *mp;
|
||||
char *cp;
|
||||
FILE *obuf;
|
||||
|
||||
obuf = stdout;
|
||||
if (setjmp(pipestop))
|
||||
goto close_pipe;
|
||||
if (value("interactive") != NOSTR &&
|
||||
(page || (cp = value("crt")) != NOSTR)) {
|
||||
if (value("interactive") != NULL &&
|
||||
(page || (cp = value("crt")) != NULL)) {
|
||||
nlines = 0;
|
||||
if (!page) {
|
||||
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
|
||||
@ -323,33 +323,40 @@ type1(msgvec, doign, page)
|
||||
warnx("%s", cp);
|
||||
obuf = stdout;
|
||||
} else
|
||||
signal(SIGPIPE, brokpipe);
|
||||
(void)signal(SIGPIPE, brokpipe);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send messages to the output.
|
||||
*
|
||||
*/
|
||||
for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
|
||||
mp = &message[*ip - 1];
|
||||
touch(mp);
|
||||
dot = mp;
|
||||
if (value("quiet") == NOSTR)
|
||||
if (value("quiet") == NULL)
|
||||
fprintf(obuf, "Message %d:\n", *ip);
|
||||
(void) sendmessage(mp, obuf, doign ? ignore : 0, NOSTR);
|
||||
(void)sendmessage(mp, obuf, doign ? ignore : 0, NULL);
|
||||
}
|
||||
|
||||
close_pipe:
|
||||
if (obuf != stdout) {
|
||||
/*
|
||||
* Ignore SIGPIPE so it can't cause a duplicate close.
|
||||
*/
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
Pclose(obuf);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
(void)signal(SIGPIPE, SIG_IGN);
|
||||
(void)Pclose(obuf);
|
||||
(void)signal(SIGPIPE, SIG_DFL);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Respond to a broken pipe signal --
|
||||
* probably caused by quitting more.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
brokpipe(signo)
|
||||
int signo;
|
||||
@ -366,15 +373,15 @@ int
|
||||
top(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register int *ip;
|
||||
register struct message *mp;
|
||||
int *ip;
|
||||
struct message *mp;
|
||||
int c, topl, lines, lineb;
|
||||
char *valtop, linebuf[LINESIZE];
|
||||
FILE *ibuf;
|
||||
|
||||
topl = 5;
|
||||
valtop = value("toplines");
|
||||
if (valtop != NOSTR) {
|
||||
if (valtop != NULL) {
|
||||
topl = atoi(valtop);
|
||||
if (topl < 0 || topl > 10000)
|
||||
topl = 5;
|
||||
@ -384,7 +391,7 @@ top(msgvec)
|
||||
mp = &message[*ip - 1];
|
||||
touch(mp);
|
||||
dot = mp;
|
||||
if (value("quiet") == NOSTR)
|
||||
if (value("quiet") == NULL)
|
||||
printf("Message %d:\n", *ip);
|
||||
ibuf = setinput(mp);
|
||||
c = mp->m_lines;
|
||||
@ -397,7 +404,7 @@ top(msgvec)
|
||||
lineb = strspn(linebuf, " \t") == strlen(linebuf);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -408,14 +415,14 @@ int
|
||||
stouch(msgvec)
|
||||
int msgvec[];
|
||||
{
|
||||
register int *ip;
|
||||
int *ip;
|
||||
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
dot = &message[*ip-1];
|
||||
dot->m_flag |= MTOUCH;
|
||||
dot->m_flag &= ~MPRESERVE;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -425,14 +432,14 @@ int
|
||||
mboxit(msgvec)
|
||||
int msgvec[];
|
||||
{
|
||||
register int *ip;
|
||||
int *ip;
|
||||
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
dot = &message[*ip-1];
|
||||
dot->m_flag |= MTOUCH|MBOX;
|
||||
dot->m_flag &= ~MPRESERVE;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -446,10 +453,10 @@ folders()
|
||||
|
||||
if (getfold(dirname, sizeof(dirname)) < 0) {
|
||||
printf("No value set for \"folder\"\n");
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
if ((cmd = value("LISTER")) == NOSTR)
|
||||
if ((cmd = value("LISTER")) == NULL)
|
||||
cmd = "ls";
|
||||
(void) run_command(cmd, 0, -1, -1, dirname, NOSTR, NOSTR);
|
||||
return 0;
|
||||
(void)run_command(cmd, 0, -1, -1, dirname, NULL, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ static const char rcsid[] =
|
||||
* More user commands.
|
||||
*/
|
||||
|
||||
extern int wait_status;
|
||||
|
||||
/*
|
||||
* If any arguments were given, go to the next applicable argument
|
||||
* following dot, otherwise, go to the next applicable message.
|
||||
@ -58,9 +60,8 @@ int
|
||||
next(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register struct message *mp;
|
||||
register int *ip, *ip2;
|
||||
int list[2], mdot;
|
||||
struct message *mp;
|
||||
int *ip, *ip2, list[2], mdot;
|
||||
|
||||
if (*msgvec != 0) {
|
||||
|
||||
@ -95,7 +96,7 @@ next(msgvec)
|
||||
ip2 = msgvec;
|
||||
} while (ip2 != ip);
|
||||
printf("No messages applicable\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -116,7 +117,7 @@ next(msgvec)
|
||||
break;
|
||||
if (mp >= &message[msgCount]) {
|
||||
printf("At EOF\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
dot = mp;
|
||||
hitit:
|
||||
@ -126,7 +127,7 @@ next(msgvec)
|
||||
|
||||
list[0] = dot - &message[0] + 1;
|
||||
list[1] = 0;
|
||||
return(type(list));
|
||||
return (type(list));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -138,7 +139,7 @@ save(str)
|
||||
char str[];
|
||||
{
|
||||
|
||||
return save1(str, 1, "save", saveignore);
|
||||
return (save1(str, 1, "save", saveignore));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -149,7 +150,7 @@ copycmd(str)
|
||||
char str[];
|
||||
{
|
||||
|
||||
return save1(str, 0, "copy", saveignore);
|
||||
return (save1(str, 0, "copy", saveignore));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -160,57 +161,57 @@ int
|
||||
save1(str, mark, cmd, ignore)
|
||||
char str[];
|
||||
int mark;
|
||||
char *cmd;
|
||||
const char *cmd;
|
||||
struct ignoretab *ignore;
|
||||
{
|
||||
register int *ip;
|
||||
register struct message *mp;
|
||||
char *file, *disp;
|
||||
int f, *msgvec;
|
||||
struct message *mp;
|
||||
char *file;
|
||||
const char *disp;
|
||||
int f, *msgvec, *ip;
|
||||
FILE *obuf;
|
||||
|
||||
msgvec = (int *) salloc((msgCount + 2) * sizeof *msgvec);
|
||||
if ((file = snarf(str, &f)) == NOSTR)
|
||||
return(1);
|
||||
msgvec = (int *)salloc((msgCount + 2) * sizeof(*msgvec));
|
||||
if ((file = snarf(str, &f)) == NULL)
|
||||
return (1);
|
||||
if (!f) {
|
||||
*msgvec = first(0, MMNORM);
|
||||
if (*msgvec == 0) {
|
||||
printf("No messages to %s.\n", cmd);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
msgvec[1] = 0;
|
||||
}
|
||||
if (f && getmsglist(str, msgvec, 0) < 0)
|
||||
return(1);
|
||||
if ((file = expand(file)) == NOSTR)
|
||||
return(1);
|
||||
return (1);
|
||||
if ((file = expand(file)) == NULL)
|
||||
return (1);
|
||||
printf("\"%s\" ", file);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
if (access(file, 0) >= 0)
|
||||
disp = "[Appended]";
|
||||
else
|
||||
disp = "[New file]";
|
||||
if ((obuf = Fopen(file, "a")) == NULL) {
|
||||
warn(NOSTR);
|
||||
return(1);
|
||||
warn((char *)NULL);
|
||||
return (1);
|
||||
}
|
||||
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
|
||||
mp = &message[*ip - 1];
|
||||
touch(mp);
|
||||
if (sendmessage(mp, obuf, ignore, NOSTR) < 0) {
|
||||
if (sendmessage(mp, obuf, ignore, NULL) < 0) {
|
||||
warnx("%s", file);
|
||||
Fclose(obuf);
|
||||
return(1);
|
||||
(void)Fclose(obuf);
|
||||
return (1);
|
||||
}
|
||||
if (mark)
|
||||
mp->m_flag |= MSAVED;
|
||||
}
|
||||
fflush(obuf);
|
||||
(void)fflush(obuf);
|
||||
if (ferror(obuf))
|
||||
warn("%s", file);
|
||||
Fclose(obuf);
|
||||
(void)Fclose(obuf);
|
||||
printf("%s\n", disp);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -222,13 +223,13 @@ swrite(str)
|
||||
char str[];
|
||||
{
|
||||
|
||||
return save1(str, 1, "write", ignoreall);
|
||||
return (save1(str, 1, "write", ignoreall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Snarf the file from the end of the command line and
|
||||
* return a pointer to it. If there is no file attached,
|
||||
* just return NOSTR. Put a null in front of the file
|
||||
* just return NULL. Put a null in front of the file
|
||||
* name so that the message list processing won't see it,
|
||||
* unless the file name is the only thing on the line, in
|
||||
* which case, return 0 in the reference flag variable.
|
||||
@ -239,7 +240,7 @@ snarf(linebuf, flag)
|
||||
char linebuf[];
|
||||
int *flag;
|
||||
{
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
*flag = 1;
|
||||
cp = strlen(linebuf) + linebuf - 1;
|
||||
@ -250,7 +251,7 @@ snarf(linebuf, flag)
|
||||
|
||||
while (cp > linebuf && isspace(*cp))
|
||||
cp--;
|
||||
*++cp = 0;
|
||||
*++cp = '\0';
|
||||
|
||||
/*
|
||||
* Now search for the beginning of the file name.
|
||||
@ -260,13 +261,13 @@ snarf(linebuf, flag)
|
||||
cp--;
|
||||
if (*cp == '\0') {
|
||||
printf("No file specified.\n");
|
||||
return(NOSTR);
|
||||
return (NULL);
|
||||
}
|
||||
if (isspace(*cp))
|
||||
*cp++ = 0;
|
||||
*cp++ = '\0';
|
||||
else
|
||||
*flag = 0;
|
||||
return(cp);
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -276,8 +277,9 @@ int
|
||||
delete(msgvec)
|
||||
int msgvec[];
|
||||
{
|
||||
|
||||
delm(msgvec);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -296,12 +298,12 @@ deltype(msgvec)
|
||||
if (list[0] > lastdot) {
|
||||
touch(dot);
|
||||
list[1] = 0;
|
||||
return(type(list));
|
||||
return (type(list));
|
||||
}
|
||||
printf("At EOF\n");
|
||||
} else
|
||||
printf("No more messages\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -313,9 +315,8 @@ int
|
||||
delm(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register struct message *mp;
|
||||
register *ip;
|
||||
int last;
|
||||
struct message *mp;
|
||||
int *ip, last;
|
||||
|
||||
last = 0;
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
@ -330,11 +331,11 @@ delm(msgvec)
|
||||
last = first(0, MDELETED);
|
||||
if (last != 0) {
|
||||
dot = &message[last-1];
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
else {
|
||||
dot = &message[0];
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,7 +343,7 @@ delm(msgvec)
|
||||
* Following can't happen -- it keeps lint happy
|
||||
*/
|
||||
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -352,8 +353,8 @@ int
|
||||
undelete_messages(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register struct message *mp;
|
||||
register *ip;
|
||||
struct message *mp;
|
||||
int *ip;
|
||||
|
||||
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
|
||||
mp = &message[*ip - 1];
|
||||
@ -361,7 +362,7 @@ undelete_messages(msgvec)
|
||||
dot = mp;
|
||||
mp->m_flag &= ~MDELETED;
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -371,24 +372,23 @@ int
|
||||
core()
|
||||
{
|
||||
int pid;
|
||||
extern int wait_status;
|
||||
|
||||
switch (pid = fork()) {
|
||||
case -1:
|
||||
warn("fork");
|
||||
return(1);
|
||||
return (1);
|
||||
case 0:
|
||||
abort();
|
||||
_exit(1);
|
||||
}
|
||||
printf("Okie dokie");
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
wait_child(pid);
|
||||
if (WIFSIGNALED(wait_status) && WCOREDUMP(wait_status))
|
||||
printf(" -- Core dumped.\n");
|
||||
else
|
||||
printf(" -- Can't dump core.\n");
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -398,14 +398,14 @@ int
|
||||
clobber(argv)
|
||||
char **argv;
|
||||
{
|
||||
register int times;
|
||||
int times;
|
||||
|
||||
if (argv[0] == 0)
|
||||
times = 1;
|
||||
else
|
||||
times = (atoi(argv[0]) + 511) / 512;
|
||||
clob1(times);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -416,7 +416,7 @@ clob1(n)
|
||||
int n;
|
||||
{
|
||||
char buf[512];
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
if (n <= 0)
|
||||
return;
|
||||
@ -434,7 +434,7 @@ retfield(list)
|
||||
char *list[];
|
||||
{
|
||||
|
||||
return ignore1(list, ignore + 1, "retained");
|
||||
return (ignore1(list, ignore + 1, "retained"));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -446,7 +446,7 @@ igfield(list)
|
||||
char *list[];
|
||||
{
|
||||
|
||||
return ignore1(list, ignore, "ignored");
|
||||
return (ignore1(list, ignore, "ignored"));
|
||||
}
|
||||
|
||||
int
|
||||
@ -454,7 +454,7 @@ saveretfield(list)
|
||||
char *list[];
|
||||
{
|
||||
|
||||
return ignore1(list, saveignore + 1, "retained");
|
||||
return (ignore1(list, saveignore + 1, "retained"));
|
||||
}
|
||||
|
||||
int
|
||||
@ -462,36 +462,36 @@ saveigfield(list)
|
||||
char *list[];
|
||||
{
|
||||
|
||||
return ignore1(list, saveignore, "ignored");
|
||||
return (ignore1(list, saveignore, "ignored"));
|
||||
}
|
||||
|
||||
int
|
||||
ignore1(list, tab, which)
|
||||
char *list[];
|
||||
struct ignoretab *tab;
|
||||
char *which;
|
||||
const char *which;
|
||||
{
|
||||
char field[LINESIZE];
|
||||
register int h;
|
||||
register struct ignore *igp;
|
||||
int h;
|
||||
struct ignore *igp;
|
||||
char **ap;
|
||||
|
||||
if (*list == NOSTR)
|
||||
return igshow(tab, which);
|
||||
if (*list == NULL)
|
||||
return (igshow(tab, which));
|
||||
for (ap = list; *ap != 0; ap++) {
|
||||
istrncpy(field, *ap, sizeof(field));
|
||||
if (member(field, tab))
|
||||
continue;
|
||||
h = hash(field);
|
||||
igp = (struct ignore *) calloc(1, sizeof (struct ignore));
|
||||
igp->i_field = calloc((unsigned) strlen(field) + 1,
|
||||
sizeof (char));
|
||||
igp = calloc(1, sizeof(struct ignore));
|
||||
igp->i_field = calloc((unsigned)strlen(field) + 1,
|
||||
sizeof(char));
|
||||
strcpy(igp->i_field, field);
|
||||
igp->i_link = tab->i_head[h];
|
||||
tab->i_head[h] = igp;
|
||||
tab->i_count++;
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -500,27 +500,26 @@ ignore1(list, tab, which)
|
||||
int
|
||||
igshow(tab, which)
|
||||
struct ignoretab *tab;
|
||||
char *which;
|
||||
const char *which;
|
||||
{
|
||||
register int h;
|
||||
int h;
|
||||
struct ignore *igp;
|
||||
char **ap, **ring;
|
||||
int igcomp();
|
||||
|
||||
if (tab->i_count == 0) {
|
||||
printf("No fields currently being %s.\n", which);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
ring = (char **) salloc((tab->i_count + 1) * sizeof (char *));
|
||||
ring = (char **)salloc((tab->i_count + 1) * sizeof(char *));
|
||||
ap = ring;
|
||||
for (h = 0; h < HSHSIZE; h++)
|
||||
for (igp = tab->i_head[h]; igp != 0; igp = igp->i_link)
|
||||
for (igp = tab->i_head[h]; igp != NULL; igp = igp->i_link)
|
||||
*ap++ = igp->i_field;
|
||||
*ap = 0;
|
||||
qsort(ring, tab->i_count, sizeof (char *), igcomp);
|
||||
qsort(ring, tab->i_count, sizeof(char *), igcomp);
|
||||
for (ap = ring; *ap != 0; ap++)
|
||||
printf("%s\n", *ap);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -530,5 +529,6 @@ int
|
||||
igcomp(l, r)
|
||||
const void *l, *r;
|
||||
{
|
||||
return (strcmp(*(char **)l, *(char **)r));
|
||||
|
||||
return (strcmp(*(const char **)l, *(const char **)r));
|
||||
}
|
||||
|
@ -57,19 +57,19 @@ shell(str)
|
||||
char *str;
|
||||
{
|
||||
sig_t sigint = signal(SIGINT, SIG_IGN);
|
||||
char *shell;
|
||||
char *sh;
|
||||
char cmd[BUFSIZ];
|
||||
|
||||
if (strlcpy(cmd, str, sizeof(cmd)) >= sizeof(cmd))
|
||||
return 1;
|
||||
return (1);
|
||||
if (bangexp(cmd, sizeof(cmd)) < 0)
|
||||
return 1;
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
(void) run_command(shell, 0, -1, -1, "-c", cmd, NOSTR);
|
||||
(void) signal(SIGINT, sigint);
|
||||
return (1);
|
||||
if ((sh = value("SHELL")) == NULL)
|
||||
sh = _PATH_CSHELL;
|
||||
(void)run_command(sh, 0, -1, -1, "-c", cmd, NULL);
|
||||
(void)signal(SIGINT, sigint);
|
||||
printf("!\n");
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -81,14 +81,14 @@ dosh(str)
|
||||
char *str;
|
||||
{
|
||||
sig_t sigint = signal(SIGINT, SIG_IGN);
|
||||
char *shell;
|
||||
char *sh;
|
||||
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
(void) run_command(shell, 0, -1, -1, NOSTR, NOSTR, NOSTR);
|
||||
(void) signal(SIGINT, sigint);
|
||||
putchar('\n');
|
||||
return 0;
|
||||
if ((sh = value("SHELL")) == NULL)
|
||||
sh = _PATH_CSHELL;
|
||||
(void)run_command(sh, 0, -1, -1, NULL, NULL, NULL);
|
||||
(void)signal(SIGINT, sigint);
|
||||
printf("\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -102,19 +102,18 @@ bangexp(str, strsize)
|
||||
{
|
||||
char bangbuf[BUFSIZ];
|
||||
static char lastbang[BUFSIZ];
|
||||
register char *cp, *cp2;
|
||||
register int n;
|
||||
int changed = 0;
|
||||
char *cp, *cp2;
|
||||
int n, changed = 0;
|
||||
|
||||
cp = str;
|
||||
cp2 = bangbuf;
|
||||
n = sizeof(bangbuf);
|
||||
while (*cp) {
|
||||
while (*cp != '\0') {
|
||||
if (*cp == '!') {
|
||||
if (n < strlen(lastbang)) {
|
||||
overf:
|
||||
printf("Command buffer overflow\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
changed++;
|
||||
if (strlcpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf))
|
||||
@ -139,13 +138,13 @@ bangexp(str, strsize)
|
||||
*cp2 = 0;
|
||||
if (changed) {
|
||||
printf("!%s\n", bangbuf);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
if (strlcpy(str, bangbuf, strsize) >= strsize)
|
||||
goto overf;
|
||||
if (strlcpy(lastbang, bangbuf, sizeof(lastbang)) >= sizeof(lastbang))
|
||||
goto overf;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -155,17 +154,17 @@ bangexp(str, strsize)
|
||||
int
|
||||
help()
|
||||
{
|
||||
register c;
|
||||
register FILE *f;
|
||||
int c;
|
||||
FILE *f;
|
||||
|
||||
if ((f = Fopen(_PATH_HELP, "r")) == NULL) {
|
||||
warn("%s", _PATH_HELP);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
while ((c = getc(f)) != EOF)
|
||||
putchar(c);
|
||||
Fclose(f);
|
||||
return(0);
|
||||
(void)Fclose(f);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -177,25 +176,25 @@ schdir(arglist)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (*arglist == NOSTR) {
|
||||
if (homedir == NOSTR)
|
||||
return(1);
|
||||
if (*arglist == NULL) {
|
||||
if (homedir == NULL)
|
||||
return (1);
|
||||
cp = homedir;
|
||||
} else
|
||||
if ((cp = expand(*arglist)) == NOSTR)
|
||||
return(1);
|
||||
if ((cp = expand(*arglist)) == NULL)
|
||||
return (1);
|
||||
if (chdir(cp) < 0) {
|
||||
warn("%s", cp);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
respond(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
if (value("Replyall") == NOSTR)
|
||||
if (value("Replyall") == NULL)
|
||||
return (dorespond(msgvec));
|
||||
else
|
||||
return (doRespond(msgvec));
|
||||
@ -217,19 +216,19 @@ dorespond(msgvec)
|
||||
|
||||
if (msgvec[1] != 0) {
|
||||
printf("Sorry, can't reply to multiple messages at once\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
mp = &message[msgvec[0] - 1];
|
||||
touch(mp);
|
||||
dot = mp;
|
||||
if ((rcv = skin(hfield("from", mp))) == NOSTR)
|
||||
if ((rcv = skin(hfield("from", mp))) == NULL)
|
||||
rcv = skin(nameof(mp, 1));
|
||||
if ((replyto = skin(hfield("reply-to", mp))) != NOSTR)
|
||||
if ((replyto = skin(hfield("reply-to", mp))) != NULL)
|
||||
np = extract(replyto, GTO);
|
||||
else if ((cp = skin(hfield("to", mp))) != NOSTR)
|
||||
else if ((cp = skin(hfield("to", mp))) != NULL)
|
||||
np = extract(cp, GTO);
|
||||
else
|
||||
np = NIL;
|
||||
np = NULL;
|
||||
np = elide(np);
|
||||
/*
|
||||
* Delete my name from the reply list,
|
||||
@ -237,35 +236,35 @@ dorespond(msgvec)
|
||||
*/
|
||||
np = delname(np, myname);
|
||||
if (altnames)
|
||||
for (ap = altnames; *ap; ap++)
|
||||
for (ap = altnames; *ap != NULL; ap++)
|
||||
np = delname(np, *ap);
|
||||
if (np != NIL && replyto == NOSTR)
|
||||
if (np != NULL && replyto == NULL)
|
||||
np = cat(np, extract(rcv, GTO));
|
||||
else if (np == NIL) {
|
||||
if (replyto != NOSTR)
|
||||
else if (np == NULL) {
|
||||
if (replyto != NULL)
|
||||
printf("Empty reply-to field -- replying to author\n");
|
||||
np = extract(rcv, GTO);
|
||||
}
|
||||
head.h_to = np;
|
||||
if ((head.h_subject = hfield("subject", mp)) == NOSTR)
|
||||
if ((head.h_subject = hfield("subject", mp)) == NULL)
|
||||
head.h_subject = hfield("subj", mp);
|
||||
head.h_subject = reedit(head.h_subject);
|
||||
if (replyto == NOSTR && (cp = skin(hfield("cc", mp))) != NOSTR) {
|
||||
if (replyto == NULL && (cp = skin(hfield("cc", mp))) != NULL) {
|
||||
np = elide(extract(cp, GCC));
|
||||
np = delname(np, myname);
|
||||
if (altnames != 0)
|
||||
for (ap = altnames; *ap; ap++)
|
||||
for (ap = altnames; *ap != NULL; ap++)
|
||||
np = delname(np, *ap);
|
||||
head.h_cc = np;
|
||||
} else
|
||||
head.h_cc = NIL;
|
||||
head.h_bcc = NIL;
|
||||
head.h_smopts = NIL;
|
||||
head.h_cc = NULL;
|
||||
head.h_bcc = NULL;
|
||||
head.h_smopts = NULL;
|
||||
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
|
||||
head.h_replyto = NOSTR;
|
||||
head.h_replyto = NULL;
|
||||
head.h_inreplyto = skin(hfield("message-id", mp));
|
||||
mail1(&head, 1);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -274,19 +273,19 @@ dorespond(msgvec)
|
||||
*/
|
||||
char *
|
||||
reedit(subj)
|
||||
register char *subj;
|
||||
char *subj;
|
||||
{
|
||||
char *newsubj;
|
||||
|
||||
if (subj == NOSTR)
|
||||
return NOSTR;
|
||||
if (subj == NULL)
|
||||
return (NULL);
|
||||
if ((subj[0] == 'r' || subj[0] == 'R') &&
|
||||
(subj[1] == 'e' || subj[1] == 'E') &&
|
||||
subj[2] == ':')
|
||||
return subj;
|
||||
return (subj);
|
||||
newsubj = salloc(strlen(subj) + 5);
|
||||
sprintf(newsubj, "Re: %s", subj);
|
||||
return newsubj;
|
||||
return (newsubj);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -297,12 +296,12 @@ int
|
||||
preserve(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register struct message *mp;
|
||||
register int *ip, mesg;
|
||||
int *ip, mesg;
|
||||
struct message *mp;
|
||||
|
||||
if (edit) {
|
||||
printf("Cannot \"preserve\" in edit mode\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
mesg = *ip;
|
||||
@ -311,7 +310,7 @@ preserve(msgvec)
|
||||
mp->m_flag &= ~MBOX;
|
||||
dot = mp;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -321,14 +320,14 @@ int
|
||||
unread(msgvec)
|
||||
int msgvec[];
|
||||
{
|
||||
register int *ip;
|
||||
int *ip;
|
||||
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
dot = &message[*ip-1];
|
||||
dot->m_flag &= ~(MREAD|MTOUCH);
|
||||
dot->m_flag |= MSTATUS;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -338,15 +337,15 @@ int
|
||||
messize(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
register struct message *mp;
|
||||
register int *ip, mesg;
|
||||
struct message *mp;
|
||||
int *ip, mesg;
|
||||
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
mesg = *ip;
|
||||
mp = &message[mesg-1];
|
||||
printf("%d: %ld/%ld\n", mesg, mp->m_lines, mp->m_size);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -358,7 +357,7 @@ rexit(e)
|
||||
int e;
|
||||
{
|
||||
if (sourcing)
|
||||
return(1);
|
||||
return (1);
|
||||
exit(e);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@ -371,27 +370,27 @@ int
|
||||
set(arglist)
|
||||
char **arglist;
|
||||
{
|
||||
register struct var *vp;
|
||||
register char *cp, *cp2;
|
||||
struct var *vp;
|
||||
char *cp, *cp2;
|
||||
char varbuf[BUFSIZ], **ap, **p;
|
||||
int errs, h, s;
|
||||
|
||||
if (*arglist == NOSTR) {
|
||||
if (*arglist == NULL) {
|
||||
for (h = 0, s = 1; h < HSHSIZE; h++)
|
||||
for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)
|
||||
for (vp = variables[h]; vp != NULL; vp = vp->v_link)
|
||||
s++;
|
||||
ap = (char **) salloc(s * sizeof *ap);
|
||||
ap = (char **)salloc(s * sizeof(*ap));
|
||||
for (h = 0, p = ap; h < HSHSIZE; h++)
|
||||
for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)
|
||||
for (vp = variables[h]; vp != NULL; vp = vp->v_link)
|
||||
*p++ = vp->v_name;
|
||||
*p = NOSTR;
|
||||
*p = NULL;
|
||||
sort(ap);
|
||||
for (p = ap; *p != NOSTR; p++)
|
||||
for (p = ap; *p != NULL; p++)
|
||||
printf("%s\t%s\n", *p, value(*p));
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
errs = 0;
|
||||
for (ap = arglist; *ap != NOSTR; ap++) {
|
||||
for (ap = arglist; *ap != NULL; ap++) {
|
||||
cp = *ap;
|
||||
cp2 = varbuf;
|
||||
while (cp2 < varbuf + sizeof(varbuf) - 1 && *cp != '=' && *cp != '\0')
|
||||
@ -408,7 +407,7 @@ set(arglist)
|
||||
}
|
||||
assign(varbuf, cp);
|
||||
}
|
||||
return(errs);
|
||||
return (errs);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -418,13 +417,13 @@ int
|
||||
unset(arglist)
|
||||
char **arglist;
|
||||
{
|
||||
register struct var *vp, *vp2;
|
||||
struct var *vp, *vp2;
|
||||
int errs, h;
|
||||
char **ap;
|
||||
|
||||
errs = 0;
|
||||
for (ap = arglist; *ap != NOSTR; ap++) {
|
||||
if ((vp2 = lookup(*ap)) == NOVAR) {
|
||||
for (ap = arglist; *ap != NULL; ap++) {
|
||||
if ((vp2 = lookup(*ap)) == NULL) {
|
||||
if (!sourcing) {
|
||||
printf("\"%s\": undefined variable\n", *ap);
|
||||
errs++;
|
||||
@ -436,7 +435,7 @@ unset(arglist)
|
||||
variables[h] = variables[h]->v_link;
|
||||
vfree(vp2->v_name);
|
||||
vfree(vp2->v_value);
|
||||
free((char *)vp2);
|
||||
(void)free(vp2);
|
||||
continue;
|
||||
}
|
||||
for (vp = variables[h]; vp->v_link != vp2; vp = vp->v_link)
|
||||
@ -444,9 +443,9 @@ unset(arglist)
|
||||
vp->v_link = vp2->v_link;
|
||||
vfree(vp2->v_name);
|
||||
vfree(vp2->v_value);
|
||||
free((char *) vp2);
|
||||
(void)free(vp2);
|
||||
}
|
||||
return(errs);
|
||||
return (errs);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -456,36 +455,35 @@ int
|
||||
group(argv)
|
||||
char **argv;
|
||||
{
|
||||
register struct grouphead *gh;
|
||||
register struct group *gp;
|
||||
register int h;
|
||||
int s;
|
||||
struct grouphead *gh;
|
||||
struct group *gp;
|
||||
char **ap, *gname, **p;
|
||||
int h, s;
|
||||
|
||||
if (*argv == NOSTR) {
|
||||
if (*argv == NULL) {
|
||||
for (h = 0, s = 1; h < HSHSIZE; h++)
|
||||
for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)
|
||||
for (gh = groups[h]; gh != NULL; gh = gh->g_link)
|
||||
s++;
|
||||
ap = (char **) salloc(s * sizeof *ap);
|
||||
ap = (char **)salloc(s * sizeof(*ap));
|
||||
for (h = 0, p = ap; h < HSHSIZE; h++)
|
||||
for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)
|
||||
for (gh = groups[h]; gh != NULL; gh = gh->g_link)
|
||||
*p++ = gh->g_name;
|
||||
*p = NOSTR;
|
||||
*p = NULL;
|
||||
sort(ap);
|
||||
for (p = ap; *p != NOSTR; p++)
|
||||
for (p = ap; *p != NULL; p++)
|
||||
printgroup(*p);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (argv[1] == NOSTR) {
|
||||
if (argv[1] == NULL) {
|
||||
printgroup(*argv);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
gname = *argv;
|
||||
h = hash(gname);
|
||||
if ((gh = findgroup(gname)) == NOGRP) {
|
||||
gh = (struct grouphead *) calloc(sizeof *gh, 1);
|
||||
if ((gh = findgroup(gname)) == NULL) {
|
||||
gh = calloc(sizeof(*gh), 1);
|
||||
gh->g_name = vcopy(gname);
|
||||
gh->g_list = NOGE;
|
||||
gh->g_list = NULL;
|
||||
gh->g_link = groups[h];
|
||||
groups[h] = gh;
|
||||
}
|
||||
@ -496,13 +494,13 @@ group(argv)
|
||||
* later anyway.
|
||||
*/
|
||||
|
||||
for (ap = argv+1; *ap != NOSTR; ap++) {
|
||||
gp = (struct group *) calloc(sizeof *gp, 1);
|
||||
for (ap = argv+1; *ap != NULL; ap++) {
|
||||
gp = calloc(sizeof(*gp), 1);
|
||||
gp->ge_name = vcopy(*ap);
|
||||
gp->ge_link = gh->g_list;
|
||||
gh->g_list = gp;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -513,10 +511,9 @@ void
|
||||
sort(list)
|
||||
char **list;
|
||||
{
|
||||
register char **ap;
|
||||
int diction();
|
||||
char **ap;
|
||||
|
||||
for (ap = list; *ap != NOSTR; ap++)
|
||||
for (ap = list; *ap != NULL; ap++)
|
||||
;
|
||||
if (ap-list < 2)
|
||||
return;
|
||||
@ -531,7 +528,7 @@ int
|
||||
diction(a, b)
|
||||
const void *a, *b;
|
||||
{
|
||||
return(strcmp(*(char **)a, *(char **)b));
|
||||
return (strcmp(*(const char **)a, *(const char **)b));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -543,7 +540,7 @@ int
|
||||
null(e)
|
||||
int e;
|
||||
{
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -552,17 +549,17 @@ null(e)
|
||||
*/
|
||||
int
|
||||
file(argv)
|
||||
register char **argv;
|
||||
char **argv;
|
||||
{
|
||||
|
||||
if (argv[0] == NOSTR) {
|
||||
if (argv[0] == NULL) {
|
||||
newfileinfo();
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
if (setfile(*argv) < 0)
|
||||
return 1;
|
||||
return (1);
|
||||
announce();
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -572,26 +569,25 @@ int
|
||||
echo(argv)
|
||||
char **argv;
|
||||
{
|
||||
register char **ap;
|
||||
register char *cp;
|
||||
char **ap, *cp;
|
||||
|
||||
for (ap = argv; *ap != NOSTR; ap++) {
|
||||
for (ap = argv; *ap != NULL; ap++) {
|
||||
cp = *ap;
|
||||
if ((cp = expand(cp)) != NOSTR) {
|
||||
if ((cp = expand(cp)) != NULL) {
|
||||
if (ap != argv)
|
||||
putchar(' ');
|
||||
printf(" ");
|
||||
printf("%s", cp);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
return 0;
|
||||
printf("\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
Respond(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
if (value("Replyall") == NOSTR)
|
||||
if (value("Replyall") == NULL)
|
||||
return (doRespond(msgvec));
|
||||
else
|
||||
return (dorespond(msgvec));
|
||||
@ -608,34 +604,33 @@ doRespond(msgvec)
|
||||
{
|
||||
struct header head;
|
||||
struct message *mp;
|
||||
register int *ap;
|
||||
register char *cp;
|
||||
char *mid;
|
||||
int *ap;
|
||||
char *cp, *mid;
|
||||
|
||||
head.h_to = NIL;
|
||||
head.h_to = NULL;
|
||||
for (ap = msgvec; *ap != 0; ap++) {
|
||||
mp = &message[*ap - 1];
|
||||
touch(mp);
|
||||
dot = mp;
|
||||
if ((cp = skin(hfield("from", mp))) == NOSTR)
|
||||
if ((cp = skin(hfield("from", mp))) == NULL)
|
||||
cp = skin(nameof(mp, 2));
|
||||
head.h_to = cat(head.h_to, extract(cp, GTO));
|
||||
mid = skin(hfield("message-id", mp));
|
||||
}
|
||||
if (head.h_to == NIL)
|
||||
return 0;
|
||||
if (head.h_to == NULL)
|
||||
return (0);
|
||||
mp = &message[msgvec[0] - 1];
|
||||
if ((head.h_subject = hfield("subject", mp)) == NOSTR)
|
||||
if ((head.h_subject = hfield("subject", mp)) == NULL)
|
||||
head.h_subject = hfield("subj", mp);
|
||||
head.h_subject = reedit(head.h_subject);
|
||||
head.h_cc = NIL;
|
||||
head.h_bcc = NIL;
|
||||
head.h_smopts = NIL;
|
||||
head.h_cc = NULL;
|
||||
head.h_bcc = NULL;
|
||||
head.h_smopts = NULL;
|
||||
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
|
||||
head.h_replyto = NOSTR;
|
||||
head.h_replyto = NULL;
|
||||
head.h_inreplyto = mid;
|
||||
mail1(&head, 1);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -646,11 +641,11 @@ int
|
||||
ifcmd(argv)
|
||||
char **argv;
|
||||
{
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
if (cond != CANY) {
|
||||
printf("Illegal nested \"if\"\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
cond = CANY;
|
||||
cp = argv[0];
|
||||
@ -665,9 +660,9 @@ ifcmd(argv)
|
||||
|
||||
default:
|
||||
printf("Unrecognized if-keyword: \"%s\"\n", cp);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -681,7 +676,7 @@ elsecmd()
|
||||
switch (cond) {
|
||||
case CANY:
|
||||
printf("\"Else\" without matching \"if\"\n");
|
||||
return(1);
|
||||
return (1);
|
||||
|
||||
case CSEND:
|
||||
cond = CRCV;
|
||||
@ -696,7 +691,7 @@ elsecmd()
|
||||
cond = CANY;
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -708,10 +703,10 @@ endifcmd()
|
||||
|
||||
if (cond == CANY) {
|
||||
printf("\"Endif\" without matching \"if\"\n");
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
cond = CANY;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -721,26 +716,26 @@ int
|
||||
alternates(namelist)
|
||||
char **namelist;
|
||||
{
|
||||
register int c;
|
||||
register char **ap, **ap2, *cp;
|
||||
int c;
|
||||
char **ap, **ap2, *cp;
|
||||
|
||||
c = argcount(namelist) + 1;
|
||||
if (c == 1) {
|
||||
if (altnames == 0)
|
||||
return(0);
|
||||
for (ap = altnames; *ap; ap++)
|
||||
return (0);
|
||||
for (ap = altnames; *ap != NULL; ap++)
|
||||
printf("%s ", *ap);
|
||||
printf("\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (altnames != 0)
|
||||
free((char *) altnames);
|
||||
altnames = (char **) calloc((unsigned) c, sizeof (char *));
|
||||
for (ap = namelist, ap2 = altnames; *ap; ap++, ap2++) {
|
||||
cp = (char *) calloc((unsigned) strlen(*ap) + 1, sizeof (char));
|
||||
(void)free(altnames);
|
||||
altnames = calloc((unsigned)c, sizeof(char *));
|
||||
for (ap = namelist, ap2 = altnames; *ap != NULL; ap++, ap2++) {
|
||||
cp = calloc((unsigned)strlen(*ap) + 1, sizeof(char));
|
||||
strcpy(cp, *ap);
|
||||
*ap2 = cp;
|
||||
}
|
||||
*ap2 = 0;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
@ -48,74 +48,77 @@ static const char rcsid[] =
|
||||
* Define all of the command names and bindings.
|
||||
*/
|
||||
|
||||
struct cmd cmdtab[] = {
|
||||
"next", next, NDMLIST, 0, MMNDEL,
|
||||
"alias", group, M|RAWLIST, 0, 1000,
|
||||
"print", type, MSGLIST, 0, MMNDEL,
|
||||
"type", type, MSGLIST, 0, MMNDEL,
|
||||
"Type", Type, MSGLIST, 0, MMNDEL,
|
||||
"Print", Type, MSGLIST, 0, MMNDEL,
|
||||
"visual", visual, I|MSGLIST, 0, MMNORM,
|
||||
"top", top, MSGLIST, 0, MMNDEL,
|
||||
"touch", stouch, W|MSGLIST, 0, MMNDEL,
|
||||
"preserve", preserve, W|MSGLIST, 0, MMNDEL,
|
||||
"delete", delete, W|P|MSGLIST, 0, MMNDEL,
|
||||
"dp", deltype, W|MSGLIST, 0, MMNDEL,
|
||||
"dt", deltype, W|MSGLIST, 0, MMNDEL,
|
||||
"undelete", undelete_messages, P|MSGLIST, MDELETED,MMNDEL,
|
||||
"unset", unset, M|RAWLIST, 1, 1000,
|
||||
"mail", sendmail, R|M|I|STRLIST, 0, 0,
|
||||
"mbox", mboxit, W|MSGLIST, 0, 0,
|
||||
"more", more, MSGLIST, 0, MMNDEL,
|
||||
"page", more, MSGLIST, 0, MMNDEL,
|
||||
"More", More, MSGLIST, 0, MMNDEL,
|
||||
"Page", More, MSGLIST, 0, MMNDEL,
|
||||
"unread", unread, MSGLIST, 0, MMNDEL,
|
||||
"!", shell, I|STRLIST, 0, 0,
|
||||
"copy", copycmd, M|STRLIST, 0, 0,
|
||||
"chdir", schdir, M|RAWLIST, 0, 1,
|
||||
"cd", schdir, M|RAWLIST, 0, 1,
|
||||
"save", save, STRLIST, 0, 0,
|
||||
"source", source, M|RAWLIST, 1, 1,
|
||||
"set", set, M|RAWLIST, 0, 1000,
|
||||
"shell", dosh, I|NOLIST, 0, 0,
|
||||
"version", pversion, M|NOLIST, 0, 0,
|
||||
"group", group, M|RAWLIST, 0, 1000,
|
||||
"write", swrite, STRLIST, 0, 0,
|
||||
"from", from, MSGLIST, 0, MMNORM,
|
||||
"file", file, T|M|RAWLIST, 0, 1,
|
||||
"folder", file, T|M|RAWLIST, 0, 1,
|
||||
"folders", folders, T|M|NOLIST, 0, 0,
|
||||
"?", help, M|NOLIST, 0, 0,
|
||||
"z", scroll, M|STRLIST, 0, 0,
|
||||
"headers", headers, MSGLIST, 0, MMNDEL,
|
||||
"help", help, M|NOLIST, 0, 0,
|
||||
"=", pdot, NOLIST, 0, 0,
|
||||
"Reply", Respond, R|I|MSGLIST, 0, MMNDEL,
|
||||
"Respond", Respond, R|I|MSGLIST, 0, MMNDEL,
|
||||
"reply", respond, R|I|MSGLIST, 0, MMNDEL,
|
||||
"respond", respond, R|I|MSGLIST, 0, MMNDEL,
|
||||
"edit", editor, I|MSGLIST, 0, MMNORM,
|
||||
"echo", echo, M|RAWLIST, 0, 1000,
|
||||
"quit", quitcmd, NOLIST, 0, 0,
|
||||
"list", pcmdlist, M|NOLIST, 0, 0,
|
||||
"xit", rexit, M|NOLIST, 0, 0,
|
||||
"exit", rexit, M|NOLIST, 0, 0,
|
||||
"size", messize, MSGLIST, 0, MMNDEL,
|
||||
"hold", preserve, W|MSGLIST, 0, MMNDEL,
|
||||
"if", ifcmd, F|M|RAWLIST, 1, 1,
|
||||
"else", elsecmd, F|M|RAWLIST, 0, 0,
|
||||
"endif", endifcmd, F|M|RAWLIST, 0, 0,
|
||||
"alternates", alternates, M|RAWLIST, 0, 1000,
|
||||
"ignore", igfield, M|RAWLIST, 0, 1000,
|
||||
"discard", igfield, M|RAWLIST, 0, 1000,
|
||||
"retain", retfield, M|RAWLIST, 0, 1000,
|
||||
"saveignore", saveigfield, M|RAWLIST, 0, 1000,
|
||||
"savediscard", saveigfield, M|RAWLIST, 0, 1000,
|
||||
"saveretain", saveretfield, M|RAWLIST, 0, 1000,
|
||||
/* "Header", Header, STRLIST, 0, 1000, */
|
||||
"core", core, M|NOLIST, 0, 0,
|
||||
"#", null, M|NOLIST, 0, 0,
|
||||
"clobber", clobber, M|RAWLIST, 0, 1,
|
||||
0, 0, 0, 0, 0
|
||||
const struct cmd cmdtab[] = {
|
||||
/* msgmask msgflag */
|
||||
/* command function argtype result & mask */
|
||||
/* ------- -------- ------- ------ ------- */
|
||||
{ "next", next, NDMLIST, 0, MMNDEL },
|
||||
{ "alias", group, M|RAWLIST, 0, 1000 },
|
||||
{ "print", type, MSGLIST, 0, MMNDEL },
|
||||
{ "type", type, MSGLIST, 0, MMNDEL },
|
||||
{ "Type", Type, MSGLIST, 0, MMNDEL },
|
||||
{ "Print", Type, MSGLIST, 0, MMNDEL },
|
||||
{ "visual", visual, I|MSGLIST, 0, MMNORM },
|
||||
{ "top", top, MSGLIST, 0, MMNDEL },
|
||||
{ "touch", stouch, W|MSGLIST, 0, MMNDEL },
|
||||
{ "preserve", preserve, W|MSGLIST, 0, MMNDEL },
|
||||
{ "delete", delete, W|P|MSGLIST, 0, MMNDEL },
|
||||
{ "dp", deltype, W|MSGLIST, 0, MMNDEL },
|
||||
{ "dt", deltype, W|MSGLIST, 0, MMNDEL },
|
||||
{ "undelete", undelete_messages, P|MSGLIST, MDELETED,MMNDEL },
|
||||
{ "unset", unset, M|RAWLIST, 1, 1000 },
|
||||
{ "mail", sendmail, R|M|I|STRLIST, 0, 0 },
|
||||
{ "mbox", mboxit, W|MSGLIST, 0, 0 },
|
||||
{ "more", more, MSGLIST, 0, MMNDEL },
|
||||
{ "page", more, MSGLIST, 0, MMNDEL },
|
||||
{ "More", More, MSGLIST, 0, MMNDEL },
|
||||
{ "Page", More, MSGLIST, 0, MMNDEL },
|
||||
{ "unread", unread, MSGLIST, 0, MMNDEL },
|
||||
{ "!", shell, I|STRLIST, 0, 0 },
|
||||
{ "copy", copycmd, M|STRLIST, 0, 0 },
|
||||
{ "chdir", schdir, M|RAWLIST, 0, 1 },
|
||||
{ "cd", schdir, M|RAWLIST, 0, 1 },
|
||||
{ "save", save, STRLIST, 0, 0 },
|
||||
{ "source", source, M|RAWLIST, 1, 1 },
|
||||
{ "set", set, M|RAWLIST, 0, 1000 },
|
||||
{ "shell", dosh, I|NOLIST, 0, 0 },
|
||||
{ "version", pversion, M|NOLIST, 0, 0 },
|
||||
{ "group", group, M|RAWLIST, 0, 1000 },
|
||||
{ "write", swrite, STRLIST, 0, 0 },
|
||||
{ "from", from, MSGLIST, 0, MMNORM },
|
||||
{ "file", file, T|M|RAWLIST, 0, 1 },
|
||||
{ "folder", file, T|M|RAWLIST, 0, 1 },
|
||||
{ "folders", folders, T|M|NOLIST, 0, 0 },
|
||||
{ "?", help, M|NOLIST, 0, 0 },
|
||||
{ "z", scroll, M|STRLIST, 0, 0 },
|
||||
{ "headers", headers, MSGLIST, 0, MMNDEL },
|
||||
{ "help", help, M|NOLIST, 0, 0 },
|
||||
{ "=", pdot, NOLIST, 0, 0 },
|
||||
{ "Reply", Respond, R|I|MSGLIST, 0, MMNDEL },
|
||||
{ "Respond", Respond, R|I|MSGLIST, 0, MMNDEL },
|
||||
{ "reply", respond, R|I|MSGLIST, 0, MMNDEL },
|
||||
{ "respond", respond, R|I|MSGLIST, 0, MMNDEL },
|
||||
{ "edit", editor, I|MSGLIST, 0, MMNORM },
|
||||
{ "echo", echo, M|RAWLIST, 0, 1000 },
|
||||
{ "quit", quitcmd, NOLIST, 0, 0 },
|
||||
{ "list", pcmdlist, M|NOLIST, 0, 0 },
|
||||
{ "xit", rexit, M|NOLIST, 0, 0 },
|
||||
{ "exit", rexit, M|NOLIST, 0, 0 },
|
||||
{ "size", messize, MSGLIST, 0, MMNDEL },
|
||||
{ "hold", preserve, W|MSGLIST, 0, MMNDEL },
|
||||
{ "if", ifcmd, F|M|RAWLIST, 1, 1 },
|
||||
{ "else", elsecmd, F|M|RAWLIST, 0, 0 },
|
||||
{ "endif", endifcmd, F|M|RAWLIST, 0, 0 },
|
||||
{ "alternates", alternates, M|RAWLIST, 0, 1000 },
|
||||
{ "ignore", igfield, M|RAWLIST, 0, 1000 },
|
||||
{ "discard", igfield, M|RAWLIST, 0, 1000 },
|
||||
{ "retain", retfield, M|RAWLIST, 0, 1000 },
|
||||
{ "saveignore", saveigfield, M|RAWLIST, 0, 1000 },
|
||||
{ "savediscard",saveigfield, M|RAWLIST, 0, 1000 },
|
||||
{ "saveretain", saveretfield, M|RAWLIST, 0, 1000 },
|
||||
/* { "Header", Header, STRLIST, 0, 1000 }, */
|
||||
{ "core", core, M|NOLIST, 0, 0 },
|
||||
{ "#", null, M|NOLIST, 0, 0 },
|
||||
{ "clobber", clobber, M|RAWLIST, 0, 1 },
|
||||
{ 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
@ -78,12 +78,9 @@ collect(hp, printheaders)
|
||||
int printheaders;
|
||||
{
|
||||
FILE *fbuf;
|
||||
int lc, cc, escape, eofcount, fd;
|
||||
register int c, t;
|
||||
char linebuf[LINESIZE], tempname[PATHSIZE], *cp;
|
||||
char getsub;
|
||||
int lc, cc, escape, eofcount, fd, c, t;
|
||||
char linebuf[LINESIZE], tempname[PATHSIZE], *cp, getsub;
|
||||
int omask;
|
||||
void collint(), collhup(), collstop();
|
||||
|
||||
collf = NULL;
|
||||
/*
|
||||
@ -92,26 +89,27 @@ collect(hp, printheaders)
|
||||
*/
|
||||
omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
|
||||
if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
|
||||
signal(SIGINT, collint);
|
||||
(void)signal(SIGINT, collint);
|
||||
if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
|
||||
signal(SIGHUP, collhup);
|
||||
(void)signal(SIGHUP, collhup);
|
||||
savetstp = signal(SIGTSTP, collstop);
|
||||
savettou = signal(SIGTTOU, collstop);
|
||||
savettin = signal(SIGTTIN, collstop);
|
||||
if (setjmp(collabort) || setjmp(colljmp)) {
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
goto err;
|
||||
}
|
||||
sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
|
||||
|
||||
noreset++;
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(collf = Fdopen(fd, "w+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
goto err;
|
||||
}
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
|
||||
/*
|
||||
* If we are going to prompt for a subject,
|
||||
@ -120,14 +118,14 @@ collect(hp, printheaders)
|
||||
*/
|
||||
t = GTO|GSUBJECT|GCC|GNL;
|
||||
getsub = 0;
|
||||
if (hp->h_subject == NOSTR && value("interactive") != NOSTR &&
|
||||
(value("ask") != NOSTR || value("asksub") != NOSTR))
|
||||
if (hp->h_subject == NULL && value("interactive") != NULL &&
|
||||
(value("ask") != NULL || value("asksub") != NULL))
|
||||
t &= ~GNL, getsub++;
|
||||
if (printheaders) {
|
||||
puthead(hp, stdout, t);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
if ((cp = value("escape")) != NOSTR)
|
||||
if ((cp = value("escape")) != NULL)
|
||||
escape = *cp;
|
||||
else
|
||||
escape = ESCAPE;
|
||||
@ -145,12 +143,12 @@ collect(hp, printheaders)
|
||||
*/
|
||||
cont:
|
||||
if (hadintr) {
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
fprintf(stderr,
|
||||
"\n(Interrupt -- one more to kill letter)\n");
|
||||
} else {
|
||||
printf("(continue)\n");
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
@ -158,8 +156,8 @@ collect(hp, printheaders)
|
||||
c = readline(stdin, linebuf, LINESIZE);
|
||||
colljmp_p = 0;
|
||||
if (c < 0) {
|
||||
if (value("interactive") != NOSTR &&
|
||||
value("ignoreeof") != NOSTR && ++eofcount < 25) {
|
||||
if (value("interactive") != NULL &&
|
||||
value("ignoreeof") != NULL && ++eofcount < 25) {
|
||||
printf("Use \".\" to terminate letter\n");
|
||||
continue;
|
||||
}
|
||||
@ -168,10 +166,10 @@ collect(hp, printheaders)
|
||||
eofcount = 0;
|
||||
hadintr = 0;
|
||||
if (linebuf[0] == '.' && linebuf[1] == '\0' &&
|
||||
value("interactive") != NOSTR &&
|
||||
(value("dot") != NOSTR || value("ignoreeof") != NOSTR))
|
||||
value("interactive") != NULL &&
|
||||
(value("dot") != NULL || value("ignoreeof") != NULL))
|
||||
break;
|
||||
if (linebuf[0] != escape || value("interactive") == NOSTR) {
|
||||
if (linebuf[0] != escape || value("interactive") == NULL) {
|
||||
if (putline(collf, linebuf) < 0)
|
||||
goto err;
|
||||
continue;
|
||||
@ -286,7 +284,7 @@ collect(hp, printheaders)
|
||||
break;
|
||||
}
|
||||
cp = expand(cp);
|
||||
if (cp == NOSTR)
|
||||
if (cp == NULL)
|
||||
break;
|
||||
if (isdir(cp)) {
|
||||
printf("%s: Directory\n", cp);
|
||||
@ -297,18 +295,18 @@ collect(hp, printheaders)
|
||||
break;
|
||||
}
|
||||
printf("\"%s\" ", cp);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
lc = 0;
|
||||
cc = 0;
|
||||
while (readline(fbuf, linebuf, LINESIZE) >= 0) {
|
||||
lc++;
|
||||
if ((t = putline(collf, linebuf)) < 0) {
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
goto err;
|
||||
}
|
||||
cc += t;
|
||||
}
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
printf("%d/%d\n", lc, cc);
|
||||
break;
|
||||
case 'w':
|
||||
@ -322,7 +320,7 @@ collect(hp, printheaders)
|
||||
fprintf(stderr, "Write what file!?\n");
|
||||
break;
|
||||
}
|
||||
if ((cp = expand(cp)) == NOSTR)
|
||||
if ((cp = expand(cp)) == NULL)
|
||||
break;
|
||||
rewind(collf);
|
||||
exwrite(cp, collf, 1);
|
||||
@ -346,8 +344,8 @@ collect(hp, printheaders)
|
||||
break;
|
||||
}
|
||||
while ((t = getc(fbuf)) != EOF)
|
||||
(void) putchar(t);
|
||||
Fclose(fbuf);
|
||||
(void)putchar(t);
|
||||
(void)Fclose(fbuf);
|
||||
break;
|
||||
case 'p':
|
||||
/*
|
||||
@ -358,7 +356,7 @@ collect(hp, printheaders)
|
||||
printf("-------\nMessage contains:\n");
|
||||
puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL);
|
||||
while ((t = getc(collf)) != EOF)
|
||||
(void) putchar(t);
|
||||
(void)putchar(t);
|
||||
goto cont;
|
||||
case '|':
|
||||
/*
|
||||
@ -383,21 +381,21 @@ collect(hp, printheaders)
|
||||
goto out;
|
||||
err:
|
||||
if (collf != NULL) {
|
||||
Fclose(collf);
|
||||
(void)Fclose(collf);
|
||||
collf = NULL;
|
||||
}
|
||||
out:
|
||||
if (collf != NULL)
|
||||
rewind(collf);
|
||||
noreset--;
|
||||
sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
|
||||
signal(SIGINT, saveint);
|
||||
signal(SIGHUP, savehup);
|
||||
signal(SIGTSTP, savetstp);
|
||||
signal(SIGTTOU, savettou);
|
||||
signal(SIGTTIN, savettin);
|
||||
sigsetmask(omask);
|
||||
return collf;
|
||||
(void)sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
|
||||
(void)signal(SIGINT, saveint);
|
||||
(void)signal(SIGHUP, savehup);
|
||||
(void)signal(SIGTSTP, savetstp);
|
||||
(void)signal(SIGTTOU, savettou);
|
||||
(void)signal(SIGTTIN, savettin);
|
||||
(void)sigsetmask(omask);
|
||||
return (collf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -409,25 +407,24 @@ exwrite(name, fp, f)
|
||||
FILE *fp;
|
||||
int f;
|
||||
{
|
||||
register FILE *of;
|
||||
register int c;
|
||||
FILE *of;
|
||||
int c, lc;
|
||||
long cc;
|
||||
int lc;
|
||||
struct stat junk;
|
||||
|
||||
if (f) {
|
||||
printf("\"%s\" ", name);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
if (stat(name, &junk) >= 0 && S_ISREG(junk.st_mode)) {
|
||||
if (!f)
|
||||
fprintf(stderr, "%s: ", name);
|
||||
fprintf(stderr, "File exists\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
if ((of = Fopen(name, "w")) == NULL) {
|
||||
warn(NOSTR);
|
||||
return(-1);
|
||||
warn((char *)NULL);
|
||||
return (-1);
|
||||
}
|
||||
lc = 0;
|
||||
cc = 0;
|
||||
@ -435,17 +432,17 @@ exwrite(name, fp, f)
|
||||
cc++;
|
||||
if (c == '\n')
|
||||
lc++;
|
||||
(void) putc(c, of);
|
||||
(void)putc(c, of);
|
||||
if (ferror(of)) {
|
||||
warnx("%s", name);
|
||||
Fclose(of);
|
||||
return(-1);
|
||||
(void)Fclose(of);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
Fclose(of);
|
||||
(void)Fclose(of);
|
||||
printf("%d/%ld\n", lc, cc);
|
||||
fflush(stdout);
|
||||
return(0);
|
||||
(void)fflush(stdout);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -461,11 +458,11 @@ mesedit(fp, c)
|
||||
FILE *nf = run_editor(fp, (off_t)-1, c, 0);
|
||||
|
||||
if (nf != NULL) {
|
||||
fseek(nf, 0L, 2);
|
||||
(void)fseek(nf, 0L, 2);
|
||||
collf = nf;
|
||||
Fclose(fp);
|
||||
(void)Fclose(fp);
|
||||
}
|
||||
(void) signal(SIGINT, sigint);
|
||||
(void)signal(SIGINT, sigint);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -482,39 +479,40 @@ mespipe(fp, cmd)
|
||||
FILE *nf;
|
||||
int fd;
|
||||
sig_t sigint = signal(SIGINT, SIG_IGN);
|
||||
char *shell, tempname[PATHSIZE];
|
||||
char *sh, tempname[PATHSIZE];
|
||||
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(nf = Fdopen(fd, "w+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
goto out;
|
||||
}
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
/*
|
||||
* stdin = current message.
|
||||
* stdout = new message.
|
||||
*/
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
if (run_command(shell,
|
||||
0, fileno(fp), fileno(nf), "-c", cmd, NOSTR) < 0) {
|
||||
(void) Fclose(nf);
|
||||
if ((sh = value("SHELL")) == NULL)
|
||||
sh = _PATH_CSHELL;
|
||||
if (run_command(sh,
|
||||
0, fileno(fp), fileno(nf), "-c", cmd, NULL) < 0) {
|
||||
(void)Fclose(nf);
|
||||
goto out;
|
||||
}
|
||||
if (fsize(nf) == 0) {
|
||||
fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
|
||||
(void) Fclose(nf);
|
||||
(void)Fclose(nf);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Take new files.
|
||||
*/
|
||||
(void) fseek(nf, 0L, 2);
|
||||
(void)fseek(nf, 0L, 2);
|
||||
collf = nf;
|
||||
(void) Fclose(fp);
|
||||
(void)Fclose(fp);
|
||||
out:
|
||||
(void) signal(SIGINT, sigint);
|
||||
(void)signal(SIGINT, sigint);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -532,26 +530,26 @@ forward(ms, fp, fn, f)
|
||||
char *fn;
|
||||
int f;
|
||||
{
|
||||
register int *msgvec;
|
||||
int *msgvec;
|
||||
struct ignoretab *ig;
|
||||
char *tabst;
|
||||
|
||||
msgvec = (int *) salloc((msgCount+1) * sizeof *msgvec);
|
||||
if (msgvec == (int *) NOSTR)
|
||||
return(0);
|
||||
msgvec = (int *)salloc((msgCount+1) * sizeof(*msgvec));
|
||||
if (msgvec == NULL)
|
||||
return (0);
|
||||
if (getmsglist(ms, msgvec, 0) < 0)
|
||||
return(0);
|
||||
return (0);
|
||||
if (*msgvec == 0) {
|
||||
*msgvec = first(0, MMNORM);
|
||||
if (*msgvec == 0) {
|
||||
printf("No appropriate messages\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
msgvec[1] = 0;
|
||||
}
|
||||
if (f == 'f' || f == 'F')
|
||||
tabst = NOSTR;
|
||||
else if ((tabst = value("indentprefix")) == NOSTR)
|
||||
tabst = NULL;
|
||||
else if ((tabst = value("indentprefix")) == NULL)
|
||||
tabst = "\t";
|
||||
ig = isupper(f) ? NULL : ignore;
|
||||
printf("Interpolating:");
|
||||
@ -562,11 +560,11 @@ forward(ms, fp, fn, f)
|
||||
printf(" %d", *msgvec);
|
||||
if (sendmessage(mp, fp, ig, tabst) < 0) {
|
||||
warnx("%s", fn);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -579,10 +577,10 @@ collstop(s)
|
||||
{
|
||||
sig_t old_action = signal(s, SIG_DFL);
|
||||
|
||||
sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
kill(0, s);
|
||||
sigblock(sigmask(s));
|
||||
signal(s, old_action);
|
||||
(void)sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
(void)kill(0, s);
|
||||
(void)sigblock(sigmask(s));
|
||||
(void)signal(s, old_action);
|
||||
if (colljmp_p) {
|
||||
colljmp_p = 0;
|
||||
hadintr = 0;
|
||||
@ -603,9 +601,9 @@ collint(s)
|
||||
* the control flow is subtle, because we can be called from ~q.
|
||||
*/
|
||||
if (!hadintr) {
|
||||
if (value("ignore") != NOSTR) {
|
||||
puts("@");
|
||||
fflush(stdout);
|
||||
if (value("ignore") != NULL) {
|
||||
printf("@");
|
||||
(void)fflush(stdout);
|
||||
clearerr(stdin);
|
||||
return;
|
||||
}
|
||||
@ -613,7 +611,7 @@ collint(s)
|
||||
longjmp(colljmp, 1);
|
||||
}
|
||||
rewind(collf);
|
||||
if (value("nosave") == NOSTR)
|
||||
if (value("nosave") == NULL)
|
||||
savedeadletter(collf);
|
||||
longjmp(collabort, 1);
|
||||
}
|
||||
@ -634,10 +632,10 @@ collhup(s)
|
||||
|
||||
void
|
||||
savedeadletter(fp)
|
||||
register FILE *fp;
|
||||
FILE *fp;
|
||||
{
|
||||
register FILE *dbuf;
|
||||
register int c;
|
||||
FILE *dbuf;
|
||||
int c;
|
||||
char *cp;
|
||||
|
||||
if (fsize(fp) == 0)
|
||||
@ -645,11 +643,11 @@ savedeadletter(fp)
|
||||
cp = getdeadletter();
|
||||
c = umask(077);
|
||||
dbuf = Fopen(cp, "a");
|
||||
(void) umask(c);
|
||||
(void)umask(c);
|
||||
if (dbuf == NULL)
|
||||
return;
|
||||
while ((c = getc(fp)) != EOF)
|
||||
(void) putc(c, dbuf);
|
||||
Fclose(dbuf);
|
||||
(void)putc(c, dbuf);
|
||||
(void)Fclose(dbuf);
|
||||
rewind(fp);
|
||||
}
|
||||
|
@ -43,16 +43,18 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
#define APPEND /* New mail goes to end of mailbox */
|
||||
@ -62,9 +64,8 @@
|
||||
#define PATHSIZE MAXPATHLEN /* Size of pathnames throughout */
|
||||
#define HSHSIZE 59 /* Hash size for aliases and vars */
|
||||
#define LINESIZE BUFSIZ /* max readable line width */
|
||||
#define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */
|
||||
#define STRINGSIZE ((unsigned)128) /* Dynamic allocation units */
|
||||
#define MAXARGC 1024 /* Maximum list of raw strings */
|
||||
#define NOSTR ((char *) 0) /* Null string pointer */
|
||||
#define MAXEXP 25 /* Maximum expansion of aliases */
|
||||
|
||||
#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
|
||||
@ -96,8 +97,8 @@ struct message {
|
||||
/*
|
||||
* Given a file address, determine the block number it represents.
|
||||
*/
|
||||
#define blockof(off) ((int) ((off) / 4096))
|
||||
#define boffsetof(off) ((int) ((off) % 4096))
|
||||
#define blockof(off) ((int)((off) / 4096))
|
||||
#define boffsetof(off) ((int)((off) % 4096))
|
||||
#define positionof(block, offset) ((off_t)(block) * 4096 + (offset))
|
||||
|
||||
/*
|
||||
@ -106,7 +107,7 @@ struct message {
|
||||
* in lex.c
|
||||
*/
|
||||
struct cmd {
|
||||
char *c_name; /* Name of command */
|
||||
const char *c_name; /* Name of command */
|
||||
int (*c_func)(); /* Implementor of the command */
|
||||
short c_argtype; /* Type of arglist (see below) */
|
||||
short c_msgflag; /* Required flags of messages */
|
||||
@ -173,13 +174,13 @@ struct headline {
|
||||
*/
|
||||
|
||||
struct header {
|
||||
struct name *h_to; /* Dynamic "To:" string */
|
||||
char *h_subject; /* Subject string */
|
||||
struct name *h_cc; /* Carbon copies string */
|
||||
struct name *h_bcc; /* Blind carbon copies */
|
||||
char *h_replyto; /* Reply address */
|
||||
char *h_inreplyto; /* Reference */
|
||||
struct name *h_smopts; /* Sendmail options */
|
||||
struct name *h_bcc; /* Blind carbon copies */
|
||||
struct name *h_cc; /* Carbon copies string */
|
||||
struct name *h_smopts; /* Sendmail options */
|
||||
struct name *h_to; /* Dynamic "To:" string */
|
||||
char *h_inreplyto; /* Reference */
|
||||
char *h_replyto; /* Reply address */
|
||||
char *h_subject; /* Subject string */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -218,20 +219,14 @@ struct grouphead {
|
||||
struct group *g_list; /* Users in group. */
|
||||
};
|
||||
|
||||
#define NIL ((struct name *) 0) /* The nil pointer for namelists */
|
||||
#define NONE ((struct cmd *) 0) /* The nil pointer to command tab */
|
||||
#define NOVAR ((struct var *) 0) /* The nil pointer to variables */
|
||||
#define NOGRP ((struct grouphead *) 0)/* The nil grouphead pointer */
|
||||
#define NOGE ((struct group *) 0) /* The nil group pointer */
|
||||
|
||||
/*
|
||||
* Structure of the hash table of ignored header fields
|
||||
*/
|
||||
struct ignoretab {
|
||||
int i_count; /* Number of entries */
|
||||
struct ignore {
|
||||
struct ignore *i_link; /* Next ignored field in bucket */
|
||||
char *i_field; /* This ignored field */
|
||||
int i_count; /* Number of entries */
|
||||
struct ignore {
|
||||
struct ignore *i_link; /* Next ignored field in bucket */
|
||||
char *i_field; /* This ignored field */
|
||||
} *i_head[HSHSIZE];
|
||||
};
|
||||
|
||||
@ -279,5 +274,5 @@ struct ignoretab {
|
||||
*/
|
||||
#define trunc(stream) { \
|
||||
(void)fflush(stream); \
|
||||
(void)ftruncate(fileno(stream), (long)ftell(stream)); \
|
||||
(void)ftruncate(fileno(stream), (off_t)ftell(stream)); \
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ editor(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
|
||||
return edit1(msgvec, 'e');
|
||||
return (edit1(msgvec, 'e'));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -70,7 +70,7 @@ visual(msgvec)
|
||||
int *msgvec;
|
||||
{
|
||||
|
||||
return edit1(msgvec, 'v');
|
||||
return (edit1(msgvec, 'v'));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -83,10 +83,9 @@ edit1(msgvec, type)
|
||||
int *msgvec;
|
||||
int type;
|
||||
{
|
||||
register int c;
|
||||
int i;
|
||||
int c, i;
|
||||
FILE *fp;
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
off_t size;
|
||||
|
||||
/*
|
||||
@ -100,7 +99,7 @@ edit1(msgvec, type)
|
||||
char *p;
|
||||
|
||||
printf("Edit message %d [ynq]? ", msgvec[i]);
|
||||
if (fgets(buf, sizeof buf, stdin) == 0)
|
||||
if (fgets(buf, sizeof(buf), stdin) == 0)
|
||||
break;
|
||||
for (p = buf; *p == ' ' || *p == '\t'; p++)
|
||||
;
|
||||
@ -114,7 +113,7 @@ edit1(msgvec, type)
|
||||
sigint = signal(SIGINT, SIG_IGN);
|
||||
fp = run_editor(setinput(mp), mp->m_size, type, readonly);
|
||||
if (fp != NULL) {
|
||||
(void) fseek(otf, 0L, 2);
|
||||
(void)fseek(otf, 0L, 2);
|
||||
size = ftell(otf);
|
||||
mp->m_block = blockof(size);
|
||||
mp->m_offset = boffsetof(size);
|
||||
@ -130,11 +129,11 @@ edit1(msgvec, type)
|
||||
}
|
||||
if (ferror(otf))
|
||||
warnx("/tmp");
|
||||
(void) Fclose(fp);
|
||||
(void)Fclose(fp);
|
||||
}
|
||||
(void) signal(SIGINT, sigint);
|
||||
(void)signal(SIGINT, sigint);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -145,17 +144,18 @@ edit1(msgvec, type)
|
||||
*/
|
||||
FILE *
|
||||
run_editor(fp, size, type, readonly)
|
||||
register FILE *fp;
|
||||
FILE *fp;
|
||||
off_t size;
|
||||
int type, readonly;
|
||||
{
|
||||
register FILE *nf = NULL;
|
||||
register int t;
|
||||
FILE *nf = NULL;
|
||||
int t;
|
||||
time_t modtime;
|
||||
char *edit, tempname[PATHSIZE];
|
||||
struct stat statb;
|
||||
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((t = mkstemp(tempname)) == -1 ||
|
||||
(nf = Fdopen(t, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
@ -163,38 +163,38 @@ run_editor(fp, size, type, readonly)
|
||||
}
|
||||
if (readonly && fchmod(t, 0400) == -1) {
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
if (size >= 0)
|
||||
while (--size >= 0 && (t = getc(fp)) != EOF)
|
||||
(void) putc(t, nf);
|
||||
(void)putc(t, nf);
|
||||
else
|
||||
while ((t = getc(fp)) != EOF)
|
||||
(void) putc(t, nf);
|
||||
(void) fflush(nf);
|
||||
(void)putc(t, nf);
|
||||
(void)fflush(nf);
|
||||
if (fstat(fileno(nf), &statb) < 0)
|
||||
modtime = 0;
|
||||
else
|
||||
modtime = statb.st_mtime;
|
||||
if (ferror(nf)) {
|
||||
(void) Fclose(nf);
|
||||
(void)Fclose(nf);
|
||||
warnx("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
nf = NULL;
|
||||
goto out;
|
||||
}
|
||||
if (Fclose(nf) < 0) {
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
nf = NULL;
|
||||
goto out;
|
||||
}
|
||||
nf = NULL;
|
||||
if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NOSTR)
|
||||
if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NULL)
|
||||
edit = type == 'e' ? _PATH_EX : _PATH_VI;
|
||||
if (run_command(edit, 0, -1, -1, tempname, NOSTR, NOSTR) < 0) {
|
||||
(void) rm(tempname);
|
||||
if (run_command(edit, 0, -1, -1, tempname, NULL, NULL) < 0) {
|
||||
(void)rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
@ -202,7 +202,7 @@ run_editor(fp, size, type, readonly)
|
||||
* temporary and return.
|
||||
*/
|
||||
if (readonly) {
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
if (stat(tempname, &statb) < 0) {
|
||||
@ -210,7 +210,7 @@ run_editor(fp, size, type, readonly)
|
||||
goto out;
|
||||
}
|
||||
if (modtime == statb.st_mtime) {
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
@ -218,10 +218,10 @@ run_editor(fp, size, type, readonly)
|
||||
*/
|
||||
if ((nf = Fopen(tempname, "a+")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
goto out;
|
||||
}
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
out:
|
||||
return nf;
|
||||
return (nf);
|
||||
}
|
||||
|
@ -45,22 +45,22 @@ struct name *outof __P((struct name *, FILE *, struct header *));
|
||||
struct name *put __P((struct name *, struct name *));
|
||||
struct name *tailof __P((struct name *));
|
||||
struct name *usermap __P((struct name *));
|
||||
FILE *Fdopen __P((int, char *));
|
||||
FILE *Fopen __P((char *, char *));
|
||||
FILE *Popen __P((char *, char *));
|
||||
FILE *Fdopen __P((int, const char *));
|
||||
FILE *Fopen __P((const char *, const char *));
|
||||
FILE *Popen __P((char *, const char *));
|
||||
FILE *collect __P((struct header *, int));
|
||||
char *copyin __P((char *, char **));
|
||||
char *detract __P((struct name *, int));
|
||||
char *expand __P((char *));
|
||||
char *getdeadletter __P((void));
|
||||
char *getname __P((int));
|
||||
char *hfield __P((char [], struct message *));
|
||||
char *hfield __P((const char *, struct message *));
|
||||
FILE *infix __P((struct header *, FILE *));
|
||||
char *ishfield __P((char [], char[], char *));
|
||||
char *ishfield __P((char [], char *, const char *));
|
||||
char *name1 __P((struct message *, int));
|
||||
char *nameof __P((struct message *, int));
|
||||
char *nextword __P((char *, char *));
|
||||
char *readtty __P((char [], char []));
|
||||
char *readtty __P((const char *, char []));
|
||||
char *reedit __P((char *));
|
||||
FILE *run_editor __P((FILE *, off_t, int, int));
|
||||
char *salloc __P((int));
|
||||
@ -70,8 +70,8 @@ char *skin __P((char *));
|
||||
char *skip_comment __P((char *));
|
||||
char *snarf __P((char [], int *));
|
||||
char *username __P((void));
|
||||
char *value __P((char []));
|
||||
char *vcopy __P((char []));
|
||||
char *value __P((const char *));
|
||||
char *vcopy __P((const char *));
|
||||
char *yankword __P((char *, char []));
|
||||
int Fclose __P((FILE *));
|
||||
int More __P((int *));
|
||||
@ -85,7 +85,7 @@ int alternates __P((char **));
|
||||
void announce __P((void));
|
||||
int append __P((struct message *, FILE *));
|
||||
int argcount __P((char **));
|
||||
void assign __P((char [], char []));
|
||||
void assign __P((const char *, const char *));
|
||||
int bangexp __P((char *, size_t));
|
||||
void brokpipe __P((int));
|
||||
int charcount __P((char *, int));
|
||||
@ -116,14 +116,14 @@ int endifcmd __P((void));
|
||||
int evalcol __P((int));
|
||||
int execute __P((char [], int));
|
||||
int exwrite __P((char [], FILE *, int));
|
||||
void fail __P((char [], char []));
|
||||
void fail __P((const char *, const char *));
|
||||
int file __P((char **));
|
||||
struct grouphead *
|
||||
findgroup __P((char []));
|
||||
void findmail __P((char *, char *, int));
|
||||
int first __P((int, int));
|
||||
void fixhead __P((struct header *, struct name *));
|
||||
void fmt __P((char *, struct name *, FILE *, int));
|
||||
void fmt __P((const char *, struct name *, FILE *, int));
|
||||
int folders __P((void));
|
||||
int forward __P((char [], FILE *, char *, int));
|
||||
void free_child __P((int));
|
||||
@ -137,7 +137,7 @@ int getuserid __P((char []));
|
||||
int grabh __P((struct header *, int));
|
||||
int group __P((char **));
|
||||
void hangup __P((int));
|
||||
int hash __P((char *));
|
||||
int hash __P((const char *));
|
||||
void hdrstop __P((int));
|
||||
int headers __P((int *));
|
||||
int help __P((void));
|
||||
@ -145,21 +145,21 @@ void holdsigs __P((void));
|
||||
int ifcmd __P((char **));
|
||||
int igcomp __P((const void *, const void *));
|
||||
int igfield __P((char *[]));
|
||||
int ignore1 __P((char *[], struct ignoretab *, char *));
|
||||
int igshow __P((struct ignoretab *, char *));
|
||||
int ignore1 __P((char *[], struct ignoretab *, const char *));
|
||||
int igshow __P((struct ignoretab *, const char *));
|
||||
void intr __P((int));
|
||||
int isdate __P((char []));
|
||||
int isdir __P((char []));
|
||||
int isfileaddr __P((char *));
|
||||
int ishead __P((char []));
|
||||
int isign __P((char *, struct ignoretab []));
|
||||
int isprefix __P((char *, char *));
|
||||
void istrncpy __P((char *, char *, size_t));
|
||||
struct cmd *
|
||||
int isign __P((const char *, struct ignoretab []));
|
||||
int isprefix __P((const char *, const char *));
|
||||
void istrncpy __P((char *, const char *, size_t));
|
||||
__const struct cmd *
|
||||
lex __P((char []));
|
||||
void load __P((char *));
|
||||
struct var *
|
||||
lookup __P((char []));
|
||||
lookup __P((const char *));
|
||||
int mail __P((struct name *,
|
||||
struct name *, struct name *, struct name *, char *, char *));
|
||||
void mail1 __P((struct header *, int));
|
||||
@ -201,7 +201,7 @@ int rexit __P((int));
|
||||
int rm __P((char *));
|
||||
int run_command __P((char *, int, int, int, char *, char *, char *));
|
||||
int save __P((char []));
|
||||
int save1 __P((char [], int, char *, struct ignoretab *));
|
||||
int save1 __P((char [], int, const char *, struct ignoretab *));
|
||||
void savedeadletter __P((FILE *));
|
||||
int saveigfield __P((char *[]));
|
||||
int savemail __P((char [], FILE *));
|
||||
|
@ -56,15 +56,17 @@ static const char rcsid[] =
|
||||
* File I/O.
|
||||
*/
|
||||
|
||||
extern int wait_status;
|
||||
|
||||
/*
|
||||
* Set up the input pointers while copying the mail file into /tmp.
|
||||
*/
|
||||
void
|
||||
setptr(ibuf)
|
||||
register FILE *ibuf;
|
||||
FILE *ibuf;
|
||||
{
|
||||
register int c, count;
|
||||
register char *cp, *cp2;
|
||||
int c, count;
|
||||
char *cp, *cp2;
|
||||
struct message this;
|
||||
FILE *mestmp;
|
||||
off_t offset;
|
||||
@ -75,7 +77,7 @@ setptr(ibuf)
|
||||
(void)snprintf(pathbuf, sizeof(pathbuf), "%s/mail.XXXXXXXXXX", tmpdir);
|
||||
if ((c = mkstemp(pathbuf)) == -1 || (mestmp = Fdopen(c, "r+")) == NULL)
|
||||
err(1, "can't open %s", pathbuf);
|
||||
(void) rm(pathbuf);
|
||||
(void)rm(pathbuf);
|
||||
|
||||
msgCount = 0;
|
||||
maybe = 1;
|
||||
@ -104,7 +106,7 @@ setptr(ibuf)
|
||||
linebuf[count - 1] = '\n';
|
||||
}
|
||||
|
||||
(void) fwrite(linebuf, sizeof *linebuf, count, otf);
|
||||
(void)fwrite(linebuf, sizeof(*linebuf), count, otf);
|
||||
if (ferror(otf))
|
||||
errx(1, "/tmp");
|
||||
if (count)
|
||||
@ -123,12 +125,12 @@ setptr(ibuf)
|
||||
inhead = 0;
|
||||
} else if (inhead) {
|
||||
for (cp = linebuf, cp2 = "status";; cp++) {
|
||||
if ((c = *cp2++) == 0) {
|
||||
if ((c = *cp2++) == '\0') {
|
||||
while (isspace(*cp++))
|
||||
;
|
||||
if (cp[-1] != ':')
|
||||
break;
|
||||
while (c = *cp++)
|
||||
while ((c = *cp++) != '\0')
|
||||
if (c == 'R')
|
||||
this.m_flag |= MREAD;
|
||||
else if (c == 'O')
|
||||
@ -157,11 +159,11 @@ putline(obuf, linebuf)
|
||||
FILE *obuf;
|
||||
char *linebuf;
|
||||
{
|
||||
register int c;
|
||||
int c;
|
||||
|
||||
c = strlen(linebuf);
|
||||
(void) fwrite(linebuf, sizeof *linebuf, c, obuf);
|
||||
(void) putc('\n', obuf);
|
||||
(void)fwrite(linebuf, sizeof(*linebuf), c, obuf);
|
||||
fprintf(obuf, "\n");
|
||||
if (ferror(obuf))
|
||||
return (-1);
|
||||
return (c + 1);
|
||||
@ -178,17 +180,17 @@ readline(ibuf, linebuf, linesize)
|
||||
char *linebuf;
|
||||
int linesize;
|
||||
{
|
||||
register int n;
|
||||
int n;
|
||||
|
||||
clearerr(ibuf);
|
||||
if (fgets(linebuf, linesize, ibuf) == NULL)
|
||||
return -1;
|
||||
return (-1);
|
||||
n = strlen(linebuf);
|
||||
if (n > 0 && linebuf[n - 1] == '\n')
|
||||
linebuf[--n] = '\0';
|
||||
if (n > 0 && linebuf[n - 1] == '\r')
|
||||
linebuf[--n] = '\0';
|
||||
return n;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -197,10 +199,10 @@ readline(ibuf, linebuf, linesize)
|
||||
*/
|
||||
FILE *
|
||||
setinput(mp)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
{
|
||||
|
||||
fflush(otf);
|
||||
(void)fflush(otf);
|
||||
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), 0) < 0)
|
||||
err(1, "fseek");
|
||||
return (itf);
|
||||
@ -214,21 +216,21 @@ void
|
||||
makemessage(f)
|
||||
FILE *f;
|
||||
{
|
||||
register size = (msgCount + 1) * sizeof (struct message);
|
||||
int size = (msgCount + 1) * sizeof(struct message);
|
||||
|
||||
if (message != 0)
|
||||
free((char *) message);
|
||||
if ((message = (struct message *) malloc((unsigned) size)) == 0)
|
||||
(void)free(message);
|
||||
if ((message = malloc((unsigned)size)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
dot = message;
|
||||
size -= sizeof (struct message);
|
||||
fflush(f);
|
||||
(void) lseek(fileno(f), (off_t)sizeof *message, 0);
|
||||
if (read(fileno(f), (char *) message, size) != size)
|
||||
size -= sizeof(struct message);
|
||||
(void)fflush(f);
|
||||
(void)lseek(fileno(f), (off_t)sizeof(*message), 0);
|
||||
if (read(fileno(f), (char *)message, size) != size)
|
||||
errx(1, "Message temporary file corrupted");
|
||||
message[msgCount].m_size = 0;
|
||||
message[msgCount].m_lines = 0;
|
||||
Fclose(f);
|
||||
(void)Fclose(f);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -240,7 +242,7 @@ append(mp, f)
|
||||
struct message *mp;
|
||||
FILE *f;
|
||||
{
|
||||
return fwrite((char *) mp, sizeof *mp, 1, f) != 1;
|
||||
return (fwrite((char *)mp, sizeof(*mp), 1, f) != 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -253,12 +255,12 @@ rm(name)
|
||||
struct stat sb;
|
||||
|
||||
if (stat(name, &sb) < 0)
|
||||
return(-1);
|
||||
return (-1);
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
errno = EISDIR;
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
return(unlink(name));
|
||||
return (unlink(name));
|
||||
}
|
||||
|
||||
static int sigdepth; /* depth of holdsigs() */
|
||||
@ -282,7 +284,7 @@ relsesigs()
|
||||
{
|
||||
|
||||
if (--sigdepth == 0)
|
||||
sigsetmask(omask);
|
||||
(void)sigsetmask(omask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -296,8 +298,8 @@ fsize(iob)
|
||||
struct stat sbuf;
|
||||
|
||||
if (fstat(fileno(iob), &sbuf) < 0)
|
||||
return 0;
|
||||
return sbuf.st_size;
|
||||
return (0);
|
||||
return (sbuf.st_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -313,15 +315,14 @@ fsize(iob)
|
||||
*/
|
||||
char *
|
||||
expand(name)
|
||||
register char *name;
|
||||
char *name;
|
||||
{
|
||||
char xname[PATHSIZE];
|
||||
char cmdbuf[PATHSIZE]; /* also used for file names */
|
||||
register int pid, l;
|
||||
register char *cp, *shell;
|
||||
int pid, l;
|
||||
char *cp, *sh;
|
||||
int pivec[2];
|
||||
struct stat sbuf;
|
||||
extern int wait_status;
|
||||
|
||||
/*
|
||||
* The order of evaluation is "%" and "#" expand into constants.
|
||||
@ -332,63 +333,64 @@ expand(name)
|
||||
switch (*name) {
|
||||
case '%':
|
||||
findmail(name[1] ? name + 1 : myname, xname, sizeof(xname));
|
||||
return savestr(xname);
|
||||
return (savestr(xname));
|
||||
case '#':
|
||||
if (name[1] != 0)
|
||||
break;
|
||||
if (prevfile[0] == 0) {
|
||||
printf("No previous file\n");
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
return savestr(prevfile);
|
||||
return (savestr(prevfile));
|
||||
case '&':
|
||||
if (name[1] == 0 && (name = value("MBOX")) == NOSTR)
|
||||
if (name[1] == 0 && (name = value("MBOX")) == NULL)
|
||||
name = "~/mbox";
|
||||
/* fall through */
|
||||
}
|
||||
if (name[0] == '+' && getfold(cmdbuf, sizeof(cmdbuf)) >= 0) {
|
||||
snprintf(xname, sizeof(xname), "%s/%s", cmdbuf, name + 1);
|
||||
(void)snprintf(xname, sizeof(xname), "%s/%s", cmdbuf, name + 1);
|
||||
name = savestr(xname);
|
||||
}
|
||||
/* catch the most common shell meta character */
|
||||
if (name[0] == '~' && homedir != NULL &&
|
||||
(name[1] == '/' || name[1] == '\0')) {
|
||||
snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1);
|
||||
(void)snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1);
|
||||
name = savestr(xname);
|
||||
}
|
||||
if (!strpbrk(name, "~{[*?$`'\"\\"))
|
||||
return name;
|
||||
return (name);
|
||||
if (pipe(pivec) < 0) {
|
||||
warn("pipe");
|
||||
return name;
|
||||
return (name);
|
||||
}
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NOSTR);
|
||||
(void)snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
|
||||
if ((sh = value("SHELL")) == NULL)
|
||||
sh = _PATH_CSHELL;
|
||||
pid = start_command(sh, 0, -1, pivec[1], "-c", cmdbuf, NULL);
|
||||
if (pid < 0) {
|
||||
close(pivec[0]);
|
||||
close(pivec[1]);
|
||||
return NOSTR;
|
||||
(void)close(pivec[0]);
|
||||
(void)close(pivec[1]);
|
||||
return (NULL);
|
||||
}
|
||||
close(pivec[1]);
|
||||
(void)close(pivec[1]);
|
||||
l = read(pivec[0], xname, BUFSIZ);
|
||||
close(pivec[0]);
|
||||
if (wait_child(pid) < 0 && WIFSIGNALED(wait_status) && WTERMSIG(wait_status) != SIGPIPE) {
|
||||
(void)close(pivec[0]);
|
||||
if (wait_child(pid) < 0 && WIFSIGNALED(wait_status) &&
|
||||
WTERMSIG(wait_status) != SIGPIPE) {
|
||||
fprintf(stderr, "\"%s\": Expansion failed.\n", name);
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
if (l < 0) {
|
||||
warn("read");
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
if (l == 0) {
|
||||
fprintf(stderr, "\"%s\": No match.\n", name);
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
if (l == BUFSIZ) {
|
||||
fprintf(stderr, "\"%s\": Expansion buffer overflow.\n", name);
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
xname[l] = '\0';
|
||||
for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
|
||||
@ -396,9 +398,9 @@ expand(name)
|
||||
cp[1] = '\0';
|
||||
if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) {
|
||||
fprintf(stderr, "\"%s\": Ambiguous.\n", name);
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
return savestr(xname);
|
||||
return (savestr(xname));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -412,13 +414,14 @@ getfold(name, namelen)
|
||||
char *folder;
|
||||
int copylen;
|
||||
|
||||
if ((folder = value("folder")) == NOSTR)
|
||||
if ((folder = value("folder")) == NULL)
|
||||
return (-1);
|
||||
if (*folder == '/')
|
||||
copylen = strlcpy(name, folder, namelen);
|
||||
else
|
||||
copylen = snprintf(name, namelen, "%s/%s", homedir ? homedir : ".", folder);
|
||||
return copylen >= namelen ? (-1) : (0);
|
||||
copylen = snprintf(name, namelen, "%s/%s",
|
||||
homedir ? homedir : ".", folder);
|
||||
return (copylen >= namelen ? (-1) : (0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -427,15 +430,15 @@ getfold(name, namelen)
|
||||
char *
|
||||
getdeadletter()
|
||||
{
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
if ((cp = value("DEAD")) == NOSTR || (cp = expand(cp)) == NOSTR)
|
||||
if ((cp = value("DEAD")) == NULL || (cp = expand(cp)) == NULL)
|
||||
cp = expand("~/dead.letter");
|
||||
else if (*cp != '/') {
|
||||
char buf[PATHSIZE];
|
||||
|
||||
(void) snprintf(buf, sizeof(buf), "~/%s", cp);
|
||||
(void)snprintf(buf, sizeof(buf), "~/%s", cp);
|
||||
cp = expand(buf);
|
||||
}
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ static const char rcsid[] =
|
||||
/* Getname / getuserid for those with hashed passwd data base). */
|
||||
|
||||
/*
|
||||
* Search the passwd file for a uid. Return name on success,
|
||||
* NOSTR on failure
|
||||
* Search the passwd file for a uid. Return name on success, NULL on failure.
|
||||
*/
|
||||
char *
|
||||
getname(uid)
|
||||
@ -56,8 +55,8 @@ getname(uid)
|
||||
struct passwd *pw;
|
||||
|
||||
if ((pw = getpwuid(uid)) == NULL)
|
||||
return NOSTR;
|
||||
return pw->pw_name;
|
||||
return (NULL);
|
||||
return (pw->pw_name);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -71,6 +70,6 @@ getuserid(name)
|
||||
struct passwd *pw;
|
||||
|
||||
if ((pw = getpwnam(name)) == NULL)
|
||||
return -1;
|
||||
return pw->pw_uid;
|
||||
return (-1);
|
||||
return (pw->pw_uid);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ ishead(linebuf)
|
||||
if (strncmp(linebuf, "From ", 5))
|
||||
return (0);
|
||||
parse(linebuf, &hl, parbuf);
|
||||
if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
|
||||
if (hl.l_from == NULL || hl.l_date == NULL) {
|
||||
fail(linebuf, "No from or date field");
|
||||
return (0);
|
||||
}
|
||||
@ -80,11 +80,11 @@ ishead(linebuf)
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
fail(linebuf, reason)
|
||||
char linebuf[], reason[];
|
||||
const char *linebuf, *reason;
|
||||
{
|
||||
|
||||
/*
|
||||
if (value("debug") == NOSTR)
|
||||
if (value("debug") == NULL)
|
||||
return;
|
||||
fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
|
||||
*/
|
||||
@ -99,15 +99,14 @@ fail(linebuf, reason)
|
||||
void
|
||||
parse(line, hl, pbuf)
|
||||
char line[], pbuf[];
|
||||
register struct headline *hl;
|
||||
struct headline *hl;
|
||||
{
|
||||
register char *cp;
|
||||
char *sp;
|
||||
char *cp, *sp;
|
||||
char word[LINESIZE];
|
||||
|
||||
hl->l_from = NOSTR;
|
||||
hl->l_tty = NOSTR;
|
||||
hl->l_date = NOSTR;
|
||||
hl->l_from = NULL;
|
||||
hl->l_tty = NULL;
|
||||
hl->l_date = NULL;
|
||||
cp = line;
|
||||
sp = pbuf;
|
||||
/*
|
||||
@ -115,13 +114,13 @@ parse(line, hl, pbuf)
|
||||
*/
|
||||
cp = nextword(cp, word);
|
||||
cp = nextword(cp, word);
|
||||
if (*word)
|
||||
if (*word != '\0')
|
||||
hl->l_from = copyin(word, &sp);
|
||||
if (cp != NOSTR && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
|
||||
if (cp != NULL && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
|
||||
cp = nextword(cp, word);
|
||||
hl->l_tty = copyin(word, &sp);
|
||||
}
|
||||
if (cp != NOSTR)
|
||||
if (cp != NULL)
|
||||
hl->l_date = copyin(cp, &sp);
|
||||
}
|
||||
|
||||
@ -133,14 +132,13 @@ parse(line, hl, pbuf)
|
||||
*/
|
||||
char *
|
||||
copyin(src, space)
|
||||
register char *src;
|
||||
char *src;
|
||||
char **space;
|
||||
{
|
||||
register char *cp;
|
||||
char *top;
|
||||
char *cp, *top;
|
||||
|
||||
top = cp = *space;
|
||||
while (*cp++ = *src++)
|
||||
while ((*cp++ = *src++) != '\0')
|
||||
;
|
||||
*space = cp;
|
||||
return (top);
|
||||
@ -171,7 +169,7 @@ isdate(date)
|
||||
char date[];
|
||||
{
|
||||
|
||||
return cmatch(date, ctype) || cmatch(date, tmztype);
|
||||
return (cmatch(date, ctype) || cmatch(date, tmztype));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -180,65 +178,65 @@ isdate(date)
|
||||
*/
|
||||
int
|
||||
cmatch(cp, tp)
|
||||
register char *cp, *tp;
|
||||
char *cp, *tp;
|
||||
{
|
||||
|
||||
while (*cp && *tp)
|
||||
while (*cp != '\0' && *tp != '\0')
|
||||
switch (*tp++) {
|
||||
case 'a':
|
||||
if (!islower(*cp++))
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
case 'A':
|
||||
if (!isupper(*cp++))
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
case ' ':
|
||||
if (*cp++ != ' ')
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
case '0':
|
||||
if (!isdigit(*cp++))
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
case 'O':
|
||||
if (*cp != ' ' && !isdigit(*cp))
|
||||
return 0;
|
||||
return (0);
|
||||
cp++;
|
||||
break;
|
||||
case ':':
|
||||
if (*cp++ != ':')
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
case 'N':
|
||||
if (*cp++ != '\n')
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
if (*cp || *tp)
|
||||
return 0;
|
||||
if (*cp != '\0' || *tp != '\0')
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Collect a liberal (space, tab delimited) word into the word buffer
|
||||
* passed. Also, return a pointer to the next word following that,
|
||||
* or NOSTR if none follow.
|
||||
* or NULL if none follow.
|
||||
*/
|
||||
char *
|
||||
nextword(wp, wbuf)
|
||||
register char *wp, *wbuf;
|
||||
char *wp, *wbuf;
|
||||
{
|
||||
register c;
|
||||
int c;
|
||||
|
||||
if (wp == NOSTR) {
|
||||
*wbuf = 0;
|
||||
return (NOSTR);
|
||||
if (wp == NULL) {
|
||||
*wbuf = '\0';
|
||||
return (NULL);
|
||||
}
|
||||
while ((c = *wp++) && c != ' ' && c != '\t') {
|
||||
while ((c = *wp++) != '\0' && c != ' ' && c != '\t') {
|
||||
*wbuf++ = c;
|
||||
if (c == '"') {
|
||||
while ((c = *wp++) && c != '"')
|
||||
while ((c = *wp++) != '\0' && c != '"')
|
||||
*wbuf++ = c;
|
||||
if (c == '"')
|
||||
*wbuf++ = c;
|
||||
@ -249,7 +247,7 @@ nextword(wp, wbuf)
|
||||
*wbuf = '\0';
|
||||
for (; c == ' ' || c == '\t'; c = *wp++)
|
||||
;
|
||||
if (c == 0)
|
||||
return (NOSTR);
|
||||
if (c == '\0')
|
||||
return (NULL);
|
||||
return (wp - 1);
|
||||
}
|
||||
|
@ -52,7 +52,10 @@ static const char rcsid[] =
|
||||
* Lexical processing of commands.
|
||||
*/
|
||||
|
||||
char *prompt = "& ";
|
||||
const char *prompt = "& ";
|
||||
|
||||
extern const struct cmd cmdtab[];
|
||||
extern const char *version;
|
||||
|
||||
/*
|
||||
* Set up editing on the given file name.
|
||||
@ -72,24 +75,24 @@ setfile(name)
|
||||
char tempname[PATHSIZE];
|
||||
static int shudclob;
|
||||
|
||||
if ((name = expand(name)) == NOSTR)
|
||||
return -1;
|
||||
if ((name = expand(name)) == NULL)
|
||||
return (-1);
|
||||
|
||||
if ((ibuf = Fopen(name, "r")) == NULL) {
|
||||
if (!isedit && errno == ENOENT)
|
||||
goto nomail;
|
||||
warn("%s", name);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (fstat(fileno(ibuf), &stb) < 0) {
|
||||
warn("fstat");
|
||||
Fclose(ibuf);
|
||||
(void)Fclose(ibuf);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (S_ISDIR(stb.st_mode) || !S_ISREG(stb.st_mode)) {
|
||||
Fclose(ibuf);
|
||||
(void)Fclose(ibuf);
|
||||
errno = S_ISDIR(stb.st_mode) ? EISDIR : EINVAL;
|
||||
warn("%s", name);
|
||||
return (-1);
|
||||
@ -115,10 +118,10 @@ setfile(name)
|
||||
if ((i = open(name, 1)) < 0)
|
||||
readonly++;
|
||||
else
|
||||
close(i);
|
||||
(void)close(i);
|
||||
if (shudclob) {
|
||||
fclose(itf);
|
||||
fclose(otf);
|
||||
(void)fclose(itf);
|
||||
(void)fclose(otf);
|
||||
}
|
||||
shudclob = 1;
|
||||
edit = isedit;
|
||||
@ -126,25 +129,26 @@ setfile(name)
|
||||
if (name != mailname)
|
||||
strlcpy(mailname, name, sizeof(mailname));
|
||||
mailsize = fsize(ibuf);
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RxXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.RxXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 || (otf = fdopen(fd, "w")) == NULL)
|
||||
err(1, "%s", tempname);
|
||||
(void) fcntl(fileno(otf), F_SETFD, 1);
|
||||
(void)fcntl(fileno(otf), F_SETFD, 1);
|
||||
if ((itf = fopen(tempname, "r")) == NULL)
|
||||
err(1, "%s", tempname);
|
||||
(void) fcntl(fileno(itf), F_SETFD, 1);
|
||||
rm(tempname);
|
||||
(void)fcntl(fileno(itf), F_SETFD, 1);
|
||||
(void)rm(tempname);
|
||||
setptr(ibuf);
|
||||
setmsize(msgCount);
|
||||
Fclose(ibuf);
|
||||
(void)Fclose(ibuf);
|
||||
relsesigs();
|
||||
sawcom = 0;
|
||||
if (!edit && msgCount == 0) {
|
||||
nomail:
|
||||
fprintf(stderr, "No mail for %s\n", who);
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int *msgvec;
|
||||
@ -157,19 +161,17 @@ int reset_on_stop; /* do a reset() if stopped */
|
||||
void
|
||||
commands()
|
||||
{
|
||||
int eofloop = 0;
|
||||
register int n;
|
||||
int n, eofloop = 0;
|
||||
char linebuf[LINESIZE];
|
||||
void intr(), stop(), hangup();
|
||||
|
||||
if (!sourcing) {
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGINT, intr);
|
||||
(void)signal(SIGINT, intr);
|
||||
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGHUP, hangup);
|
||||
signal(SIGTSTP, stop);
|
||||
signal(SIGTTOU, stop);
|
||||
signal(SIGTTIN, stop);
|
||||
(void)signal(SIGHUP, hangup);
|
||||
(void)signal(SIGTSTP, stop);
|
||||
(void)signal(SIGTTOU, stop);
|
||||
(void)signal(SIGTTIN, stop);
|
||||
}
|
||||
setexit();
|
||||
for (;;) {
|
||||
@ -177,11 +179,11 @@ commands()
|
||||
* Print the prompt, if needed. Clear out
|
||||
* string space, and flush the output.
|
||||
*/
|
||||
if (!sourcing && value("interactive") != NOSTR) {
|
||||
if (!sourcing && value("interactive") != NULL) {
|
||||
reset_on_stop = 1;
|
||||
printf("%s", prompt);
|
||||
}
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
sreset();
|
||||
/*
|
||||
* Read a line of commands from the current input
|
||||
@ -210,8 +212,8 @@ commands()
|
||||
unstack();
|
||||
continue;
|
||||
}
|
||||
if (value("interactive") != NOSTR &&
|
||||
value("ignoreeof") != NOSTR &&
|
||||
if (value("interactive") != NULL &&
|
||||
value("ignoreeof") != NULL &&
|
||||
++eofloop < 25) {
|
||||
printf("Use \"quit\" to quit.\n");
|
||||
continue;
|
||||
@ -238,10 +240,9 @@ execute(linebuf, contxt)
|
||||
{
|
||||
char word[LINESIZE];
|
||||
char *arglist[MAXARGC];
|
||||
struct cmd *com;
|
||||
register char *cp, *cp2;
|
||||
register int c;
|
||||
int muvec[2];
|
||||
const struct cmd *com;
|
||||
char *cp, *cp2;
|
||||
int c, muvec[2];
|
||||
int e = 1;
|
||||
|
||||
/*
|
||||
@ -261,10 +262,10 @@ execute(linebuf, contxt)
|
||||
goto out;
|
||||
}
|
||||
shell(cp+1);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
cp2 = word;
|
||||
while (*cp && strchr(" \t0123456789$^.:/-+*'\"", *cp) == NOSTR)
|
||||
while (*cp != '\0' && strchr(" \t0123456789$^.:/-+*'\"", *cp) == NULL)
|
||||
*cp2++ = *cp++;
|
||||
*cp2 = '\0';
|
||||
|
||||
@ -277,9 +278,9 @@ execute(linebuf, contxt)
|
||||
*/
|
||||
|
||||
if (sourcing && *word == '\0')
|
||||
return(0);
|
||||
return (0);
|
||||
com = lex(word);
|
||||
if (com == NONE) {
|
||||
if (com == NULL) {
|
||||
printf("Unknown command: \"%s\"\n", word);
|
||||
goto out;
|
||||
}
|
||||
@ -290,8 +291,8 @@ execute(linebuf, contxt)
|
||||
*/
|
||||
|
||||
if ((com->c_argtype & F) == 0)
|
||||
if (cond == CRCV && !rcvmode || cond == CSEND && rcvmode)
|
||||
return(0);
|
||||
if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode))
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Process the arguments to the command, depending
|
||||
@ -332,8 +333,7 @@ execute(linebuf, contxt)
|
||||
if ((c = getmsglist(cp, msgvec, com->c_msgflag)) < 0)
|
||||
break;
|
||||
if (c == 0) {
|
||||
*msgvec = first(com->c_msgflag,
|
||||
com->c_msgmask);
|
||||
*msgvec = first(com->c_msgflag, com->c_msgmask);
|
||||
msgvec[1] = 0;
|
||||
}
|
||||
if (*msgvec == 0) {
|
||||
@ -372,16 +372,16 @@ execute(linebuf, contxt)
|
||||
* A vector of strings, in shell style.
|
||||
*/
|
||||
if ((c = getrawlist(cp, arglist,
|
||||
sizeof arglist / sizeof *arglist)) < 0)
|
||||
sizeof(arglist) / sizeof(*arglist))) < 0)
|
||||
break;
|
||||
if (c < com->c_minargs) {
|
||||
printf("%s requires at least %d arg(s)\n",
|
||||
com->c_name, com->c_minargs);
|
||||
com->c_name, com->c_minargs);
|
||||
break;
|
||||
}
|
||||
if (c > com->c_maxargs) {
|
||||
printf("%s takes no more than %d arg(s)\n",
|
||||
com->c_name, com->c_maxargs);
|
||||
com->c_name, com->c_maxargs);
|
||||
break;
|
||||
}
|
||||
e = (*com->c_func)(arglist);
|
||||
@ -406,14 +406,14 @@ execute(linebuf, contxt)
|
||||
*/
|
||||
if (e) {
|
||||
if (e < 0)
|
||||
return 1;
|
||||
return (1);
|
||||
if (loading)
|
||||
return 1;
|
||||
return (1);
|
||||
if (sourcing)
|
||||
unstack();
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
if (value("autoprint") != NOSTR && com->c_argtype & P)
|
||||
if (value("autoprint") != NULL && com->c_argtype & P)
|
||||
if ((dot->m_flag & MDELETED) == 0) {
|
||||
muvec[0] = dot - &message[0] + 1;
|
||||
muvec[1] = 0;
|
||||
@ -421,7 +421,7 @@ execute(linebuf, contxt)
|
||||
}
|
||||
if (!sourcing && (com->c_argtype & T) == 0)
|
||||
sawcom = 1;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -434,8 +434,8 @@ setmsize(sz)
|
||||
{
|
||||
|
||||
if (msgvec != 0)
|
||||
free((char *) msgvec);
|
||||
msgvec = (int *) calloc((unsigned) (sz + 1), sizeof *msgvec);
|
||||
(void)free(msgvec);
|
||||
msgvec = calloc((unsigned)(sz + 1), sizeof(*msgvec));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -443,15 +443,14 @@ setmsize(sz)
|
||||
* to the passed command "word"
|
||||
*/
|
||||
|
||||
struct cmd *
|
||||
__const struct cmd *
|
||||
lex(word)
|
||||
char word[];
|
||||
{
|
||||
register struct cmd *cp;
|
||||
extern struct cmd cmdtab[];
|
||||
const struct cmd *cp;
|
||||
|
||||
/*
|
||||
* ignore trailing chars after `#'
|
||||
* ignore trailing chars after `#'
|
||||
*
|
||||
* lines with beginning `#' are comments
|
||||
* spaces before `#' are ignored in execute()
|
||||
@ -461,10 +460,10 @@ lex(word)
|
||||
*(word+1) = '\0';
|
||||
|
||||
|
||||
for (cp = &cmdtab[0]; cp->c_name != NOSTR; cp++)
|
||||
for (cp = &cmdtab[0]; cp->c_name != NULL; cp++)
|
||||
if (isprefix(word, cp->c_name))
|
||||
return(cp);
|
||||
return(NONE);
|
||||
return (cp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -473,16 +472,16 @@ lex(word)
|
||||
*/
|
||||
int
|
||||
isprefix(as1, as2)
|
||||
char *as1, *as2;
|
||||
const char *as1, *as2;
|
||||
{
|
||||
register char *s1, *s2;
|
||||
const char *s1, *s2;
|
||||
|
||||
s1 = as1;
|
||||
s2 = as2;
|
||||
while (*s1++ == *s2)
|
||||
if (*s2++ == '\0')
|
||||
return(1);
|
||||
return(*--s1 == '\0');
|
||||
return (1);
|
||||
return (*--s1 == '\0');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -511,7 +510,7 @@ intr(s)
|
||||
close_all_files();
|
||||
|
||||
if (image >= 0) {
|
||||
close(image);
|
||||
(void)close(image);
|
||||
image = -1;
|
||||
}
|
||||
fprintf(stderr, "Interrupt\n");
|
||||
@ -527,10 +526,10 @@ stop(s)
|
||||
{
|
||||
sig_t old_action = signal(s, SIG_DFL);
|
||||
|
||||
sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
kill(0, s);
|
||||
sigblock(sigmask(s));
|
||||
signal(s, old_action);
|
||||
(void)sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
(void)kill(0, s);
|
||||
(void)sigblock(sigmask(s));
|
||||
(void)signal(s, old_action);
|
||||
if (reset_on_stop) {
|
||||
reset_on_stop = 0;
|
||||
reset(0);
|
||||
@ -563,7 +562,7 @@ announce()
|
||||
vec[0] = mdot;
|
||||
vec[1] = 0;
|
||||
dot = &message[mdot - 1];
|
||||
if (msgCount > 0 && value("noheader") == NOSTR) {
|
||||
if (msgCount > 0 && value("noheader") == NULL) {
|
||||
inithdr++;
|
||||
headers(vec);
|
||||
inithdr = 0;
|
||||
@ -577,8 +576,8 @@ announce()
|
||||
int
|
||||
newfileinfo()
|
||||
{
|
||||
register struct message *mp;
|
||||
register int u, n, mdot, d, s;
|
||||
struct message *mp;
|
||||
int u, n, mdot, d, s;
|
||||
char fname[PATHSIZE+1], zname[PATHSIZE+1], *ename;
|
||||
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
@ -607,7 +606,8 @@ newfileinfo()
|
||||
if (getfold(fname, sizeof(fname) - 1) >= 0) {
|
||||
strcat(fname, "/");
|
||||
if (strncmp(fname, mailname, strlen(fname)) == 0) {
|
||||
snprintf(zname, sizeof(zname), "+%s", mailname + strlen(fname));
|
||||
(void)snprintf(zname, sizeof(zname), "+%s",
|
||||
mailname + strlen(fname));
|
||||
ename = zname;
|
||||
}
|
||||
}
|
||||
@ -627,7 +627,7 @@ newfileinfo()
|
||||
if (readonly)
|
||||
printf(" [Read only]");
|
||||
printf("\n");
|
||||
return(mdot);
|
||||
return (mdot);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -639,10 +639,9 @@ int
|
||||
pversion(e)
|
||||
int e;
|
||||
{
|
||||
extern char *version;
|
||||
|
||||
printf("Version %s\n", version);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -652,7 +651,7 @@ void
|
||||
load(name)
|
||||
char *name;
|
||||
{
|
||||
register FILE *in, *oldin;
|
||||
FILE *in, *oldin;
|
||||
|
||||
if ((in = Fopen(name, "r")) == NULL)
|
||||
return;
|
||||
@ -664,5 +663,5 @@ load(name)
|
||||
loading = 0;
|
||||
sourcing = 0;
|
||||
input = oldin;
|
||||
Fclose(in);
|
||||
(void)Fclose(in);
|
||||
}
|
||||
|
@ -60,21 +60,21 @@ getmsglist(buf, vector, flags)
|
||||
char *buf;
|
||||
int *vector, flags;
|
||||
{
|
||||
register int *ip;
|
||||
register struct message *mp;
|
||||
int *ip;
|
||||
struct message *mp;
|
||||
|
||||
if (msgCount == 0) {
|
||||
*vector = 0;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
if (markall(buf, flags) < 0)
|
||||
return(-1);
|
||||
return (-1);
|
||||
ip = vector;
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if (mp->m_flag & MMARK)
|
||||
*ip++ = mp - &message[0] + 1;
|
||||
*ip = 0;
|
||||
return(ip - vector);
|
||||
return (ip - vector);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -104,12 +104,12 @@ struct coltab {
|
||||
int co_mask; /* m_status bits to mask */
|
||||
int co_equal; /* ... must equal this */
|
||||
} coltab[] = {
|
||||
'n', CMNEW, MNEW, MNEW,
|
||||
'o', CMOLD, MNEW, 0,
|
||||
'u', CMUNREAD, MREAD, 0,
|
||||
'd', CMDELETED, MDELETED, MDELETED,
|
||||
'r', CMREAD, MREAD, MREAD,
|
||||
0, 0, 0, 0
|
||||
{ 'n', CMNEW, MNEW, MNEW },
|
||||
{ 'o', CMOLD, MNEW, 0 },
|
||||
{ 'u', CMUNREAD, MREAD, 0 },
|
||||
{ 'd', CMDELETED, MDELETED, MDELETED},
|
||||
{ 'r', CMREAD, MREAD, MREAD },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
static int lastcolmod;
|
||||
@ -119,9 +119,9 @@ markall(buf, f)
|
||||
char buf[];
|
||||
int f;
|
||||
{
|
||||
register char **np;
|
||||
register int i;
|
||||
register struct message *mp;
|
||||
char **np;
|
||||
int i;
|
||||
struct message *mp;
|
||||
char *namelist[NMLSIZE], *bufp;
|
||||
int tok, beg, mc, star, other, valdot, colmod, colresult;
|
||||
|
||||
@ -143,13 +143,13 @@ markall(buf, f)
|
||||
number:
|
||||
if (star) {
|
||||
printf("No numbers mixed with *\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
mc++;
|
||||
other++;
|
||||
if (beg != 0) {
|
||||
if (check(lexnumber, f))
|
||||
return(-1);
|
||||
return (-1);
|
||||
for (i = beg; i <= lexnumber; i++)
|
||||
if (f == MDELETED || (message[i - 1].m_flag & MDELETED) == 0)
|
||||
mark(i);
|
||||
@ -158,7 +158,7 @@ markall(buf, f)
|
||||
}
|
||||
beg = lexnumber;
|
||||
if (check(beg, f))
|
||||
return(-1);
|
||||
return (-1);
|
||||
tok = scan(&bufp);
|
||||
regret(tok);
|
||||
if (tok != TDASH) {
|
||||
@ -170,14 +170,14 @@ markall(buf, f)
|
||||
case TPLUS:
|
||||
if (beg != 0) {
|
||||
printf("Non-numeric second argument\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
i = valdot;
|
||||
do {
|
||||
i++;
|
||||
if (i > msgCount) {
|
||||
printf("Referencing beyond EOF\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
} while ((message[i - 1].m_flag & MDELETED) != f);
|
||||
mark(i);
|
||||
@ -190,7 +190,7 @@ markall(buf, f)
|
||||
i--;
|
||||
if (i <= 0) {
|
||||
printf("Referencing before 1\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
} while ((message[i - 1].m_flag & MDELETED) != f);
|
||||
mark(i);
|
||||
@ -200,7 +200,7 @@ markall(buf, f)
|
||||
case TSTRING:
|
||||
if (beg != 0) {
|
||||
printf("Non-numeric second argument\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
other++;
|
||||
if (lexstring[0] == ':') {
|
||||
@ -208,7 +208,7 @@ markall(buf, f)
|
||||
if (colresult == 0) {
|
||||
printf("Unknown colon modifier \"%s\"\n",
|
||||
lexstring);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
colmod |= colresult;
|
||||
}
|
||||
@ -221,24 +221,24 @@ markall(buf, f)
|
||||
case TDOT:
|
||||
lexnumber = metamess(lexstring[0], f);
|
||||
if (lexnumber == -1)
|
||||
return(-1);
|
||||
return (-1);
|
||||
goto number;
|
||||
|
||||
case TSTAR:
|
||||
if (other) {
|
||||
printf("Can't mix \"*\" with anything\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
star++;
|
||||
break;
|
||||
|
||||
case TERROR:
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
tok = scan(&bufp);
|
||||
}
|
||||
lastcolmod = colmod;
|
||||
*np = NOSTR;
|
||||
*np = NULL;
|
||||
mc = 0;
|
||||
if (star) {
|
||||
for (i = 0; i < msgCount; i++)
|
||||
@ -248,9 +248,9 @@ markall(buf, f)
|
||||
}
|
||||
if (mc == 0) {
|
||||
printf("No applicable messages.\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -271,7 +271,7 @@ markall(buf, f)
|
||||
|
||||
if (np > namelist) {
|
||||
for (i = 1; i <= msgCount; i++) {
|
||||
for (mc = 0, np = &namelist[0]; *np != NOSTR; np++)
|
||||
for (mc = 0, np = &namelist[0]; *np != NULL; np++)
|
||||
if (**np == '/') {
|
||||
if (matchsubj(*np, i)) {
|
||||
mc++;
|
||||
@ -301,10 +301,10 @@ markall(buf, f)
|
||||
if (mc == 0) {
|
||||
printf("No applicable messages from {%s",
|
||||
namelist[0]);
|
||||
for (np = &namelist[1]; *np != NOSTR; np++)
|
||||
for (np = &namelist[1]; *np != NULL; np++)
|
||||
printf(", %s", *np);
|
||||
printf("}\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,10 +315,10 @@ markall(buf, f)
|
||||
|
||||
if (colmod != 0) {
|
||||
for (i = 1; i <= msgCount; i++) {
|
||||
register struct coltab *colp;
|
||||
struct coltab *colp;
|
||||
|
||||
mp = &message[i - 1];
|
||||
for (colp = &coltab[0]; colp->co_char; colp++)
|
||||
for (colp = &coltab[0]; colp->co_char != '\0'; colp++)
|
||||
if (colp->co_bit & colmod)
|
||||
if ((mp->m_flag & colp->co_mask)
|
||||
!= colp->co_equal)
|
||||
@ -329,17 +329,17 @@ markall(buf, f)
|
||||
if (mp->m_flag & MMARK)
|
||||
break;
|
||||
if (mp >= &message[msgCount]) {
|
||||
register struct coltab *colp;
|
||||
struct coltab *colp;
|
||||
|
||||
printf("No messages satisfy");
|
||||
for (colp = &coltab[0]; colp->co_char; colp++)
|
||||
for (colp = &coltab[0]; colp->co_char != '\0'; colp++)
|
||||
if (colp->co_bit & colmod)
|
||||
printf(" :%c", colp->co_char);
|
||||
printf("\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -350,14 +350,14 @@ int
|
||||
evalcol(col)
|
||||
int col;
|
||||
{
|
||||
register struct coltab *colp;
|
||||
struct coltab *colp;
|
||||
|
||||
if (col == 0)
|
||||
return(lastcolmod);
|
||||
for (colp = &coltab[0]; colp->co_char; colp++)
|
||||
return (lastcolmod);
|
||||
for (colp = &coltab[0]; colp->co_char != '\0'; colp++)
|
||||
if (colp->co_char == col)
|
||||
return(colp->co_bit);
|
||||
return(0);
|
||||
return (colp->co_bit);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -369,18 +369,18 @@ int
|
||||
check(mesg, f)
|
||||
int mesg, f;
|
||||
{
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
|
||||
if (mesg < 1 || mesg > msgCount) {
|
||||
printf("%d: Invalid message number\n", mesg);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
mp = &message[mesg-1];
|
||||
if (f != MDELETED && (mp->m_flag & MDELETED) != 0) {
|
||||
printf("%d: Inappropriate message\n", mesg);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -393,12 +393,12 @@ getrawlist(line, argv, argc)
|
||||
char **argv;
|
||||
int argc;
|
||||
{
|
||||
register char c, *cp, *cp2, quotec;
|
||||
char c, *cp, *cp2, quotec;
|
||||
int argn;
|
||||
char *linebuf;
|
||||
size_t linebufsize = BUFSIZ;
|
||||
|
||||
if ((linebuf = (char *)malloc(linebufsize)) == NULL)
|
||||
if ((linebuf = malloc(linebufsize)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
|
||||
argn = 0;
|
||||
@ -468,8 +468,8 @@ getrawlist(line, argv, argc)
|
||||
if (c == '?')
|
||||
*cp2++ = '\177';
|
||||
/* null doesn't show up anyway */
|
||||
else if (c >= 'A' && c <= '_' ||
|
||||
c >= 'a' && c <= 'z')
|
||||
else if ((c >= 'A' && c <= '_') ||
|
||||
(c >= 'a' && c <= 'z'))
|
||||
*cp2++ = c & 037;
|
||||
else {
|
||||
*cp2++ = '^';
|
||||
@ -487,9 +487,9 @@ getrawlist(line, argv, argc)
|
||||
*cp2 = '\0';
|
||||
argv[argn++] = savestr(linebuf);
|
||||
}
|
||||
argv[argn] = NOSTR;
|
||||
free(linebuf);
|
||||
return argn;
|
||||
argv[argn] = NULL;
|
||||
(void)free(linebuf);
|
||||
return (argn);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -503,30 +503,30 @@ struct lex {
|
||||
char l_char;
|
||||
char l_token;
|
||||
} singles[] = {
|
||||
'$', TDOLLAR,
|
||||
'.', TDOT,
|
||||
'^', TUP,
|
||||
'*', TSTAR,
|
||||
'-', TDASH,
|
||||
'+', TPLUS,
|
||||
'(', TOPEN,
|
||||
')', TCLOSE,
|
||||
0, 0
|
||||
{ '$', TDOLLAR },
|
||||
{ '.', TDOT },
|
||||
{ '^', TUP },
|
||||
{ '*', TSTAR },
|
||||
{ '-', TDASH },
|
||||
{ '+', TPLUS },
|
||||
{ '(', TOPEN },
|
||||
{ ')', TCLOSE },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
scan(sp)
|
||||
char **sp;
|
||||
{
|
||||
register char *cp, *cp2;
|
||||
register int c;
|
||||
register struct lex *lp;
|
||||
char *cp, *cp2;
|
||||
int c;
|
||||
struct lex *lp;
|
||||
int quotec;
|
||||
|
||||
if (regretp >= 0) {
|
||||
strcpy(lexstring, string_stack[regretp]);
|
||||
lexnumber = numberstack[regretp];
|
||||
return(regretstack[regretp--]);
|
||||
return (regretstack[regretp--]);
|
||||
}
|
||||
cp = *sp;
|
||||
cp2 = lexstring;
|
||||
@ -546,7 +546,7 @@ scan(sp)
|
||||
|
||||
if (c == '\0') {
|
||||
*sp = --cp;
|
||||
return(TEOL);
|
||||
return (TEOL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -564,7 +564,7 @@ scan(sp)
|
||||
}
|
||||
*cp2 = '\0';
|
||||
*sp = --cp;
|
||||
return(TNUMBER);
|
||||
return (TNUMBER);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -572,12 +572,12 @@ scan(sp)
|
||||
* if found.
|
||||
*/
|
||||
|
||||
for (lp = &singles[0]; lp->l_char != 0; lp++)
|
||||
for (lp = &singles[0]; lp->l_char != '\0'; lp++)
|
||||
if (c == lp->l_char) {
|
||||
lexstring[0] = c;
|
||||
lexstring[1] = '\0';
|
||||
*sp = cp;
|
||||
return(lp->l_token);
|
||||
return (lp->l_token);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -604,13 +604,13 @@ scan(sp)
|
||||
*cp2++ = c;
|
||||
c = *cp++;
|
||||
}
|
||||
if (quotec && c == 0) {
|
||||
if (quotec && c == '\0') {
|
||||
fprintf(stderr, "Missing %c\n", quotec);
|
||||
return TERROR;
|
||||
return (TERROR);
|
||||
}
|
||||
*sp = --cp;
|
||||
*cp2 = '\0';
|
||||
return(TSTRING);
|
||||
return (TSTRING);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -645,19 +645,19 @@ int
|
||||
first(f, m)
|
||||
int f, m;
|
||||
{
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
|
||||
if (msgCount == 0)
|
||||
return 0;
|
||||
return (0);
|
||||
f &= MDELETED;
|
||||
m &= MDELETED;
|
||||
for (mp = dot; mp < &message[msgCount]; mp++)
|
||||
if ((mp->m_flag & m) == f)
|
||||
return mp - message + 1;
|
||||
return (mp - message + 1);
|
||||
for (mp = dot-1; mp >= &message[0]; mp--)
|
||||
if ((mp->m_flag & m) == f)
|
||||
return mp - message + 1;
|
||||
return 0;
|
||||
return (mp - message + 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -669,21 +669,21 @@ matchsender(str, mesg)
|
||||
char *str;
|
||||
int mesg;
|
||||
{
|
||||
register char *cp, *cp2, *backup;
|
||||
char *cp, *cp2, *backup;
|
||||
|
||||
if (!*str) /* null string matches nothing instead of everything */
|
||||
return 0;
|
||||
if (*str == '\0') /* null string matches nothing instead of everything */
|
||||
return (0);
|
||||
backup = cp2 = nameof(&message[mesg - 1], 0);
|
||||
cp = str;
|
||||
while (*cp2) {
|
||||
if (*cp == 0)
|
||||
return(1);
|
||||
while (*cp2 != '\0') {
|
||||
if (*cp == '\0')
|
||||
return (1);
|
||||
if (toupper(*cp++) != toupper(*cp2++)) {
|
||||
cp2 = ++backup;
|
||||
cp = str;
|
||||
}
|
||||
}
|
||||
return(*cp == 0);
|
||||
return (*cp == '\0');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -700,8 +700,8 @@ matchsubj(str, mesg)
|
||||
char *str;
|
||||
int mesg;
|
||||
{
|
||||
register struct message *mp;
|
||||
register char *cp, *cp2, *backup;
|
||||
struct message *mp;
|
||||
char *cp, *cp2, *backup;
|
||||
|
||||
str++;
|
||||
if (*str == '\0')
|
||||
@ -714,7 +714,7 @@ matchsubj(str, mesg)
|
||||
* Now look, ignoring case, for the word in the string.
|
||||
*/
|
||||
|
||||
if (value("searchheaders") && (cp = strchr(str, ':'))) {
|
||||
if (value("searchheaders") && (cp = strchr(str, ':')) != NULL) {
|
||||
*cp++ = '\0';
|
||||
cp2 = hfield(str, mp);
|
||||
cp[-1] = ':';
|
||||
@ -723,18 +723,18 @@ matchsubj(str, mesg)
|
||||
cp = str;
|
||||
cp2 = hfield("subject", mp);
|
||||
}
|
||||
if (cp2 == NOSTR)
|
||||
return(0);
|
||||
if (cp2 == NULL)
|
||||
return (0);
|
||||
backup = cp2;
|
||||
while (*cp2) {
|
||||
if (*cp == 0)
|
||||
return(1);
|
||||
while (*cp2 != '\0') {
|
||||
if (*cp == '\0')
|
||||
return (1);
|
||||
if (toupper(*cp++) != toupper(*cp2++)) {
|
||||
cp2 = ++backup;
|
||||
cp = str;
|
||||
}
|
||||
}
|
||||
return(*cp == 0);
|
||||
return (*cp == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -744,7 +744,7 @@ void
|
||||
mark(mesg)
|
||||
int mesg;
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
i = mesg;
|
||||
if (i < 1 || i > msgCount)
|
||||
@ -759,7 +759,7 @@ void
|
||||
unmark(mesg)
|
||||
int mesg;
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
i = mesg;
|
||||
if (i < 1 || i > msgCount)
|
||||
@ -774,8 +774,8 @@ int
|
||||
metamess(meta, f)
|
||||
int meta, f;
|
||||
{
|
||||
register int c, m;
|
||||
register struct message *mp;
|
||||
int c, m;
|
||||
struct message *mp;
|
||||
|
||||
c = meta;
|
||||
switch (c) {
|
||||
@ -785,9 +785,9 @@ metamess(meta, f)
|
||||
*/
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if ((mp->m_flag & MDELETED) == f)
|
||||
return(mp - &message[0] + 1);
|
||||
return (mp - &message[0] + 1);
|
||||
printf("No applicable messages\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
|
||||
case '$':
|
||||
/*
|
||||
@ -795,9 +795,9 @@ metamess(meta, f)
|
||||
*/
|
||||
for (mp = &message[msgCount-1]; mp >= &message[0]; mp--)
|
||||
if ((mp->m_flag & MDELETED) == f)
|
||||
return(mp - &message[0] + 1);
|
||||
return (mp - &message[0] + 1);
|
||||
printf("No applicable messages\n");
|
||||
return(-1);
|
||||
return (-1);
|
||||
|
||||
case '.':
|
||||
/*
|
||||
@ -806,12 +806,12 @@ metamess(meta, f)
|
||||
m = dot - &message[0] + 1;
|
||||
if ((dot->m_flag & MDELETED) != f) {
|
||||
printf("%d: Inappropriate message\n", m);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
return(m);
|
||||
return (m);
|
||||
|
||||
default:
|
||||
printf("Unknown metachar (%c)\n", c);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
@ -57,26 +57,26 @@ static const char rcsid[] =
|
||||
|
||||
jmp_buf hdrjmp;
|
||||
|
||||
extern const char *version;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
struct name *to, *cc, *bcc, *smopts;
|
||||
char *subject, *replyto;
|
||||
char *ef, *cp;
|
||||
char nosrc = 0;
|
||||
void hdrstop();
|
||||
sig_t prevint;
|
||||
void sigchild();
|
||||
|
||||
/*
|
||||
* Set up a reasonable environment.
|
||||
* Figure out whether we are being run interactively,
|
||||
* start the SIGCHLD catcher, and so forth.
|
||||
*/
|
||||
(void) signal(SIGCHLD, sigchild);
|
||||
(void)signal(SIGCHLD, sigchild);
|
||||
if (isatty(0))
|
||||
assign("interactive", "");
|
||||
image = -1;
|
||||
@ -87,13 +87,13 @@ main(argc, argv)
|
||||
* of users to mail to. Argp will be set to point to the
|
||||
* first of these users.
|
||||
*/
|
||||
ef = NOSTR;
|
||||
to = NIL;
|
||||
cc = NIL;
|
||||
bcc = NIL;
|
||||
smopts = NIL;
|
||||
subject = NOSTR;
|
||||
replyto = NOSTR;
|
||||
ef = NULL;
|
||||
to = NULL;
|
||||
cc = NULL;
|
||||
bcc = NULL;
|
||||
smopts = NULL;
|
||||
subject = NULL;
|
||||
replyto = NULL;
|
||||
while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) {
|
||||
switch (i) {
|
||||
case 'T':
|
||||
@ -103,16 +103,16 @@ main(argc, argv)
|
||||
*/
|
||||
Tflag = optarg;
|
||||
if ((i = open(Tflag, O_CREAT | O_TRUNC | O_WRONLY,
|
||||
0600)) < 0)
|
||||
0600)) < 0)
|
||||
err(1, "%s", Tflag);
|
||||
close(i);
|
||||
(void)close(i);
|
||||
break;
|
||||
case 'u':
|
||||
/*
|
||||
* Next argument is person to pretend to be.
|
||||
*/
|
||||
myname = optarg;
|
||||
unsetenv("MAIL");
|
||||
unsetenv("MAIL");
|
||||
break;
|
||||
case 'i':
|
||||
/*
|
||||
@ -141,7 +141,7 @@ main(argc, argv)
|
||||
* getopt() can't handle optional arguments, so here
|
||||
* is an ugly hack to get around it.
|
||||
*/
|
||||
if ((argv[optind]) && (argv[optind][0] != '-'))
|
||||
if ((argv[optind] != NULL) && (argv[optind][0] != '-'))
|
||||
ef = argv[optind++];
|
||||
else
|
||||
ef = "&";
|
||||
@ -192,16 +192,16 @@ Usage: %s [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
for (i = optind; (argv[i]) && (*argv[i] != '-'); i++)
|
||||
for (i = optind; (argv[i] != NULL) && (*argv[i] != '-'); i++)
|
||||
to = cat(to, nalloc(argv[i], GTO));
|
||||
for (; argv[i]; i++)
|
||||
for (; argv[i] != NULL; i++)
|
||||
smopts = cat(smopts, nalloc(argv[i], 0));
|
||||
/*
|
||||
* Check for inconsistent arguments.
|
||||
*/
|
||||
if (to == NIL && (subject != NOSTR || cc != NIL || bcc != NIL))
|
||||
if (to == NULL && (subject != NULL || cc != NULL || bcc != NULL))
|
||||
errx(1, "You must specify direct recipients with -s, -c, or -b.");
|
||||
if (ef != NOSTR && to != NIL)
|
||||
if (ef != NULL && to != NULL)
|
||||
errx(1, "Cannot give -f and people to send to.");
|
||||
tinit();
|
||||
setscreensize();
|
||||
@ -239,26 +239,24 @@ Usage: %s [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
* Decide whether we are editing a mailbox or reading
|
||||
* the system mailbox, and open up the right stuff.
|
||||
*/
|
||||
if (ef == NOSTR)
|
||||
if (ef == NULL)
|
||||
ef = "%";
|
||||
if (setfile(ef) < 0)
|
||||
exit(1); /* error already reported */
|
||||
if (setjmp(hdrjmp) == 0) {
|
||||
extern char *version;
|
||||
|
||||
if ((prevint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
|
||||
signal(SIGINT, hdrstop);
|
||||
if (value("quiet") == NOSTR)
|
||||
(void)signal(SIGINT, hdrstop);
|
||||
if (value("quiet") == NULL)
|
||||
printf("Mail version %s. Type ? for help.\n",
|
||||
version);
|
||||
announce();
|
||||
fflush(stdout);
|
||||
signal(SIGINT, prevint);
|
||||
(void)fflush(stdout);
|
||||
(void)signal(SIGINT, prevint);
|
||||
}
|
||||
commands();
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
(void)signal(SIGHUP, SIG_IGN);
|
||||
(void)signal(SIGINT, SIG_IGN);
|
||||
(void)signal(SIGQUIT, SIG_IGN);
|
||||
quit();
|
||||
exit(0);
|
||||
}
|
||||
@ -266,12 +264,13 @@ Usage: %s [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
|
||||
/*
|
||||
* Interrupt printing of the headers.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
hdrstop(signo)
|
||||
int signo;
|
||||
{
|
||||
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
fprintf(stderr, "\nInterrupt\n");
|
||||
longjmp(hdrjmp, 1);
|
||||
}
|
||||
@ -291,7 +290,7 @@ setscreensize()
|
||||
struct termios tio;
|
||||
speed_t speed = 0;
|
||||
|
||||
if (ioctl(1, TIOCGWINSZ, (char *) &ws) < 0)
|
||||
if (ioctl(1, TIOCGWINSZ, (char *)&ws) < 0)
|
||||
ws.ws_col = ws.ws_row = 0;
|
||||
if (tcgetattr(1, &tio) != -1)
|
||||
speed = cfgetospeed(&tio);
|
||||
|
@ -59,14 +59,14 @@ nalloc(str, ntype)
|
||||
char str[];
|
||||
int ntype;
|
||||
{
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
|
||||
np = (struct name *) salloc(sizeof *np);
|
||||
np->n_flink = NIL;
|
||||
np->n_blink = NIL;
|
||||
np = (struct name *)salloc(sizeof(*np));
|
||||
np->n_flink = NULL;
|
||||
np->n_blink = NULL;
|
||||
np->n_type = ntype;
|
||||
np->n_name = savestr(str);
|
||||
return(np);
|
||||
return (np);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -76,48 +76,47 @@ struct name *
|
||||
tailof(name)
|
||||
struct name *name;
|
||||
{
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
|
||||
np = name;
|
||||
if (np == NIL)
|
||||
return(NIL);
|
||||
while (np->n_flink != NIL)
|
||||
if (np == NULL)
|
||||
return (NULL);
|
||||
while (np->n_flink != NULL)
|
||||
np = np->n_flink;
|
||||
return(np);
|
||||
return (np);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract a list of names from a line,
|
||||
* and make a list of names from it.
|
||||
* Return the list or NIL if none found.
|
||||
* Return the list or NULL if none found.
|
||||
*/
|
||||
struct name *
|
||||
extract(line, ntype)
|
||||
char line[];
|
||||
int ntype;
|
||||
{
|
||||
register char *cp;
|
||||
register struct name *top, *np, *t;
|
||||
char *nbuf;
|
||||
char *cp, *nbuf;
|
||||
struct name *top, *np, *t;
|
||||
|
||||
if (line == NOSTR || *line == '\0')
|
||||
return NIL;
|
||||
if ((nbuf = (char *)malloc(strlen(line) + 1)) == NULL)
|
||||
if (line == NULL || *line == '\0')
|
||||
return (NULL);
|
||||
if ((nbuf = malloc(strlen(line) + 1)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
top = NIL;
|
||||
np = NIL;
|
||||
top = NULL;
|
||||
np = NULL;
|
||||
cp = line;
|
||||
while ((cp = yankword(cp, nbuf)) != NOSTR) {
|
||||
while ((cp = yankword(cp, nbuf)) != NULL) {
|
||||
t = nalloc(nbuf, ntype);
|
||||
if (top == NIL)
|
||||
if (top == NULL)
|
||||
top = t;
|
||||
else
|
||||
np->n_flink = t;
|
||||
t->n_blink = np;
|
||||
np = t;
|
||||
}
|
||||
free(nbuf);
|
||||
return top;
|
||||
(void)free(nbuf);
|
||||
return (top);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -125,22 +124,21 @@ extract(line, ntype)
|
||||
*/
|
||||
char *
|
||||
detract(np, ntype)
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
int ntype;
|
||||
{
|
||||
register int s;
|
||||
register char *cp, *top;
|
||||
register struct name *p;
|
||||
register int comma;
|
||||
int s, comma;
|
||||
char *cp, *top;
|
||||
struct name *p;
|
||||
|
||||
comma = ntype & GCOMMA;
|
||||
if (np == NIL)
|
||||
return(NOSTR);
|
||||
if (np == NULL)
|
||||
return (NULL);
|
||||
ntype &= ~GCOMMA;
|
||||
s = 0;
|
||||
if (debug && comma)
|
||||
fprintf(stderr, "detract asked to insert commas\n");
|
||||
for (p = np; p != NIL; p = p->n_flink) {
|
||||
for (p = np; p != NULL; p = p->n_flink) {
|
||||
if (ntype && (p->n_type & GMASK) != ntype)
|
||||
continue;
|
||||
s += strlen(p->n_name) + 1;
|
||||
@ -148,22 +146,22 @@ detract(np, ntype)
|
||||
s++;
|
||||
}
|
||||
if (s == 0)
|
||||
return(NOSTR);
|
||||
return (NULL);
|
||||
s += 2;
|
||||
top = salloc(s);
|
||||
cp = top;
|
||||
for (p = np; p != NIL; p = p->n_flink) {
|
||||
for (p = np; p != NULL; p = p->n_flink) {
|
||||
if (ntype && (p->n_type & GMASK) != ntype)
|
||||
continue;
|
||||
cp += strlcpy(cp, p->n_name, strlen(p->n_name) + 1);
|
||||
if (comma && p->n_flink != NIL)
|
||||
if (comma && p->n_flink != NULL)
|
||||
*cp++ = ',';
|
||||
*cp++ = ' ';
|
||||
}
|
||||
*--cp = '\0';
|
||||
if (comma && *--cp == ',')
|
||||
*cp = '\0';
|
||||
return(top);
|
||||
return (top);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -174,14 +172,14 @@ char *
|
||||
yankword(ap, wbuf)
|
||||
char *ap, wbuf[];
|
||||
{
|
||||
register char *cp, *cp2;
|
||||
char *cp, *cp2;
|
||||
|
||||
cp = ap;
|
||||
for (;;) {
|
||||
if (*cp == '\0')
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
if (*cp == '(') {
|
||||
register int nesting = 0;
|
||||
int nesting = 0;
|
||||
|
||||
while (*cp != '\0') {
|
||||
switch (*cp++) {
|
||||
@ -204,10 +202,11 @@ yankword(ap, wbuf)
|
||||
for (cp2 = wbuf; *cp && (*cp2++ = *cp++) != '>';)
|
||||
;
|
||||
else
|
||||
for (cp2 = wbuf; *cp && !strchr(" \t,(", *cp); *cp2++ = *cp++)
|
||||
for (cp2 = wbuf; *cp != '\0' && strchr(" \t,(", *cp) == NULL;
|
||||
*cp2++ = *cp++)
|
||||
;
|
||||
*cp2 = '\0';
|
||||
return cp;
|
||||
return (cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -224,18 +223,17 @@ outof(names, fo, hp)
|
||||
FILE *fo;
|
||||
struct header *hp;
|
||||
{
|
||||
register int c;
|
||||
register struct name *np, *top;
|
||||
time_t now, time();
|
||||
char *date, *fname, *ctime();
|
||||
int c, ispipe;
|
||||
struct name *np, *top;
|
||||
time_t now;
|
||||
char *date, *fname;
|
||||
FILE *fout, *fin;
|
||||
int ispipe;
|
||||
|
||||
top = names;
|
||||
np = names;
|
||||
(void) time(&now);
|
||||
(void)time(&now);
|
||||
date = ctime(&now);
|
||||
while (np != NIL) {
|
||||
while (np != NULL) {
|
||||
if (!isfileaddr(np->n_name) && np->n_name[0] != '|') {
|
||||
np = np->n_flink;
|
||||
continue;
|
||||
@ -255,8 +253,8 @@ outof(names, fo, hp)
|
||||
int fd;
|
||||
char tempname[PATHSIZE];
|
||||
|
||||
snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.ReXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(fout = Fdopen(fd, "a")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
@ -264,29 +262,29 @@ outof(names, fo, hp)
|
||||
goto cant;
|
||||
}
|
||||
image = open(tempname, O_RDWR);
|
||||
(void) rm(tempname);
|
||||
(void)rm(tempname);
|
||||
if (image < 0) {
|
||||
warn("%s", tempname);
|
||||
senderr++;
|
||||
(void) Fclose(fout);
|
||||
(void)Fclose(fout);
|
||||
goto cant;
|
||||
}
|
||||
(void) fcntl(image, F_SETFD, 1);
|
||||
(void)fcntl(image, F_SETFD, 1);
|
||||
fprintf(fout, "From %s %s", myname, date);
|
||||
puthead(hp, fout,
|
||||
GTO|GSUBJECT|GCC|GREPLYTO|GINREPLYTO|GNL);
|
||||
GTO|GSUBJECT|GCC|GREPLYTO|GINREPLYTO|GNL);
|
||||
while ((c = getc(fo)) != EOF)
|
||||
(void) putc(c, fout);
|
||||
(void)putc(c, fout);
|
||||
rewind(fo);
|
||||
(void) putc('\n', fout);
|
||||
(void) fflush(fout);
|
||||
fprintf(fout, "\n");
|
||||
(void)fflush(fout);
|
||||
if (ferror(fout)) {
|
||||
warn("%s", tempname);
|
||||
senderr++;
|
||||
Fclose(fout);
|
||||
(void)Fclose(fout);
|
||||
goto cant;
|
||||
}
|
||||
(void) Fclose(fout);
|
||||
(void)Fclose(fout);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -297,7 +295,7 @@ outof(names, fo, hp)
|
||||
|
||||
if (ispipe) {
|
||||
int pid;
|
||||
char *shell;
|
||||
char *sh;
|
||||
|
||||
/*
|
||||
* XXX
|
||||
@ -306,11 +304,11 @@ outof(names, fo, hp)
|
||||
* share the same lseek location and trample
|
||||
* on one another.
|
||||
*/
|
||||
if ((shell = value("SHELL")) == NOSTR)
|
||||
shell = _PATH_CSHELL;
|
||||
pid = start_command(shell, sigmask(SIGHUP)|
|
||||
sigmask(SIGINT)|sigmask(SIGQUIT),
|
||||
image, -1, "-c", fname, NOSTR);
|
||||
if ((sh = value("SHELL")) == NULL)
|
||||
sh = _PATH_CSHELL;
|
||||
pid = start_command(sh,
|
||||
sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT),
|
||||
image, -1, "-c", fname, NULL);
|
||||
if (pid < 0) {
|
||||
senderr++;
|
||||
goto cant;
|
||||
@ -330,22 +328,22 @@ outof(names, fo, hp)
|
||||
fin = Fdopen(f, "r");
|
||||
if (fin == NULL) {
|
||||
fprintf(stderr, "Can't reopen image\n");
|
||||
(void) Fclose(fout);
|
||||
(void)Fclose(fout);
|
||||
senderr++;
|
||||
goto cant;
|
||||
}
|
||||
rewind(fin);
|
||||
while ((c = getc(fin)) != EOF)
|
||||
(void) putc(c, fout);
|
||||
(void)putc(c, fout);
|
||||
if (ferror(fout)) {
|
||||
warnx("%s", fname);
|
||||
senderr++;
|
||||
Fclose(fout);
|
||||
Fclose(fin);
|
||||
(void)Fclose(fout);
|
||||
(void)Fclose(fin);
|
||||
goto cant;
|
||||
}
|
||||
(void) Fclose(fout);
|
||||
(void) Fclose(fin);
|
||||
(void)Fclose(fout);
|
||||
(void)Fclose(fin);
|
||||
}
|
||||
cant:
|
||||
/*
|
||||
@ -357,10 +355,10 @@ outof(names, fo, hp)
|
||||
np = np->n_flink;
|
||||
}
|
||||
if (image >= 0) {
|
||||
(void) close(image);
|
||||
(void)close(image);
|
||||
image = -1;
|
||||
}
|
||||
return(top);
|
||||
return (top);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -372,17 +370,17 @@ int
|
||||
isfileaddr(name)
|
||||
char *name;
|
||||
{
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
if (*name == '+')
|
||||
return 1;
|
||||
for (cp = name; *cp; cp++) {
|
||||
return (1);
|
||||
for (cp = name; *cp != '\0'; cp++) {
|
||||
if (*cp == '!' || *cp == '%' || *cp == '@')
|
||||
return 0;
|
||||
return (0);
|
||||
if (*cp == '/')
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -396,14 +394,14 @@ struct name *
|
||||
usermap(names)
|
||||
struct name *names;
|
||||
{
|
||||
register struct name *new, *np, *cp;
|
||||
struct name *new, *np, *cp;
|
||||
struct grouphead *gh;
|
||||
register int metoo;
|
||||
int metoo;
|
||||
|
||||
new = NIL;
|
||||
new = NULL;
|
||||
np = names;
|
||||
metoo = (value("metoo") != NOSTR);
|
||||
while (np != NIL) {
|
||||
metoo = (value("metoo") != NULL);
|
||||
while (np != NULL) {
|
||||
if (np->n_name[0] == '\\') {
|
||||
cp = np->n_flink;
|
||||
new = put(new, np);
|
||||
@ -412,13 +410,13 @@ usermap(names)
|
||||
}
|
||||
gh = findgroup(np->n_name);
|
||||
cp = np->n_flink;
|
||||
if (gh != NOGRP)
|
||||
if (gh != NULL)
|
||||
new = gexpand(new, gh, metoo, np->n_type);
|
||||
else
|
||||
new = put(new, np);
|
||||
np = cp;
|
||||
}
|
||||
return(new);
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -441,16 +439,16 @@ gexpand(nlist, gh, metoo, ntype)
|
||||
|
||||
if (depth > MAXEXP) {
|
||||
printf("Expanding alias to depth larger than %d\n", MAXEXP);
|
||||
return(nlist);
|
||||
return (nlist);
|
||||
}
|
||||
depth++;
|
||||
for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link) {
|
||||
for (gp = gh->g_list; gp != NULL; gp = gp->ge_link) {
|
||||
cp = gp->ge_name;
|
||||
if (*cp == '\\')
|
||||
goto quote;
|
||||
if (strcmp(cp, gh->g_name) == 0)
|
||||
goto quote;
|
||||
if ((ngh = findgroup(cp)) != NOGRP) {
|
||||
if ((ngh = findgroup(cp)) != NULL) {
|
||||
nlist = gexpand(nlist, ngh, metoo, ntype);
|
||||
continue;
|
||||
}
|
||||
@ -460,7 +458,7 @@ gexpand(nlist, gh, metoo, ntype)
|
||||
* At this point should allow to expand
|
||||
* to self if only person in group
|
||||
*/
|
||||
if (gp == gh->g_list && gp->ge_link == NOGE)
|
||||
if (gp == gh->g_list && gp->ge_link == NULL)
|
||||
goto skip;
|
||||
if (!metoo && strcmp(cp, myname) == 0)
|
||||
np->n_type |= GDEL;
|
||||
@ -468,7 +466,7 @@ gexpand(nlist, gh, metoo, ntype)
|
||||
nlist = put(nlist, np);
|
||||
}
|
||||
depth--;
|
||||
return(nlist);
|
||||
return (nlist);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -478,16 +476,16 @@ struct name *
|
||||
cat(n1, n2)
|
||||
struct name *n1, *n2;
|
||||
{
|
||||
register struct name *tail;
|
||||
struct name *tail;
|
||||
|
||||
if (n1 == NIL)
|
||||
return(n2);
|
||||
if (n2 == NIL)
|
||||
return(n1);
|
||||
if (n1 == NULL)
|
||||
return (n2);
|
||||
if (n2 == NULL)
|
||||
return (n1);
|
||||
tail = tailof(n1);
|
||||
tail->n_flink = n2;
|
||||
n2->n_blink = tail;
|
||||
return(n1);
|
||||
return (n1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -498,8 +496,8 @@ char **
|
||||
unpack(np)
|
||||
struct name *np;
|
||||
{
|
||||
register char **ap, **top;
|
||||
register struct name *n;
|
||||
char **ap, **top;
|
||||
struct name *n;
|
||||
int t, extra, metoo, verbose;
|
||||
|
||||
n = np;
|
||||
@ -513,13 +511,13 @@ unpack(np)
|
||||
*/
|
||||
extra = 2;
|
||||
extra++;
|
||||
metoo = value("metoo") != NOSTR;
|
||||
metoo = value("metoo") != NULL;
|
||||
if (metoo)
|
||||
extra++;
|
||||
verbose = value("verbose") != NOSTR;
|
||||
verbose = value("verbose") != NULL;
|
||||
if (verbose)
|
||||
extra++;
|
||||
top = (char **) salloc((t + extra) * sizeof *top);
|
||||
top = (char **)salloc((t + extra) * sizeof(*top));
|
||||
ap = top;
|
||||
*ap++ = "send-mail";
|
||||
*ap++ = "-i";
|
||||
@ -527,11 +525,11 @@ unpack(np)
|
||||
*ap++ = "-m";
|
||||
if (verbose)
|
||||
*ap++ = "-v";
|
||||
for (; n != NIL; n = n->n_flink)
|
||||
for (; n != NULL; n = n->n_flink)
|
||||
if ((n->n_type & GDEL) == 0)
|
||||
*ap++ = n->n_name;
|
||||
*ap = NOSTR;
|
||||
return(top);
|
||||
*ap = NULL;
|
||||
return (top);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -543,21 +541,21 @@ struct name *
|
||||
elide(names)
|
||||
struct name *names;
|
||||
{
|
||||
register struct name *np, *t, *new;
|
||||
struct name *np, *t, *new;
|
||||
struct name *x;
|
||||
|
||||
if (names == NIL)
|
||||
return(NIL);
|
||||
if (names == NULL)
|
||||
return (NULL);
|
||||
new = names;
|
||||
np = names;
|
||||
np = np->n_flink;
|
||||
if (np != NIL)
|
||||
np->n_blink = NIL;
|
||||
new->n_flink = NIL;
|
||||
while (np != NIL) {
|
||||
if (np != NULL)
|
||||
np->n_blink = NULL;
|
||||
new->n_flink = NULL;
|
||||
while (np != NULL) {
|
||||
t = new;
|
||||
while (strcasecmp(t->n_name, np->n_name) < 0) {
|
||||
if (t->n_flink == NIL)
|
||||
if (t->n_flink == NULL)
|
||||
break;
|
||||
t = t->n_flink;
|
||||
}
|
||||
@ -572,7 +570,7 @@ elide(names)
|
||||
np->n_blink = t;
|
||||
t = np;
|
||||
np = np->n_flink;
|
||||
t->n_flink = NIL;
|
||||
t->n_flink = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -587,7 +585,7 @@ elide(names)
|
||||
np = np->n_flink;
|
||||
t->n_flink = new;
|
||||
new->n_blink = t;
|
||||
t->n_blink = NIL;
|
||||
t->n_blink = NULL;
|
||||
new = t;
|
||||
continue;
|
||||
}
|
||||
@ -611,12 +609,12 @@ elide(names)
|
||||
*/
|
||||
|
||||
np = new;
|
||||
while (np != NIL) {
|
||||
while (np != NULL) {
|
||||
t = np;
|
||||
while (t->n_flink != NIL &&
|
||||
strcasecmp(np->n_name, t->n_flink->n_name) == 0)
|
||||
while (t->n_flink != NULL &&
|
||||
strcasecmp(np->n_name, t->n_flink->n_name) == 0)
|
||||
t = t->n_flink;
|
||||
if (t == np || t == NIL) {
|
||||
if (t == np || t == NULL) {
|
||||
np = np->n_flink;
|
||||
continue;
|
||||
}
|
||||
@ -627,11 +625,11 @@ elide(names)
|
||||
*/
|
||||
|
||||
np->n_flink = t->n_flink;
|
||||
if (t->n_flink != NIL)
|
||||
if (t->n_flink != NULL)
|
||||
t->n_flink->n_blink = np;
|
||||
np = np->n_flink;
|
||||
}
|
||||
return(new);
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -643,10 +641,10 @@ put(list, node)
|
||||
struct name *list, *node;
|
||||
{
|
||||
node->n_flink = list;
|
||||
node->n_blink = NIL;
|
||||
if (list != NIL)
|
||||
node->n_blink = NULL;
|
||||
if (list != NULL)
|
||||
list->n_blink = node;
|
||||
return(node);
|
||||
return (node);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -655,14 +653,14 @@ put(list, node)
|
||||
*/
|
||||
int
|
||||
count(np)
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
{
|
||||
register int c;
|
||||
int c;
|
||||
|
||||
for (c = 0; np != NIL; np = np->n_flink)
|
||||
for (c = 0; np != NULL; np = np->n_flink)
|
||||
if ((np->n_type & GDEL) == 0)
|
||||
c++;
|
||||
return c;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -670,28 +668,28 @@ count(np)
|
||||
*/
|
||||
struct name *
|
||||
delname(np, name)
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
char name[];
|
||||
{
|
||||
register struct name *p;
|
||||
struct name *p;
|
||||
|
||||
for (p = np; p != NIL; p = p->n_flink)
|
||||
for (p = np; p != NULL; p = p->n_flink)
|
||||
if (strcasecmp(p->n_name, name) == 0) {
|
||||
if (p->n_blink == NIL) {
|
||||
if (p->n_flink != NIL)
|
||||
p->n_flink->n_blink = NIL;
|
||||
if (p->n_blink == NULL) {
|
||||
if (p->n_flink != NULL)
|
||||
p->n_flink->n_blink = NULL;
|
||||
np = p->n_flink;
|
||||
continue;
|
||||
}
|
||||
if (p->n_flink == NIL) {
|
||||
if (p->n_blink != NIL)
|
||||
p->n_blink->n_flink = NIL;
|
||||
if (p->n_flink == NULL) {
|
||||
if (p->n_blink != NULL)
|
||||
p->n_blink->n_flink = NULL;
|
||||
continue;
|
||||
}
|
||||
p->n_blink->n_flink = p->n_flink;
|
||||
p->n_flink->n_blink = p->n_blink;
|
||||
}
|
||||
return np;
|
||||
return (np);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -704,10 +702,10 @@ void
|
||||
prettyprint(name)
|
||||
struct name *name;
|
||||
{
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
|
||||
np = name;
|
||||
while (np != NIL) {
|
||||
while (np != NULL) {
|
||||
fprintf(stderr, "%s(%d) ", np->n_name, np->n_type);
|
||||
np = np->n_flink;
|
||||
}
|
||||
|
@ -35,8 +35,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#define _PATH_EX "/usr/bin/ex"
|
||||
#define _PATH_HELP "/usr/share/misc/mail.help"
|
||||
#define _PATH_TILDE "/usr/share/misc/mail.tildehelp"
|
||||
|
@ -48,19 +48,19 @@ static const char rcsid[] =
|
||||
#define WRITE 1
|
||||
|
||||
struct fp {
|
||||
FILE *fp;
|
||||
int pipe;
|
||||
int pid;
|
||||
struct fp *link;
|
||||
FILE *fp;
|
||||
int pipe;
|
||||
int pid;
|
||||
struct fp *link;
|
||||
};
|
||||
static struct fp *fp_head;
|
||||
|
||||
struct child {
|
||||
int pid;
|
||||
char done;
|
||||
char free;
|
||||
int status;
|
||||
struct child *link;
|
||||
int pid;
|
||||
char done;
|
||||
char free;
|
||||
int status;
|
||||
struct child *link;
|
||||
};
|
||||
static struct child *child;
|
||||
static struct child *findchild __P((int));
|
||||
@ -68,30 +68,30 @@ static void delchild __P((struct child *));
|
||||
static int file_pid __P((FILE *));
|
||||
|
||||
FILE *
|
||||
Fopen(file, mode)
|
||||
char *file, *mode;
|
||||
Fopen(path, mode)
|
||||
const char *path, *mode;
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(file, mode)) != NULL) {
|
||||
if ((fp = fopen(path, mode)) != NULL) {
|
||||
register_file(fp, 0, 0);
|
||||
(void) fcntl(fileno(fp), F_SETFD, 1);
|
||||
(void)fcntl(fileno(fp), F_SETFD, 1);
|
||||
}
|
||||
return fp;
|
||||
return (fp);
|
||||
}
|
||||
|
||||
FILE *
|
||||
Fdopen(fd, mode)
|
||||
int fd;
|
||||
char *mode;
|
||||
const char *mode;
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fdopen(fd, mode)) != NULL) {
|
||||
register_file(fp, 0, 0);
|
||||
(void) fcntl(fileno(fp), F_SETFD, 1);
|
||||
(void)fcntl(fileno(fp), F_SETFD, 1);
|
||||
}
|
||||
return fp;
|
||||
return (fp);
|
||||
}
|
||||
|
||||
int
|
||||
@ -99,13 +99,13 @@ Fclose(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
unregister_file(fp);
|
||||
return fclose(fp);
|
||||
return (fclose(fp));
|
||||
}
|
||||
|
||||
FILE *
|
||||
Popen(cmd, mode)
|
||||
char *cmd;
|
||||
char *mode;
|
||||
const char *mode;
|
||||
{
|
||||
int p[2];
|
||||
int myside, hisside, fd0, fd1;
|
||||
@ -113,9 +113,9 @@ Popen(cmd, mode)
|
||||
FILE *fp;
|
||||
|
||||
if (pipe(p) < 0)
|
||||
return NULL;
|
||||
(void) fcntl(p[READ], F_SETFD, 1);
|
||||
(void) fcntl(p[WRITE], F_SETFD, 1);
|
||||
return (NULL);
|
||||
(void)fcntl(p[READ], F_SETFD, 1);
|
||||
(void)fcntl(p[WRITE], F_SETFD, 1);
|
||||
if (*mode == 'r') {
|
||||
myside = p[READ];
|
||||
fd0 = -1;
|
||||
@ -125,15 +125,15 @@ Popen(cmd, mode)
|
||||
hisside = fd0 = p[READ];
|
||||
fd1 = -1;
|
||||
}
|
||||
if ((pid = start_command(cmd, 0, fd0, fd1, NOSTR, NOSTR, NOSTR)) < 0) {
|
||||
close(p[READ]);
|
||||
close(p[WRITE]);
|
||||
return NULL;
|
||||
if ((pid = start_command(cmd, 0, fd0, fd1, NULL, NULL, NULL)) < 0) {
|
||||
(void)close(p[READ]);
|
||||
(void)close(p[WRITE]);
|
||||
return (NULL);
|
||||
}
|
||||
(void) close(hisside);
|
||||
(void)close(hisside);
|
||||
if ((fp = fdopen(myside, mode)) != NULL)
|
||||
register_file(fp, 1, pid);
|
||||
return fp;
|
||||
return (fp);
|
||||
}
|
||||
|
||||
int
|
||||
@ -145,22 +145,22 @@ Pclose(ptr)
|
||||
|
||||
i = file_pid(ptr);
|
||||
unregister_file(ptr);
|
||||
(void) fclose(ptr);
|
||||
(void)fclose(ptr);
|
||||
omask = sigblock(sigmask(SIGINT)|sigmask(SIGHUP));
|
||||
i = wait_child(i);
|
||||
sigsetmask(omask);
|
||||
return i;
|
||||
(void)sigsetmask(omask);
|
||||
return (i);
|
||||
}
|
||||
|
||||
void
|
||||
close_all_files()
|
||||
{
|
||||
|
||||
while (fp_head)
|
||||
while (fp_head != NULL)
|
||||
if (fp_head->pipe)
|
||||
(void) Pclose(fp_head->fp);
|
||||
(void)Pclose(fp_head->fp);
|
||||
else
|
||||
(void) Fclose(fp_head->fp);
|
||||
(void)Fclose(fp_head->fp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -170,7 +170,7 @@ register_file(fp, pipe, pid)
|
||||
{
|
||||
struct fp *fpp;
|
||||
|
||||
if ((fpp = (struct fp *) malloc(sizeof *fpp)) == NULL)
|
||||
if ((fpp = malloc(sizeof(*fpp))) == NULL)
|
||||
err(1, "Out of memory");
|
||||
fpp->fp = fp;
|
||||
fpp->pipe = pipe;
|
||||
@ -185,10 +185,10 @@ unregister_file(fp)
|
||||
{
|
||||
struct fp **pp, *p;
|
||||
|
||||
for (pp = &fp_head; p = *pp; pp = &p->link)
|
||||
for (pp = &fp_head; (p = *pp) != NULL; pp = &p->link)
|
||||
if (p->fp == fp) {
|
||||
*pp = p->link;
|
||||
free((char *) p);
|
||||
(void)free(p);
|
||||
return;
|
||||
}
|
||||
errx(1, "Invalid file pointer");
|
||||
@ -201,7 +201,7 @@ file_pid(fp)
|
||||
{
|
||||
struct fp *p;
|
||||
|
||||
for (p = fp_head; p; p = p->link)
|
||||
for (p = fp_head; p != NULL; p = p->link)
|
||||
if (p->fp == fp)
|
||||
return (p->pid);
|
||||
errx(1, "Invalid file pointer");
|
||||
@ -225,8 +225,8 @@ run_command(cmd, mask, infd, outfd, a0, a1, a2)
|
||||
int pid;
|
||||
|
||||
if ((pid = start_command(cmd, mask, infd, outfd, a0, a1, a2)) < 0)
|
||||
return -1;
|
||||
return wait_command(pid);
|
||||
return (-1);
|
||||
return (wait_command(pid));
|
||||
}
|
||||
|
||||
/*VARARGS4*/
|
||||
@ -240,22 +240,22 @@ start_command(cmd, mask, infd, outfd, a0, a1, a2)
|
||||
|
||||
if ((pid = fork()) < 0) {
|
||||
warn("fork");
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
if (pid == 0) {
|
||||
char *argv[100];
|
||||
int i = getrawlist(cmd, argv, sizeof argv / sizeof *argv);
|
||||
int i = getrawlist(cmd, argv, sizeof(argv) / sizeof(*argv));
|
||||
|
||||
if ((argv[i++] = a0) != NOSTR &&
|
||||
(argv[i++] = a1) != NOSTR &&
|
||||
(argv[i++] = a2) != NOSTR)
|
||||
argv[i] = NOSTR;
|
||||
if ((argv[i++] = a0) != NULL &&
|
||||
(argv[i++] = a1) != NULL &&
|
||||
(argv[i++] = a2) != NULL)
|
||||
argv[i] = NULL;
|
||||
prepare_child(mask, infd, outfd);
|
||||
execvp(argv[0], argv);
|
||||
warn("%s", argv[0]);
|
||||
_exit(1);
|
||||
}
|
||||
return pid;
|
||||
return (pid);
|
||||
}
|
||||
|
||||
void
|
||||
@ -274,10 +274,10 @@ prepare_child(mask, infd, outfd)
|
||||
dup2(outfd, 1);
|
||||
for (i = 1; i <= NSIG; i++)
|
||||
if (mask & sigmask(i))
|
||||
(void) signal(i, SIG_IGN);
|
||||
(void)signal(i, SIG_IGN);
|
||||
if ((mask & sigmask(SIGINT)) == 0)
|
||||
(void) signal(SIGINT, SIG_DFL);
|
||||
(void) sigsetmask(0);
|
||||
(void)signal(SIGINT, SIG_DFL);
|
||||
(void)sigsetmask(0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -287,50 +287,51 @@ wait_command(pid)
|
||||
|
||||
if (wait_child(pid) < 0) {
|
||||
printf("Fatal error in process.\n");
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct child *
|
||||
findchild(pid)
|
||||
int pid;
|
||||
{
|
||||
register struct child **cpp;
|
||||
struct child **cpp;
|
||||
|
||||
for (cpp = &child; *cpp != NULL && (*cpp)->pid != pid;
|
||||
cpp = &(*cpp)->link)
|
||||
cpp = &(*cpp)->link)
|
||||
;
|
||||
if (*cpp == NULL) {
|
||||
*cpp = (struct child *) malloc(sizeof (struct child));
|
||||
*cpp = malloc(sizeof(struct child));
|
||||
if (*cpp == NULL)
|
||||
err(1, "Out of memory");
|
||||
(*cpp)->pid = pid;
|
||||
(*cpp)->done = (*cpp)->free = 0;
|
||||
(*cpp)->link = NULL;
|
||||
}
|
||||
return *cpp;
|
||||
return (*cpp);
|
||||
}
|
||||
|
||||
static void
|
||||
delchild(cp)
|
||||
register struct child *cp;
|
||||
struct child *cp;
|
||||
{
|
||||
register struct child **cpp;
|
||||
struct child **cpp;
|
||||
|
||||
for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link)
|
||||
;
|
||||
*cpp = cp->link;
|
||||
free((char *) cp);
|
||||
(void)free(cp);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
sigchild(signo)
|
||||
int signo;
|
||||
{
|
||||
int pid;
|
||||
int status;
|
||||
register struct child *cp;
|
||||
struct child *cp;
|
||||
|
||||
while ((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0) {
|
||||
cp = findchild(pid);
|
||||
@ -353,14 +354,14 @@ wait_child(pid)
|
||||
int pid;
|
||||
{
|
||||
int mask = sigblock(sigmask(SIGCHLD));
|
||||
register struct child *cp = findchild(pid);
|
||||
struct child *cp = findchild(pid);
|
||||
|
||||
while (!cp->done)
|
||||
sigpause(mask);
|
||||
wait_status = cp->status;
|
||||
delchild(cp);
|
||||
sigsetmask(mask);
|
||||
return((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0);
|
||||
(void)sigsetmask(mask);
|
||||
return ((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -371,11 +372,11 @@ free_child(pid)
|
||||
int pid;
|
||||
{
|
||||
int mask = sigblock(sigmask(SIGCHLD));
|
||||
register struct child *cp = findchild(pid);
|
||||
struct child *cp = findchild(pid);
|
||||
|
||||
if (cp->done)
|
||||
delchild(cp);
|
||||
else
|
||||
cp->free = 1;
|
||||
sigsetmask(mask);
|
||||
(void)sigsetmask(mask);
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ quitcmd()
|
||||
* Otherwise, return -1 to abort command loop.
|
||||
*/
|
||||
if (sourcing)
|
||||
return 1;
|
||||
return -1;
|
||||
return (1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -74,9 +74,8 @@ quit()
|
||||
{
|
||||
int mcount, p, modify, autohold, anystat, holdbit, nohold;
|
||||
FILE *ibuf, *obuf, *fbuf, *rbuf, *readstat, *abuf;
|
||||
register struct message *mp;
|
||||
register int c;
|
||||
int fd;
|
||||
struct message *mp;
|
||||
int c, fd;
|
||||
struct stat minfo;
|
||||
char *mbox, tempname[PATHSIZE];
|
||||
|
||||
@ -108,31 +107,32 @@ quit()
|
||||
fbuf = Fopen(mailname, "r");
|
||||
if (fbuf == NULL)
|
||||
goto newmail;
|
||||
flock(fileno(fbuf), LOCK_EX);
|
||||
(void)flock(fileno(fbuf), LOCK_EX);
|
||||
rbuf = NULL;
|
||||
if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
|
||||
printf("New mail has arrived.\n");
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RqXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.RqXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(rbuf = Fdopen(fd, "w")) == NULL)
|
||||
goto newmail;
|
||||
#ifdef APPEND
|
||||
fseek(fbuf, (long)mailsize, 0);
|
||||
(void)fseek(fbuf, (long)mailsize, 0);
|
||||
while ((c = getc(fbuf)) != EOF)
|
||||
(void) putc(c, rbuf);
|
||||
(void)putc(c, rbuf);
|
||||
#else
|
||||
p = minfo.st_size - mailsize;
|
||||
while (p-- > 0) {
|
||||
c = getc(fbuf);
|
||||
if (c == EOF)
|
||||
goto newmail;
|
||||
(void) putc(c, rbuf);
|
||||
(void)putc(c, rbuf);
|
||||
}
|
||||
#endif
|
||||
Fclose(rbuf);
|
||||
(void)Fclose(rbuf);
|
||||
if ((rbuf = Fopen(tempname, "r")) == NULL)
|
||||
goto newmail;
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -140,10 +140,10 @@ quit()
|
||||
*/
|
||||
|
||||
anystat = 0;
|
||||
autohold = value("hold") != NOSTR;
|
||||
autohold = value("hold") != NULL;
|
||||
holdbit = autohold ? MPRESERVE : MBOX;
|
||||
nohold = MBOX|MSAVED|MDELETED|MPRESERVE;
|
||||
if (value("keepsave") != NOSTR)
|
||||
if (value("keepsave") != NULL)
|
||||
nohold &= ~MSAVED;
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++) {
|
||||
if (mp->m_flag & MNEW) {
|
||||
@ -158,9 +158,9 @@ quit()
|
||||
mp->m_flag |= holdbit;
|
||||
}
|
||||
modify = 0;
|
||||
if (Tflag != NOSTR) {
|
||||
if (Tflag != NULL) {
|
||||
if ((readstat = Fopen(Tflag, "w")) == NULL)
|
||||
Tflag = NOSTR;
|
||||
Tflag = NULL;
|
||||
}
|
||||
for (c = 0, p = 0, mp = &message[0]; mp < &message[msgCount]; mp++) {
|
||||
if (mp->m_flag & MBOX)
|
||||
@ -169,25 +169,25 @@ quit()
|
||||
p++;
|
||||
if (mp->m_flag & MODIFY)
|
||||
modify++;
|
||||
if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
|
||||
if (Tflag != NULL && (mp->m_flag & (MREAD|MDELETED)) != 0) {
|
||||
char *id;
|
||||
|
||||
if ((id = hfield("article-id", mp)) != NOSTR)
|
||||
if ((id = hfield("article-id", mp)) != NULL)
|
||||
fprintf(readstat, "%s\n", id);
|
||||
}
|
||||
}
|
||||
if (Tflag != NOSTR)
|
||||
Fclose(readstat);
|
||||
if (Tflag != NULL)
|
||||
(void)Fclose(readstat);
|
||||
if (p == msgCount && !modify && !anystat) {
|
||||
printf("Held %d message%s in %s\n",
|
||||
p, p == 1 ? "" : "s", mailname);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
if (c == 0) {
|
||||
if (p != 0) {
|
||||
writeback(rbuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
goto cream;
|
||||
@ -202,58 +202,59 @@ quit()
|
||||
|
||||
mbox = expand("&");
|
||||
mcount = c;
|
||||
if (value("append") == NOSTR) {
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RmXXXXXXXXXX", tmpdir);
|
||||
if (value("append") == NULL) {
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.RmXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(obuf = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
if ((ibuf = Fopen(tempname, "r")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
rm(tempname);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
(void)rm(tempname);
|
||||
(void)Fclose(obuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
if ((abuf = Fopen(mbox, "r")) != NULL) {
|
||||
while ((c = getc(abuf)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
Fclose(abuf);
|
||||
(void)putc(c, obuf);
|
||||
(void)Fclose(abuf);
|
||||
}
|
||||
if (ferror(obuf)) {
|
||||
warnx("%s", tempname);
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(ibuf);
|
||||
(void)Fclose(obuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
Fclose(obuf);
|
||||
close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
(void)Fclose(obuf);
|
||||
(void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
if ((obuf = Fopen(mbox, "r+")) == NULL) {
|
||||
warn("%s", mbox);
|
||||
Fclose(ibuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(ibuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (value("append") != NOSTR) {
|
||||
if (value("append") != NULL) {
|
||||
if ((obuf = Fopen(mbox, "a")) == NULL) {
|
||||
warn("%s", mbox);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
fchmod(fileno(obuf), 0600);
|
||||
(void)fchmod(fileno(obuf), 0600);
|
||||
}
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if (mp->m_flag & MBOX)
|
||||
if (sendmessage(mp, obuf, saveignore, NOSTR) < 0) {
|
||||
if (sendmessage(mp, obuf, saveignore, NULL) < 0) {
|
||||
warnx("%s", mbox);
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(ibuf);
|
||||
(void)Fclose(obuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -263,26 +264,26 @@ quit()
|
||||
* If we are appending, this is unnecessary.
|
||||
*/
|
||||
|
||||
if (value("append") == NOSTR) {
|
||||
if (value("append") == NULL) {
|
||||
rewind(ibuf);
|
||||
c = getc(ibuf);
|
||||
while (c != EOF) {
|
||||
(void) putc(c, obuf);
|
||||
(void)putc(c, obuf);
|
||||
if (ferror(obuf))
|
||||
break;
|
||||
c = getc(ibuf);
|
||||
}
|
||||
Fclose(ibuf);
|
||||
fflush(obuf);
|
||||
(void)Fclose(ibuf);
|
||||
(void)fflush(obuf);
|
||||
}
|
||||
trunc(obuf);
|
||||
if (ferror(obuf)) {
|
||||
warn("%s", mbox);
|
||||
Fclose(obuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(obuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
Fclose(obuf);
|
||||
(void)Fclose(obuf);
|
||||
if (mcount == 1)
|
||||
printf("Saved 1 message in mbox\n");
|
||||
else
|
||||
@ -295,12 +296,12 @@ quit()
|
||||
|
||||
if (p != 0) {
|
||||
writeback(rbuf);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, remove his /usr/mail file.
|
||||
* Finally, remove his /var/mail file.
|
||||
* If new mail has arrived, copy it back.
|
||||
*/
|
||||
|
||||
@ -310,22 +311,22 @@ quit()
|
||||
if (abuf == NULL)
|
||||
goto newmail;
|
||||
while ((c = getc(rbuf)) != EOF)
|
||||
(void) putc(c, abuf);
|
||||
Fclose(rbuf);
|
||||
(void)putc(c, abuf);
|
||||
(void)Fclose(rbuf);
|
||||
trunc(abuf);
|
||||
Fclose(abuf);
|
||||
(void)Fclose(abuf);
|
||||
alter(mailname);
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
}
|
||||
demail();
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
return;
|
||||
|
||||
newmail:
|
||||
printf("Thou hast new mail.\n");
|
||||
if (fbuf != NULL)
|
||||
Fclose(fbuf);
|
||||
(void)Fclose(fbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -336,52 +337,52 @@ quit()
|
||||
*/
|
||||
int
|
||||
writeback(res)
|
||||
register FILE *res;
|
||||
FILE *res;
|
||||
{
|
||||
register struct message *mp;
|
||||
register int p, c;
|
||||
struct message *mp;
|
||||
int p, c;
|
||||
FILE *obuf;
|
||||
|
||||
p = 0;
|
||||
if ((obuf = Fopen(mailname, "r+")) == NULL) {
|
||||
warn("%s", mailname);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
#ifndef APPEND
|
||||
if (res != NULL)
|
||||
while ((c = getc(res)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
(void)putc(c, obuf);
|
||||
#endif
|
||||
for (mp = &message[0]; mp < &message[msgCount]; mp++)
|
||||
if ((mp->m_flag&MPRESERVE)||(mp->m_flag&MTOUCH)==0) {
|
||||
p++;
|
||||
if (sendmessage(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
|
||||
if (sendmessage(mp, obuf, NULL, NULL) < 0) {
|
||||
warnx("%s", mailname);
|
||||
Fclose(obuf);
|
||||
return(-1);
|
||||
(void)Fclose(obuf);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
#ifdef APPEND
|
||||
if (res != NULL)
|
||||
while ((c = getc(res)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
(void)putc(c, obuf);
|
||||
#endif
|
||||
fflush(obuf);
|
||||
(void)fflush(obuf);
|
||||
trunc(obuf);
|
||||
if (ferror(obuf)) {
|
||||
warn("%s", mailname);
|
||||
Fclose(obuf);
|
||||
return(-1);
|
||||
(void)Fclose(obuf);
|
||||
return (-1);
|
||||
}
|
||||
if (res != NULL)
|
||||
Fclose(res);
|
||||
Fclose(obuf);
|
||||
(void)Fclose(res);
|
||||
(void)Fclose(obuf);
|
||||
alter(mailname);
|
||||
if (p == 1)
|
||||
printf("Held 1 message in %s\n", mailname);
|
||||
else
|
||||
printf("Held %d messages in %s\n", p, mailname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -391,8 +392,8 @@ writeback(res)
|
||||
void
|
||||
edstop()
|
||||
{
|
||||
register int gotcha, c;
|
||||
register struct message *mp;
|
||||
int gotcha, c;
|
||||
struct message *mp;
|
||||
FILE *obuf, *ibuf, *readstat;
|
||||
struct stat statb;
|
||||
char tempname[PATHSIZE];
|
||||
@ -400,9 +401,9 @@ edstop()
|
||||
if (readonly)
|
||||
return;
|
||||
holdsigs();
|
||||
if (Tflag != NOSTR) {
|
||||
if (Tflag != NULL) {
|
||||
if ((readstat = Fopen(Tflag, "w")) == NULL)
|
||||
Tflag = NOSTR;
|
||||
Tflag = NULL;
|
||||
}
|
||||
for (mp = &message[0], gotcha = 0; mp < &message[msgCount]; mp++) {
|
||||
if (mp->m_flag & MNEW) {
|
||||
@ -411,49 +412,51 @@ edstop()
|
||||
}
|
||||
if (mp->m_flag & (MODIFY|MDELETED|MSTATUS))
|
||||
gotcha++;
|
||||
if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
|
||||
if (Tflag != NULL && (mp->m_flag & (MREAD|MDELETED)) != 0) {
|
||||
char *id;
|
||||
|
||||
if ((id = hfield("article-id", mp)) != NOSTR)
|
||||
if ((id = hfield("article-id", mp)) != NULL)
|
||||
fprintf(readstat, "%s\n", id);
|
||||
}
|
||||
}
|
||||
if (Tflag != NOSTR)
|
||||
Fclose(readstat);
|
||||
if (!gotcha || Tflag != NOSTR)
|
||||
if (Tflag != NULL)
|
||||
(void)Fclose(readstat);
|
||||
if (!gotcha || Tflag != NULL)
|
||||
goto done;
|
||||
ibuf = NULL;
|
||||
if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) {
|
||||
int fd;
|
||||
|
||||
snprintf(tempname, sizeof(tempname), "%s/mbox.XXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) {
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mbox.XXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(obuf = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
if ((ibuf = Fopen(mailname, "r")) == NULL) {
|
||||
warn("%s", mailname);
|
||||
Fclose(obuf);
|
||||
rm(tempname);
|
||||
(void)Fclose(obuf);
|
||||
(void)rm(tempname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
fseek(ibuf, (long)mailsize, 0);
|
||||
(void)fseek(ibuf, (long)mailsize, 0);
|
||||
while ((c = getc(ibuf)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
Fclose(ibuf);
|
||||
Fclose(obuf);
|
||||
(void)putc(c, obuf);
|
||||
(void)Fclose(ibuf);
|
||||
(void)Fclose(obuf);
|
||||
if ((ibuf = Fopen(tempname, "r")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
rm(tempname);
|
||||
(void)rm(tempname);
|
||||
}
|
||||
printf("\"%s\" ", mailname);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
if ((obuf = Fopen(mailname, "r+")) == NULL) {
|
||||
warn("%s", mailname);
|
||||
relsesigs();
|
||||
@ -465,7 +468,7 @@ edstop()
|
||||
if ((mp->m_flag & MDELETED) != 0)
|
||||
continue;
|
||||
c++;
|
||||
if (sendmessage(mp, obuf, (struct ignoretab *) NULL, NOSTR) < 0) {
|
||||
if (sendmessage(mp, obuf, NULL, NULL) < 0) {
|
||||
warnx("%s", mailname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
@ -474,22 +477,22 @@ edstop()
|
||||
gotcha = (c == 0 && ibuf == NULL);
|
||||
if (ibuf != NULL) {
|
||||
while ((c = getc(ibuf)) != EOF)
|
||||
(void) putc(c, obuf);
|
||||
Fclose(ibuf);
|
||||
(void)putc(c, obuf);
|
||||
(void)Fclose(ibuf);
|
||||
}
|
||||
fflush(obuf);
|
||||
(void)fflush(obuf);
|
||||
if (ferror(obuf)) {
|
||||
warn("%s", mailname);
|
||||
relsesigs();
|
||||
reset(0);
|
||||
}
|
||||
Fclose(obuf);
|
||||
(void)Fclose(obuf);
|
||||
if (gotcha) {
|
||||
rm(mailname);
|
||||
(void)rm(mailname);
|
||||
printf("removed\n");
|
||||
} else
|
||||
printf("complete\n");
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
|
||||
done:
|
||||
relsesigs();
|
||||
|
@ -57,29 +57,26 @@ static const char rcsid[] =
|
||||
*/
|
||||
int
|
||||
sendmessage(mp, obuf, doign, prefix)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
FILE *obuf;
|
||||
struct ignoretab *doign;
|
||||
char *prefix;
|
||||
{
|
||||
long count;
|
||||
register FILE *ibuf;
|
||||
char line[LINESIZE];
|
||||
FILE *ibuf;
|
||||
char *cp, *cp2, line[LINESIZE];
|
||||
int ishead, infld, ignoring, dostat, firstline;
|
||||
register char *cp, *cp2;
|
||||
register int c;
|
||||
int length;
|
||||
int prefixlen;
|
||||
int c, length, prefixlen;
|
||||
|
||||
/*
|
||||
* Compute the prefix string, without trailing whitespace
|
||||
*/
|
||||
if (prefix != NOSTR) {
|
||||
if (prefix != NULL) {
|
||||
cp2 = 0;
|
||||
for (cp = prefix; *cp; cp++)
|
||||
for (cp = prefix; *cp != '\0'; cp++)
|
||||
if (*cp != ' ' && *cp != '\t')
|
||||
cp2 = cp;
|
||||
prefixlen = cp2 == 0 ? 0 : cp2 - prefix + 1;
|
||||
prefixlen = cp2 == NULL ? 0 : cp2 - prefix + 1;
|
||||
}
|
||||
ibuf = setinput(mp);
|
||||
count = mp->m_size;
|
||||
@ -125,7 +122,8 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
/*
|
||||
* Pick up the header field if we have one.
|
||||
*/
|
||||
for (cp = line; (c = *cp++) && c != ':' && !isspace(c);)
|
||||
for (cp = line; (c = *cp++) != '\0' && c != ':' &&
|
||||
!isspace(c);)
|
||||
;
|
||||
cp2 = --cp;
|
||||
while (isspace(*cp++))
|
||||
@ -142,7 +140,7 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
}
|
||||
if (doign != ignoreall)
|
||||
/* add blank line */
|
||||
(void) putc('\n', obuf);
|
||||
(void)putc('\n', obuf);
|
||||
ishead = 0;
|
||||
ignoring = 0;
|
||||
} else {
|
||||
@ -150,7 +148,7 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
* If it is an ignored field and
|
||||
* we care about such things, skip it.
|
||||
*/
|
||||
*cp2 = 0; /* temporarily null terminate */
|
||||
*cp2 = '\0'; /* temporarily null terminate */
|
||||
if (doign && isign(line, doign))
|
||||
ignoring = 1;
|
||||
else if ((line[0] == 's' || line[0] == 'S') &&
|
||||
@ -176,16 +174,16 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
* Strip trailing whitespace from prefix
|
||||
* if line is blank.
|
||||
*/
|
||||
if (prefix != NOSTR) {
|
||||
if (prefix != NULL) {
|
||||
if (length > 1)
|
||||
fputs(prefix, obuf);
|
||||
else
|
||||
(void) fwrite(prefix, sizeof *prefix,
|
||||
prefixlen, obuf);
|
||||
(void)fwrite(prefix, sizeof(*prefix),
|
||||
prefixlen, obuf);
|
||||
}
|
||||
(void) fwrite(line, sizeof *line, length, obuf);
|
||||
(void)fwrite(line, sizeof(*line), length, obuf);
|
||||
if (ferror(obuf))
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -193,7 +191,7 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
*/
|
||||
if (doign == ignoreall)
|
||||
count--; /* skip final blank line */
|
||||
if (prefix != NOSTR)
|
||||
if (prefix != NULL)
|
||||
while (count > 0) {
|
||||
if (fgets(line, sizeof(line), ibuf) == NULL) {
|
||||
c = 0;
|
||||
@ -207,26 +205,26 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
if (c > 1)
|
||||
fputs(prefix, obuf);
|
||||
else
|
||||
(void) fwrite(prefix, sizeof *prefix,
|
||||
prefixlen, obuf);
|
||||
(void) fwrite(line, sizeof *line, c, obuf);
|
||||
(void)fwrite(prefix, sizeof(*prefix),
|
||||
prefixlen, obuf);
|
||||
(void)fwrite(line, sizeof(*line), c, obuf);
|
||||
if (ferror(obuf))
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
else
|
||||
while (count > 0) {
|
||||
c = count < LINESIZE ? count : LINESIZE;
|
||||
if ((c = fread(line, sizeof *line, c, ibuf)) <= 0)
|
||||
if ((c = fread(line, sizeof(*line), c, ibuf)) <= 0)
|
||||
break;
|
||||
count -= c;
|
||||
if (fwrite(line, sizeof *line, c, obuf) != c)
|
||||
return -1;
|
||||
if (fwrite(line, sizeof(*line), c, obuf) != c)
|
||||
return (-1);
|
||||
}
|
||||
if (doign == ignoreall && c > 0 && line[c - 1] != '\n')
|
||||
/* no final blank line */
|
||||
if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF)
|
||||
return -1;
|
||||
return 0;
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -234,21 +232,21 @@ sendmessage(mp, obuf, doign, prefix)
|
||||
*/
|
||||
void
|
||||
statusput(mp, obuf, prefix)
|
||||
register struct message *mp;
|
||||
struct message *mp;
|
||||
FILE *obuf;
|
||||
char *prefix;
|
||||
{
|
||||
char statout[3];
|
||||
register char *cp = statout;
|
||||
char *cp = statout;
|
||||
|
||||
if (mp->m_flag & MREAD)
|
||||
*cp++ = 'R';
|
||||
if ((mp->m_flag & MNEW) == 0)
|
||||
*cp++ = 'O';
|
||||
*cp = 0;
|
||||
if (statout[0])
|
||||
*cp = '\0';
|
||||
if (statout[0] != '\0')
|
||||
fprintf(obuf, "%sStatus: %s\n",
|
||||
prefix == NOSTR ? "" : prefix, statout);
|
||||
prefix == NULL ? "" : prefix, statout);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -268,9 +266,9 @@ mail(to, cc, bcc, smopts, subject, replyto)
|
||||
head.h_bcc = bcc;
|
||||
head.h_smopts = smopts;
|
||||
head.h_replyto = replyto;
|
||||
head.h_inreplyto = NOSTR;
|
||||
head.h_inreplyto = NULL;
|
||||
mail1(&head, 0);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@ -285,15 +283,15 @@ sendmail(str)
|
||||
struct header head;
|
||||
|
||||
head.h_to = extract(str, GTO);
|
||||
head.h_subject = NOSTR;
|
||||
head.h_cc = NIL;
|
||||
head.h_bcc = NIL;
|
||||
head.h_smopts = NIL;
|
||||
head.h_subject = NULL;
|
||||
head.h_cc = NULL;
|
||||
head.h_bcc = NULL;
|
||||
head.h_smopts = NULL;
|
||||
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
|
||||
head.h_replyto = NOSTR;
|
||||
head.h_inreplyto = NOSTR;
|
||||
head.h_replyto = NULL;
|
||||
head.h_inreplyto = NULL;
|
||||
mail1(&head, 0);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -317,16 +315,16 @@ mail1(hp, printheaders)
|
||||
*/
|
||||
if ((mtf = collect(hp, printheaders)) == NULL)
|
||||
return;
|
||||
if (value("interactive") != NOSTR) {
|
||||
if (value("askcc") != NOSTR)
|
||||
if (value("interactive") != NULL) {
|
||||
if (value("askcc") != NULL)
|
||||
grabh(hp, GCC);
|
||||
else {
|
||||
printf("EOT\n");
|
||||
(void) fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
}
|
||||
if (fsize(mtf) == 0) {
|
||||
if (hp->h_subject == NOSTR)
|
||||
if (hp->h_subject == NULL)
|
||||
printf("No message, no subject; hope that's ok\n");
|
||||
else
|
||||
printf("Null message body; hope that's ok\n");
|
||||
@ -338,7 +336,7 @@ mail1(hp, printheaders)
|
||||
*/
|
||||
senderr = 0;
|
||||
to = usermap(cat(hp->h_bcc, cat(hp->h_to, hp->h_cc)));
|
||||
if (to == NIL) {
|
||||
if (to == NULL) {
|
||||
printf("No recipients specified\n");
|
||||
senderr++;
|
||||
}
|
||||
@ -362,13 +360,13 @@ mail1(hp, printheaders)
|
||||
char **t;
|
||||
|
||||
printf("Sendmail arguments:");
|
||||
for (t = namelist; *t != NOSTR; t++)
|
||||
for (t = namelist; *t != NULL; t++)
|
||||
printf(" \"%s\"", *t);
|
||||
printf("\n");
|
||||
goto out;
|
||||
}
|
||||
if ((cp = value("record")) != NOSTR)
|
||||
(void) savemail(expand(cp), mtf);
|
||||
if ((cp = value("record")) != NULL)
|
||||
(void)savemail(expand(cp), mtf);
|
||||
/*
|
||||
* Fork, set up the temporary mail file as standard
|
||||
* input for "mail", and exec with the user list we generated
|
||||
@ -384,7 +382,7 @@ mail1(hp, printheaders)
|
||||
prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)|
|
||||
sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU),
|
||||
fileno(mtf), -1);
|
||||
if ((cp = value("sendmail")) != NOSTR)
|
||||
if ((cp = value("sendmail")) != NULL)
|
||||
cp = expand(cp);
|
||||
else
|
||||
cp = _PATH_SENDMAIL;
|
||||
@ -392,12 +390,12 @@ mail1(hp, printheaders)
|
||||
warn("%s", cp);
|
||||
_exit(1);
|
||||
}
|
||||
if (value("verbose") != NOSTR)
|
||||
(void) wait_child(pid);
|
||||
if (value("verbose") != NULL)
|
||||
(void)wait_child(pid);
|
||||
else
|
||||
free_child(pid);
|
||||
out:
|
||||
(void) Fclose(mtf);
|
||||
(void)Fclose(mtf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -409,21 +407,21 @@ fixhead(hp, tolist)
|
||||
struct header *hp;
|
||||
struct name *tolist;
|
||||
{
|
||||
register struct name *np;
|
||||
struct name *np;
|
||||
|
||||
hp->h_to = NIL;
|
||||
hp->h_cc = NIL;
|
||||
hp->h_bcc = NIL;
|
||||
for (np = tolist; np != NIL; np = np->n_flink)
|
||||
hp->h_to = NULL;
|
||||
hp->h_cc = NULL;
|
||||
hp->h_bcc = NULL;
|
||||
for (np = tolist; np != NULL; np = np->n_flink)
|
||||
if ((np->n_type & GMASK) == GTO)
|
||||
hp->h_to =
|
||||
cat(hp->h_to, nalloc(np->n_name, np->n_type));
|
||||
cat(hp->h_to, nalloc(np->n_name, np->n_type));
|
||||
else if ((np->n_type & GMASK) == GCC)
|
||||
hp->h_cc =
|
||||
cat(hp->h_cc, nalloc(np->n_name, np->n_type));
|
||||
cat(hp->h_cc, nalloc(np->n_name, np->n_type));
|
||||
else if ((np->n_type & GMASK) == GBCC)
|
||||
hp->h_bcc =
|
||||
cat(hp->h_bcc, nalloc(np->n_name, np->n_type));
|
||||
cat(hp->h_bcc, nalloc(np->n_name, np->n_type));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -435,48 +433,48 @@ infix(hp, fi)
|
||||
struct header *hp;
|
||||
FILE *fi;
|
||||
{
|
||||
register FILE *nfo, *nfi;
|
||||
register int c;
|
||||
int fd;
|
||||
FILE *nfo, *nfi;
|
||||
int c, fd;
|
||||
char tempname[PATHSIZE];
|
||||
|
||||
snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
(void)snprintf(tempname, sizeof(tempname),
|
||||
"%s/mail.RsXXXXXXXXXX", tmpdir);
|
||||
if ((fd = mkstemp(tempname)) == -1 ||
|
||||
(nfo = Fdopen(fd, "w")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
return(fi);
|
||||
return (fi);
|
||||
}
|
||||
if ((nfi = Fopen(tempname, "r")) == NULL) {
|
||||
warn("%s", tempname);
|
||||
(void) Fclose(nfo);
|
||||
(void) rm(tempname);
|
||||
return(fi);
|
||||
(void)Fclose(nfo);
|
||||
(void)rm(tempname);
|
||||
return (fi);
|
||||
}
|
||||
(void) rm(tempname);
|
||||
(void) puthead(hp, nfo,
|
||||
GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA);
|
||||
(void)rm(tempname);
|
||||
(void)puthead(hp, nfo,
|
||||
GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA);
|
||||
c = getc(fi);
|
||||
while (c != EOF) {
|
||||
(void) putc(c, nfo);
|
||||
(void)putc(c, nfo);
|
||||
c = getc(fi);
|
||||
}
|
||||
if (ferror(fi)) {
|
||||
warnx("read");
|
||||
rewind(fi);
|
||||
return(fi);
|
||||
return (fi);
|
||||
}
|
||||
(void) fflush(nfo);
|
||||
(void)fflush(nfo);
|
||||
if (ferror(nfo)) {
|
||||
warn("%s", tempname);
|
||||
(void) Fclose(nfo);
|
||||
(void) Fclose(nfi);
|
||||
(void)Fclose(nfo);
|
||||
(void)Fclose(nfi);
|
||||
rewind(fi);
|
||||
return(fi);
|
||||
return (fi);
|
||||
}
|
||||
(void) Fclose(nfo);
|
||||
(void) Fclose(fi);
|
||||
(void)Fclose(nfo);
|
||||
(void)Fclose(fi);
|
||||
rewind(nfi);
|
||||
return(nfi);
|
||||
return (nfi);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -489,24 +487,24 @@ puthead(hp, fo, w)
|
||||
FILE *fo;
|
||||
int w;
|
||||
{
|
||||
register int gotcha;
|
||||
int gotcha;
|
||||
|
||||
gotcha = 0;
|
||||
if (hp->h_to != NIL && w & GTO)
|
||||
if (hp->h_to != NULL && w & GTO)
|
||||
fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++;
|
||||
if (hp->h_subject != NOSTR && w & GSUBJECT)
|
||||
if (hp->h_subject != NULL && w & GSUBJECT)
|
||||
fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++;
|
||||
if (hp->h_cc != NIL && w & GCC)
|
||||
if (hp->h_cc != NULL && w & GCC)
|
||||
fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++;
|
||||
if (hp->h_bcc != NIL && w & GBCC)
|
||||
if (hp->h_bcc != NULL && w & GBCC)
|
||||
fmt("Bcc:", hp->h_bcc, fo, w&GCOMMA), gotcha++;
|
||||
if (hp->h_replyto != NOSTR && w & GREPLYTO)
|
||||
if (hp->h_replyto != NULL && w & GREPLYTO)
|
||||
fprintf(fo, "Reply-To: %s\n", hp->h_replyto), gotcha++;
|
||||
if (hp->h_inreplyto != NOSTR && w & GINREPLYTO)
|
||||
if (hp->h_inreplyto != NULL && w & GINREPLYTO)
|
||||
fprintf(fo, "In-Reply-To: <%s>\n", hp->h_inreplyto), gotcha++;
|
||||
if (gotcha && w & GNL)
|
||||
(void) putc('\n', fo);
|
||||
return(0);
|
||||
(void)putc('\n', fo);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -514,33 +512,33 @@ puthead(hp, fo, w)
|
||||
*/
|
||||
void
|
||||
fmt(str, np, fo, comma)
|
||||
char *str;
|
||||
register struct name *np;
|
||||
const char *str;
|
||||
struct name *np;
|
||||
FILE *fo;
|
||||
int comma;
|
||||
{
|
||||
register col, len;
|
||||
int col, len;
|
||||
|
||||
comma = comma ? 1 : 0;
|
||||
col = strlen(str);
|
||||
if (col)
|
||||
fputs(str, fo);
|
||||
for (; np != NIL; np = np->n_flink) {
|
||||
if (np->n_flink == NIL)
|
||||
for (; np != NULL; np = np->n_flink) {
|
||||
if (np->n_flink == NULL)
|
||||
comma = 0;
|
||||
len = strlen(np->n_name);
|
||||
col++; /* for the space */
|
||||
if (col + len + comma > 72 && col > 4) {
|
||||
fputs("\n ", fo);
|
||||
fprintf(fo, "\n ");
|
||||
col = 4;
|
||||
} else
|
||||
putc(' ', fo);
|
||||
fprintf(fo, " ");
|
||||
fputs(np->n_name, fo);
|
||||
if (comma)
|
||||
putc(',', fo);
|
||||
fprintf(fo, ",");
|
||||
col += len + comma;
|
||||
}
|
||||
putc('\n', fo);
|
||||
fprintf(fo, "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -551,27 +549,26 @@ fmt(str, np, fo, comma)
|
||||
int
|
||||
savemail(name, fi)
|
||||
char name[];
|
||||
register FILE *fi;
|
||||
FILE *fi;
|
||||
{
|
||||
register FILE *fo;
|
||||
FILE *fo;
|
||||
char buf[BUFSIZ];
|
||||
register i;
|
||||
time_t now, time();
|
||||
char *ctime();
|
||||
int i;
|
||||
time_t now;
|
||||
|
||||
if ((fo = Fopen(name, "a")) == NULL) {
|
||||
warn("%s", name);
|
||||
return (-1);
|
||||
}
|
||||
(void) time(&now);
|
||||
(void)time(&now);
|
||||
fprintf(fo, "From %s %s", myname, ctime(&now));
|
||||
while ((i = fread(buf, 1, sizeof buf, fi)) > 0)
|
||||
(void) fwrite(buf, 1, i, fo);
|
||||
(void) putc('\n', fo);
|
||||
(void) fflush(fo);
|
||||
while ((i = fread(buf, 1, sizeof(buf), fi)) > 0)
|
||||
(void)fwrite(buf, 1, i, fo);
|
||||
fprintf(fo, "\n");
|
||||
(void)fflush(fo);
|
||||
if (ferror(fo))
|
||||
warn("%s", name);
|
||||
(void) Fclose(fo);
|
||||
(void)Fclose(fo);
|
||||
rewind(fi);
|
||||
return (0);
|
||||
}
|
||||
|
@ -62,17 +62,16 @@ char *
|
||||
salloc(size)
|
||||
int size;
|
||||
{
|
||||
register char *t;
|
||||
register int s;
|
||||
register struct strings *sp;
|
||||
int index;
|
||||
char *t;
|
||||
int s, index;
|
||||
struct strings *sp;
|
||||
|
||||
s = size;
|
||||
s += (sizeof (char *) - 1);
|
||||
s &= ~(sizeof (char *) - 1);
|
||||
s += (sizeof(char *) - 1);
|
||||
s &= ~(sizeof(char *) - 1);
|
||||
index = 0;
|
||||
for (sp = &stringdope[0]; sp < &stringdope[NSPACE]; sp++) {
|
||||
if (sp->s_topFree == NOSTR && (STRINGSIZE << index) >= s)
|
||||
if (sp->s_topFree == NULL && (STRINGSIZE << index) >= s)
|
||||
break;
|
||||
if (sp->s_nleft >= s)
|
||||
break;
|
||||
@ -80,9 +79,9 @@ salloc(size)
|
||||
}
|
||||
if (sp >= &stringdope[NSPACE])
|
||||
errx(1, "String too large");
|
||||
if (sp->s_topFree == NOSTR) {
|
||||
if (sp->s_topFree == NULL) {
|
||||
index = sp - &stringdope[0];
|
||||
if ((sp->s_topFree = malloc(STRINGSIZE << index)) == NOSTR)
|
||||
if ((sp->s_topFree = malloc(STRINGSIZE << index)) == NULL)
|
||||
err(1, "No room for space %d", index);
|
||||
sp->s_nextFree = sp->s_topFree;
|
||||
sp->s_nleft = STRINGSIZE << index;
|
||||
@ -90,7 +89,7 @@ salloc(size)
|
||||
sp->s_nleft -= s;
|
||||
t = sp->s_nextFree;
|
||||
sp->s_nextFree += s;
|
||||
return(t);
|
||||
return (t);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -101,14 +100,14 @@ salloc(size)
|
||||
void
|
||||
sreset()
|
||||
{
|
||||
register struct strings *sp;
|
||||
register int index;
|
||||
struct strings *sp;
|
||||
int index;
|
||||
|
||||
if (noreset)
|
||||
return;
|
||||
index = 0;
|
||||
for (sp = &stringdope[0]; sp < &stringdope[NSPACE]; sp++) {
|
||||
if (sp->s_topFree == NOSTR)
|
||||
if (sp->s_topFree == NULL)
|
||||
continue;
|
||||
sp->s_nextFree = sp->s_topFree;
|
||||
sp->s_nleft = STRINGSIZE << index;
|
||||
@ -123,8 +122,8 @@ sreset()
|
||||
void
|
||||
spreserve()
|
||||
{
|
||||
register struct strings *sp;
|
||||
struct strings *sp;
|
||||
|
||||
for (sp = &stringdope[0]; sp < &stringdope[NSPACE]; sp++)
|
||||
sp->s_topFree = NOSTR;
|
||||
sp->s_topFree = NULL;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ char *tmpdir;
|
||||
void
|
||||
tinit()
|
||||
{
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
|
||||
tmpdir = _PATH_TMP;
|
||||
@ -70,23 +70,23 @@ tinit()
|
||||
* It's okay to call savestr in here because main will
|
||||
* do a spreserve() after us.
|
||||
*/
|
||||
if (myname != NOSTR) {
|
||||
if (myname != NULL) {
|
||||
if (getuserid(myname) < 0)
|
||||
errx(1, "\"%s\" is not a user of this system", myname);
|
||||
} else {
|
||||
if ((cp = username()) == NOSTR) {
|
||||
if ((cp = username()) == NULL) {
|
||||
myname = "ubluit";
|
||||
if (rcvmode)
|
||||
errx(1, "Who are you!?");
|
||||
} else
|
||||
myname = savestr(cp);
|
||||
}
|
||||
if ((cp = getenv("HOME")) == NOSTR || *cp == '\0' ||
|
||||
if ((cp = getenv("HOME")) == NULL || *cp == '\0' ||
|
||||
strlen(cp) >= PATHSIZE)
|
||||
homedir = NULL;
|
||||
else
|
||||
homedir = savestr(cp);
|
||||
if (debug)
|
||||
printf("user = %s, homedir = %s\n", myname,
|
||||
homedir ? homedir : "NONE");
|
||||
homedir ? homedir : "NONE");
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ grabh(hp, gflags)
|
||||
sig_t savettou;
|
||||
sig_t savettin;
|
||||
int errs;
|
||||
void ttyint();
|
||||
|
||||
savetstp = signal(SIGTSTP, SIG_DFL);
|
||||
savettou = signal(SIGTTOU, SIG_DFL);
|
||||
@ -85,7 +84,7 @@ grabh(hp, gflags)
|
||||
#endif
|
||||
if (tcgetattr(fileno(stdin), &tio) < 0) {
|
||||
warn("tcgetattr(stdin)");
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
c_erase = tio.c_cc[VERASE];
|
||||
c_kill = tio.c_cc[VKILL];
|
||||
@ -93,9 +92,9 @@ grabh(hp, gflags)
|
||||
tio.c_cc[VERASE] = 0;
|
||||
tio.c_cc[VKILL] = 0;
|
||||
if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL)
|
||||
signal(SIGINT, SIG_DFL);
|
||||
(void)signal(SIGINT, SIG_DFL);
|
||||
if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL)
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
#else
|
||||
if (setjmp(intjmp))
|
||||
goto out;
|
||||
@ -103,7 +102,7 @@ grabh(hp, gflags)
|
||||
#endif
|
||||
if (gflags & GTO) {
|
||||
#ifndef TIOCSTI
|
||||
if (!ttyset && hp->h_to != NIL)
|
||||
if (!ttyset && hp->h_to != NULL)
|
||||
ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||
#endif
|
||||
hp->h_to =
|
||||
@ -111,14 +110,14 @@ grabh(hp, gflags)
|
||||
}
|
||||
if (gflags & GSUBJECT) {
|
||||
#ifndef TIOCSTI
|
||||
if (!ttyset && hp->h_subject != NOSTR)
|
||||
if (!ttyset && hp->h_subject != NULL)
|
||||
ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||
#endif
|
||||
hp->h_subject = readtty("Subject: ", hp->h_subject);
|
||||
}
|
||||
if (gflags & GCC) {
|
||||
#ifndef TIOCSTI
|
||||
if (!ttyset && hp->h_cc != NIL)
|
||||
if (!ttyset && hp->h_cc != NULL)
|
||||
ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||
#endif
|
||||
hp->h_cc =
|
||||
@ -126,25 +125,25 @@ grabh(hp, gflags)
|
||||
}
|
||||
if (gflags & GBCC) {
|
||||
#ifndef TIOCSTI
|
||||
if (!ttyset && hp->h_bcc != NIL)
|
||||
if (!ttyset && hp->h_bcc != NULL)
|
||||
ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||
#endif
|
||||
hp->h_bcc =
|
||||
extract(readtty("Bcc: ", detract(hp->h_bcc, 0)), GBCC);
|
||||
}
|
||||
out:
|
||||
signal(SIGTSTP, savetstp);
|
||||
signal(SIGTTOU, savettou);
|
||||
signal(SIGTTIN, savettin);
|
||||
(void)signal(SIGTSTP, savetstp);
|
||||
(void)signal(SIGTTOU, savettou);
|
||||
(void)signal(SIGTTIN, savettin);
|
||||
#ifndef TIOCSTI
|
||||
tio.c_cc[VERASE] = c_erase;
|
||||
tio.c_cc[VKILL] = c_kill;
|
||||
if (ttyset)
|
||||
tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||
signal(SIGQUIT, savequit);
|
||||
(void)signal(SIGQUIT, savequit);
|
||||
#endif
|
||||
signal(SIGINT, saveint);
|
||||
return(errs);
|
||||
(void)signal(SIGINT, saveint);
|
||||
return (errs);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -156,29 +155,29 @@ grabh(hp, gflags)
|
||||
|
||||
char *
|
||||
readtty(pr, src)
|
||||
char pr[], src[];
|
||||
const char *pr;
|
||||
char src[];
|
||||
{
|
||||
char ch, canonb[BUFSIZ];
|
||||
int c;
|
||||
register char *cp, *cp2;
|
||||
void ttystop();
|
||||
char *cp, *cp2;
|
||||
|
||||
fputs(pr, stdout);
|
||||
fflush(stdout);
|
||||
if (src != NOSTR && strlen(src) > BUFSIZ - 2) {
|
||||
(void)fflush(stdout);
|
||||
if (src != NULL && strlen(src) > BUFSIZ - 2) {
|
||||
printf("too long to edit\n");
|
||||
return(src);
|
||||
return (src);
|
||||
}
|
||||
#ifndef TIOCSTI
|
||||
if (src != NOSTR)
|
||||
if (src != NULL)
|
||||
strlcpy(canonb, src, sizeof(canonb));
|
||||
else
|
||||
*canonb = '\0';
|
||||
fputs(canonb, stdout);
|
||||
fflush(stdout);
|
||||
(void)fflush(stdout);
|
||||
#else
|
||||
cp = src == NOSTR ? "" : src;
|
||||
while (c = *cp++) {
|
||||
cp = src == NULL ? "" : src;
|
||||
while ((c = *cp++) != '\0') {
|
||||
if (c == c_erase || c == c_kill) {
|
||||
ch = '\\';
|
||||
ioctl(0, TIOCSTI, &ch);
|
||||
@ -195,9 +194,9 @@ readtty(pr, src)
|
||||
cp2 = cp;
|
||||
if (setjmp(rewrite))
|
||||
goto redo;
|
||||
signal(SIGTSTP, ttystop);
|
||||
signal(SIGTTOU, ttystop);
|
||||
signal(SIGTTIN, ttystop);
|
||||
(void)signal(SIGTSTP, ttystop);
|
||||
(void)signal(SIGTTOU, ttystop);
|
||||
(void)signal(SIGTTIN, ttystop);
|
||||
clearerr(stdin);
|
||||
while (cp2 < canonb + BUFSIZ) {
|
||||
c = getc(stdin);
|
||||
@ -205,22 +204,22 @@ readtty(pr, src)
|
||||
break;
|
||||
*cp2++ = c;
|
||||
}
|
||||
*cp2 = 0;
|
||||
signal(SIGTSTP, SIG_DFL);
|
||||
signal(SIGTTOU, SIG_DFL);
|
||||
signal(SIGTTIN, SIG_DFL);
|
||||
*cp2 = '\0';
|
||||
(void)signal(SIGTSTP, SIG_DFL);
|
||||
(void)signal(SIGTTOU, SIG_DFL);
|
||||
(void)signal(SIGTTIN, SIG_DFL);
|
||||
if (c == EOF && ferror(stdin)) {
|
||||
redo:
|
||||
cp = strlen(canonb) > 0 ? canonb : NOSTR;
|
||||
cp = strlen(canonb) > 0 ? canonb : NULL;
|
||||
clearerr(stdin);
|
||||
return(readtty(pr, cp));
|
||||
return (readtty(pr, cp));
|
||||
}
|
||||
#ifndef TIOCSTI
|
||||
if (cp == NOSTR || *cp == '\0')
|
||||
return(src);
|
||||
if (cp == NULL || *cp == '\0')
|
||||
return (src);
|
||||
cp2 = cp;
|
||||
if (!ttyset)
|
||||
return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR);
|
||||
return (strlen(canonb) > 0 ? savestr(canonb) : NULL);
|
||||
while (*cp != '\0') {
|
||||
c = *cp++;
|
||||
if (c == c_erase) {
|
||||
@ -248,8 +247,8 @@ readtty(pr, src)
|
||||
*cp2 = '\0';
|
||||
#endif
|
||||
if (equal("", canonb))
|
||||
return(NOSTR);
|
||||
return(savestr(canonb));
|
||||
return (NULL);
|
||||
return (savestr(canonb));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -261,10 +260,10 @@ ttystop(s)
|
||||
{
|
||||
sig_t old_action = signal(s, SIG_DFL);
|
||||
|
||||
sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
kill(0, s);
|
||||
sigblock(sigmask(s));
|
||||
signal(s, old_action);
|
||||
(void)sigsetmask(sigblock(0) & ~sigmask(s));
|
||||
(void)kill(0, s);
|
||||
(void)sigblock(sigmask(s));
|
||||
(void)signal(s, old_action);
|
||||
longjmp(rewrite, 1);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ findmail(user, buf, buflen)
|
||||
char *user, *buf;
|
||||
int buflen;
|
||||
{
|
||||
char *tmp = getenv("MAIL");
|
||||
char *tmp = getenv("MAIL");
|
||||
|
||||
if (tmp == NULL)
|
||||
(void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user);
|
||||
@ -75,8 +75,8 @@ void
|
||||
demail()
|
||||
{
|
||||
|
||||
if (value("keep") != NOSTR || rm(mailname) < 0)
|
||||
close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
if (value("keep") != NULL || rm(mailname) < 0)
|
||||
(void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -88,12 +88,12 @@ username()
|
||||
char *np;
|
||||
uid_t uid;
|
||||
|
||||
if ((np = getenv("USER")) != NOSTR)
|
||||
return np;
|
||||
if ((np = getenv("LOGNAME")) != NOSTR)
|
||||
return np;
|
||||
if ((np = getname(uid = getuid())) != NOSTR)
|
||||
return np;
|
||||
if ((np = getenv("USER")) != NULL)
|
||||
return (np);
|
||||
if ((np = getenv("LOGNAME")) != NULL)
|
||||
return (np);
|
||||
if ((np = getname(uid = getuid())) != NULL)
|
||||
return (np);
|
||||
printf("Cannot associate a name with uid %u\n", (unsigned)uid);
|
||||
return NOSTR;
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -53,15 +53,15 @@ static const char rcsid[] =
|
||||
*/
|
||||
void
|
||||
assign(name, value)
|
||||
char name[], value[];
|
||||
const char *name, *value;
|
||||
{
|
||||
register struct var *vp;
|
||||
register int h;
|
||||
struct var *vp;
|
||||
int h;
|
||||
|
||||
h = hash(name);
|
||||
vp = lookup(name);
|
||||
if (vp == NOVAR) {
|
||||
vp = (struct var *) calloc(sizeof *vp, 1);
|
||||
if (vp == NULL) {
|
||||
vp = calloc(sizeof(*vp), 1);
|
||||
vp->v_name = vcopy(name);
|
||||
vp->v_link = variables[h];
|
||||
variables[h] = vp;
|
||||
@ -80,8 +80,8 @@ void
|
||||
vfree(cp)
|
||||
char *cp;
|
||||
{
|
||||
if (*cp)
|
||||
free(cp);
|
||||
if (*cp != '\0')
|
||||
(void)free(cp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -91,18 +91,18 @@ vfree(cp)
|
||||
|
||||
char *
|
||||
vcopy(str)
|
||||
char str[];
|
||||
const char *str;
|
||||
{
|
||||
char *new;
|
||||
unsigned len;
|
||||
|
||||
if (*str == '\0')
|
||||
return "";
|
||||
return ("");
|
||||
len = strlen(str) + 1;
|
||||
if ((new = malloc(len)) == NULL)
|
||||
err(1, "Out of memory");
|
||||
bcopy(str, new, (int) len);
|
||||
return new;
|
||||
bcopy(str, new, (int)len);
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -112,13 +112,13 @@ vcopy(str)
|
||||
|
||||
char *
|
||||
value(name)
|
||||
char name[];
|
||||
const char *name;
|
||||
{
|
||||
register struct var *vp;
|
||||
struct var *vp;
|
||||
|
||||
if ((vp = lookup(name)) == NOVAR)
|
||||
return(getenv(name));
|
||||
return(vp->v_value);
|
||||
if ((vp = lookup(name)) == NULL)
|
||||
return (getenv(name));
|
||||
return (vp->v_value);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -128,14 +128,14 @@ value(name)
|
||||
|
||||
struct var *
|
||||
lookup(name)
|
||||
register char name[];
|
||||
const char *name;
|
||||
{
|
||||
register struct var *vp;
|
||||
struct var *vp;
|
||||
|
||||
for (vp = variables[hash(name)]; vp != NOVAR; vp = vp->v_link)
|
||||
for (vp = variables[hash(name)]; vp != NULL; vp = vp->v_link)
|
||||
if (*vp->v_name == *name && equal(vp->v_name, name))
|
||||
return(vp);
|
||||
return(NOVAR);
|
||||
return (vp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -144,14 +144,14 @@ lookup(name)
|
||||
|
||||
struct grouphead *
|
||||
findgroup(name)
|
||||
register char name[];
|
||||
char name[];
|
||||
{
|
||||
register struct grouphead *gh;
|
||||
struct grouphead *gh;
|
||||
|
||||
for (gh = groups[hash(name)]; gh != NOGRP; gh = gh->g_link)
|
||||
for (gh = groups[hash(name)]; gh != NULL; gh = gh->g_link)
|
||||
if (*gh->g_name == *name && equal(gh->g_name, name))
|
||||
return(gh);
|
||||
return(NOGRP);
|
||||
return (gh);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -161,17 +161,17 @@ void
|
||||
printgroup(name)
|
||||
char name[];
|
||||
{
|
||||
register struct grouphead *gh;
|
||||
register struct group *gp;
|
||||
struct grouphead *gh;
|
||||
struct group *gp;
|
||||
|
||||
if ((gh = findgroup(name)) == NOGRP) {
|
||||
if ((gh = findgroup(name)) == NULL) {
|
||||
printf("\"%s\": not a group\n", name);
|
||||
return;
|
||||
}
|
||||
printf("%s\t", gh->g_name);
|
||||
for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link)
|
||||
for (gp = gh->g_list; gp != NULL; gp = gp->ge_link)
|
||||
printf(" %s", gp->ge_name);
|
||||
putchar('\n');
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -180,11 +180,11 @@ printgroup(name)
|
||||
*/
|
||||
int
|
||||
hash(name)
|
||||
register char *name;
|
||||
const char *name;
|
||||
{
|
||||
register h = 0;
|
||||
int h = 0;
|
||||
|
||||
while (*name) {
|
||||
while (*name != '\0') {
|
||||
h <<= 2;
|
||||
h += *name++;
|
||||
}
|
||||
|
@ -43,4 +43,4 @@ static const char rcsid[] =
|
||||
* Just keep track of the date/sid of this version of Mail.
|
||||
* Load this file first to get a "total" Mail version.
|
||||
*/
|
||||
char *version = "8.1 6/6/93";
|
||||
const char *version = "8.1 6/6/93";
|
||||
|
Loading…
Reference in New Issue
Block a user