Blame gnu/getopt_int.h

Packit 1ef1a9
/* Internal declarations for getopt.
Packit 1ef1a9
   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2015 Free Software
Packit 1ef1a9
   Foundation, Inc.
Packit 1ef1a9
   This file is part of the GNU C Library.
Packit 1ef1a9
Packit 1ef1a9
   This program is free software: you can redistribute it and/or modify
Packit 1ef1a9
   it under the terms of the GNU General Public License as published by
Packit 1ef1a9
   the Free Software Foundation; either version 3 of the License, or
Packit 1ef1a9
   (at your option) any later version.
Packit 1ef1a9
Packit 1ef1a9
   This program is distributed in the hope that it will be useful,
Packit 1ef1a9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1ef1a9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 1ef1a9
   GNU General Public License for more details.
Packit 1ef1a9
Packit 1ef1a9
   You should have received a copy of the GNU General Public License
Packit 1ef1a9
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 1ef1a9
Packit 1ef1a9
#ifndef _GETOPT_INT_H
Packit 1ef1a9
#define _GETOPT_INT_H   1
Packit 1ef1a9
Packit 1ef1a9
#include <getopt.h>
Packit 1ef1a9
Packit 1ef1a9
extern int _getopt_internal (int ___argc, char **___argv,
Packit 1ef1a9
                             const char *__shortopts,
Packit 1ef1a9
                             const struct option *__longopts, int *__longind,
Packit 1ef1a9
                             int __long_only, int __posixly_correct);
Packit 1ef1a9
Packit 1ef1a9

Packit 1ef1a9
/* Reentrant versions which can handle parsing multiple argument
Packit 1ef1a9
   vectors at the same time.  */
Packit 1ef1a9
Packit 1ef1a9
/* Describe how to deal with options that follow non-option ARGV-elements.
Packit 1ef1a9
Packit 1ef1a9
   If the caller did not specify anything,
Packit 1ef1a9
   the default is REQUIRE_ORDER if the environment variable
Packit 1ef1a9
   POSIXLY_CORRECT is defined, PERMUTE otherwise.
Packit 1ef1a9
Packit 1ef1a9
   REQUIRE_ORDER means don't recognize them as options;
Packit 1ef1a9
   stop option processing when the first non-option is seen.
Packit 1ef1a9
   This is what Unix does.
Packit 1ef1a9
   This mode of operation is selected by either setting the environment
Packit 1ef1a9
   variable POSIXLY_CORRECT, or using '+' as the first character
Packit 1ef1a9
   of the list of option characters, or by calling getopt.
Packit 1ef1a9
Packit 1ef1a9
   PERMUTE is the default.  We permute the contents of ARGV as we
Packit 1ef1a9
   scan, so that eventually all the non-options are at the end.
Packit 1ef1a9
   This allows options to be given in any order, even with programs
Packit 1ef1a9
   that were not written to expect this.
Packit 1ef1a9
Packit 1ef1a9
   RETURN_IN_ORDER is an option available to programs that were
Packit 1ef1a9
   written to expect options and other ARGV-elements in any order
Packit 1ef1a9
   and that care about the ordering of the two.  We describe each
Packit 1ef1a9
   non-option ARGV-element as if it were the argument of an option
Packit 1ef1a9
   with character code 1.  Using '-' as the first character of the
Packit 1ef1a9
   list of option characters selects this mode of operation.
Packit 1ef1a9
Packit 1ef1a9
   The special argument '--' forces an end of option-scanning regardless
Packit 1ef1a9
   of the value of 'ordering'.  In the case of RETURN_IN_ORDER, only
Packit 1ef1a9
   '--' can cause 'getopt' to return -1 with 'optind' != ARGC.  */
Packit 1ef1a9
Packit 1ef1a9
enum __ord
Packit 1ef1a9
  {
Packit 1ef1a9
    REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
Packit 1ef1a9
  };
