summaryrefslogtreecommitdiff
path: root/src/win32/getopt/getopt.h
blob: 4f21e69dc2a932f93b72db9e29b2f2b148f1b715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef GETOPT_H
#define GETOPT_H

#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif

#if defined(_MSC_VER)
// These may be used to initialize structures and it fails with MSVC
#define no_argument 0
#define required_argument  1
#define optional_argument  2
#else
extern const int32_t no_argument;
extern const int32_t required_argument;
extern const int32_t optional_argument;
#endif

extern char* optarg;
extern int32_t optind, opterr, optopt;

struct option {
    const char* name;
    int32_t has_arg;
    int* flag;
    int32_t val;
};

int32_t getopt(int32_t argc, char* const argv[], const char* optstring);

int32_t getopt_long(int32_t argc,
                char* const argv[],
                const char* optstring,
                const struct option* longopts,
                int* longindex);

#if defined(__cplusplus)
}
#endif

#endif // GETOPT_H