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