version 1.14, 2001/10/11 20:59:46 |
version 1.15, 2001/11/20 20:50:00 |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
int main __P((int, char **)); |
int main __P((int, char **)); |
|
__dead void usage __P((void)); |
|
|
/* |
/* |
* Mail -- a mail program |
* Mail -- a mail program |
|
|
* Startup -- interface with user. |
* Startup -- interface with user. |
*/ |
*/ |
|
|
sigjmp_buf hdrjmp; |
|
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
int argc; |
int argc; |
|
|
char *subject; |
char *subject; |
char *ef; |
char *ef; |
char nosrc = 0; |
char nosrc = 0; |
sig_t prevint; |
|
char *rc; |
char *rc; |
|
extern char *version; |
|
|
/* |
/* |
* Set up a reasonable environment. |
* Set up a reasonable environment. |
|
|
* start the SIGCHLD catcher, and so forth. |
* start the SIGCHLD catcher, and so forth. |
*/ |
*/ |
(void)signal(SIGCHLD, sigchild); |
(void)signal(SIGCHLD, sigchild); |
|
(void)signal(SIGPIPE, SIG_IGN); |
if (isatty(0)) |
if (isatty(0)) |
assign("interactive", ""); |
assign("interactive", ""); |
image = -1; |
image = -1; |
|
|
*/ |
*/ |
bcc = cat(bcc, nalloc(optarg, GBCC)); |
bcc = cat(bcc, nalloc(optarg, GBCC)); |
break; |
break; |
case '?': |
default: |
fprintf(stderr, "\ |
usage(); |
Usage: %s [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\ |
/*NOTREACHED*/ |
[- sendmail-options ...]\n\ |
|
%s [-iInNv] -f [name]\n\ |
|
%s [-iInNv] [-u user]\n", __progname, __progname, __progname); |
|
exit(1); |
|
} |
} |
} |
} |
for (i = optind; (argv[i]) && (*argv[i] != '-'); i++) |
for (i = optind; (argv[i]) && (*argv[i] != '-'); i++) |
|
|
errx(1, "You must specify direct recipients with -s, -c, or -b"); |
errx(1, "You must specify direct recipients with -s, -c, or -b"); |
if (ef != NULL && to != NIL) |
if (ef != NULL && to != NIL) |
errx(1, "Cannot give -f and people to send to"); |
errx(1, "Cannot give -f and people to send to"); |
|
/* |
|
* Block SIGINT except where we install an explicit handler for it. |
|
*/ |
|
sigemptyset(&intset); |
|
sigaddset(&intset, SIGINT); |
|
(void)sigprocmask(SIG_BLOCK, &intset, NULL); |
|
/* |
|
* Initialization. |
|
*/ |
tinit(); |
tinit(); |
setscreensize(); |
setscreensize(); |
input = stdin; |
input = stdin; |
|
|
ef = "%"; |
ef = "%"; |
if (setfile(ef) < 0) |
if (setfile(ef) < 0) |
exit(1); /* error already reported */ |
exit(1); /* error already reported */ |
if (sigsetjmp(hdrjmp, 1) == 0) { |
|
extern char *version; |
|
|
|
if ((prevint = signal(SIGINT, SIG_IGN)) != SIG_IGN) |
if (value("quiet") == NULL) |
(void)signal(SIGINT, hdrstop); |
(void)printf("Mail version %s. Type ? for help.\n", |
if (value("quiet") == NULL) |
version); |
(void)printf("Mail version %s. Type ? for help.\n", |
announce(); |
version); |
(void)fflush(stdout); |
announce(); |
|
(void)fflush(stdout); |
|
(void)signal(SIGINT, prevint); |
|
} |
|
commands(); |
commands(); |
(void)signal(SIGHUP, SIG_IGN); |
(void)ignoresig(SIGHUP, NULL, NULL); |
(void)signal(SIGINT, SIG_IGN); |
(void)ignoresig(SIGINT, NULL, NULL); |
(void)signal(SIGQUIT, SIG_IGN); |
(void)ignoresig(SIGQUIT, NULL, NULL); |
quit(); |
quit(); |
exit(0); |
exit(0); |
} |
} |
|
|
/* |
/* |
* Interrupt printing of the headers. |
|
*/ |
|
void |
|
hdrstop(signo) |
|
int signo; |
|
{ |
|
|
|
fflush(stdout); |
|
fputs("\nInterrupt\n", stderr); |
|
siglongjmp(hdrjmp, 1); |
|
} |
|
|
|
/* |
|
* Compute what the screen size for printing headers should be. |
* Compute what the screen size for printing headers should be. |
* We use the following algorithm for the height: |
* We use the following algorithm for the height: |
* If baud rate < 1200, use 9 |
* If baud rate < 1200, use 9 |
|
|
realscreenheight = 24; |
realscreenheight = 24; |
if ((screenwidth = ws.ws_col) == 0) |
if ((screenwidth = ws.ws_col) == 0) |
screenwidth = 80; |
screenwidth = 80; |
|
} |
|
|
|
__dead void |
|
usage() |
|
{ |
|
|
|
fprintf(stderr, "usage: %s [-iInv] [-s subject] [-c cc-addr] " |
|
"[-b bcc-addr] to-addr ...\n", __progname); |
|
fprintf(stderr, " %*s [- sendmail-options ...]\n", |
|
(int)strlen(__progname), ""); |
|
fprintf(stderr, " %s [-iInNv] -f [name]\n", __progname); |
|
fprintf(stderr, " %s [-iInNv] [-u user]\n", __progname); |
|
exit(1); |
} |
} |