BSD 4_4_Lite2 release
[unix-history] / usr / src / usr.bin / mail / main.c
index 1e1579b..0dfac86 100644 (file)
@@ -38,7 +38,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)main.c     8.2 (Berkeley) 4/20/95";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -66,6 +66,7 @@ main(argc, argv)
        void hdrstop();
        sig_t prevint;
        void sigchild();
        void hdrstop();
        sig_t prevint;
        void sigchild();
+       char *rc;
 
        /*
         * Set up a reasonable environment.
 
        /*
         * Set up a reasonable environment.
@@ -213,7 +214,9 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
         * Expand returns a savestr, but load only uses the file name
         * for fopen, so it's safe to do this.
         */
         * Expand returns a savestr, but load only uses the file name
         * for fopen, so it's safe to do this.
         */
-       load(expand("~/.mailrc"));
+       if ((rc = getenv("MAILRC")) == 0)
+               rc = "~/.mailrc";
+       load(expand(rc));
        if (!rcvmode) {
                mail(to, cc, bcc, smopts, subject);
                /*
        if (!rcvmode) {
                mail(to, cc, bcc, smopts, subject);
                /*
@@ -274,16 +277,19 @@ hdrstop(signo)
 void
 setscreensize()
 {
 void
 setscreensize()
 {
-       struct sgttyb tbuf;
+       struct termios tbuf;
        struct winsize ws;
        struct winsize ws;
+       int ospeed;
 
        if (ioctl(1, TIOCGWINSZ, (char *) &ws) < 0)
                ws.ws_col = ws.ws_row = 0;
 
        if (ioctl(1, TIOCGWINSZ, (char *) &ws) < 0)
                ws.ws_col = ws.ws_row = 0;
-       if (ioctl(1, TIOCGETP, &tbuf) < 0)
-               tbuf.sg_ospeed = B9600;
-       if (tbuf.sg_ospeed < B1200)
+       if (ioctl(1, TIOCGETA, &tbuf) < 0)
+               ospeed = B9600;
+       else
+               ospeed = cfgetospeed(&tbuf);
+       if (ospeed < B1200)
                screenheight = 9;
                screenheight = 9;
-       else if (tbuf.sg_ospeed == B1200)
+       else if (ospeed == B1200)
                screenheight = 14;
        else if (ws.ws_row != 0)
                screenheight = ws.ws_row;
                screenheight = 14;
        else if (ws.ws_row != 0)
                screenheight = ws.ws_row;