/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: temp.c 1.4 89/11/15 $@(#)mailx:temp.c	1.5"
#

#include "rcv.h"

/*
 * mailx -- a modified version of a University of California at Berkeley
 *	mail program
 *
 * Give names to all the temporary files that we will need.
 */


char	tempMail[14];
char	tempQuit[14];
char	tempEdit[14];
char	tempSet[14];
char	tempResid[14];
char	tempMesg[14];
char	tempZedit[14];

tinit()
{
	register char *cp, *cp2;
	char uname[PATHSIZE];
	register int err = 0;
	register int pid;
	char tbuf[PATHSIZE];

	pid = getpid();
	sprintf(tempMail, "/tmp/Rs%-d", pid);
	sprintf(tempResid, "/tmp/Rq%-d", pid);
	sprintf(tempQuit, "/tmp/Rm%-d", pid);
	sprintf(tempEdit, "/tmp/Re%-d", pid);
	sprintf(tempSet, "/tmp/Rx%-d", pid);
	sprintf(tempMesg, "/tmp/Rx%-d", pid);
	sprintf(tempZedit, "/tmp/Rz%-d", pid);

	if (strlen(myname) != 0) {
		uid = getuserid(myname);
		if (uid == -1) {
			printf(gettxt("mailx:180", "\"%s\" is not a user of this system\n"),
			    myname);
			exit(1);
		}
	}
	else {
		uid = getuid() & UIDMASK;
		if (username(uid, uname) < 0) {
			copy("ubluit", myname);
			err++;
			if (rcvmode) {
				printf(gettxt("mailx:181", "Who are you!?\n"));
				exit(1);
			}
		}
		else
			copy(uname, myname);
	}
	strcpy(homedir, Getf("HOME"));
	findmail();
	assign("MBOX", Getf("MBOX"));
	assign("MAILRC", Getf("MAILRC"));
	assign("DEAD", Getf("DEAD"));
	assign("save", "");
	assign("asksub", "");
	assign("header", "");
}
