8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mailx / usg.local.c
blob2519e5e0211e0fc9b2f36a0f0397292bad9a0bc4
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 * The Regents of the University of California
34 * All Rights Reserved
36 * University Acknowledgment- Portions of this document are derived from
37 * software developed by the University of California, Berkeley, and its
38 * contributors.
41 #pragma ident "%Z%%M% %I% %E% SMI"
44 * mailx -- a modified version of a University of California at Berkeley
45 * mail program
47 * Local routines that are installation dependent.
50 #include "rcv.h"
52 static int ismailbox(char *file);
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.
59 void
60 findmail(char *name)
62 register char *cp;
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;
76 if (issysmbox)
77 lockname = strrchr(mailname, '/') + 1;
81 * Make sure file matches (/usr|/var)(/spool)?/mail/.
82 * If is does, it's a "system mailbox", return true.
84 static int
85 ismailbox(char *file)
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
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