xref: /csrg-svn/usr.bin/mail/temp.c (revision 42741)
122468Sdist /*
222468Sdist  * Copyright (c) 1980 Regents of the University of California.
333499Sbostic  * All rights reserved.
433499Sbostic  *
5*42741Sbostic  * %sccs.include.redist.c%
622468Sdist  */
722468Sdist 
834905Sbostic #ifndef lint
9*42741Sbostic static char sccsid[] = "@(#)temp.c	5.14 (Berkeley) 06/01/90";
1034905Sbostic #endif /* not lint */
111246Skas 
121246Skas #include "rcv.h"
131246Skas 
141246Skas /*
151246Skas  * Mail -- a mail program
161246Skas  *
171246Skas  * Give names to all the temporary files that we will need.
181246Skas  */
191246Skas 
2037870Sbostic char	tempMail[24];
2137870Sbostic char	tempQuit[24];
2237870Sbostic char	tempEdit[24];
2337870Sbostic char	tempSet[24];
2437870Sbostic char	tempResid[24];
2537870Sbostic char	tempMesg[24];
261246Skas 
271246Skas tinit()
281246Skas {
2931142Sedward 	register char *cp;
301246Skas 
3137870Sbostic 	strcpy(tempMail, _PATH_TMP);
3238698Sbostic 	mktemp(strcat(tempMail, "RsXXXXXX"));
3337870Sbostic 	strcpy(tempResid, _PATH_TMP);
3438698Sbostic 	mktemp(strcat(tempResid, "RqXXXXXX"));
3537870Sbostic 	strcpy(tempQuit, _PATH_TMP);
3638698Sbostic 	mktemp(strcat(tempQuit, "RmXXXXXX"));
3737870Sbostic 	strcpy(tempEdit, _PATH_TMP);
3838698Sbostic 	mktemp(strcat(tempEdit, "ReXXXXXX"));
3937870Sbostic 	strcpy(tempSet, _PATH_TMP);
4038698Sbostic 	mktemp(strcat(tempSet, "RxXXXXXX"));
4137870Sbostic 	strcpy(tempMesg, _PATH_TMP);
4238698Sbostic 	mktemp(strcat(tempMesg, "RxXXXXXX"));
431246Skas 
4434968Sedward 	/*
4534968Sedward 	 * It's okay to call savestr in here because main will
4634968Sedward 	 * do a spreserve() after us.
4734968Sedward 	 */
4834968Sedward 	if (myname != NOSTR) {
4934968Sedward 		if (getuserid(myname) < 0) {
501725Skas 			printf("\"%s\" is not a user of this system\n",
511725Skas 			    myname);
521725Skas 			exit(1);
531725Skas 		}
5434962Sedward 	} else {
5534968Sedward 		if ((cp = username()) == NOSTR) {
5634968Sedward 			myname = "ubluit";
571246Skas 			if (rcvmode) {
581246Skas 				printf("Who are you!?\n");
591246Skas 				exit(1);
601246Skas 			}
6131142Sedward 		} else
6234968Sedward 			myname = savestr(cp);
631246Skas 	}
6435374Sedward 	if ((cp = getenv("HOME")) == NOSTR)
651246Skas 		cp = ".";
6634968Sedward 	homedir = savestr(cp);
6734968Sedward 	if (debug)
6835374Sedward 		printf("user = %s, homedir = %s\n", myname, homedir);
691246Skas }
70