xref: /illumos-gate/usr/src/cmd/mailx/temp.c (revision 2a8bcb4e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright (c) 1985-2001 by Sun Microsystems, Inc.
28  * All rights reserved.
29  */
30 
31 /*
32  * University Copyright- Copyright (c) 1982, 1986, 1988
33  * The Regents of the University of California
34  * All Rights Reserved
35  *
36  * University Acknowledgment- Portions of this document are derived from
37  * software developed by the University of California, Berkeley, and its
38  * contributors.
39  */
40 
41 #include "rcv.h"
42 #include <pwd.h>
43 #include <locale.h>
44 
45 #ifdef preSVr4
46 extern struct passwd *getpwnam();
47 extern struct passwd *getpwuid();
48 #endif
49 
50 /*
51  * mailx -- a modified version of a University of California at Berkeley
52  *	mail program
53  *
54  * Give names to all the temporary files that we will need.
55  */
56 
57 void
tinit(void)58 tinit(void)
59 {
60 	register pid_t pid = mypid;
61 	struct passwd *pwd;
62 
63 
64 	snprintf(tempMail, TMPSIZ, "/tmp/Rs%-ld", pid);
65 	snprintf(tempQuit, TMPSIZ, "/tmp/Rm%-ld", pid);
66 	snprintf(tempEdit, TMPSIZ, "/tmp/Re%-ld", pid);
67 	snprintf(tempMesg, TMPSIZ, "/tmp/Rx%-ld", pid);
68 	snprintf(tempZedit, TMPSIZ, "/tmp/Rz%-ld", pid);
69 
70 	/* get the name associated with this uid */
71 	pwd = getpwuid(uid = myruid);
72 	if (!pwd) {
73 		printf(gettext("Error looking up username for uid=%d\n"), uid);
74 		exit(1);
75 	}
76 	else
77 		copy(pwd->pw_name, myname);
78 	endpwent();
79 
80 	nstrcpy(homedir, PATHSIZE, Getf("HOME"));
81 	findmail(NULL);
82 	assign("MBOX", Getf("MBOX"));
83 	assign("MAILRC", Getf("MAILRC"));
84 	assign("DEAD", Getf("DEAD"));
85 	assign("save", "");
86 	assign("asksub", "");
87 	assign("header", "");
88 	assign("prompt", "? ");
89 	assign("pipeignore", "");
90 	assign("replyall", "");
91 	assign("from", "");
92 	assign("fcc", "");
93 }
94