cctools
|
00001 /* Internal declarations for getopt. 00002 Copyright (C) 1989-1994,1996-1999,2001,2003,2004 00003 Free Software Foundation, Inc. 00004 This file is part of the GNU C Library. 00005 00006 The GNU C Library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 The GNU C Library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with the GNU C Library; if not, write to the Free 00018 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00019 02111-1307 USA. */ 00020 00021 #ifndef _GETOPT_INT_H 00022 #define _GETOPT_INT_H 1 00023 00024 extern int _getopt_internal (int ___argc, char *const *___argv, 00025 const char *__shortopts, 00026 const struct option *__longopts, int *__longind, 00027 int __long_only); 00028 00029 00030 /* Reentrant versions which can handle parsing multiple argument 00031 vectors at the same time. */ 00032 00033 /* Data type for reentrant functions. */ 00034 struct _getopt_data 00035 { 00036 /* These have exactly the same meaning as the corresponding global 00037 variables, except that they are used for the reentrant 00038 versions of getopt. */ 00039 int optind; 00040 int opterr; 00041 int optopt; 00042 char *optarg; 00043 00044 /* Internal members. */ 00045 00046 /* True if the internal members have been initialized. */ 00047 int __initialized; 00048 00049 /* The next char to be scanned in the option-element 00050 in which the last option character we returned was found. 00051 This allows us to pick up the scan where we left off. 00052 00053 If this is zero, or a null string, it means resume the scan 00054 by advancing to the next ARGV-element. */ 00055 char *__nextchar; 00056 00057 /* Describe how to deal with options that follow non-option ARGV-elements. 00058 00059 If the caller did not specify anything, 00060 the default is REQUIRE_ORDER if the environment variable 00061 POSIXLY_CORRECT is defined, PERMUTE otherwise. 00062 00063 REQUIRE_ORDER means don't recognize them as options; 00064 stop option processing when the first non-option is seen. 00065 This is what Unix does. 00066 This mode of operation is selected by either setting the environment 00067 variable POSIXLY_CORRECT, or using `+' as the first character 00068 of the list of option characters. 00069 00070 PERMUTE is the default. We permute the contents of ARGV as we 00071 scan, so that eventually all the non-options are at the end. 00072 This allows options to be given in any order, even with programs 00073 that were not written to expect this. 00074 00075 RETURN_IN_ORDER is an option available to programs that were 00076 written to expect options and other ARGV-elements in any order 00077 and that care about the ordering of the two. We describe each 00078 non-option ARGV-element as if it were the argument of an option 00079 with character code 1. Using `-' as the first character of the 00080 list of option characters selects this mode of operation. 00081 00082 The special argument `--' forces an end of option-scanning regardless 00083 of the value of `ordering'. In the case of RETURN_IN_ORDER, only 00084 `--' can cause `getopt' to return -1 with `optind' != ARGC. */ 00085 00086 enum 00087 { 00088 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER 00089 } __ordering; 00090 00091 /* If the POSIXLY_CORRECT environment variable is set. */ 00092 int __posixly_correct; 00093 00094 00095 /* Handle permutation of arguments. */ 00096 00097 /* Describe the part of ARGV that contains non-options that have 00098 been skipped. `first_nonopt' is the index in ARGV of the first 00099 of them; `last_nonopt' is the index after the last of them. */ 00100 00101 int __first_nonopt; 00102 int __last_nonopt; 00103 00104 #if defined _LIBC && defined USE_NONOPTION_FLAGS 00105 int __nonoption_flags_max_len; 00106 int __nonoption_flags_len; 00107 # endif 00108 }; 00109 00110 /* The initializer is necessary to set OPTIND and OPTERR to their 00111 default values and to clear the initialization flag. */ 00112 #define _GETOPT_DATA_INITIALIZER { 1, 1 } 00113 00114 extern int _getopt_internal_r (int ___argc, char *const *___argv, 00115 const char *__shortopts, 00116 const struct option *__longopts, int *__longind, 00117 int __long_only, struct _getopt_data *__data); 00118 00119 extern int _getopt_long_r (int ___argc, char *const *___argv, 00120 const char *__shortopts, 00121 const struct option *__longopts, int *__longind, 00122 struct _getopt_data *__data); 00123 00124 extern int _getopt_long_only_r (int ___argc, char *const *___argv, 00125 const char *__shortopts, 00126 const struct option *__longopts, 00127 int *__longind, 00128 struct _getopt_data *__data); 00129 00130 #endif /* getopt_int.h */