Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:48

0001 //===-- GetOptInc.h ---------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_HOST_COMMON_GETOPTINC_H
0010 #define LLDB_HOST_COMMON_GETOPTINC_H
0011 
0012 #include "lldb/lldb-defines.h"
0013 
0014 #if defined(_MSC_VER) || defined(_AIX)
0015 #define REPLACE_GETOPT
0016 #define REPLACE_GETOPT_LONG
0017 #endif
0018 #if defined(_MSC_VER) || defined(__NetBSD__) || defined(_AIX)
0019 #define REPLACE_GETOPT_LONG_ONLY
0020 #endif
0021 
0022 #if defined(REPLACE_GETOPT)
0023 // from getopt.h
0024 #define no_argument 0
0025 #define required_argument 1
0026 #define optional_argument 2
0027 
0028 // option structure
0029 struct option {
0030   const char *name;
0031   // has_arg can't be an enum because some compilers complain about type
0032   // mismatches in all the code that assumes it is an int.
0033   int has_arg;
0034   int *flag;
0035   int val;
0036 };
0037 
0038 int getopt(int argc, char *const argv[], const char *optstring);
0039 
0040 // from getopt.h
0041 extern char *optarg;
0042 extern int optind;
0043 extern int opterr;
0044 extern int optopt;
0045 
0046 // defined in unistd.h
0047 extern int optreset;
0048 #else
0049 #include <getopt.h>
0050 #include <unistd.h>
0051 #endif
0052 
0053 #if defined(REPLACE_GETOPT_LONG)
0054 int getopt_long(int argc, char *const *argv, const char *optstring,
0055                 const struct option *longopts, int *longindex);
0056 #endif
0057 
0058 #if defined(REPLACE_GETOPT_LONG_ONLY)
0059 int getopt_long_only(int argc, char *const *argv, const char *optstring,
0060                      const struct option *longopts, int *longindex);
0061 #endif
0062 
0063 #endif // LLDB_HOST_COMMON_GETOPTINC_H