Merge branch 'master' of ../null
[unleashed.git] / include / getopt.h
blobadf98d096c4b05693d9c00e2a970e5c45011cbcf
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 2014 Garrett D'Amore <garrett@damore.org>
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
30 * GNU-like getopt_long(), getopt_long_only().
31 * Solaris-specific getopt_clip().
34 #ifndef _GETOPT_H
35 #define _GETOPT_H
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
43 * Values for has_arg field.
45 * optional_argument is not supported by getopt_clip()
47 #define no_argument 0
48 #define required_argument 1
49 #define optional_argument 2
51 struct option {
52 char *name; /* name of long option */
53 int has_arg; /* whether option takes an argument */
54 int *flag; /* if not NULL, set *flag to val when option found */
55 int val; /* if flag is not NULL, value to set *flag to. */
56 /* if flag is NULL, return value */
60 * External variables used by these routines.
62 extern char *optarg;
63 extern int opterr;
64 extern int optind;
65 extern int optopt;
68 * The use of getopt_long_only in new development is strongly discouraged.
70 extern int getopt_long(int, char * const *, const char *,
71 const struct option *, int *);
72 extern int getopt_long_only(int, char * const *, const char *,
73 const struct option *, int *);
74 extern int getopt_clip(int, char * const *, const char *,
75 const struct option *, int *);
77 #ifdef __cplusplus
79 #endif
81 #endif /* _GETOPT_H */