Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
getopt.h
Go to the documentation of this file.
1 /* Declarations for getopt.
2  Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
3  This file is part of the GNU C Library.
4 
5  The GNU C Library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public License as
7  published by the Free Software Foundation; either version 2 of the
8  License, or (at your option) any later version.
9 
10  The GNU C Library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public
16  License along with the GNU C Library; see the file COPYING.LIB. If not,
17  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  Boston, MA 02111-1307, USA. */
19 
20 #pragma once
21 #ifndef _GETOPT_H
22 
23 #ifndef __need_getopt
24 # define _GETOPT_H 1
25 #endif
26 
27 #if !defined(MTS_EXPORT_CORE)
28  #if MTS_BUILD_MODULE == MTS_MODULE_CORE
29  #define MTS_EXPORT_CORE __declspec(dllexport)
30  #else
31  #define MTS_EXPORT_CORE __declspec(dllimport)
32  #endif
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /* For communication from `getopt' to the caller.
40  When `getopt' finds an option that takes an argument,
41  the argument value is returned here.
42  Also, when `ordering' is RETURN_IN_ORDER,
43  each non-option ARGV-element is returned here. */
44 
45 extern MTS_EXPORT_CORE char *optarg;
46 
47 /* Index in ARGV of the next element to be scanned.
48  This is used for communication to and from the caller
49  and for communication between successive calls to `getopt'.
50 
51  On entry to `getopt', zero means this is the first call; initialize.
52 
53  When `getopt' returns -1, this is the index of the first of the
54  non-option elements that the caller should itself scan.
55 
56  Otherwise, `optind' communicates from one call to the next
57  how much of ARGV has been scanned so far. */
58 
59 extern MTS_EXPORT_CORE int optind;
60 
61 /* Callers store zero here to inhibit the error message `getopt' prints
62  for unrecognized options. */
63 
64 extern MTS_EXPORT_CORE int opterr;
65 
66 /* Set to an option character which was unrecognized. */
67 
68 extern MTS_EXPORT_CORE int optopt;
69 
70 #ifndef __need_getopt
71 /* Describe the long-named options requested by the application.
72  The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
73  of `struct option' terminated by an element containing a name which is
74  zero.
75 
76  The field `has_arg' is:
77  no_argument (or 0) if the option does not take an argument,
78  required_argument (or 1) if the option requires an argument,
79  optional_argument (or 2) if the option takes an optional argument.
80 
81  If the field `flag' is not NULL, it points to a variable that is set
82  to the value given in the field `val' when the option is found, but
83  left unchanged if the option is not found.
84 
85  To have a long-named option do something other than set an `int' to
86  a compiled-in constant, such as set a value from `optarg', set the
87  option's `flag' field to zero and its `val' field to a nonzero
88  value (the equivalent single-letter option character, if there is
89  one). For long options that have a zero `flag' field, `getopt'
90  returns the contents of the `val' field. */
91 
92 struct option
93 {
94  const char *name;
95  /* has_arg can't be an enum because some compilers complain about
96  type mismatches in all the code that assumes it is an int. */
97  int has_arg;
98  int *flag;
99  int val;
100 };
101 
102 /* Names for the values of the `has_arg' field of `struct option'. */
103 
104 # define no_argument 0
105 # define required_argument 1
106 # define optional_argument 2
107 #endif /* need getopt */
108 
109 
110 /* Get definitions and prototypes for functions to process the
111  arguments in ARGV (ARGC of them, minus the program name) for
112  options given in OPTS.
113 
114  Return the option character from OPTS just read. Return -1 when
115  there are no more options. For unrecognized options, or options
116  missing arguments, `optopt' is set to the option letter, and '?' is
117  returned.
118 
119  The OPTS string is a list of characters which are recognized option
120  letters, optionally followed by colons, specifying that that letter
121  takes an argument, to be placed in `optarg'.
122 
123  If a letter in OPTS is followed by two colons, its argument is
124  optional. This behavior is specific to the GNU `getopt'.
125 
126  The argument `--' causes premature termination of argument
127  scanning, explicitly telling `getopt' that there are no more
128  options.
129 
130  If OPTS begins with `--', then non-option arguments are treated as
131  arguments to the option '\0'. This behavior is specific to the GNU
132  `getopt'. */
133 
134 /* Many other libraries have conflicting prototypes for getopt, with
135  differences in the consts, in stdlib.h. To avoid compilation
136  errors, only prototype getopt for the GNU C library. */
137 extern MTS_EXPORT_CORE int getopt (int __argc, char *const *__argv, const char *__shortopts);
138 
139 # ifndef __need_getopt
140 extern MTS_EXPORT_CORE int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
141  const struct option *__longopts, int *__longind);
142 extern MTS_EXPORT_CORE int getopt_long_only (int __argc, char *const *__argv,
143  const char *__shortopts,
144  const struct option *__longopts, int *__longind);
145 
146 /* Internal only. Users should not call this directly. */
147 extern MTS_EXPORT_CORE int _getopt_internal (int __argc, char *const *__argv,
148  const char *__shortopts,
149  const struct option *__longopts, int *__longind,
150  int __long_only);
151 # endif
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 /* Make sure we later can get all the definitions and declarations. */
158 #undef __need_getopt
159 
160 #endif /* getopt.h */
int val
Definition: getopt.h:99
char *const const char * __shortopts
Definition: getopt.h:137
char *const const char const struct option int * __longind
Definition: getopt.h:141
#define MTS_EXPORT_CORE
Definition: getopt.h:29
char *const const char const struct option * __longopts
Definition: getopt.h:141
Definition: getopt.h:92
const char * name
Definition: getopt.h:94
int * flag
Definition: getopt.h:98
char *const const char const struct option int int __long_only
Definition: getopt.h:149
char *const * __argv
Definition: getopt.h:137
int has_arg
Definition: getopt.h:97