xref: /csrg-svn/usr.bin/mail/temp.c (revision 34753)
122468Sdist /*
222468Sdist  * Copyright (c) 1980 Regents of the University of California.
333499Sbostic  * All rights reserved.
433499Sbostic  *
533499Sbostic  * Redistribution and use in source and binary forms are permitted
633499Sbostic  * provided that this notice is preserved and that due credit is given
733499Sbostic  * to the University of California at Berkeley. The name of the University
833499Sbostic  * may not be used to endorse or promote products derived from this
933499Sbostic  * software without specific prior written permission. This software
1033499Sbostic  * is provided ``as is'' without express or implied warranty.
1122468Sdist  */
1222468Sdist 
1333499Sbostic #ifdef notdef
14*34753Sedward static char sccsid[] = "@(#)temp.c	5.5 (Berkeley) 06/17/88";
1533499Sbostic #endif /* notdef */
161246Skas 
171246Skas #include "rcv.h"
181246Skas 
191246Skas /*
201246Skas  * Mail -- a mail program
211246Skas  *
221246Skas  * Give names to all the temporary files that we will need.
231246Skas  */
241246Skas 
251246Skas char	tempMail[14];
261246Skas char	tempQuit[14];
271246Skas char	tempEdit[14];
281246Skas char	tempSet[14];
291246Skas char	tempResid[14];
301246Skas char	tempMesg[14];
311246Skas 
321246Skas tinit()
331246Skas {
3431142Sedward 	register char *cp;
351488Skas 	char uname[PATHSIZE];
361246Skas 	register int pid;
3731142Sedward 	uid_t getuid();
381246Skas 
391246Skas 	pid = getpid();
401246Skas 	sprintf(tempMail, "/tmp/Rs%05d", pid);
411246Skas 	sprintf(tempResid, "/tmp/Rq%05d", pid);
421246Skas 	sprintf(tempQuit, "/tmp/Rm%05d", pid);
431246Skas 	sprintf(tempEdit, "/tmp/Re%05d", pid);
441246Skas 	sprintf(tempSet, "/tmp/Rx%05d", pid);
451246Skas 	sprintf(tempMesg, "/tmp/Rx%05d", pid);
461246Skas 
471246Skas 	if (strlen(myname) != 0) {
481246Skas 		uid = getuserid(myname);
491725Skas 		if (uid == -1) {
501725Skas 			printf("\"%s\" is not a user of this system\n",
511725Skas 			    myname);
521725Skas 			exit(1);
531725Skas 		}
541246Skas 	}
551246Skas 	else {
5631142Sedward 		uid = getuid();
571246Skas 		if (username(uid, uname) < 0) {
5831142Sedward 			strcpy(myname, "ubluit");
591246Skas 			if (rcvmode) {
601246Skas 				printf("Who are you!?\n");
611246Skas 				exit(1);
621246Skas 			}
6331142Sedward 		} else
6431142Sedward 			strcpy(myname, uname);
651246Skas 	}
6631142Sedward 	if ((cp = value("HOME")) == NOSTR)
671246Skas 		cp = ".";
6831142Sedward 	strcpy(homedir, cp);
6931142Sedward 	strcpy(copy(homedir, mailrc), "/.mailrc");
7031142Sedward 	strcpy(copy(homedir, deadletter), "/dead.letter");
711246Skas 	if (debug) {
72*34753Sedward 		printf("uid = %d, user = %s\n", uid, myname);
73*34753Sedward 		printf("deadletter = %s, mailrc = %s\n", deadletter, mailrc);
741246Skas 	}
751246Skas }
76