1 /* 2 * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _GETOPT_H 6 #define _GETOPT_H 7 8 9 #include <unistd.h> 10 11 12 /* This header defines the available GNU extensions to the getopt() functionality */ 13 14 struct option { 15 const char *name; 16 int has_arg; 17 int *flag; 18 int val; 19 }; 20 21 /* Options for the "has_arg" field */ 22 23 #define no_argument 0 24 #define required_argument 1 25 #define optional_argument 2 26 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 extern int getopt_long(int argc, char * const *argv, const char *shortOptions, 33 const struct option *longOptions, int *_longIndex); 34 extern int getopt_long_only(int argc, char * const *argv, const char *shortOptions, 35 const struct option *longOptions, int *_longIndex); 36 37 #ifdef __cplusplus 38 } 39 #endif 40 41 #endif /* _GETOPT_H */ 42