p9y
[m6w6/libmemcached] / src / p9y / getopt.hpp
1 #pragma once
2
3 #include "mem_config.h"
4
5 #ifdef HAVE_GETOPT_H
6 # include <getopt.h>
7 #else
8
9 # ifdef __cplusplus
10 extern "C" {
11 # endif
12
13 extern int opterr; /* if error message should be printed */
14 extern int optind; /* index into parent argv vector */
15 extern char *optarg; /* argument associated with option */
16
17 struct option /* specification for a long form option... */
18 {
19 const char *name; /* option name, without leading hyphens */
20 int has_arg; /* does it take an argument? */
21 int *flag; /* where to save its status, or NULL */
22 int val; /* its associated status value */
23 };
24
25 enum /* permitted values for its `has_arg' field... */
26 {
27 no_argument = 0, /* option never takes an argument */
28 required_argument, /* option always requires an argument */
29 optional_argument /* option may take an argument */
30 };
31
32 int getopt(int nargc, char * const *nargv, const char *options);
33 int getopt_long(int nargc, char * const *nargv, const char *options,
34 const struct option *long_options, int *idx);
35 int getopt_long_only(int nargc, char * const *nargv, const char *options,
36 const struct option *long_options, int *idx);
37
38 # ifdef __cplusplus
39 }
40 # endif
41
42 #endif // HAVE_GETOPT_H