Flush out the last dregs in the terminal before quitting when
[unix-history] / usr / src / usr.bin / mail / temp.c
index f39ef5b..ce9a9e6 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)temp.c     5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)temp.c     5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -37,8 +37,6 @@ char  tempMesg[14];
 tinit()
 {
        register char *cp;
 tinit()
 {
        register char *cp;
-       char uname[PATHSIZE];
-       uid_t getuid();
 
        mktemp(strcpy(tempMail, "/tmp/RsXXXXXX"));
        mktemp(strcpy(tempResid, "/tmp/RqXXXXXX"));
 
        mktemp(strcpy(tempMail, "/tmp/RsXXXXXX"));
        mktemp(strcpy(tempResid, "/tmp/RqXXXXXX"));
@@ -47,32 +45,29 @@ tinit()
        mktemp(strcpy(tempSet, "/tmp/RxXXXXXX"));
        mktemp(strcpy(tempMesg, "/tmp/RxXXXXXX"));
 
        mktemp(strcpy(tempSet, "/tmp/RxXXXXXX"));
        mktemp(strcpy(tempMesg, "/tmp/RxXXXXXX"));
 
-       if (strlen(myname) != 0) {
-               uid = getuserid(myname);
-               if (uid == -1) {
+       /*
+        * It's okay to call savestr in here because main will
+        * do a spreserve() after us.
+        */
+       if (myname != NOSTR) {
+               if (getuserid(myname) < 0) {
                        printf("\"%s\" is not a user of this system\n",
                            myname);
                        exit(1);
                }
                        printf("\"%s\" is not a user of this system\n",
                            myname);
                        exit(1);
                }
-       }
-       else {
-               uid = getuid();
-               if (username(uid, uname) < 0) {
-                       strcpy(myname, "ubluit");
+       } else {
+               if ((cp = username()) == NOSTR) {
+                       myname = "ubluit";
                        if (rcvmode) {
                                printf("Who are you!?\n");
                                exit(1);
                        }
                } else
                        if (rcvmode) {
                                printf("Who are you!?\n");
                                exit(1);
                        }
                } else
-                       strcpy(myname, uname);
+                       myname = savestr(cp);
        }
        }
-       if ((cp = value("HOME")) == NOSTR)
+       if ((cp = getenv("HOME")) == NOSTR)
                cp = ".";
                cp = ".";
-       strcpy(homedir, cp);
-       strcpy(copy(homedir, mailrc), "/.mailrc");
-       strcpy(copy(homedir, deadletter), "/dead.letter");
-       if (debug) {
-               printf("uid = %d, user = %s\n", uid, myname);
-               printf("deadletter = %s, mailrc = %s\n", deadletter, mailrc);
-       }
+       homedir = savestr(cp);
+       if (debug)
+               printf("user = %s, homedir = %s\n", myname, homedir);
 }
 }