xref: /csrg-svn/usr.bin/mail/temp.c (revision 38698)
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
634905Sbostic  * provided that the above copyright notice and this paragraph are
734905Sbostic  * duplicated in all such forms and that any documentation,
834905Sbostic  * advertising materials, and other materials related to such
934905Sbostic  * distribution and use acknowledge that the software was developed
1034905Sbostic  * by the University of California, Berkeley.  The name of the
1134905Sbostic  * University may not be used to endorse or promote products derived
1234905Sbostic  * from this software without specific prior written permission.
1334905Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434905Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534905Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1622468Sdist  */
1722468Sdist 
1834905Sbostic #ifndef lint
19*38698Sbostic static char sccsid[] = "@(#)temp.c	5.13 (Berkeley) 08/21/89";
2034905Sbostic #endif /* not lint */
211246Skas 
221246Skas #include "rcv.h"
231246Skas 
241246Skas /*
251246Skas  * Mail -- a mail program
261246Skas  *
271246Skas  * Give names to all the temporary files that we will need.
281246Skas  */
291246Skas 
3037870Sbostic char	tempMail[24];
3137870Sbostic char	tempQuit[24];
3237870Sbostic char	tempEdit[24];
3337870Sbostic char	tempSet[24];
3437870Sbostic char	tempResid[24];
3537870Sbostic char	tempMesg[24];
361246Skas 
371246Skas tinit()
381246Skas {
3931142Sedward 	register char *cp;
401246Skas 
4137870Sbostic 	strcpy(tempMail, _PATH_TMP);
42*38698Sbostic 	mktemp(strcat(tempMail, "RsXXXXXX"));
4337870Sbostic 	strcpy(tempResid, _PATH_TMP);
44*38698Sbostic 	mktemp(strcat(tempResid, "RqXXXXXX"));
4537870Sbostic 	strcpy(tempQuit, _PATH_TMP);
46*38698Sbostic 	mktemp(strcat(tempQuit, "RmXXXXXX"));
4737870Sbostic 	strcpy(tempEdit, _PATH_TMP);
48*38698Sbostic 	mktemp(strcat(tempEdit, "ReXXXXXX"));
4937870Sbostic 	strcpy(tempSet, _PATH_TMP);
50*38698Sbostic 	mktemp(strcat(tempSet, "RxXXXXXX"));
5137870Sbostic 	strcpy(tempMesg, _PATH_TMP);
52*38698Sbostic 	mktemp(strcat(tempMesg, "RxXXXXXX"));
531246Skas 
5434968Sedward 	/*
5534968Sedward 	 * It's okay to call savestr in here because main will
5634968Sedward 	 * do a spreserve() after us.
5734968Sedward 	 */
5834968Sedward 	if (myname != NOSTR) {
5934968Sedward 		if (getuserid(myname) < 0) {
601725Skas 			printf("\"%s\" is not a user of this system\n",
611725Skas 			    myname);
621725Skas 			exit(1);
631725Skas 		}
6434962Sedward 	} else {
6534968Sedward 		if ((cp = username()) == NOSTR) {
6634968Sedward 			myname = "ubluit";
671246Skas 			if (rcvmode) {
681246Skas 				printf("Who are you!?\n");
691246Skas 				exit(1);
701246Skas 			}
7131142Sedward 		} else
7234968Sedward 			myname = savestr(cp);
731246Skas 	}
7435374Sedward 	if ((cp = getenv("HOME")) == NOSTR)
751246Skas 		cp = ".";
7634968Sedward 	homedir = savestr(cp);
7734968Sedward 	if (debug)
7835374Sedward 		printf("user = %s, homedir = %s\n", myname, homedir);
791246Skas }
80