1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)temp.c 5.16 (Berkeley) 03/11/92"; 10 #endif /* not lint */ 11 12 #include <errno.h> 13 #include "rcv.h" 14 15 /* 16 * Mail -- a mail program 17 * 18 * Give names to all the temporary files that we will need. 19 */ 20 21 char tempMail[24]; 22 char tempQuit[24]; 23 char tempEdit[24]; 24 char tempResid[24]; 25 char tempMesg[24]; 26 char *tmpdir; 27 28 tinit() 29 { 30 register char *cp; 31 int len; 32 33 if ((tmpdir = getenv("TMPDIR")) == NULL) 34 tmpdir = _PATH_TMP; 35 else { 36 len = strlen(tmpdir); 37 if ((cp = malloc(len + 2)) == NULL) { 38 (void)fprintf(stderr, "mail: %s\n", strerror(errno)); 39 exit (1); 40 } 41 (void)strcpy(cp, tmpdir); 42 cp[len] = '/'; 43 cp[len + 1] = '\0'; 44 tmpdir = cp; 45 } 46 47 strcpy(tempMail, tmpdir); 48 mktemp(strcat(tempMail, "RsXXXXXX")); 49 strcpy(tempResid, tmpdir); 50 mktemp(strcat(tempResid, "RqXXXXXX")); 51 strcpy(tempQuit, tmpdir); 52 mktemp(strcat(tempQuit, "RmXXXXXX")); 53 strcpy(tempEdit, tmpdir); 54 mktemp(strcat(tempEdit, "ReXXXXXX")); 55 strcpy(tempMesg, tmpdir); 56 mktemp(strcat(tempMesg, "RxXXXXXX")); 57 58 /* 59 * It's okay to call savestr in here because main will 60 * do a spreserve() after us. 61 */ 62 if (myname != NOSTR) { 63 if (getuserid(myname) < 0) { 64 printf("\"%s\" is not a user of this system\n", 65 myname); 66 exit(1); 67 } 68 } else { 69 if ((cp = username()) == NOSTR) { 70 myname = "ubluit"; 71 if (rcvmode) { 72 printf("Who are you!?\n"); 73 exit(1); 74 } 75 } else 76 myname = savestr(cp); 77 } 78 if ((cp = getenv("HOME")) == NOSTR) 79 cp = "."; 80 homedir = savestr(cp); 81 if (debug) 82 printf("user = %s, homedir = %s\n", myname, homedir); 83 } 84