Packit 1ef1a9
Packit 1ef1a9
/* Data type for reentrant functions.  */
Packit 1ef1a9
struct _getopt_data
Packit 1ef1a9
{
Packit 1ef1a9
  /* These have exactly the same meaning as the corresponding global
Packit 1ef1a9
     variables, except that they are used for the reentrant
Packit 1ef1a9
     versions of getopt.  */
Packit 1ef1a9
  int optind;
Packit 1ef1a9
  int opterr;
Packit 1ef1a9
  int optopt;
Packit 1ef1a9
  char *optarg;
Packit 1ef1a9
Packit 1ef1a9
  /* Internal members.  */
Packit 1ef1a9
Packit 1ef1a9
  /* True if the internal members have been initialized.  */
Packit 1ef1a9
  int __initialized;
Packit 1ef1a9
Packit 1ef1a9
  /* The next char to be scanned in the option-element
Packit 1ef1a9
     in which the last option character we returned was found.
Packit 1ef1a9
     This allows us to pick up the scan where we left off.
Packit 1ef1a9
Packit 1ef1a9
     If this is zero, or a null string, it means resume the scan
Packit 1ef1a9
     by advancing to the next ARGV-element.  */
Packit 1ef1a9
  char *__nextchar;
Packit 1ef1a9
Packit 1ef1a9
  /* See __ord above.  */
Packit 1ef1a9
  enum __ord __ordering;
Packit 1ef1a9
Packit 1ef1a9
  /* If the POSIXLY_CORRECT environment variable is set
Packit 1ef1a9
     or getopt was called.  */
Packit 1ef1a9
  int __posixly_correct;
Packit 1ef1a9
Packit 1ef1a9
Packit 1ef1a9
  /* Handle permutation of arguments.  */
Packit 1ef1a9
Packit 1ef1a9
  /* Describe the part of ARGV that contains non-options that have
Packit 1ef1a9
     been skipped.  'first_nonopt' is the index in ARGV of the first
Packit 1ef1a9
     of them; 'last_nonopt' is the index after the last of them.  */
Packit 1ef1a9
Packit 1ef1a9
  int __first_nonopt;
Packit 1ef1a9
  int __last_nonopt;
Packit 1ef1a9
Packit 1ef1a9
#if defined _LIBC && defined USE_NONOPTION_FLAGS
Packit 1ef1a9
  int __nonoption_flags_max_len;
Packit 1ef1a9
  int __nonoption_flags_len;
Packit 1ef1a9
#endif
Packit 1ef1a9
};
Packit 1ef1a9
Packit 1ef1a9
/* The initializer is necessary to set OPTIND and OPTERR to their
Packit 1ef1a9
   default values and to clear the initialization flag.  */
Packit 1ef1a9
#define _GETOPT_DATA_INITIALIZER        { 1, 1 }
Packit 1ef1a9
Packit 1ef1a9
extern int _getopt_internal_r (int ___argc, char **___argv,
Packit 1ef1a9
                               const char *__shortopts,
Packit 1ef1a9
                               const struct option *__longopts, int *__longind,
Packit 1ef1a9
                               int __long_only, struct _getopt_data *__data,
Packit 1ef1a9
                               int __posixly_correct);
Packit 1ef1a9
Packit 1ef1a9
extern int _getopt_long_r (int ___argc, char **___argv,
Packit 1ef1a9
                           const char *__shortopts,
Packit 1ef1a9
                           const struct option *__longopts, int *__longind,
Packit 1ef1a9
                           struct _getopt_data *__data);
Packit 1ef1a9
Packit 1ef1a9
extern int _getopt_long_only_r (int ___argc, char **___argv,
Packit 1ef1a9
                                const char *__shortopts,
Packit 1ef1a9
                                const struct option *__longopts,
Packit 1ef1a9
                                int *__longind,
Packit 1ef1a9
                                struct _getopt_data *__data);
Packit 1ef1a9
Packit 1ef1a9
#endif /* getopt_int.h */