From 20503c70478e0f83b7cafebbbb759de801a1d53e Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 24 Dec 2014 17:10:40 -0800 Subject: Check for getopt_long(), not getopt(). We support three types of platforms: 1) UN*Xes that have both getopt() and getopt_long(); 2) UN*Xes that have getopt() but not getopt_long(); 3) Windows, which has neither. Checking for getopt_long() lets us distinguish between 1) and 2) and build getopt_long() for them. Change-Id: Iaf0f142f9bebaa2eed2128d544ec9786711def45 Reviewed-on: https://code.wireshark.org/review/6045 Reviewed-by: Guy Harris --- ConfigureChecks.cmake | 2 +- capinfos.c | 2 +- captype.c | 2 +- cmakeconfig.h.in | 4 ++-- configure.ac | 4 ++-- dumpcap.c | 2 +- editcap.c | 2 +- mergecap.c | 2 +- randpkt.c | 2 +- rawshark.c | 2 +- reordercap.c | 2 +- text2pcap.c | 2 +- tfshark.c | 2 +- tshark.c | 2 +- ui/gtk/main.c | 2 +- ui/qt/main.cpp | 10 ++++++---- wsutil/CMakeLists.txt | 2 +- 17 files changed, 24 insertions(+), 22 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 03beda2232..bc530a93b7 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -77,7 +77,7 @@ cmake_pop_check_state() # check_symbol_exists("floorl" "math.h" HAVE_FLOORL) check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2) -check_function_exists("getopt" HAVE_GETOPT) +check_function_exists("getopt_long" HAVE_GETOPT_LONG) check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER) check_function_exists("inet_aton" HAVE_INET_ATON) check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO) diff --git a/capinfos.c b/capinfos.c index 8b4bfeaf05..3559fb9da1 100644 --- a/capinfos.c +++ b/capinfos.c @@ -100,7 +100,7 @@ #include #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/captype.c b/captype.c index 5d6789ddb7..3dc8f73f29 100644 --- a/captype.c +++ b/captype.c @@ -70,7 +70,7 @@ #include #endif /* _WIN32 */ -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index a0388be056..d5b29529cc 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -72,8 +72,8 @@ /* Define to 1 if you have the `gethostbyname2' function. */ #cmakedefine HAVE_GETHOSTBYNAME2 1 -/* Define to 1 if you have the getopt function. */ -#cmakedefine HAVE_GETOPT 1 +/* Define to 1 if you have the getopt_long function. */ +#cmakedefine HAVE_GETOPT_LONG 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GETOPT_H 1 diff --git a/configure.ac b/configure.ac index 86fb03f8f4..5ebfa04c7f 100644 --- a/configure.ac +++ b/configure.ac @@ -2665,10 +2665,10 @@ AC_C_BIGENDIAN # XXX - do we need this? AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNC(getopt, +AC_CHECK_FUNC(getopt_long, [ GETOPT_LO="" - AC_DEFINE(HAVE_GETOPT, 1, [Define to 1 if you have the getopt function.]) + AC_DEFINE(HAVE_GETOPT_LONG, 1, [Define to 1 if you have the getopt_long function.]) ], GETOPT_LO="wsgetopt.lo") AC_SUBST(GETOPT_LO) diff --git a/dumpcap.c b/dumpcap.c index 31e40f7252..b3fb1128d5 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -74,7 +74,7 @@ #include #include -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/editcap.c b/editcap.c index 911e556a38..37680bdddd 100644 --- a/editcap.c +++ b/editcap.c @@ -64,7 +64,7 @@ #include "wtap.h" -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/mergecap.c b/mergecap.c index 9cd1d7066d..89a27f5a8c 100644 --- a/mergecap.c +++ b/mergecap.c @@ -49,7 +49,7 @@ #include #include "wtap.h" -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include #endif diff --git a/randpkt.c b/randpkt.c index d19545987f..4269485777 100644 --- a/randpkt.c +++ b/randpkt.c @@ -27,7 +27,7 @@ #include #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/rawshark.c b/rawshark.c index c0a0593096..cbb69afb4d 100644 --- a/rawshark.c +++ b/rawshark.c @@ -60,7 +60,7 @@ # include #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/reordercap.c b/reordercap.c index ba5a9d87a4..b70b7e3839 100644 --- a/reordercap.c +++ b/reordercap.c @@ -42,7 +42,7 @@ #include "wtap.h" -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/text2pcap.c b/text2pcap.c index bdbd4e4ddc..e3ef07311c 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -133,7 +133,7 @@ #include /* to get the libz version number */ #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/tfshark.c b/tfshark.c index 30c91a4cff..6004720cea 100644 --- a/tfshark.c +++ b/tfshark.c @@ -53,7 +53,7 @@ #include /* to get the libz version number */ #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/tshark.c b/tshark.c index 52cc84679a..973a31f812 100644 --- a/tshark.c +++ b/tshark.c @@ -58,7 +58,7 @@ # include #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 6675ec29d5..86c5150c2f 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -40,7 +40,7 @@ #include #endif -#ifndef HAVE_GETOPT +#ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 3048c92b5e..2acdb80688 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -33,10 +33,12 @@ #include /* to get the libz version number */ #endif -#ifndef HAVE_GETOPT -# include "wsutil/wsgetopt.h" -#else -# include +#ifdef HAVE_GETOPT_H +#include +#endif + +#ifndef HAVE_GETOPT_LONG +#include "wsutil/wsgetopt.h" #endif #include diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index f0595000ac..d4fed7d70f 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -85,7 +85,7 @@ if(HAVE_SSE4_2) set(WSUTIL_FILES ${WSUTIL_FILES} ws_mempbrk_sse42.c) endif() -if(NOT HAVE_GETOPT) +if(NOT HAVE_GETOPT_LONG) set(WSUTIL_FILES ${WSUTIL_FILES} wsgetopt.c) endif() -- cgit v1.2.3