aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ConfigureChecks.cmake5
-rw-r--r--Makefile.common4
-rw-r--r--Makefile.nmake38
-rw-r--r--capinfos.c6
-rw-r--r--cmakeconfig.h.in6
-rw-r--r--config.h.win321
-rw-r--r--configure.in14
-rw-r--r--dumpcap.c7
-rw-r--r--editcap.c8
-rw-r--r--gtk/main.c7
-rw-r--r--mergecap.c8
-rw-r--r--randpkt.c9
-rw-r--r--rawshark.c7
-rw-r--r--text2pcap.c6
-rw-r--r--tshark.c7
-rw-r--r--wsgetopt.c (renamed from getopt.c)2
-rw-r--r--wsgetopt.h (renamed from getopt.h)0
17 files changed, 71 insertions, 64 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 6e728cef58..d1056affa6 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -1,5 +1,4 @@
-# todo: result for NEED_... is wrong (inverted), at least
-# in the case of getopt
+# todo: result for NEED_... is wrong (inverted)
#check system for includes
include(CheckIncludeFile)
@@ -9,7 +8,7 @@ check_include_file("direct.h" HAVE_DIRECT_H)
check_include_file("dirent.h" HAVE_DIRENT_H)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("fcntl.h" HAVE_FCNTL_H)
-check_include_file("getopt.h" NEED_GETOPT_H)
+check_include_file("getopt.h" HAVE_GETOPT_H)
check_include_file("grp.h" HAVE_GRP_H)
check_include_file("g_ascii_strtoull.h" NEED_G_ASCII_STRTOULL_H)
check_include_file("inet/aton.h" NEED_INET_ATON_H)
diff --git a/Makefile.common b/Makefile.common
index 39496e7e3b..b2995d6820 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -122,7 +122,7 @@ TSHARK_TAP_SRC = \
# helpers already available on some platforms (and on others not)
EXTRA_wireshark_SOURCES = \
- getopt.c \
+ wsgetopt.c \
inet_ntop.c \
inet_pton.c \
strerror.c \
@@ -131,7 +131,7 @@ EXTRA_wireshark_SOURCES = \
# corresponding headers
EXTRA_wireshark_INCLUDES = \
- getopt.h \
+ wsgetopt.h \
inet_v6defs.h \
strerror.h \
strptime.h
diff --git a/Makefile.nmake b/Makefile.nmake
index a1da5b323a..7809cae3e2 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -73,7 +73,7 @@ dumpcap_OBJECTS = $(dumpcap_SOURCES:.c=.obj)
randpkt_OBJECTS = $(randpkt_SOURCES:.c=.obj)
EXTRA_OBJECTS = \
- getopt.obj \
+ wsgetopt.obj \
inet_ntop.obj \
inet_pton.obj \
strptime.obj
@@ -244,28 +244,28 @@ $(RESOURCES): image
wiretap\wiretap-$(WTAP_VERSION).lib: image $(ZLIB_DLL) wiretap
-wireshark.exe : $(LIBS_CHECK) config.h svnversion.h $(wireshark_OBJECTS) getopt.obj inet_ntop.obj inet_pton.obj codecs epan gtk image\wireshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk\libui.lib plugins
+wireshark.exe : $(LIBS_CHECK) config.h svnversion.h $(wireshark_OBJECTS) wsgetopt.obj inet_ntop.obj inet_pton.obj codecs epan gtk image\wireshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk\libui.lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) getopt.obj inet_ntop.obj inet_pton.obj $(GTK_LIBS) codecs\codecs.lib gtk\libui.lib $(wireshark_OBJECTS) image\wireshark.res
+ /OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) wsgetopt.obj inet_ntop.obj inet_pton.obj $(GTK_LIBS) codecs\codecs.lib gtk\libui.lib $(wireshark_OBJECTS) image\wireshark.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "wireshark.exe.manifest" -outputresource:wireshark.exe;1
!ENDIF
-tshark.exe : $(LIBS_CHECK) config.h svnversion.h $(tshark_OBJECTS) getopt.obj inet_ntop.obj epan image\tshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
+tshark.exe : $(LIBS_CHECK) config.h svnversion.h $(tshark_OBJECTS) wsgetopt.obj inet_ntop.obj epan image\tshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(tshark_LIBS) $(tshark_OBJECTS) getopt.obj inet_ntop.obj image\tshark.res
+ /OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(tshark_LIBS) $(tshark_OBJECTS) wsgetopt.obj inet_ntop.obj image\tshark.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "tshark.exe.manifest" -outputresource:tshark.exe;1
!ENDIF
-rawshark.exe : $(LIBS_CHECK) config.h svnversion.h $(rawshark_OBJECTS) getopt.obj inet_ntop.obj epan image\rawshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
+rawshark.exe : $(LIBS_CHECK) config.h svnversion.h $(rawshark_OBJECTS) wsgetopt.obj inet_ntop.obj epan image\rawshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:rawshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(rawshark_LIBS) $(rawshark_OBJECTS) getopt.obj inet_ntop.obj image\rawshark.res
+ /OUT:rawshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(rawshark_LIBS) $(rawshark_OBJECTS) wsgetopt.obj inet_ntop.obj image\rawshark.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "rawshark.exe.manifest" -outputresource:rawshark.exe;1
@@ -273,10 +273,10 @@ rawshark.exe : $(LIBS_CHECK) config.h svnversion.h $(rawshark_OBJECTS) getopt.ob
# XXX: This makefile does not properly handle doing a 'nmake ... capinfos.exe' directly since some of the .objs
# (e.g. epan\plugins.obj) must be built first using epan\Makefile.nmake (which happens for 'nmake ... all').
-capinfos.exe : $(LIBS_CHECK) config.h $(capinfos_OBJECTS) getopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\capinfos.res
+capinfos.exe : $(LIBS_CHECK) config.h $(capinfos_OBJECTS) wsgetopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\capinfos.res
@echo Linking $@
$(LINK) @<<
- /OUT:capinfos.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(capinfos_OBJECTS) getopt.obj $(capinfos_LIBS) image\capinfos.res
+ /OUT:capinfos.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(capinfos_OBJECTS) wsgetopt.obj $(capinfos_LIBS) image\capinfos.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "capinfos.exe.manifest" -outputresource:capinfos.exe;1
@@ -284,28 +284,28 @@ capinfos.exe : $(LIBS_CHECK) config.h $(capinfos_OBJECTS) getopt.obj wsutil\libw
# XXX: This makefile does not properly handle doing a 'nmake ... editcap.exe' directly since some of the .objs
# (e.g. epan\plugins.obj) must be built first using epan\Makefile.nmake (which happens for 'nmake ... all').
-editcap.exe : $(LIBS_CHECK) config.h $(editcap_OBJECTS) getopt.obj strptime.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\editcap.res
+editcap.exe : $(LIBS_CHECK) config.h $(editcap_OBJECTS) wsgetopt.obj strptime.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\editcap.res
@echo Linking $@
$(LINK) @<<
- /OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(editcap_OBJECTS) getopt.obj strptime.obj $(editcap_LIBS) image\editcap.res
+ /OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(editcap_OBJECTS) wsgetopt.obj strptime.obj $(editcap_LIBS) image\editcap.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "editcap.exe.manifest" -outputresource:editcap.exe;1
!ENDIF
-mergecap.exe : $(LIBS_CHECK) config.h svnversion.h mergecap.obj merge.obj getopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
+mergecap.exe : $(LIBS_CHECK) config.h svnversion.h mergecap.obj merge.obj wsgetopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
@echo Linking $@
$(LINK) @<<
- /OUT:mergecap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console mergecap.obj merge.obj getopt.obj $(mergecap_LIBS) image\mergecap.res
+ /OUT:mergecap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console mergecap.obj merge.obj wsgetopt.obj $(mergecap_LIBS) image\mergecap.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "mergecap.exe.manifest" -outputresource:mergecap.exe;1
!ENDIF
-text2pcap.exe : $(LIBS_CHECK) config.h text2pcap.obj text2pcap-scanner.obj getopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib strptime.obj image\text2pcap.res
+text2pcap.exe : $(LIBS_CHECK) config.h text2pcap.obj text2pcap-scanner.obj wsgetopt.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib strptime.obj image\text2pcap.res
@echo Linking $@
$(LINK) @<<
- /OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console text2pcap.obj text2pcap-scanner.obj getopt.obj $(text2pcap_LIBS) strptime.obj image\text2pcap.res
+ /OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console text2pcap.obj text2pcap-scanner.obj wsgetopt.obj $(text2pcap_LIBS) strptime.obj image\text2pcap.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "text2pcap.exe.manifest" -outputresource:text2pcap.exe;1
@@ -320,19 +320,19 @@ dftest.exe : $(dftest_OBJECTS) epan
mt.exe -nologo -manifest "dftest.exe.manifest" -outputresource:dftest.exe;1
!ENDIF
-randpkt.exe : $(randpkt_OBJECTS) getopt.obj
+randpkt.exe : $(randpkt_OBJECTS) wsgetopt.obj
@echo Linking $@
$(LINK) @<<
- /OUT:randpkt.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(randpkt_LIBS) $(randpkt_OBJECTS) getopt.obj
+ /OUT:randpkt.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(randpkt_LIBS) $(randpkt_OBJECTS) wsgetopt.obj
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "randpkt.exe.manifest" -outputresource:randpkt.exe;1
!ENDIF
-dumpcap.exe : $(LIBS_CHECK) config.h svnversion.h $(dumpcap_OBJECTS) getopt.obj inet_ntop.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\dumpcap.res
+dumpcap.exe : $(LIBS_CHECK) config.h svnversion.h $(dumpcap_OBJECTS) wsgetopt.obj inet_ntop.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\dumpcap.res
@echo Linking $@
$(LINK) @<<
- /OUT:dumpcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dumpcap_LIBS) $(dumpcap_OBJECTS) getopt.obj inet_ntop.obj image\dumpcap.res
+ /OUT:dumpcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dumpcap_LIBS) $(dumpcap_OBJECTS) wsgetopt.obj inet_ntop.obj image\dumpcap.res
<<
!IF $(MSC_VER_REQUIRED) >= 1400
mt.exe -nologo -manifest "dumpcap.exe.manifest" -outputresource:dumpcap.exe;1
diff --git a/capinfos.c b/capinfos.c
index 972ff13cc7..e562236ac5 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -51,8 +51,10 @@
#include "wtap.h"
#include <wsutil/privileges.h>
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
static gboolean cap_file_type = FALSE; /* Do not report capture type */
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index f3ce7afc9a..14a364aaa5 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -39,6 +39,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H 1
+/* Define to 1 if you have the <getopt.h> header file. */
+#cmakedefine HAVE_GETOPT_H 1
+
/* Define to 1 if you have the `chown' function. */
#cmakedefine HAVE_CHOWN 1
@@ -276,9 +279,6 @@
/* Note: always defines PRI[doxu]64 macros so inttypes.h becomes useless.*/
#cmakedefine INTTYPES_H_DEFINES_FORMATS 1
-/* Define if getopt.h needs to be included */
-#cmakedefine NEED_GETOPT_H 1
-
/* Define if g_ascii_strtoull.h needs to be included */
#cmakedefine NEED_G_ASCII_STRTOULL_H 1
diff --git a/config.h.win32 b/config.h.win32
index 6cc50556c1..a1714b5c6a 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -203,7 +203,6 @@
#define NEED_INET_ATON_H 1
#define NEED_INET_V6DEFS_H 1
-#define NEED_GETOPT_H 1
#define NEED_STRPTIME_H 1
#ifndef WIN32
diff --git a/configure.in b/configure.in
index c7c1f6c90a..5ec0a1dbad 100644
--- a/configure.in
+++ b/configure.in
@@ -1421,13 +1421,15 @@ AC_PROG_GCC_TRADITIONAL
GETOPT_C=""
GETOPT_O=""
-AC_CHECK_FUNC(getopt, GETOPT_O="",
- [GETOPT_O="getopt.o"
- AC_DEFINE(NEED_GETOPT_H, 1, [Define if getopt.h needs to be included])
-])
+AC_CHECK_FUNC(getopt,
+ [GETOPT_O=""
+ AC_DEFINE(HAVE_GETOPT_H, 1, [Define to 1 if you have the <getopt.h> header file.])
+ ],
+ GETOPT_O="wsgetopt.o"
+)
if test "$ac_cv_func_getopt" = no ; then
- GETOPT_C="getopt.c"
- GETOPT_O="getopt.o"
+ GETOPT_C="wsgetopt.c"
+ GETOPT_O="wsgetopt.o"
fi
AC_SUBST(GETOPT_C)
AC_SUBST(GETOPT_O)
diff --git a/dumpcap.c b/dumpcap.c
index f9538caff1..99dd98f0d1 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -51,8 +51,10 @@
#include <signal.h>
#include <errno.h>
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#ifdef HAVE_NETDB_H
@@ -2543,7 +2545,6 @@ int
main(int argc, char *argv[])
{
int opt;
- extern char *optarg;
gboolean arg_error = FALSE;
#ifdef _WIN32
diff --git a/editcap.c b/editcap.c
index b401066535..5937cbac37 100644
--- a/editcap.c
+++ b/editcap.c
@@ -42,8 +42,10 @@
#include "wtap.h"
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#ifdef _WIN32
@@ -672,8 +674,6 @@ main(int argc, char *argv[])
wtap *wth;
int i, j, err;
gchar *err_info;
- extern char *optarg;
- extern int optind;
int opt;
char *p;
unsigned int snaplen = 0; /* No limit */
diff --git a/gtk/main.c b/gtk/main.c
index dfdb3713bc..e7550ce963 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -45,8 +45,10 @@
#include "strerror.h"
#endif
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#ifdef _WIN32 /* Needed for console I/O */
@@ -1816,7 +1818,6 @@ main(int argc, char *argv[])
char *init_progfile_dir_error;
char *s;
int opt;
- extern char *optarg;
gboolean arg_error = FALSE;
extern int splash_register_freq; /* Found in about_dlg.c */
diff --git a/mergecap.c b/mergecap.c
index 2f493c895e..bf58298cca 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -27,8 +27,10 @@
#include <string.h>
#include "wtap.h"
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#include "svnversion.h"
@@ -140,8 +142,6 @@ static void list_encap_types(void) {
int
main(int argc, char *argv[])
{
- extern char *optarg;
- extern int optind;
int opt;
gboolean do_append = FALSE;
gboolean verbose = FALSE;
diff --git a/randpkt.c b/randpkt.c
index 2d92d95ea6..a018265112 100644
--- a/randpkt.c
+++ b/randpkt.c
@@ -27,8 +27,10 @@
#include "config.h"
#endif
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#ifdef HAVE_UNISTD_H
@@ -500,9 +502,6 @@ main(int argc, char **argv)
guint8 buffer[65536];
int opt;
- extern char *optarg;
- extern int optind;
-
int produce_count = 1000; /* number of pkts to produce */
int produce_type = PKT_ETHERNET;
char *produce_filename = NULL;
diff --git a/rawshark.c b/rawshark.c
index 794e2a173a..247cafbc3c 100644
--- a/rawshark.c
+++ b/rawshark.c
@@ -65,8 +65,10 @@
#include "strerror.h"
#endif
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#include <glib.h>
@@ -428,7 +430,6 @@ main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt, i;
- extern char *optarg;
gboolean arg_error = FALSE;
#ifdef _WIN32
diff --git a/text2pcap.c b/text2pcap.c
index b799262c6f..2b47f9f835 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -125,8 +125,10 @@
#include <errno.h>
#include <assert.h>
-#ifdef NEED_GETOPT_H
-# include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#ifdef NEED_STRPTIME_H
diff --git a/tshark.c b/tshark.c
index 3cef9e486c..b925efcab1 100644
--- a/tshark.c
+++ b/tshark.c
@@ -55,8 +55,10 @@
#include "strerror.h"
#endif
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
#endif
#include <glib.h>
@@ -733,7 +735,6 @@ main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt;
- extern char *optarg;
gboolean arg_error = FALSE;
#ifdef _WIN32
diff --git a/getopt.c b/wsgetopt.c
index 47c70d047d..2fc16c04b1 100644
--- a/getopt.c
+++ b/wsgetopt.c
@@ -83,7 +83,7 @@
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
-#include "getopt.h"
+#include "wsgetopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
diff --git a/getopt.h b/wsgetopt.h
index e22c634bcc..e22c634bcc 100644
--- a/getopt.h
+++ b/wsgetopt.h