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 2014 Garrett D'Amore <garrett@damore.org> 24 * 25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 /* 30 * Copyright 2020 Joyent Inc. 31 */ 32 33 /* 34 * GNU-like getopt_long(), getopt_long_only(). 35 * Solaris-specific getopt_clip(). 36 */ 37 38 #ifndef _GETOPT_H 39 #define _GETOPT_H 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 46 /* 47 * Values for has_arg field. 48 * 49 * optional_argument is not supported by getopt_clip() 50 */ 51 #define no_argument 0 52 #define required_argument 1 53 #define optional_argument 2 54 55 struct option { 56 const char *name; /* name of long option */ 57 int has_arg; /* whether option takes an argument */ 58 int *flag; /* if not NULL, set *flag to val when option */ 59 /* found */ 60 int val; /* if flag is not NULL, value to set *flag */ 61 /* to. */ 62 /* if flag is NULL, return value */ 63 }; 64 65 /* 66 * External variables used by these routines. 67 */ 68 extern char *optarg; 69 extern int opterr; 70 extern int optind; 71 extern int optopt; 72 73 /* 74 * The use of getopt_long_only in new development is strongly discouraged. 75 */ 76 extern int getopt_long(int, char * const *, const char *, 77 const struct option *, int *); 78 extern int getopt_long_only(int, char * const *, const char *, 79 const struct option *, int *); 80 extern int getopt_clip(int, char * const *, const char *, 81 const struct option *, int *); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif /* _GETOPT_H */ 88