GNU Radio 3.6.5 C++ API

getopt.h

Go to the documentation of this file.
00001 /* Declarations for getopt.
00002    Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU General Public License as published by the
00006    Free Software Foundation; either version 3, or (at your option) any
00007    later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
00017 
00018 #ifndef _GETOPT_H
00019 #define _GETOPT_H 1
00020 
00021 #ifdef  __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 /* For communication from `getopt' to the caller.
00026    When `getopt' finds an option that takes an argument,
00027    the argument value is returned here.
00028    Also, when `ordering' is RETURN_IN_ORDER,
00029    each non-option ARGV-element is returned here.  */
00030 
00031 extern char *optarg;
00032 
00033 /* Index in ARGV of the next element to be scanned.
00034    This is used for communication to and from the caller
00035    and for communication between successive calls to `getopt'.
00036 
00037    On entry to `getopt', zero means this is the first call; initialize.
00038 
00039    When `getopt' returns EOF, this is the index of the first of the
00040    non-option elements that the caller should itself scan.
00041 
00042    Otherwise, `optind' communicates from one call to the next
00043    how much of ARGV has been scanned so far.  */
00044 
00045 extern int optind;
00046 
00047 /* Callers store zero here to inhibit the error message `getopt' prints
00048    for unrecognized options.  */
00049 
00050 extern int opterr;
00051 
00052 /* Set to an option character which was unrecognized.  */
00053 
00054 extern int optopt;
00055 
00056 /* Describe the long-named options requested by the application.
00057    The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
00058    of `struct option' terminated by an element containing a name which is
00059    zero.
00060 
00061    The field `has_arg' is:
00062    no_argument          (or 0) if the option does not take an argument,
00063    required_argument    (or 1) if the option requires an argument,
00064    optional_argument    (or 2) if the option takes an optional argument.
00065 
00066    If the field `flag' is not NULL, it points to a variable that is set
00067    to the value given in the field `val' when the option is found, but
00068    left unchanged if the option is not found.
00069 
00070    To have a long-named option do something other than set an `int' to
00071    a compiled-in constant, such as set a value from `optarg', set the
00072    option's `flag' field to zero and its `val' field to a nonzero
00073    value (the equivalent single-letter option character, if there is
00074    one).  For long options that have a zero `flag' field, `getopt'
00075    returns the contents of the `val' field.  */
00076 
00077 struct option
00078 {
00079 #if     __STDC__
00080   const char *name;
00081 #else
00082   char *name;
00083 #endif
00084   /* has_arg can't be an enum because some compilers complain about
00085      type mismatches in all the code that assumes it is an int.  */
00086   int has_arg;
00087   int *flag;
00088   int val;
00089 };
00090 
00091 /* Names for the values of the `has_arg' field of `struct option'.  */
00092 
00093 #define no_argument             0
00094 #define required_argument       1
00095 #define optional_argument       2
00096 
00097 #if __STDC__
00098 #if defined(__GNU_LIBRARY__)
00099 /* Many other libraries have conflicting prototypes for getopt, with
00100    differences in the consts, in stdlib.h.  To avoid compilation
00101    errors, only prototype getopt for the GNU C library.  */
00102 extern int getopt (int argc, char *const *argv, const char *shortopts);
00103 #else /* not __GNU_LIBRARY__ */
00104 extern int getopt ();
00105 #endif /* not __GNU_LIBRARY__ */
00106 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
00107                         const struct option *longopts, int *longind);
00108 extern int getopt_long_only (int argc, char *const *argv,
00109                              const char *shortopts,
00110                              const struct option *longopts, int *longind);
00111 
00112 /* Internal only.  Users should not call this directly.  */
00113 extern int _getopt_internal (int argc, char *const *argv,
00114                              const char *shortopts,
00115                              const struct option *longopts, int *longind,
00116                              int long_only);
00117 #else /* not __STDC__ */
00118 extern int getopt ();
00119 extern int getopt_long ();
00120 extern int getopt_long_only ();
00121 
00122 extern int _getopt_internal ();
00123 #endif /* not __STDC__ */
00124 
00125 #ifdef  __cplusplus
00126 }
00127 #endif
00128 
00129 #endif /* _GETOPT_H */