aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Rogers <mrogers@redhat.com>2016-02-24 16:06:53 -0500
committerGreg Hudson <ghudson@mit.edu>2016-03-31 11:27:38 -0400
commit8f9ade8ec50cde1176411085294f85ecfb2820a4 (patch)
tree80cb15f1fa7209259e197aee62d83e711a1e3027
parent33b862799efa65b16e2acd1510c84d9f1ded2cbb (diff)
downloadkrb5-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
-rw-r--r--src/Makefile.in8
-rw-r--r--src/clients/kcpytkt/Makefile.in2
-rw-r--r--src/clients/kcpytkt/kcpytkt.c7
-rw-r--r--src/clients/kdeltkt/Makefile.in2
-rw-r--r--src/clients/kdeltkt/kdeltkt.c7
-rw-r--r--src/clients/kdestroy/Makefile.in2
-rw-r--r--src/clients/kdestroy/kdestroy.c6
-rw-r--r--src/clients/kinit/Makefile.in6
-rw-r--r--src/clients/kinit/kinit.c37
-rw-r--r--src/clients/klist/Makefile.in2
-rw-r--r--src/clients/klist/klist.c6
-rw-r--r--src/clients/kswitch/Makefile.in2
-rw-r--r--src/clients/kvno/Makefile.in2
-rw-r--r--src/clients/kvno/kvno.c4
-rw-r--r--src/configure.in20
-rw-r--r--src/include/k5-platform.h39
-rw-r--r--src/util/support/Makefile.in23
-rw-r--r--src/util/support/deps6
-rw-r--r--src/util/support/getopt.c (renamed from src/util/windows/getopt.c)14
-rw-r--r--src/util/support/getopt_long.c (renamed from src/util/windows/getopt_long.c)13
-rw-r--r--src/util/windows/Makefile.in6
-rw-r--r--src/util/windows/getopt.h34
-rw-r--r--src/windows/installer/wix/files.wxi2
-rw-r--r--src/windows/ms2mit/Makefile.in4
-rw-r--r--src/windows/ms2mit/mit2ms.c4
-rw-r--r--src/windows/ms2mit/ms2mit.c3
26 files changed, 114 insertions, 147 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 6c5e939..8b9e790 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -511,7 +511,6 @@ install-windows::
copy windows\kfwlogon\$(OUTPRE)*.exe "$(KRB_INSTALL_DIR)\bin\."
copy windows\kfwlogon\$(OUTPRE)*.dll "$(KRB_INSTALL_DIR)\bin\."
$(INSTALLDBGSYMS) windows\kfwlogon\$(OUTPRE)*.pdb "$(KRB_INSTALL_DIR)\bin\."
- copy util\windows\$(OUTPRE)*.lib $(KRB_INSTALL_DIR)\lib\."
copy util\wshelper\$(OUTPRE)$(DLIB).lib "$(KRB_INSTALL_DIR)\lib\."
copy util\wshelper\$(OUTPRE)$(DLIB).dll "$(KRB_INSTALL_DIR)\bin\."
$(INSTALLDBGSYMS) util\wshelper\$(OUTPRE)$(DLIB).pdb "$(KRB_INSTALL_DIR)\bin\."
@@ -635,11 +634,10 @@ BSDFILES = \
lib/krb5/krb/strftime.c \
lib/krb5/krb/strptime.c \
slave/kpropd_rpc.c \
+ util/support/getopt.c \
+ util/support/getopt_long.c \
util/support/mkstemp.c \
- util/support/strlcpy.c \
- util/windows/getopt.c \
- util/windows/getopt.h \
- util/windows/getopt_long.c
+ util/support/strlcpy.c
OTHEREXCLUDES = \
include/iprop.h \
diff --git a/src/clients/kcpytkt/Makefile.in b/src/clients/kcpytkt/Makefile.in
index ea73514..8b70201 100644
--- a/src/clients/kcpytkt/Makefile.in
+++ b/src/clients/kcpytkt/Makefile.in
@@ -18,7 +18,7 @@ all-mac::
kcpytkt: kcpytkt.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ kcpytkt.o $(KRB5_BASE_LIBS)
-##WIN32##$(KCPYTKT): $(OUTPRE)kcpytkt.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KCPYTKT): $(OUTPRE)kcpytkt.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) /out:$@ $**
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kcpytkt/kcpytkt.c b/src/clients/kcpytkt/kcpytkt.c
index 90b260b..47147cd 100644
--- a/src/clients/kcpytkt/kcpytkt.c
+++ b/src/clients/kcpytkt/kcpytkt.c
@@ -2,14 +2,9 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include <string.h>
#include <krb5.h>
-
-extern int optind;
-extern char *optarg;
+#include "k5-platform.h"
static char *prog;
diff --git a/src/clients/kdeltkt/Makefile.in b/src/clients/kdeltkt/Makefile.in
index e140b7b..529592a 100644
--- a/src/clients/kdeltkt/Makefile.in
+++ b/src/clients/kdeltkt/Makefile.in
@@ -18,7 +18,7 @@ all-mac::
kdeltkt: kdeltkt.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ kdeltkt.o $(KRB5_BASE_LIBS)
-##WIN32##$(KDELTKT): $(OUTPRE)kdeltkt.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KDELTKT): $(OUTPRE)kdeltkt.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) /out:$@ $**
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kdeltkt/kdeltkt.c b/src/clients/kdeltkt/kdeltkt.c
index 2f09c9d..9c7a549 100644
--- a/src/clients/kdeltkt/kdeltkt.c
+++ b/src/clients/kdeltkt/kdeltkt.c
@@ -2,14 +2,9 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include <string.h>
#include <krb5.h>
-
-extern int optind;
-extern char *optarg;
+#include "k5-platform.h"
static char *prog;
diff --git a/src/clients/kdestroy/Makefile.in b/src/clients/kdestroy/Makefile.in
index f299352..05f0a44 100644
--- a/src/clients/kdestroy/Makefile.in
+++ b/src/clients/kdestroy/Makefile.in
@@ -21,7 +21,7 @@ all-unix:: kdestroy
kdestroy: kdestroy.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ kdestroy.o $(KRB5_BASE_LIBS)
-##WIN32##$(KDESTROY): $(OUTPRE)kdestroy.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KDESTROY): $(OUTPRE)kdestroy.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) -out:$@ $**
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kdestroy/kdestroy.c b/src/clients/kdestroy/kdestroy.c
index 299838f..410d6cf 100644
--- a/src/clients/kdestroy/kdestroy.c
+++ b/src/clients/kdestroy/kdestroy.c
@@ -30,12 +30,6 @@
#include <locale.h>
#include <string.h>
#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef _WIN32
-#include <getopt.h>
-#endif
#ifdef __STDC__
#define BELL_CHAR '\a'
diff --git a/src/clients/kinit/Makefile.in b/src/clients/kinit/Makefile.in
index b1cd278..c7975c9 100644
--- a/src/clients/kinit/Makefile.in
+++ b/src/clients/kinit/Makefile.in
@@ -2,9 +2,7 @@ mydir=clients$(S)kinit
BUILDTOP=$(REL)..$(S)..
SRCS=kinit.c kinit_kdb.c
-
-##WIN32##LOCALINCLUDES=-I$(BUILDTOP)\util\windows
-##WIN32##DEFINES=-DGETOPT_LONG
+##WIN32##LOCALINCLUDES=-I$(BUILDTOP)\util\windows -I$(BUILDTOP)\util\support
##WIN32##VERSIONRC = $(BUILDTOP)\windows\version.rc
##WIN32##RCFLAGS=$(CPPFLAGS) -I$(top_srcdir) -D_WIN32 -DRES_ONLY
@@ -22,7 +20,7 @@ all-unix:: kinit
kinit: kinit.o kinit_kdb.o $(KRB5_BASE_DEPLIBS) $(KADMSRV_DEPLIBS)
$(CC_LINK) -o $@ kinit.o kinit_kdb.o $(KADMSRV_LIBS) $(KRB5_BASE_LIBS)
-##WIN32##$(KINIT): $(OUTPRE)kinit.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.lib $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KINIT): $(OUTPRE)kinit.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) -out:$@ $** advapi32.lib
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c
index c442c53..3653960 100644
--- a/src/clients/kinit/kinit.c
+++ b/src/clients/kinit/kinit.c
@@ -26,7 +26,7 @@
#include "autoconf.h"
#include <k5-int.h>
-#include "k5-platform.h" /* for asprintf */
+#include "k5-platform.h" /* for asprintf and getopt */
#include <krb5.h>
#include "extern.h"
#include <locale.h>
@@ -36,23 +36,6 @@
#include <errno.h>
#include <com_err.h>
-#ifdef GETOPT_LONG
-#include <getopt.h>
-#else
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#ifdef sun
-/* SunOS4 unistd didn't declare these; okay to make unconditional? */
-extern int optind;
-extern char *optarg;
-#endif /* sun */
-#else
-extern int optind;
-extern char *optarg;
-extern int getopt();
-#endif /* HAVE_UNISTD_H */
-#endif /* GETOPT_LONG */
-
#ifndef _WIN32
#define GET_PROGNAME(x) (strrchr((x), '/') ? strrchr((x), '/')+1 : (x))
#else
@@ -140,7 +123,6 @@ struct k5_data
krb5_boolean switch_to_cache;
};
-#ifdef GETOPT_LONG
/* if struct[2] == NULL, then long_getopt acts as if the short flag
struct[3] was specified. If struct[2] != NULL, then struct[3] is
stored in *(struct[2]), the array index which was specified is
@@ -158,31 +140,19 @@ struct option long_options[] = {
{ NULL, 0, NULL, 0 }
};
-#define GETOPT(argc, argv, str) getopt_long(argc, argv, str, long_options, 0)
-#else
-#define GETOPT(argc, argv, str) getopt(argc, argv, str)
-#endif
+const char *shopts = "r:fpFPn54aAVl:s:c:kit:T:RS:vX:CEI:";
static void
usage()
{
#define USAGE_BREAK "\n\t"
-#ifdef GETOPT_LONG
#define USAGE_LONG_FORWARDABLE " | --forwardable | --noforwardable"
#define USAGE_LONG_PROXIABLE " | --proxiable | --noproxiable"
#define USAGE_LONG_ADDRESSES " | --addresses | --noaddresses"
#define USAGE_LONG_CANONICALIZE " | --canonicalize"
#define USAGE_LONG_ENTERPRISE " | --enterprise"
#define USAGE_BREAK_LONG USAGE_BREAK
-#else
-#define USAGE_LONG_FORWARDABLE ""
-#define USAGE_LONG_PROXIABLE ""
-#define USAGE_LONG_ADDRESSES ""
-#define USAGE_LONG_CANONICALIZE ""
-#define USAGE_LONG_ENTERPRISE ""
-#define USAGE_BREAK_LONG ""
-#endif
fprintf(stderr, "Usage: %s [-V] "
"[-l lifetime] [-s start_time] "
@@ -288,8 +258,7 @@ parse_options(argc, argv, opts)
int errflg = 0;
int i;
- while ((i = GETOPT(argc, argv,
- "r:fpFPn54aAVl:s:c:kit:T:RS:vX:CEI:")) != -1) {
+ while ((i = getopt_long(argc, argv, shopts, long_options, 0)) != -1) {
switch (i) {
case 'V':
opts->verbose = 1;
diff --git a/src/clients/klist/Makefile.in b/src/clients/klist/Makefile.in
index 3cdbb86..79255f2 100644
--- a/src/clients/klist/Makefile.in
+++ b/src/clients/klist/Makefile.in
@@ -21,7 +21,7 @@ all-unix:: klist
klist: klist.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ klist.o $(KRB5_BASE_LIBS)
-##WIN32##$(KLIST): $(OUTPRE)klist.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.lib $(SLIB) $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KLIST): $(OUTPRE)klist.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) -out:$@ $** ws2_32.lib $(SCLIB)
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c
index 0f6ca8a..f8183dd 100644
--- a/src/clients/klist/klist.c
+++ b/src/clients/klist/klist.c
@@ -29,12 +29,6 @@
#include <com_err.h>
#include <locale.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef _WIN32
-#include <getopt.h>
-#endif
#include <string.h>
#include <stdio.h>
#include <time.h>
diff --git a/src/clients/kswitch/Makefile.in b/src/clients/kswitch/Makefile.in
index b46fec6..e2a58dc 100644
--- a/src/clients/kswitch/Makefile.in
+++ b/src/clients/kswitch/Makefile.in
@@ -19,7 +19,7 @@ all-unix:: kswitch
kswitch: kswitch.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ kswitch.o $(KRB5_BASE_LIBS)
-##WIN32##$(KSWITCH): $(OUTPRE)kswitch.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KSWITCH): $(OUTPRE)kswitch.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) -out:$@ $**
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kvno/Makefile.in b/src/clients/kvno/Makefile.in
index 58519ae..6495080 100644
--- a/src/clients/kvno/Makefile.in
+++ b/src/clients/kvno/Makefile.in
@@ -22,7 +22,7 @@ all-unix:: kvno
kvno: kvno.o $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ kvno.o $(KRB5_BASE_LIBS)
-##WIN32##$(KVNO): $(OUTPRE)kvno.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj $(KLIB) $(CLIB) $(EXERES)
+##WIN32##$(KVNO): $(OUTPRE)kvno.obj $(SLIB) $(KLIB) $(CLIB) $(EXERES)
##WIN32## link $(EXE_LINKOPTS) /out:$@ $**
##WIN32## $(_VC_MANIFEST_EMBED_EXE)
diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c
index 377d4f3..80bee59 100644
--- a/src/clients/kvno/kvno.c
+++ b/src/clients/kvno/kvno.c
@@ -30,10 +30,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef _WIN32
-#include <getopt.h>
-#endif
-
#include <string.h>
extern int optind;
diff --git a/src/configure.in b/src/configure.in
index 605b0c0..8216045 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -145,6 +145,26 @@ EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_strlcpy krb5int_strlcat"])
AC_SUBST(STRLCPY_OBJ)
AC_SUBST(STRLCPY_ST_OBJ)
+AC_CHECK_FUNC(getopt,
+[GETOPT_ST_OBJ=
+GETOPT_OBJ=
+AC_DEFINE(HAVE_GETOPT, 1, [Define if system getopt should be used.])],
+[GETOPT_ST_OBJ='getopt.o'
+GETOPT_OBJ='$(OUTPRE)getopt.$(OBJEXT)'
+EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS k5_optind k5_optarg k5_opterr k5_optopt k5_getopt"])
+AC_SUBST(GETOPT_OBJ)
+AC_SUBST(GETOPT_ST_OBJ)
+
+AC_CHECK_FUNC(getopt_long,
+[GETOPT_LONG_ST_OBJ=
+GETOPT_LONG_OBJ=
+AC_DEFINE(HAVE_GETOPT_LONG, 1, [Define if system getopt_long should be used.])],
+[GETOPT_LONG_ST_OBJ='getopt_long.o'
+GETOPT_LONG_OBJ='$(OUTPRE)getopt_long.$(OBJEXT)'
+EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS k5_getopt_long"])
+AC_SUBST(GETOPT_LONG_OBJ)
+AC_SUBST(GETOPT_LONG_ST_OBJ)
+
AC_CHECK_FUNC(fnmatch,
[FNMATCH_ST_OBJ=
FNMATCH_OBJ=],
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 */
diff --git a/src/util/support/Makefile.in b/src/util/support/Makefile.in
index 5d38b03..d5da898 100644
--- a/src/util/support/Makefile.in
+++ b/src/util/support/Makefile.in
@@ -43,6 +43,16 @@ PRINTF_OBJ= @PRINTF_OBJ@
##DOS##PRINTF_ST_OBJ= printf.o
##DOS##PRINTF_OBJ= $(OUTPRE)printf.$(OBJEXT)
+GETOPT_ST_OBJ= @GETOPT_ST_OBJ@
+GETOPT_OBJ= @GETOPT_OBJ@
+##DOS##GETOPT_ST_OBJ= getopt.o
+##DOS##GETOPT_OBJ= $(OUTPRE)getopt.$(OBJEXT)
+
+GETOPT_LONG_ST_OBJ= @GETOPT_LONG_ST_OBJ@
+GETOPT_LONG_OBJ= @GETOPT_LONG_OBJ@
+##DOS##GETOPT_LONG_ST_OBJ= getopt_long.o
+##DOS##GETOPT_LONG_OBJ= $(OUTPRE)getopt_long.$(OBJEXT)
+
IPC_ST_OBJ=
IPC_OBJ=
##DOS##IPC_ST_OBJ= ipc_stream.o
@@ -78,7 +88,9 @@ STLIBOBJS= \
$(STRLCPY_ST_OBJ) \
$(FNMATCH_ST_OBJ) \
$(PRINTF_ST_OBJ) \
- $(MKSTEMP_ST_OBJ)
+ $(MKSTEMP_ST_OBJ) \
+ $(GETOPT_ST_OBJ) \
+ $(GETOPT_LONG_ST_OBJ)
LIBOBJS= \
$(OUTPRE)threads.$(OBJEXT) \
@@ -101,7 +113,9 @@ LIBOBJS= \
$(STRLCPY_OBJ) \
$(FNMATCH_OBJ) \
$(PRINTF_OBJ) \
- $(MKSTEMP_OBJ)
+ $(MKSTEMP_OBJ) \
+ $(GETOPT_OBJ) \
+ $(GETOPT_LONG_OBJ)
SRCS=\
$(srcdir)/threads.c \
@@ -128,7 +142,9 @@ SRCS=\
$(srcdir)/json.c \
$(srcdir)/bcmp.c \
$(srcdir)/strerror_r.c \
- $(srcdir)/t_utf8.c
+ $(srcdir)/t_utf8.c \
+ $(srcdir)/getopt.c \
+ $(srcdir)/getopt_long.c
SHLIB_EXPDEPS =
# Add -lm if dumping thread stats, for sqrt.
@@ -156,6 +172,7 @@ SHLIB_EXPORT_FILE=libkrb5support.exports
EXTRA_SUPPORT_SYMS= @EXTRA_SUPPORT_SYMS@
##DOS##EXTRA_SUPPORT_SYMS= krb5int_mkstemp krb5int_strlcpy krb5int_strlcat \
+##DOS## k5_optind k5_optarg k5_opterr k5_optopt k5_getopt k5_getopt_long \
##DOS## krb5int_vasprintf krb5int_asprintf krb5int_gettimeofday $(IPC_SYMS)
##DOS##!if 0
diff --git a/src/util/support/deps b/src/util/support/deps
index b27c97d..4dff014 100644
--- a/src/util/support/deps
+++ b/src/util/support/deps
@@ -84,3 +84,9 @@ strerror_r.so strerror_r.po $(OUTPRE)strerror_r.$(OBJEXT): \
t_utf8.so t_utf8.po $(OUTPRE)t_utf8.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
$(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-thread.h \
$(top_srcdir)/include/k5-utf8.h t_utf8.c
+getopt.so getopt.po $(OUTPRE)getopt.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
+ $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-thread.h \
+ getopt.c
+getopt_long.so getopt_long.po $(OUTPRE)getopt_long.$(OBJEXT): \
+ $(BUILDTOP)/include/autoconf.h $(top_srcdir)/include/k5-platform.h \
+ $(top_srcdir)/include/k5-thread.h getopt_long.c
diff --git a/src/util/windows/getopt.c b/src/util/support/getopt.c
index 4f9f062..44cda68 100644
--- a/src/util/windows/getopt.c
+++ b/src/util/support/getopt.c
@@ -34,6 +34,7 @@
* SUCH DAMAGE.
*/
+#if !defined(HAVE_GETOPT) || !defined(HAVE_UNISTD_H)
#if 0
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif
@@ -42,19 +43,14 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include "k5-platform.h"
#define __P(x) x
#define _DIAGASSERT(x) assert(x)
-#ifdef __weak_alias
-__weak_alias(getopt,_getopt);
-#endif
-
-
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
+ optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
static char * _progname __P((char *));
@@ -98,8 +94,7 @@ getopt(nargc, nargv, ostr)
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(ostr != NULL);
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
+ if (!*place) { /* update scanning pointer */
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
@@ -151,3 +146,4 @@ getopt(nargc, nargv, ostr)
}
return (optopt); /* dump back option letter */
}
+#endif /* !defined(HAVE_GETOPT) || !defined(HAVE_UNISTD_H) */
diff --git a/src/util/windows/getopt_long.c b/src/util/support/getopt_long.c
index 5002804..1b508a1 100644
--- a/src/util/windows/getopt_long.c
+++ b/src/util/support/getopt_long.c
@@ -31,18 +31,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#ifndef HAVE_GETOPT_LONG
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "getopt.h"
-
-extern int opterr; /* if error message should be printed */
-extern int optind; /* index into parent argv vector */
-extern int optopt; /* character checked for validity */
-extern int optreset; /* reset getopt */
-extern char *optarg; /* argument associated with option */
+#include "k5-platform.h"
#define __P(x) x
#define _DIAGASSERT(x) assert(x)
@@ -86,8 +81,7 @@ getopt_internal(nargc, nargv, ostr)
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(ostr != NULL);
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
+ if (!*place) { /* update scanning pointer */
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
@@ -235,3 +229,4 @@ getopt_long(nargc, nargv, options, long_options, index)
}
return(retval);
}
+#endif /* not HAVE_GETOPT_LONG */
diff --git a/src/util/windows/Makefile.in b/src/util/windows/Makefile.in
index f857c46..65b323c 100644
--- a/src/util/windows/Makefile.in
+++ b/src/util/windows/Makefile.in
@@ -1,15 +1,11 @@
BUILDTOP = ..\..
-all-windows:: $(OUTPRE)libecho.exe $(OUTPRE)getopt.lib
+all-windows:: $(OUTPRE)libecho.exe
$(OUTPRE)libecho.exe: $(OUTPRE)libecho.obj
link -out:$@ $** $(SCLIB)
$(_VC_MANIFEST_EMBED_EXE)
-
-$(OUTPRE)getopt.lib: $(OUTPRE)getopt.obj $(OUTPRE)getopt_long.obj
- lib -out:$@ $**
-
install-windows::
clean-windows::
diff --git a/src/util/windows/getopt.h b/src/util/windows/getopt.h
deleted file mode 100644
index 8832dbc..0000000
--- a/src/util/windows/getopt.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t -*- */
-#ifndef __GETOPT_H__
-#define __GETOPT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int opterr; /* if error message should be printed */
-extern int optind; /* index into parent argv vector */
-extern int optopt; /* character checked for validity */
-extern int optreset; /* reset getopt */
-extern char *optarg; /* argument associated with option */
-
-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(int, char**, char*);
-int getopt_long(int, char**, char*, struct option*, int*);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __GETOPT_H__ */
diff --git a/src/windows/installer/wix/files.wxi b/src/windows/installer/wix/files.wxi
index ee18251..9194caf 100644
--- a/src/windows/installer/wix/files.wxi
+++ b/src/windows/installer/wix/files.wxi
@@ -418,7 +418,6 @@
<Directory Id="dirlib_i386" Name="i386" FileSource="$(var.LibDir)">
<Component Win64="$(var.Win64)" Id="cmp_dirlib_i386" Guid="CFEE3ED4-92D4-49e1-BB78-8BCBC60C3E57" DiskId="1">
<File Id="fil_comerr32_lib" Name="comerr32.lib" />
- <File Id="fil_getopt_32_lib" Name="getopt.lib" />
<File Id="fil_gssapi32_lib" Name="gssapi32.lib" />
<File Id="fil_krb5_32_lib" Name="krb5_32.lib" KeyPath="yes" />
<File Id="fil_krbcc32_lib" Name="krbcc32.lib" />
@@ -432,7 +431,6 @@
<Directory Id="dirlib_amd64" Name="amd64" FileSource="$(var.LibDir)">
<Component Win64="$(var.Win64)" Id="cmp_dirlib_amd64" Guid="F9A54201-FFD6-4a45-B021-276D9F6C40A2" DiskId="1">
<File Id="fil_comerr64_lib" Name="comerr64.lib" />
- <File Id="fil_getopt_64_lib" Name="getopt.lib" />
<File Id="fil_gssapi64_lib" Name="gssapi64.lib" />
<File Id="fil_krb5_64_lib" Name="krb5_64.lib" KeyPath="yes" />
<File Id="fil_krbcc64_lib" Name="krbcc64.lib" />
diff --git a/src/windows/ms2mit/Makefile.in b/src/windows/ms2mit/Makefile.in
index 59d5e7f..9af69ce 100644
--- a/src/windows/ms2mit/Makefile.in
+++ b/src/windows/ms2mit/Makefile.in
@@ -24,11 +24,11 @@ $(MIT2MSRES): $(VERSIONRC)
all-windows:: $(MS2MIT) $(MIT2MS)
$(MS2MIT): $(OUTPRE)ms2mit.obj $(MS2MITRES)
- link $(EXE_LINKOPTS) -out:$@ $(OUTPRE)ms2mit.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj user32.lib advapi32.lib $(KLIB) $(CLIB) $(MS2MITRES)
+ link $(EXE_LINKOPTS) -out:$@ $(OUTPRE)ms2mit.obj $(SLIB) user32.lib advapi32.lib $(KLIB) $(CLIB) $(MS2MITRES)
$(_VC_MANIFEST_EMBED_EXE)
$(MIT2MS): $(OUTPRE)mit2ms.obj $(MIT2MSRES)
- link $(EXE_LINKOPTS) -out:$@ $(OUTPRE)mit2ms.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.obj user32.lib advapi32.lib $(KLIB) $(CLIB) $(MIT2MSRES)
+ link $(EXE_LINKOPTS) -out:$@ $(OUTPRE)mit2ms.obj $(SLIB) user32.lib advapi32.lib $(KLIB) $(CLIB) $(MIT2MSRES)
$(_VC_MANIFEST_EMBED_EXE)
install::
diff --git a/src/windows/ms2mit/mit2ms.c b/src/windows/ms2mit/mit2ms.c
index 5dc057e..24153ce 100644
--- a/src/windows/ms2mit/mit2ms.c
+++ b/src/windows/ms2mit/mit2ms.c
@@ -26,9 +26,7 @@
#include "krb5.h"
#include <stdio.h>
#include <string.h>
-
-extern int optind;
-extern char *optarg;
+#include "k5-platform.h"
static char *prog;
diff --git a/src/windows/ms2mit/ms2mit.c b/src/windows/ms2mit/ms2mit.c
index ebc9abd..c332503 100644
--- a/src/windows/ms2mit/ms2mit.c
+++ b/src/windows/ms2mit/ms2mit.c
@@ -29,9 +29,6 @@
#include <string.h>
#include <time.h>
-extern int optind;
-extern char *optarg;
-
static char *prog;
static void