root/maint/gnulib/lib/getopt_int.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* Internal declarations for getopt.
   2    Copyright (C) 1989-2021 Free Software Foundation, Inc.
   3    This file is part of the GNU C Library and is also part of gnulib.
   4    Patches to this file should be submitted to both projects.
   5 
   6    The GNU C Library is free software; you can redistribute it and/or
   7    modify it under the terms of the GNU Lesser General Public
   8    License as published by the Free Software Foundation; either
   9    version 2.1 of the License, or (at your option) any later version.
  10 
  11    The GNU C Library is distributed in the hope that it will be useful,
  12    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14    Lesser General Public License for more details.
  15 
  16    You should have received a copy of the GNU Lesser General Public
  17    License along with the GNU C Library; if not, see
  18    <https://www.gnu.org/licenses/>.  */
  19 
  20 #ifndef _GETOPT_INT_H
  21 #define _GETOPT_INT_H   1
  22 
  23 #include <getopt.h>
  24 
  25 extern int _getopt_internal (int ___argc, char **___argv,
  26                              const char *__shortopts,
  27                              const struct option *__longopts, int *__longind,
  28                              int __long_only, int __posixly_correct);
  29 
  30 
  31 /* Reentrant versions which can handle parsing multiple argument
  32    vectors at the same time.  */
  33 
  34 /* Describe how to deal with options that follow non-option ARGV-elements.
  35 
  36    REQUIRE_ORDER means don't recognize them as options; stop option
  37    processing when the first non-option is seen.  This is what POSIX
  38    specifies should happen.
  39 
  40    PERMUTE means permute the contents of ARGV as we scan, so that
  41    eventually all the non-options are at the end.  This allows options
  42    to be given in any order, even with programs that were not written
  43    to expect this.
  44 
  45    RETURN_IN_ORDER is an option available to programs that were
  46    written to expect options and other ARGV-elements in any order
  47    and that care about the ordering of the two.  We describe each
  48    non-option ARGV-element as if it were the argument of an option
  49    with character code 1.
  50 
  51    The special argument '--' forces an end of option-scanning regardless
  52    of the value of 'ordering'.  In the case of RETURN_IN_ORDER, only
  53    '--' can cause 'getopt' to return -1 with 'optind' != ARGC.  */
  54 
  55 enum __ord
  56   {
  57     REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
  58   };
  59 
  60 /* Data type for reentrant functions.  */
  61 struct _getopt_data
  62 {
  63   /* These have exactly the same meaning as the corresponding global
  64      variables, except that they are used for the reentrant
  65      versions of getopt.  */
  66   int optind;
  67   int opterr;
  68   int optopt;
  69   char *optarg;
  70 
  71   /* Internal members.  */
  72 
  73   /* True if the internal members have been initialized.  */
  74   int __initialized;
  75 
  76   /* The next char to be scanned in the option-element
  77      in which the last option character we returned was found.
  78      This allows us to pick up the scan where we left off.
  79 
  80      If this is zero, or a null string, it means resume the scan
  81      by advancing to the next ARGV-element.  */
  82   char *__nextchar;
  83 
  84   /* See __ord above.  */
  85   enum __ord __ordering;
  86 
  87   /* Handle permutation of arguments.  */
  88 
  89   /* Describe the part of ARGV that contains non-options that have
  90      been skipped.  'first_nonopt' is the index in ARGV of the first
  91      of them; 'last_nonopt' is the index after the last of them.  */
  92 
  93   int __first_nonopt;
  94   int __last_nonopt;
  95 };
  96 
  97 /* The initializer is necessary to set OPTIND and OPTERR to their
  98    default values and to clear the initialization flag.  */
  99 #define _GETOPT_DATA_INITIALIZER        { 1, 1 }
 100 
 101 extern int _getopt_internal_r (int ___argc, char **___argv,
 102                                const char *__shortopts,
 103                                const struct option *__longopts, int *__longind,
 104                                int __long_only, struct _getopt_data *__data,
 105                                int __posixly_correct);
 106 
 107 extern int _getopt_long_r (int ___argc, char **___argv,
 108                            const char *__shortopts,
 109                            const struct option *__longopts, int *__longind,
 110                            struct _getopt_data *__data);
 111 
 112 extern int _getopt_long_only_r (int ___argc, char **___argv,
 113                                 const char *__shortopts,
 114                                 const struct option *__longopts,
 115                                 int *__longind,
 116                                 struct _getopt_data *__data);
 117 
 118 #endif /* getopt_int.h */

/* [previous][next][first][last][top][bottom][index][help] */