added [ and ] tokens for vectors, haven't done the real work yet.
[unix-history] / usr / src / usr.bin / mail / temp.c
CommitLineData
761330fe
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
2ae9f53f 7#ifndef lint
2fd8b883 8static char *sccsid = "@(#)temp.c 5.2 (Berkeley) %G%";
761330fe 9#endif not lint
ca3f0029
KS
10
11#include "rcv.h"
12
13/*
14 * Mail -- a mail program
15 *
16 * Give names to all the temporary files that we will need.
17 */
18
ca3f0029
KS
19char tempMail[14];
20char tempQuit[14];
21char tempEdit[14];
22char tempSet[14];
23char tempResid[14];
24char tempMesg[14];
25
26tinit()
27{
28 register char *cp, *cp2;
6d3a0f2f 29 char uname[PATHSIZE];
ca3f0029
KS
30 register int err = 0;
31 register int pid;
32
33 pid = getpid();
34 sprintf(tempMail, "/tmp/Rs%05d", pid);
35 sprintf(tempResid, "/tmp/Rq%05d", pid);
36 sprintf(tempQuit, "/tmp/Rm%05d", pid);
37 sprintf(tempEdit, "/tmp/Re%05d", pid);
38 sprintf(tempSet, "/tmp/Rx%05d", pid);
39 sprintf(tempMesg, "/tmp/Rx%05d", pid);
40
41 if (strlen(myname) != 0) {
42 uid = getuserid(myname);
95bf992b
KS
43 if (uid == -1) {
44 printf("\"%s\" is not a user of this system\n",
45 myname);
46 exit(1);
47 }
ca3f0029
KS
48 }
49 else {
50 uid = getuid() & UIDMASK;
51 if (username(uid, uname) < 0) {
52 copy("ubluit", myname);
ca3f0029
KS
53 err++;
54 if (rcvmode) {
55 printf("Who are you!?\n");
56 exit(1);
57 }
58 }
95bf992b
KS
59 else
60 copy(uname, myname);
ca3f0029 61 }
ca3f0029
KS
62 cp = value("HOME");
63 if (cp == NOSTR)
64 cp = ".";
65 copy(cp, homedir);
66 findmail();
67 cp = copy(homedir, mbox);
68 copy("/mbox", cp);
69 cp = copy(homedir, mailrc);
70 copy("/.mailrc", cp);
71 cp = copy(homedir, deadletter);
72 copy("/dead.letter", cp);
73 if (debug) {
74 printf("uid = %d, user = %s, mailname = %s\n",
75 uid, myname, mailname);
76 printf("deadletter = %s, mailrc = %s, mbox = %s\n",
77 deadletter, mailrc, mbox);
78 }
79}