Back to index

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