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 /* 23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 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 /* 42 * mailx -- a modified version of a University of California at Berkeley 43 * mail program 44 * 45 * Local routines that are installation dependent. 46 */ 47 48 #include "rcv.h" 49 50 static int ismailbox(char *file); 51 52 /* 53 * Locate the user's mailbox file (ie, the place where new, unread 54 * mail is queued). In SVr4 UNIX, it is in /var/mail/name. 55 * In preSVr4 UNIX, it is in either /usr/mail/name or /usr/spool/mail/name. 56 */ 57 void 58 findmail(char *name) 59 { 60 register char *cp; 61 62 if (name != NOSTR) { 63 copy(name, copy(maildir, mailname)); 64 issysmbox = 1; /* it's a system mailbox */ 65 } else if ((cp = getenv("MAIL")) != NULL) { 66 /* if $MAIL is set, use it */ 67 nstrcpy(mailname, PATHSIZE, cp); 68 issysmbox = ismailbox(mailname); 69 /* XXX - should warn that there's no locking? */ 70 } else { 71 copy(myname, copy(maildir, mailname)); 72 issysmbox = 1; 73 } 74 if (issysmbox) 75 lockname = strrchr(mailname, '/') + 1; 76 } 77 78 /* 79 * Make sure file matches (/usr|/var)(/spool)?/mail/. 80 * If is does, it's a "system mailbox", return true. 81 */ 82 static int 83 ismailbox(char *file) 84 { 85 #ifdef preSVr4 86 return (strncmp(file, maildir, strlen(maildir)) == 0); 87 #else 88 if (strncmp(file, "/var", 4) != 0 89 && strncmp(file, "/usr", 4) != 0 90 ) 91 return (0); 92 file += 4; 93 if (strncmp(file, "/spool", 6) == 0) 94 file += 6; 95 return (strncmp(file, "/mail/", 6) == 0); 96 #endif 97 } 98