Back to index

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