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