1292932Sdim#pragma once 2292932Sdim 3292932Sdim#include "lldb/lldb-defines.h" 4292932Sdim 5292932Sdim#if defined(_MSC_VER) 6292932Sdim#define REPLACE_GETOPT 7292932Sdim#define REPLACE_GETOPT_LONG 8292932Sdim#endif 9292932Sdim#if defined(_MSC_VER) || defined(__NetBSD__) 10292932Sdim#define REPLACE_GETOPT_LONG_ONLY 11292932Sdim#endif 12292932Sdim 13292932Sdim#if defined(REPLACE_GETOPT) 14292932Sdim// from getopt.h 15314564Sdim#define no_argument 0 16292932Sdim#define required_argument 1 17292932Sdim#define optional_argument 2 18292932Sdim 19292932Sdim// option structure 20314564Sdimstruct option { 21314564Sdim const char *name; 22341825Sdim // has_arg can't be an enum because some compilers complain about type 23341825Sdim // mismatches in all the code that assumes it is an int. 24314564Sdim int has_arg; 25314564Sdim int *flag; 26314564Sdim int val; 27292932Sdim}; 28292932Sdim 29314564Sdimint getopt(int argc, char *const argv[], const char *optstring); 30292932Sdim 31292932Sdim// from getopt.h 32314564Sdimextern char *optarg; 33314564Sdimextern int optind; 34314564Sdimextern int opterr; 35314564Sdimextern int optopt; 36292932Sdim 37292932Sdim// defined in unistd.h 38314564Sdimextern int optreset; 39292932Sdim#else 40314564Sdim#include <getopt.h> 41314564Sdim#include <unistd.h> 42292932Sdim#endif 43292932Sdim 44292932Sdim#if defined(REPLACE_GETOPT_LONG) 45314564Sdimint getopt_long(int argc, char *const *argv, const char *optstring, 46314564Sdim const struct option *longopts, int *longindex); 47292932Sdim#endif 48292932Sdim 49292932Sdim#if defined(REPLACE_GETOPT_LONG_ONLY) 50314564Sdimint getopt_long_only(int argc, char *const *argv, const char *optstring, 51314564Sdim const struct option *longopts, int *longindex); 52292932Sdim#endif 53