1 /* 2 This getopt_long() is compatible with GNU's, however, added original 3 extention (short 1 byte option). 4 5 6 Copyright (c) 2004 Koji Arai 7 8 Permission is hereby granted, free of charge, to any person 9 obtaining a copy of this software and associated documentation files 10 (the "Software"), to deal in the Software without restriction, 11 including without limitation the rights to use, copy, modify, merge, 12 publish, distribute, sublicense, and/or sell copies of the Software, 13 and to permit persons to whom the Software is furnished to do so, 14 subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be 17 included in all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 SOFTWARE. 27 */ 28 29 #ifndef _GETOPT_H 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 struct option { 36 const char *name; 37 int has_arg; 38 39 /* values of has_arg */ 40 #define no_argument 0 41 #define required_argument 1 42 #define optional_argument 2 43 44 int *flag; 45 int val; 46 }; 47 48 extern char *optarg; 49 extern int optind; 50 51 int getopt_long(int argc, char **argv, 52 const char *shortopts, 53 struct option *longopts, 54 int *indexptr); 55 56 #ifdef __cplusplus 57 } 58 #endif 59 60 #endif /* _GETOPT_H */ 61