diff options
author | Matt Rogers <mrogers@redhat.com> | 2016-02-24 16:06:53 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2016-03-31 11:27:38 -0400 |
commit | 8f9ade8ec50cde1176411085294f85ecfb2820a4 (patch) | |
tree | 80cb15f1fa7209259e197aee62d83e711a1e3027 /src/include/k5-platform.h | |
parent | 33b862799efa65b16e2acd1510c84d9f1ded2cbb (diff) | |
download | krb5-8f9ade8ec50cde1176411085294f85ecfb2820a4.zip krb5-8f9ade8ec50cde1176411085294f85ecfb2820a4.tar.gz krb5-8f9ade8ec50cde1176411085294f85ecfb2820a4.tar.bz2 |
Move the util/windows getopt to libkrb5support
Relocate the internal getopt() and getopt_long() code to util/support,
and build conditionally. Put declarations in k5-platform.h. Adjust
Windows build directives for src/clients. Remove getopt-related #defines
from kinit.c, allowing kinit to use getopt_long() on all platforms.
[ghudson@mit.edu: fix some Windows build issues]
ticket: 8391
Diffstat (limited to 'src/include/k5-platform.h')
-rw-r--r-- | src/include/k5-platform.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index cff7dc3..994f463 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -63,6 +63,10 @@ #include <fnmatch.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifdef _WIN32 #define CAN_COPY_VA_LIST #endif @@ -1060,4 +1064,39 @@ int k5_path_isabs(const char *path); #endif #define N_(s) s +#if !defined(HAVE_GETOPT) || !defined(HAVE_UNISTD_H) +extern int k5_opterr; +extern int k5_optind; +extern int k5_optopt; +extern char *k5_optarg; +#define opterr k5_opterr +#define optind k5_optind +#define optopt k5_optopt +#define optarg k5_optarg + +extern int k5_getopt(int nargc, char * const nargv[], const char *ostr); +#define getopt k5_getopt +#endif /* HAVE_GETOPT */ + +#ifdef HAVE_GETOPT_LONG +#include <getopt.h> +#else + +struct option +{ + const char *name; + int has_arg; + int *flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +extern int k5_getopt_long(int nargc, char **nargv, char *options, + struct option *long_options, int *index); +#define getopt_long k5_getopt_long +#endif /* HAVE_GETOPT_LONG */ + #endif /* K5_PLATFORM_H */ |