xref: /original-bsd/usr.bin/mail/temp.c (revision 0b685140)
1 #
2 
3 #include "rcv.h"
4 
5 /*
6  * Mail -- a mail program
7  *
8  * Give names to all the temporary files that we will need.
9  */
10 
11 static char *SccsId = "@(#)temp.c	2.1 07/01/81";
12 
13 char	tempMail[14];
14 char	tempQuit[14];
15 char	tempEdit[14];
16 char	tempSet[14];
17 char	tempResid[14];
18 char	tempMesg[14];
19 
20 tinit()
21 {
22 	register char *cp, *cp2;
23 	char uname[PATHSIZE];
24 	register int err = 0;
25 	register int pid;
26 
27 	pid = getpid();
28 	sprintf(tempMail, "/tmp/Rs%05d", pid);
29 	sprintf(tempResid, "/tmp/Rq%05d", pid);
30 	sprintf(tempQuit, "/tmp/Rm%05d", pid);
31 	sprintf(tempEdit, "/tmp/Re%05d", pid);
32 	sprintf(tempSet, "/tmp/Rx%05d", pid);
33 	sprintf(tempMesg, "/tmp/Rx%05d", pid);
34 
35 	if (strlen(myname) != 0) {
36 		uid = getuserid(myname);
37 		if (uid == -1) {
38 			printf("\"%s\" is not a user of this system\n",
39 			    myname);
40 			exit(1);
41 		}
42 	}
43 	else {
44 		uid = getuid() & UIDMASK;
45 		if (username(uid, uname) < 0) {
46 			copy("ubluit", myname);
47 			err++;
48 			if (rcvmode) {
49 				printf("Who are you!?\n");
50 				exit(1);
51 			}
52 		}
53 		else
54 			copy(uname, myname);
55 	}
56 	mailname = mailspace;
57 	cp = value("HOME");
58 	if (cp == NOSTR)
59 		cp = ".";
60 	copy(cp, homedir);
61 	findmail();
62 	cp = copy(homedir, mbox);
63 	copy("/mbox", cp);
64 	cp = copy(homedir, mailrc);
65 	copy("/.mailrc", cp);
66 	cp = copy(homedir, deadletter);
67 	copy("/dead.letter", cp);
68 	if (debug) {
69 		printf("uid = %d, user = %s, mailname = %s\n",
70 		    uid, myname, mailname);
71 		printf("deadletter = %s, mailrc = %s, mbox = %s\n",
72 		    deadletter, mailrc, mbox);
73 	}
74 }
75