From cad65de2a9a9b7d29b98f0d2997772c057f92e29 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 24 Mar 2021 16:21:24 +0100 Subject: Provide Musl derived fallbacks for getopt/getopt_long/getsubopt Signed-off-by: David Oberhollenzer --- include/compat.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/compat.h b/include/compat.h index e5785d3..8a2522e 100644 --- a/include/compat.h +++ b/include/compat.h @@ -181,6 +181,31 @@ void w32_perror(const char *str); char *strndup(const char *str, size_t max_len); #endif +#ifndef HAVE_GETOPT +extern char *optarg; +extern int optind, opterr, optopt, optpos, optreset; + +void __getopt_msg(const char *a, const char *b, const char *c, size_t l); + +int getopt(int argc, char * const argv[], const char *optstring); +#endif + +#ifndef HAVE_GETOPT_LONG +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +int getopt_long(int, char *const *, const char *, + const struct option *, int *); +#endif + #ifndef HAVE_GETSUBOPT int getsubopt(char **opt, char *const *keys, char **val); #endif -- cgit v1.2.3