Debian Codegraph @

libretro-common/include/compat/getopt.h

raw symbols SCIP
1 /* Copyright (C) 2010-2016 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (compat_getopt.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __LIBRETRO_SDK_COMPAT_GETOPT_H
24 #define __LIBRETRO_SDK_COMPAT_GETOPT_H
25
26 #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
27 #include "../../../config.h"
28 #endif
29
30 /* Custom implementation of the GNU getopt_long for portability.
31 * Not designed to be fully compatible, but compatible with
32 * the features RetroArch uses. */
33
34 #ifdef HAVE_GETOPT_LONG
35 #include <getopt.h>
36 #else
37 /* Avoid possible naming collisions during link since we
38 * prefer to use the actual name. */
39 #define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex)
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 struct option
46 {
47 const char *name;
48 int has_arg;
49 int *flag;
50 int val;
51 };
52
53 /* argv[] is declared with char * const argv[] in GNU,
54 * but this makes no sense, as non-POSIX getopt_long
55 * mutates argv (non-opts are moved to the end). */
56 int getopt_long(int argc, char *argv[],
57 const char *optstring, const struct option *longopts, int *longindex);
58 extern char *optarg;
59 extern int optind, opterr, optopt;
60 #ifdef __cplusplus
61 }
62 #endif
63
64 /* If these are variously #defined, then we have bigger problems */
65 #ifndef no_argument
66 #define no_argument 0
67 #define required_argument 1
68 #define optional_argument 2
69 #endif
70
71 /* HAVE_GETOPT_LONG */
72 #endif
73
74 /* pragma once */
75 #endif
76