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