version 1.25, 2001/11/20 20:50:00 |
version 1.26, 2001/11/21 15:26:39 |
|
|
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; |
static const char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; |
#else |
#else |
static char rcsid[] = "$OpenBSD$"; |
static const char rcsid[] = "$OpenBSD$"; |
#endif |
#endif |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
|
|
* signficance for mbox and so forth. |
* signficance for mbox and so forth. |
*/ |
*/ |
int |
int |
setfile(name) |
setfile(char *name) |
char *name; |
|
{ |
{ |
FILE *ibuf; |
FILE *ibuf; |
int i, fd; |
int i, fd; |
|
|
* while we are reading the new file, else we will ruin |
* while we are reading the new file, else we will ruin |
* the message[] data structure. |
* the message[] data structure. |
*/ |
*/ |
|
|
holdsigs(); |
holdsigs(); |
if (shudclob) |
if (shudclob) |
quit(); |
quit(); |
|
|
* Copy the messages into /tmp |
* Copy the messages into /tmp |
* and set pointers. |
* and set pointers. |
*/ |
*/ |
|
|
readonly = 0; |
readonly = 0; |
if ((i = open(name, 1)) < 0) |
if ((i = open(name, O_WRONLY, 0)) < 0) |
readonly++; |
readonly++; |
else |
else |
(void)close(i); |
(void)close(i); |
|
|
shudclob = 1; |
shudclob = 1; |
edit = isedit; |
edit = isedit; |
strcpy(prevfile, mailname); |
strcpy(prevfile, mailname); |
if (name != mailname) { |
if (name != mailname) |
strncpy(mailname, name, sizeof(mailname) - 1); |
strlcpy(mailname, name, sizeof(mailname)); |
mailname[sizeof(mailname) - 1] = '\0'; |
|
} |
|
mailsize = fsize(ibuf); |
mailsize = fsize(ibuf); |
(void)snprintf(tempname, sizeof(tempname), |
(void)snprintf(tempname, sizeof(tempname), |
"%s/mail.RxXXXXXXXXXX", tmpdir); |
"%s/mail.RxXXXXXXXXXX", tmpdir); |
|
|
* started reading mail. |
* started reading mail. |
*/ |
*/ |
int |
int |
incfile() |
incfile(void) |
{ |
{ |
int newsize; |
int newsize; |
int omsgCount = msgCount; |
int omsgCount = msgCount; |
|
|
* print no prompt. |
* print no prompt. |
*/ |
*/ |
void |
void |
commands() |
commands(void) |
{ |
{ |
int n, sig, *sigp; |
int n, sig, *sigp; |
int eofloop = 0; |
int eofloop = 0; |
|
|
* Contxt is non-zero if called while composing mail. |
* Contxt is non-zero if called while composing mail. |
*/ |
*/ |
int |
int |
execute(linebuf, contxt) |
execute(char *linebuf, int contxt) |
char linebuf[]; |
|
int contxt; |
|
{ |
{ |
char word[LINESIZE]; |
char word[LINESIZE]; |
char *arglist[MAXARGC]; |
char *arglist[MAXARGC]; |
|
|
* Handle ! escapes differently to get the correct |
* Handle ! escapes differently to get the correct |
* lexical conventions. |
* lexical conventions. |
*/ |
*/ |
|
|
for (cp = linebuf; isspace(*cp); cp++) |
for (cp = linebuf; isspace(*cp); cp++) |
; |
; |
if (*cp == '!') { |
if (*cp == '!') { |
|
|
* however, we ignore blank lines to eliminate |
* however, we ignore blank lines to eliminate |
* confusion. |
* confusion. |
*/ |
*/ |
|
|
if (sourcing && *word == '\0') |
if (sourcing && *word == '\0') |
return(0); |
return(0); |
com = lex(word); |
com = lex(word); |
if (com == NONE) { |
if (com == NULL) { |
printf("Unknown command: \"%s\"\n", word); |
printf("Unknown command: \"%s\"\n", word); |
goto out; |
goto out; |
} |
} |
|
|
* See if we should execute the command -- if a conditional |
* See if we should execute the command -- if a conditional |
* we always execute it, otherwise, check the state of cond. |
* we always execute it, otherwise, check the state of cond. |
*/ |
*/ |
|
|
if ((com->c_argtype & F) == 0) |
if ((com->c_argtype & F) == 0) |
if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode)) |
if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode)) |
return(0); |
return(0); |
|
|
* If we are sourcing an interactive command, it's |
* If we are sourcing an interactive command, it's |
* an error. |
* an error. |
*/ |
*/ |
|
|
if (!rcvmode && (com->c_argtype & M) == 0) { |
if (!rcvmode && (com->c_argtype & M) == 0) { |
printf("May not execute \"%s\" while sending\n", |
printf("May not execute \"%s\" while sending\n", |
com->c_name); |
com->c_name); |
|
|
* lists to message list functions. |
* lists to message list functions. |
*/ |
*/ |
void |
void |
setmsize(sz) |
setmsize(int sz) |
int sz; |
|
{ |
{ |
|
|
if (msgvec != 0) |
if (msgvec != 0) |
|
|
*/ |
*/ |
|
|
const struct cmd * |
const struct cmd * |
lex(word) |
lex(char *word) |
char word[]; |
|
{ |
{ |
extern const struct cmd cmdtab[]; |
extern const struct cmd cmdtab[]; |
const struct cmd *cp; |
const struct cmd *cp; |
|
|
for (cp = &cmdtab[0]; cp->c_name != NULL; cp++) |
for (cp = &cmdtab[0]; cp->c_name != NULL; cp++) |
if (isprefix(word, cp->c_name)) |
if (isprefix(word, cp->c_name)) |
return(cp); |
return(cp); |
return(NONE); |
return(NULL); |
} |
} |
|
|
/* |
/* |
|
|
* Return true if yep. |
* Return true if yep. |
*/ |
*/ |
int |
int |
isprefix(as1, as2) |
isprefix(char *as1, char *as2) |
char *as1, *as2; |
|
{ |
{ |
char *s1, *s2; |
char *s1, *s2; |
|
|
|
|
* Close all open files except 0, 1, 2, and the temporary. |
* Close all open files except 0, 1, 2, and the temporary. |
* Also, unstack all source files. |
* Also, unstack all source files. |
*/ |
*/ |
|
|
int inithdr; /* am printing startup headers */ |
int inithdr; /* am printing startup headers */ |
|
|
void |
void |
dointr() |
dointr(void) |
{ |
{ |
|
|
noreset = 0; |
noreset = 0; |
|
|
* give the message count, and print a header listing. |
* give the message count, and print a header listing. |
*/ |
*/ |
void |
void |
announce() |
announce(void) |
{ |
{ |
int vec[2], mdot; |
int vec[2], mdot; |
|
|
|
|
* Return a likely place to set dot. |
* Return a likely place to set dot. |
*/ |
*/ |
int |
int |
newfileinfo(omsgCount) |
newfileinfo(int omsgCount) |
int omsgCount; |
|
{ |
{ |
struct message *mp; |
struct message *mp; |
int u, n, mdot, d, s; |
int u, n, mdot, d, s; |
|
|
} |
} |
ename = mailname; |
ename = mailname; |
if (getfold(fname, sizeof(fname)) >= 0) { |
if (getfold(fname, sizeof(fname)) >= 0) { |
strncat(fname, "/", sizeof(fname) - strlen(fname) - 1); |
strlcat(fname, "/", sizeof(fname)); |
if (strncmp(fname, mailname, strlen(fname)) == 0) { |
if (strncmp(fname, mailname, strlen(fname)) == 0) { |
(void)snprintf(zname, sizeof(zname), "+%s", |
(void)snprintf(zname, sizeof(zname), "+%s", |
mailname + strlen(fname)); |
mailname + strlen(fname)); |
|
|
/* |
/* |
* Print the current version number. |
* Print the current version number. |
*/ |
*/ |
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
int |
int |
pversion(v) |
pversion(void *v) |
void *v; |
|
{ |
{ |
extern char *version; |
extern const char version[]; |
|
|
printf("Version %s\n", version); |
printf("Version %s\n", version); |
return(0); |
return(0); |
|
|
* Load a file of user definitions. |
* Load a file of user definitions. |
*/ |
*/ |
void |
void |
load(name) |
load(char *name) |
char *name; |
|
{ |
{ |
FILE *in, *oldin; |
FILE *in, *oldin; |
|
|