xref: /csrg-svn/usr.bin/mail/v7.local.c (revision 31142)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char *sccsid = "@(#)v7.local.c	5.3 (Berkeley) 05/18/87";
9 #endif not lint
10 
11 /*
12  * Mail -- a mail program
13  *
14  * Version 7
15  *
16  * Local routines that are installation dependent.
17  */
18 
19 #include "rcv.h"
20 
21 /*
22  * Locate the user's mailbox file (ie, the place where new, unread
23  * mail is queued).  In Version 7, it is in /usr/spool/mail/name.
24  */
25 
26 findmail()
27 {
28 
29 	strcpy(copy("/usr/spool/mail/", mailname), myname);
30 	if (isdir(mailname)) {
31 		stradd(mailname, '/');
32 		strcat(mailname, myname);
33 	}
34 }
35 
36 /*
37  * Get rid of the queued mail.
38  */
39 
40 demail()
41 {
42 
43 	if (value("keep") != NOSTR)
44 		close(creat(mailname, 0666));
45 	else {
46 		if (remove(mailname) < 0)
47 			close(creat(mailname, 0666));
48 	}
49 }
50 
51 /*
52  * Discover user login name.
53  */
54 
55 username(uid, namebuf)
56 	char namebuf[];
57 {
58 	register char *np;
59 
60 	if (uid == getuid() && (np = getenv("USER")) != NOSTR) {
61 		strncpy(namebuf, np, PATHSIZE);
62 		return(0);
63 	}
64 	return(getname(uid, namebuf));
65 }
66