* Startup -- interface with user.
*/
-static char *SccsId = "@(#)main.c 1.2 %G%";
+static char *SccsId = "@(#)main.c 2.8 %G%";
+
+jmp_buf hdrjmp;
/*
* Find out who the user is, copy his mail file (if exists) into
{
register char *ef;
register int i, argp;
- int mustsend, uflag;
+ int mustsend, uflag, hdrstop(), (*prevint)(), f;
FILE *ibuf, *ftat;
extern char _sobuf[];
+ struct sgttyb tbuf;
#ifdef signal
Siginit();
mypid = getpid();
intty = isatty(0);
outtty = isatty(1);
+ if (outtty) {
+ gtty(1, &tbuf);
+ baud = tbuf.sg_ospeed;
+ }
+ else
+ baud = B9600;
image = -1;
setbuf(stdout, _sobuf);
i++;
break;
+ case 'T':
+ /*
+ * Next argument is temp file to write which
+ * articles have been read/deleted for netnews.
+ */
+ if (i >= argc - 1) {
+ fprintf(stderr, "Name required after -T\n");
+ exit(1);
+ }
+ Tflag = argv[i+1];
+ if ((f = creat(Tflag, 0600)) < 0) {
+ perror(Tflag);
+ exit(1);
+ }
+ close(f);
+ i++;
+ break;
+
case 'u':
/*
* Next argument is person to pretend to be.
*/
uflag++;
if (i >= argc - 1) {
- fprintf(stderr, "You obviously dont know what you're doing\n");
+ fprintf(stderr, "Missing user name for -u\n");
exit(1);
}
strcpy(myname, argv[i+1]);
nosrc++;
break;
+ case 'N':
+ /*
+ * Avoid initial header printing.
+ */
+ noheader++;
+ break;
+
default:
fprintf(stderr, "Unknown flag: %s\n", argv[i]);
exit(1);
* Check for inconsistent arguments.
*/
- if (rflag != NOSTR && strcmp(rflag, "daemon") == 0) {
- ftat = fopen("/crp/kas/gotcha", "a");
- if (ftat != NULL) {
- fprintf(ftat, "user daemon, real uid %d\n", getuid());
- fclose(ftat);
- }
- }
if (ef != NOSTR && argp != -1) {
fprintf(stderr, "Cannot give -f and people to send to.\n");
exit(1);
exit(1);
}
tinit();
+ input = stdin;
+ rcvmode = argp == -1;
+ if (!nosrc)
+ load(MASTER);
+ load(mailrc);
if (argp != -1) {
- commands();
mail(&argv[argp]);
/*
* the system mailbox, and open up the right stuff.
*/
- rcvmode++;
if (ef != NOSTR) {
+ char *ename;
+
edit++;
- editfile = mailname = ef;
+ ename = expand(ef);
+ if (ename != ef) {
+ ef = (char *) calloc(1, strlen(ename) + 1);
+ strcpy(ef, ename);
+ }
+ editfile = ef;
+ strcpy(mailname, ef);
}
- if (setfile(mailname, edit) < 0)
+ if (setfile(mailname, edit) < 0) {
+ if (edit)
+ perror(mailname);
+ else
+ fprintf(stderr, "No mail for %s\n", myname);
exit(1);
+ }
+ if (!edit && !noheader && value("noheader") == NOSTR) {
+ if (setjmp(hdrjmp) == 0) {
+ if ((prevint = sigset(SIGINT, SIG_IGN)) != SIG_IGN)
+ sigset(SIGINT, hdrstop);
+ announce();
+ fflush(stdout);
+ sigset(SIGINT, prevint);
+ }
+ }
+ if (edit)
+ newfileinfo();
+ if (!edit && msgCount == 0) {
+ printf("No mail\n");
+ fflush(stdout);
+ exit(0);
+ }
commands();
- if (!edit)
+ if (!edit) {
+ sigset(SIGHUP, SIG_IGN);
+ sigset(SIGINT, SIG_IGN);
+ sigset(SIGQUIT, SIG_IGN);
quit();
+ }
exit(0);
}
+
+/*
+ * Interrupt printing of the headers.
+ */
+hdrstop()
+{
+
+ clrbuf(stdout);
+ printf("\nInterrupt\n");
+ fflush(stdout);
+ sigrelse(SIGINT);
+ longjmp(hdrjmp, 1);
+}