1cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Declarations for getopt. 205436638acc7c010349a69c3395f1a57c642dc62Ying Wang Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2012 Free Software 305436638acc7c010349a69c3395f1a57c642dc62Ying Wang Foundation, Inc. 4cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project This file is part of the GNU C Library. 5cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 605436638acc7c010349a69c3395f1a57c642dc62Ying Wang This program is free software: you can redistribute it and/or modify 7cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project it under the terms of the GNU General Public License as published by 805436638acc7c010349a69c3395f1a57c642dc62Ying Wang the Free Software Foundation; either version 3 of the License, or 905436638acc7c010349a69c3395f1a57c642dc62Ying Wang (at your option) any later version. 10cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 11cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project This program is distributed in the hope that it will be useful, 12cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project but WITHOUT ANY WARRANTY; without even the implied warranty of 13cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project GNU General Public License for more details. 15cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1605436638acc7c010349a69c3395f1a57c642dc62Ying Wang You should have received a copy of the GNU General Public License 1705436638acc7c010349a69c3395f1a57c642dc62Ying Wang along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 1905436638acc7c010349a69c3395f1a57c642dc62Ying Wang#ifndef _@GUARD_PREFIX@_GETOPT_H 2005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 2105436638acc7c010349a69c3395f1a57c642dc62Ying Wang#if __GNUC__ >= 3 2205436638acc7c010349a69c3395f1a57c642dc62Ying Wang@PRAGMA_SYSTEM_HEADER@ 2305436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif 2405436638acc7c010349a69c3395f1a57c642dc62Ying Wang@PRAGMA_COLUMNS@ 2505436638acc7c010349a69c3395f1a57c642dc62Ying Wang 2605436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* The include_next requires a split double-inclusion guard. We must 2705436638acc7c010349a69c3395f1a57c642dc62Ying Wang also inform the replacement unistd.h to not recursively use 2805436638acc7c010349a69c3395f1a57c642dc62Ying Wang <getopt.h>; our definitions will be present soon enough. */ 2905436638acc7c010349a69c3395f1a57c642dc62Ying Wang#if @HAVE_GETOPT_H@ 3005436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define _GL_SYSTEM_GETOPT 3105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ 3205436638acc7c010349a69c3395f1a57c642dc62Ying Wang# undef _GL_SYSTEM_GETOPT 3305436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif 3405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 3505436638acc7c010349a69c3395f1a57c642dc62Ying Wang#ifndef _@GUARD_PREFIX@_GETOPT_H 36cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 37cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#ifndef __need_getopt 3805436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define _@GUARD_PREFIX@_GETOPT_H 1 39cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 40cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 41cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Standalone applications should #define __GETOPT_PREFIX to an 42cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project identifier that prefixes the external functions and variables 43cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project defined in this header. When this happens, include the 44cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project headers that might declare getopt so that they will not cause 4505436638acc7c010349a69c3395f1a57c642dc62Ying Wang confusion if included after this file (if the system had <getopt.h>, 4605436638acc7c010349a69c3395f1a57c642dc62Ying Wang we have already included it). Then systematically rename 47cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project identifiers so that they do not collide with the system functions 48cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project and variables. Renaming avoids problems with some compilers and 49cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project linkers. */ 50cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#if defined __GETOPT_PREFIX && !defined __need_getopt 5105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# if !@HAVE_GETOPT_H@ 5205436638acc7c010349a69c3395f1a57c642dc62Ying Wang# include <stdlib.h> 5305436638acc7c010349a69c3395f1a57c642dc62Ying Wang# include <stdio.h> 5405436638acc7c010349a69c3395f1a57c642dc62Ying Wang# include <unistd.h> 5505436638acc7c010349a69c3395f1a57c642dc62Ying Wang# endif 56cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef __need_getopt 57cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef getopt 58cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef getopt_long 59cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef getopt_long_only 60cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef optarg 61cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef opterr 62cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef optind 63cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# undef optopt 6405436638acc7c010349a69c3395f1a57c642dc62Ying Wang# undef option 65cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __GETOPT_CONCAT(x, y) x ## y 66cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) 67cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) 68cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define getopt __GETOPT_ID (getopt) 69cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define getopt_long __GETOPT_ID (getopt_long) 70cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define getopt_long_only __GETOPT_ID (getopt_long_only) 71cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define optarg __GETOPT_ID (optarg) 72cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define opterr __GETOPT_ID (opterr) 73cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define optind __GETOPT_ID (optind) 74cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define optopt __GETOPT_ID (optopt) 7505436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define option __GETOPT_ID (option) 7605436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define _getopt_internal __GETOPT_ID (getopt_internal) 77cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 78cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 79cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Standalone applications get correct prototypes for getopt_long and 80cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project getopt_long_only; they declare "char **argv". libc uses prototypes 81cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project with "char *const *argv" that are incorrect because getopt_long and 82cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project getopt_long_only can permute argv; this is required for backward 83cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project compatibility (e.g., for LSB 2.0.1). 84cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 8505436638acc7c010349a69c3395f1a57c642dc62Ying Wang This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', 86cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project but it caused redefinition warnings if both unistd.h and getopt.h were 87cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project included, since unistd.h includes getopt.h having previously defined 88cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project __need_getopt. 89cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 90cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project The only place where __getopt_argv_const is used is in definitions 91cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project of getopt_long and getopt_long_only below, but these are visible 92cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project only if __need_getopt is not defined, so it is quite safe to rewrite 93cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project the conditional as follows: 94cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project*/ 95cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#if !defined __need_getopt 96cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# if defined __GETOPT_PREFIX 97cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __getopt_argv_const /* empty */ 98cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# else 99cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __getopt_argv_const const 100cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# endif 101cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 102cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 103cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* If __GNU_LIBRARY__ is not already defined, either we are being used 104cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project standalone, or this is the first header included in the source file. 105cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project If we are being used with glibc, we need to include <features.h>, but 106cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project that does not exist if we are standalone. So: if __GNU_LIBRARY__ is 107cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project not defined, include <ctype.h>, which will pull in <features.h> for us 108cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project if it's from glibc. (Why ctype.h? It's guaranteed to exist and it 109cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project doesn't flood the namespace with stuff the way some other headers do.) */ 110cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#if !defined __GNU_LIBRARY__ 111cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# include <ctype.h> 112cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 113cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 114cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#ifndef __THROW 115cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# ifndef __GNUC_PREREQ 116cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __GNUC_PREREQ(maj, min) (0) 117cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# endif 118cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# if defined __cplusplus && __GNUC_PREREQ (2,8) 11905436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define __THROW throw () 120cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# else 121cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# define __THROW 122cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# endif 123cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 124cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 12505436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* The definition of _GL_ARG_NONNULL is copied here. */ 12605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 12705436638acc7c010349a69c3395f1a57c642dc62Ying Wang#ifdef __cplusplus 128cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern "C" { 129cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 130cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 13105436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* For communication from 'getopt' to the caller. 13205436638acc7c010349a69c3395f1a57c642dc62Ying Wang When 'getopt' finds an option that takes an argument, 133cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project the argument value is returned here. 13405436638acc7c010349a69c3395f1a57c642dc62Ying Wang Also, when 'ordering' is RETURN_IN_ORDER, 135cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project each non-option ARGV-element is returned here. */ 136cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 137cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern char *optarg; 138cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 139cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Index in ARGV of the next element to be scanned. 140cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project This is used for communication to and from the caller 14105436638acc7c010349a69c3395f1a57c642dc62Ying Wang and for communication between successive calls to 'getopt'. 142cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 14305436638acc7c010349a69c3395f1a57c642dc62Ying Wang On entry to 'getopt', zero means this is the first call; initialize. 144cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 14505436638acc7c010349a69c3395f1a57c642dc62Ying Wang When 'getopt' returns -1, this is the index of the first of the 146cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project non-option elements that the caller should itself scan. 147cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 14805436638acc7c010349a69c3395f1a57c642dc62Ying Wang Otherwise, 'optind' communicates from one call to the next 149cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project how much of ARGV has been scanned so far. */ 150cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 151cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int optind; 152cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 15305436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* Callers store zero here to inhibit the error message 'getopt' prints 154cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project for unrecognized options. */ 155cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 156cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int opterr; 157cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 158cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Set to an option character which was unrecognized. */ 159cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 160cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int optopt; 161cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 162cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#ifndef __need_getopt 163cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Describe the long-named options requested by the application. 164cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 16505436638acc7c010349a69c3395f1a57c642dc62Ying Wang of 'struct option' terminated by an element containing a name which is 166cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project zero. 167cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 16805436638acc7c010349a69c3395f1a57c642dc62Ying Wang The field 'has_arg' is: 16905436638acc7c010349a69c3395f1a57c642dc62Ying Wang no_argument (or 0) if the option does not take an argument, 17005436638acc7c010349a69c3395f1a57c642dc62Ying Wang required_argument (or 1) if the option requires an argument, 17105436638acc7c010349a69c3395f1a57c642dc62Ying Wang optional_argument (or 2) if the option takes an optional argument. 172cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 17305436638acc7c010349a69c3395f1a57c642dc62Ying Wang If the field 'flag' is not NULL, it points to a variable that is set 17405436638acc7c010349a69c3395f1a57c642dc62Ying Wang to the value given in the field 'val' when the option is found, but 175cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project left unchanged if the option is not found. 176cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 17705436638acc7c010349a69c3395f1a57c642dc62Ying Wang To have a long-named option do something other than set an 'int' to 17805436638acc7c010349a69c3395f1a57c642dc62Ying Wang a compiled-in constant, such as set a value from 'optarg', set the 17905436638acc7c010349a69c3395f1a57c642dc62Ying Wang option's 'flag' field to zero and its 'val' field to a nonzero 180cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project value (the equivalent single-letter option character, if there is 18105436638acc7c010349a69c3395f1a57c642dc62Ying Wang one). For long options that have a zero 'flag' field, 'getopt' 18205436638acc7c010349a69c3395f1a57c642dc62Ying Wang returns the contents of the 'val' field. */ 183cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 18405436638acc7c010349a69c3395f1a57c642dc62Ying Wang# if !GNULIB_defined_struct_option 185cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectstruct option 186cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project{ 187cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project const char *name; 188cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project /* has_arg can't be an enum because some compilers complain about 189cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project type mismatches in all the code that assumes it is an int. */ 190cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int has_arg; 191cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int *flag; 192cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project int val; 193cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project}; 19405436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define GNULIB_defined_struct_option 1 19505436638acc7c010349a69c3395f1a57c642dc62Ying Wang# endif 196cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 19705436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* Names for the values of the 'has_arg' field of 'struct option'. */ 198cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 19905436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define no_argument 0 20005436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define required_argument 1 20105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# define optional_argument 2 20205436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif /* need getopt */ 203cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 204cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 205cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Get definitions and prototypes for functions to process the 206cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project arguments in ARGV (ARGC of them, minus the program name) for 207cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project options given in OPTS. 208cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 209cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project Return the option character from OPTS just read. Return -1 when 210cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project there are no more options. For unrecognized options, or options 21105436638acc7c010349a69c3395f1a57c642dc62Ying Wang missing arguments, 'optopt' is set to the option letter, and '?' is 212cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project returned. 213cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 214cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project The OPTS string is a list of characters which are recognized option 215cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project letters, optionally followed by colons, specifying that that letter 21605436638acc7c010349a69c3395f1a57c642dc62Ying Wang takes an argument, to be placed in 'optarg'. 217cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 218cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project If a letter in OPTS is followed by two colons, its argument is 21905436638acc7c010349a69c3395f1a57c642dc62Ying Wang optional. This behavior is specific to the GNU 'getopt'. 220cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 22105436638acc7c010349a69c3395f1a57c642dc62Ying Wang The argument '--' causes premature termination of argument 22205436638acc7c010349a69c3395f1a57c642dc62Ying Wang scanning, explicitly telling 'getopt' that there are no more 223cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project options. 224cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 22505436638acc7c010349a69c3395f1a57c642dc62Ying Wang If OPTS begins with '-', then non-option arguments are treated as 22605436638acc7c010349a69c3395f1a57c642dc62Ying Wang arguments to the option '\1'. This behavior is specific to the GNU 22705436638acc7c010349a69c3395f1a57c642dc62Ying Wang 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in 22805436638acc7c010349a69c3395f1a57c642dc62Ying Wang the environment, then do not permute arguments. */ 229cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 230cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int getopt (int ___argc, char *const *___argv, const char *__shortopts) 23105436638acc7c010349a69c3395f1a57c642dc62Ying Wang __THROW _GL_ARG_NONNULL ((2, 3)); 232cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 233cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#ifndef __need_getopt 234cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, 23505436638acc7c010349a69c3395f1a57c642dc62Ying Wang const char *__shortopts, 23605436638acc7c010349a69c3395f1a57c642dc62Ying Wang const struct option *__longopts, int *__longind) 23705436638acc7c010349a69c3395f1a57c642dc62Ying Wang __THROW _GL_ARG_NONNULL ((2, 3)); 238cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectextern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, 23905436638acc7c010349a69c3395f1a57c642dc62Ying Wang const char *__shortopts, 24005436638acc7c010349a69c3395f1a57c642dc62Ying Wang const struct option *__longopts, int *__longind) 24105436638acc7c010349a69c3395f1a57c642dc62Ying Wang __THROW _GL_ARG_NONNULL ((2, 3)); 242cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 243cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 244cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 24505436638acc7c010349a69c3395f1a57c642dc62Ying Wang#ifdef __cplusplus 246cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project} 247cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#endif 248cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 249cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project/* Make sure we later can get all the definitions and declarations. */ 250cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project#undef __need_getopt 251cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 25205436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif /* _@GUARD_PREFIX@_GETOPT_H */ 25305436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif /* _@GUARD_PREFIX@_GETOPT_H */ 254