Rizin
unix-like reverse engineering framework and cli tools
getopt1.c
Go to the documentation of this file.
1 /* getopt_long and getopt_long_only entry points for GNU getopt.
2  Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
3  Free Software Foundation, Inc.
4  This file is part of the GNU C Library.
5 
6  The GNU C Library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public License as
8  published by the Free Software Foundation; either version 2 of the
9  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  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public
17  License along with the GNU C Library; see the file COPYING.LIB. If not,
18  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  Boston, MA 02111-1307, USA. */
20 ␌
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 
25 #include "getopt.h"
26 
27 #if !defined __STDC__ || !__STDC__
28 /* This is a separate conditional since some stdc systems
29  reject `defined (const)'. */
30 #ifndef const
31 #define const
32 #endif
33 #endif
34 
35 #include <stdio.h>
36 
37 /* Comment out all this code if we are using the GNU C Library, and are not
38  actually compiling the library itself. This code is part of the GNU C
39  Library, but also included in many other GNU distributions. Compiling
40  and linking in this code is a waste when using the GNU C library
41  (especially if it is a shared library). Rather than having every GNU
42  program understand `configure --with-gnu-libc' and omit the object files,
43  it is simpler to just do this in the source for each such file. */
44 
45 #define GETOPT_INTERFACE_VERSION 2
46 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
47 #include <gnu-versions.h>
48 #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
49 #define ELIDE_CODE
50 #endif
51 #endif
52 
53 #ifndef ELIDE_CODE
54 
55 
56 /* This needs to come after some library #include
57  to get __GNU_LIBRARY__ defined. */
58 #ifdef __GNU_LIBRARY__
59 #include <stdlib.h>
60 #endif
61 
62 int
63 getopt_long (argc, argv, options, long_options, opt_index)
64  int argc;
65  char *const *argv;
66  const char *options;
67  const struct option *long_options;
68  int *opt_index;
69 {
70  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
71 }
72 
73 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
74  If an option that starts with '-' (not '--') doesn't match a long option,
75  but does match a short option, it is parsed as a short option
76  instead. */
77 
78 int
79 getopt_long_only (argc, argv, options, long_options, opt_index)
80  int argc;
81  char *const *argv;
82  const char *options;
83  const struct option *long_options;
84  int *opt_index;
85 {
86  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
87 }
88 
89 
90 #endif /* Not ELIDE_CODE. */
int getopt_long_only(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
Definition: getopt1.c:79
int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
Definition: getopt1.c:63
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
Definition: getopt.h:84
int _getopt_internal(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
Definition: getopt.c:514