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 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 * Returned chars for getopt_ext
40 /* A non-option argument was found */
41 #define GETOPT_NON_OPTION_ARG 1
43 /* All arguments have been parsed */
44 #define GETOPT_DONE_PARSING -1
46 /* An invalid option was found */
47 #define GETOPT_ERR_INVALID_OPT -2
49 /* An invalid non-option argument was found */
50 #define GETOPT_ERR_INVALID_ARG -3
52 /* No argument for valid option expecting an argument */
53 #define GETOPT_ERR_MISSING_ARG -4
60 * Identical to getopt(3), except that
62 * 1. If "-" is the first character of optstring, each non-option argv
63 * element is handled as if it were the argument of an option with
64 * character code GETOPT_NON_OPTION_ARG. The result is that
65 * GETOPT_DONE_PARSING will not be returned until the end of the
66 * argument list has been reached.
68 * This mirrors the functionality provided by GNU getopt.
70 * 2. GETOPT_ERR_INVALID_OPT or GETOPT_ERR_MISSING_ARG is returned
71 * instead of '?'. Subsequently "-?" can be used as a valid
74 * 3. GETOPT_DONE_PARSING, GETOPT_ERR_INVALID_ARG, or
75 * GETOPT_NON_OPTION_ARG is returned instead of -1.
78 * The number of arguments in the array
84 * The option letters, with ':' following options with
85 * required arguments. See note about "-" as the first
88 * @return GETOPT_ERR_INVALID_OPT
89 * if the option is not found in optstring
91 * GETOPT_ERR_MISSING_ARG
92 * if the option requires an argument which is missing
94 * GETOPT_ERR_INVALID_ARG
95 * if "-" is not the first character in optstring and a
96 * non-option argument is encountered
98 * GETOPT_NON_OPTION_ARG
99 * if "-" is the first character in optstring and a
100 * non-option argument is encountered
102 * GETOPT_DONE_PARSING
103 * if the end of the argument list is reached
106 * the option character itself, if none of the above
109 extern int getopt_ext(int argc
, char * const argv
[], const char *optstring
);
115 #endif /* _GETOPTEXT_H */