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