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
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]
23 * Copyright 2005 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 */
31 #pragma ident "%Z%%M% %I% %E% SMI"
35 Parse the command line.
36 Return index of first non-option field (i.e. user)
39 parse(int argc
, char **argv
)
43 static char pn
[] = "parse";
46 "mail +" means to print in reverse order and is
47 equivalent to "mail -r"
49 if ((argc
> 1) && (argv
[1][0] == '+')) {
57 while ((c
= getopt(argc
, argv
, "m:f:x:shrpPqeEdtT:w")) != EOF
) {
60 Set debugging level...
66 /* Keep trace file even if successful */
73 for backwards compatability with mailx...
76 /* ignore this option */
79 * Deliver directly to a mailbox. Do Not go to sendmail
108 * use alternate file as mailfile, when reading mail
109 * use this from user when sending mail.
115 strncpy(from_user
, optarg
, sizeof (from_user
));
116 from_user
[sizeof (from_user
) - 1] = '\0';
133 print without prompting
145 override selective display default setting
168 print by first in, first out order
180 add To: line to letters
199 if (msgtype
[0] == '\0' || msgtype
[0] == '-') {
217 if (argc
== optind
) {
221 "-m option used but no recipient(s) specified.");
226 "-t option used but no recipient(s) specified.");
231 "-w option used but no recipient(s) specified.");
235 if (mailfile
[0] == '-') {
237 "Files names must not begin with '-'");
245 if (ismail
&& (goerr
> 0)) {
246 errmsg(E_SYNTAX
,"Usage: [-ehpPqr] [-f file] [-x debuglevel]");
247 (void) fprintf (stderr
, "or\t[-tw] [-m message_type] [-T file] [-x debuglevel] persons\n");
248 (void) fprintf (stderr
, "or\t[-x debuglevel]\n");