4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mail / v7.local.c
index 84b1c6c..c624950 100644 (file)
@@ -1,4 +1,13 @@
-#
+/*
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) %G%";
+#endif /* not lint */
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
  */
 
 #include "rcv.h"
  */
 
 #include "rcv.h"
-
-static char *SccsId = "@(#)v7.local.c  1.2 %G%";
+#include <fcntl.h>
+#include "extern.h"
 
 /*
  * Locate the user's mailbox file (ie, the place where new, unread
 
 /*
  * Locate the user's mailbox file (ie, the place where new, unread
- * mail is queued).  In Version 7, it is in /usr/spool/mail/name.
+ * mail is queued).
  */
  */
-
-findmail()
+void
+findmail(user, buf)
+       char *user, *buf;
 {
 {
-       register char *cp;
-
-       cp = copy("/usr/spool/mail/", mailname);
-       copy(myname, cp);
-       if (isdir(mailname)) {
-               stradd(mailname, '/');
-               strcat(mailname, myname);
-       }
+       (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, user);
 }
 
 /*
  * Get rid of the queued mail.
  */
 }
 
 /*
  * Get rid of the queued mail.
  */
-
+void
 demail()
 {
 
 demail()
 {
 
-       remove(mailname);
+       if (value("keep") != NOSTR || rm(mailname) < 0)
+               close(creat(mailname, 0600));
 }
 
 /*
  * Discover user login name.
  */
 }
 
 /*
  * Discover user login name.
  */
-
-username(uid, namebuf)
-       char namebuf[];
+char *
+username()
 {
 {
-       register char *np;
+       char *np;
 
 
-       if (uid == getuid() && (np = getenv("USER")) != NOSTR) {
-               strncpy(namebuf, np, PATHSIZE);
-               return(0);
-       }
-       return(getname(uid, namebuf));
+       if ((np = getenv("USER")) != NOSTR)
+               return np;
+       return getname(getuid());
 }
 }