xref: /original-bsd/usr.bin/mail/temp.c (revision 91abda3c)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)temp.c	5.14 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 #include "rcv.h"
13 
14 /*
15  * Mail -- a mail program
16  *
17  * Give names to all the temporary files that we will need.
18  */
19 
20 char	tempMail[24];
21 char	tempQuit[24];
22 char	tempEdit[24];
23 char	tempSet[24];
24 char	tempResid[24];
25 char	tempMesg[24];
26 
27 tinit()
28 {
29 	register char *cp;
30 
31 	strcpy(tempMail, _PATH_TMP);
32 	mktemp(strcat(tempMail, "RsXXXXXX"));
33 	strcpy(tempResid, _PATH_TMP);
34 	mktemp(strcat(tempResid, "RqXXXXXX"));
35 	strcpy(tempQuit, _PATH_TMP);
36 	mktemp(strcat(tempQuit, "RmXXXXXX"));
37 	strcpy(tempEdit, _PATH_TMP);
38 	mktemp(strcat(tempEdit, "ReXXXXXX"));
39 	strcpy(tempSet, _PATH_TMP);
40 	mktemp(strcat(tempSet, "RxXXXXXX"));
41 	strcpy(tempMesg, _PATH_TMP);
42 	mktemp(strcat(tempMesg, "RxXXXXXX"));
43 
44 	/*
45 	 * It's okay to call savestr in here because main will
46 	 * do a spreserve() after us.
47 	 */
48 	if (myname != NOSTR) {
49 		if (getuserid(myname) < 0) {
50 			printf("\"%s\" is not a user of this system\n",
51 			    myname);
52 			exit(1);
53 		}
54 	} else {
55 		if ((cp = username()) == NOSTR) {
56 			myname = "ubluit";
57 			if (rcvmode) {
58 				printf("Who are you!?\n");
59 				exit(1);
60 			}
61 		} else
62 			myname = savestr(cp);
63 	}
64 	if ((cp = getenv("HOME")) == NOSTR)
65 		cp = ".";
66 	homedir = savestr(cp);
67 	if (debug)
68 		printf("user = %s, homedir = %s\n", myname, homedir);
69 }
70