xref: /original-bsd/usr.bin/mail/v7.local.c (revision c3e32dec)
1 /*
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)v7.local.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 /*
13  * Mail -- a mail program
14  *
15  * Version 7
16  *
17  * Local routines that are installation dependent.
18  */
19 
20 #include "rcv.h"
21 #include <fcntl.h>
22 #include "extern.h"
23 
24 /*
25  * Locate the user's mailbox file (ie, the place where new, unread
26  * mail is queued).
27  */
28 void
29 findmail(user, buf)
30 	char *user, *buf;
31 {
32 	(void)sprintf(buf, "%s/%s", _PATH_MAILDIR, user);
33 }
34 
35 /*
36  * Get rid of the queued mail.
37  */
38 void
39 demail()
40 {
41 
42 	if (value("keep") != NOSTR || rm(mailname) < 0)
43 		close(creat(mailname, 0600));
44 }
45 
46 /*
47  * Discover user login name.
48  */
49 char *
50 username()
51 {
52 	char *np;
53 
54 	if ((np = getenv("USER")) != NOSTR)
55 		return np;
56 	return getname(getuid());
57 }
58