diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 918a62803d..cfa63150ea 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -31,7 +31,6 @@ check_include_file("dlfcn.h" HAVE_DLFCN_H) check_include_file("fcntl.h" HAVE_FCNTL_H) check_include_file("getopt.h" HAVE_GETOPT_H) check_include_file("grp.h" HAVE_GRP_H) -check_include_file("inet/aton.h" HAVE_INET_ATON_H) check_include_file("inttypes.h" HAVE_INTTYPES_H) check_include_file("memory.h" HAVE_MEMORY_H) check_include_file("netinet/in.h" HAVE_NETINET_IN_H) @@ -83,6 +82,7 @@ cmake_pop_check_state() check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2) check_function_exists("getopt" HAVE_GETOPT) check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER) +check_function_exists("inet_aton" HAVE_INET_ATON) check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO) check_function_exists("issetugid" HAVE_ISSETUGID) check_function_exists("mmap" HAVE_MMAP) @@ -91,6 +91,18 @@ check_function_exists("mkdtemp" HAVE_MKDTEMP) check_function_exists("mkstemp" HAVE_MKSTEMP) check_function_exists("setresgid" HAVE_SETRESGID) check_function_exists("setresuid" HAVE_SETRESUID) + +# +# Windows doesn't have strncasecmp, but does have stricmp, which has +# the same signature and behavior. We #define strncasecmp to stricmp +# on Windows. +# +if(WIN32) + check_function_exists("stricmp" HAVE_STRNCASECMP) +else() + check_function_exists("strncasecmp" HAVE_STRNCASECMP) +endif() +check_function_exists("strptime" HAVE_STRPTIME) check_function_exists("sysconf" HAVE_SYSCONF) #Struct members diff --git a/config.h.win32 b/config.h.win32 index 2db0fed132..b19b7dc7b6 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -216,9 +216,14 @@ /* Define to have ntddndis.h */ @HAVE_NTDDNDIS_H@ -/* #undef HAVE_INET_ATON_H */ +/* Define to 1 if you have the strncasecmp function. */ +/* Actually, we don't, but we have strnicmp, and #define strncasecmp to strnicmp below */ +#define HAVE_STRNCASECMP 1 + +/* Define if you have the strptime function. */ +/* #undef HAVE_STRPTIME 1 */ + #define NEED_INET_V6DEFS_H 1 -#define NEED_STRPTIME_H 1 #ifndef WIN32 #define WIN32 1 diff --git a/configure.ac b/configure.ac index 13347884f6..13c1de5f94 100644 --- a/configure.ac +++ b/configure.ac @@ -2530,38 +2530,30 @@ AC_C_BIGENDIAN # XXX - do we need this? AC_PROG_GCC_TRADITIONAL -GETOPT_LO="" AC_CHECK_FUNC(getopt, - [GETOPT_LO="" - AC_DEFINE(HAVE_GETOPT, 1, [Define to 1 if you have the getopt function.]) + [ + GETOPT_LO="" + AC_DEFINE(HAVE_GETOPT, 1, [Define to 1 if you have the getopt function.]) ], - GETOPT_LO="wsgetopt.lo" -) -if test "$ac_cv_func_getopt" = no ; then - GETOPT_LO="wsgetopt.lo" -fi -AM_CONDITIONAL(NEED_GETOPT_LO, test "x$ac_cv_func_getopt" = "xno") + GETOPT_LO="wsgetopt.lo") AC_SUBST(GETOPT_LO) -AC_CHECK_FUNC(strncasecmp, STRNCASECMP_LO="", +AC_CHECK_FUNC(strncasecmp, + [ + STRNCASECMP_LO="" + AC_DEFINE(HAVE_STRNCASECMP, 1, [Define to 1 if you have the strncasecmp function.]) + ], STRNCASECMP_LO="strncasecmp.lo") -if test "$ac_cv_func_strncasecmp" = no ; then - STRNCASECMP_LO="strncasecmp.lo" -fi -AM_CONDITIONAL(NEED_STRNCASECMP_LO, test "x$ac_cv_func_strncasecmp" = "xno") AC_SUBST(STRNCASECMP_LO) AC_CHECK_FUNCS(mkstemp mkdtemp) -AC_SEARCH_LIBS(inet_aton, [socket nsl], have_inet_aton=yes, - have_inet_aton=no) -if test "$have_inet_aton" = no; then - INET_ATON_LO="inet_aton.lo" - AC_DEFINE(HAVE_INET_ATON_H, 0, [Define unless inet/aton.h needs to be included]) -else - INET_ATON_LO="" -fi -AM_CONDITIONAL(NEED_INET_ATON_LO, test "x$have_inet_aton" = "xno") +AC_SEARCH_LIBS(inet_aton, [socket nsl], + [ + INET_ATON_LO="" + AC_DEFINE(HAVE_INET_ATON, 0, [Define to 1 if you have the inet_aton function.]) + ], + INET_ATON_LO="inet_aton.lo") AC_SUBST(INET_ATON_LO) AC_SEARCH_LIBS(inet_pton, [socket nsl], [ @@ -2623,15 +2615,12 @@ extern const char *inet_ntop(int, const void *, char *, socklen_t);],, [ AM_CONDITIONAL(NEED_INET_NTOP_LO, test "x$INET_NTOP_LO" != "x") AC_SUBST(INET_NTOP_LO) -AC_CHECK_FUNC(strptime, STRPTIME_LO="", - [STRPTIME_LO="strptime.lo" - AC_DEFINE(NEED_STRPTIME_H, 1, [Define if strptime.h needs to be included]) -]) -if test "$ac_cv_func_strptime" = no ; then - STRPTIME_LO="strptime.lo" -fi -AC_SUBST(STRPTIME_C) -AM_CONDITIONAL(NEED_STRPTIME_LO, test "x$ac_cv_func_strptime" = "no") +AC_CHECK_FUNC(strptime, + [ + STRPTIME_LO="" + AC_DEFINE(HAVE_STRPTIME, 1, [Define if you have the strptime function.]) + ], + STRPTIME_LO="strptime.lo") AC_SUBST(STRPTIME_LO) AC_CHECK_FUNCS(getprotobynumber gethostbyname2) diff --git a/editcap.c b/editcap.c index 4432d41984..a6d4720e3c 100644 --- a/editcap.c +++ b/editcap.c @@ -77,7 +77,7 @@ #endif #endif -#ifdef NEED_STRPTIME_H +#ifndef HAVE_STRPTIME # include "wsutil/strptime.h" #endif diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index fbfc7295de..7e1420976c 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -85,7 +85,7 @@ #include /* needed to define AF_ values on Windows */ #endif -#ifndef HAVE_INET_ATON_H +#ifndef HAVE_INET_ATON # include "wsutil/inet_aton.h" #endif diff --git a/epan/dissectors/packet-dcom.c b/epan/dissectors/packet-dcom.c index d26b407f96..c185ce4d0d 100644 --- a/epan/dissectors/packet-dcom.c +++ b/epan/dissectors/packet-dcom.c @@ -81,7 +81,9 @@ #include #include #include +#ifndef HAVE_INET_ATON #include +#endif #include #include #include diff --git a/epan/dissectors/packet-lbmr.c b/epan/dissectors/packet-lbmr.c index f891bcc236..8e95b68bc9 100644 --- a/epan/dissectors/packet-lbmr.c +++ b/epan/dissectors/packet-lbmr.c @@ -41,7 +41,9 @@ #include #include #include -#include +#ifndef HAVE_INET_ATON + #include +#endif #include #include "packet-lbm.h" #include "packet-lbtru.h" diff --git a/epan/dissectors/packet-lbtrm.c b/epan/dissectors/packet-lbtrm.c index 4fa8b42820..c7165aa59f 100644 --- a/epan/dissectors/packet-lbtrm.c +++ b/epan/dissectors/packet-lbtrm.c @@ -38,7 +38,9 @@ #include #include #include -#include +#ifndef HAVE_INET_ATON + #include +#endif #include #include "packet-lbm.h" #include "packet-lbtrm.h" diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c index 8b3471956f..1bbf793169 100644 --- a/epan/ftypes/ftype-time.c +++ b/epan/ftypes/ftype-time.c @@ -39,7 +39,7 @@ #include #include -#ifdef NEED_STRPTIME_H +#ifndef HAVE_STRPTIME #include "wsutil/strptime.h" #endif diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 1ad77b7cf9..11fe105cdf 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -59,7 +59,7 @@ * yet defined. */ #include -/*#ifdef NEED_STRPTIME_H*/ +/*#ifndef HAVE_STRPTIME*/ #ifndef strptime #include "wsutil/strptime.h" #endif diff --git a/text2pcap.c b/text2pcap.c index e308ffc3ea..d5ba3e718d 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -139,7 +139,7 @@ #include "wsutil/wsgetopt.h" #endif -#ifdef NEED_STRPTIME_H +#ifndef HAVE_STRPTIME # include "wsutil/strptime.h" #endif @@ -159,7 +159,7 @@ #include /* needed to define AF_ values on Windows */ #endif -#ifndef HAVE_INET_ATON_H +#ifndef HAVE_INET_ATON # include "wsutil/inet_aton.h" #endif diff --git a/ui/text_import.c b/ui/text_import.c index 374b5af283..7b40c49a50 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -125,7 +125,7 @@ #include #include -#ifdef NEED_STRPTIME_H +#ifndef HAVE_STRPTIME # include "wsutil/strptime.h" #endif diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 385acc6e73..c2e0c22186 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -25,32 +25,14 @@ DIST_SUBDIRS = $(SUBDIRS) ACLOCAL_AMFLAGS = `../aclocal-flags` # Optional objects that I know how to build. These will be -# linked into libwsutil. -wsutil_optional_objects = - -if NEED_GETOPT_LO -wsutil_optional_objects += @GETOPT_LO@ -endif - -if NEED_INET_ATON_LO -wsutil_optional_objects += @INET_ATON_LO@ -endif - -if NEED_INET_NTOP_LO -wsutil_optional_objects += @INET_NTOP_LO@ -endif - -if NEED_INET_PTON_LO -wsutil_optional_objects += @INET_PTON_LO@ -endif - -if NEED_STRNCASECMP_LO -wsutil_optional_objects += @STRNCASECMP_LO@ -endif - -if NEED_STRPTIME_LO -wsutil_optional_objects += @STRPTIME_LO@ -endif +# linked into libwsutil if necessary. +wsutil_optional_objects = \ + @GETOPT_LO@ \ + @INET_ATON_LO@ \ + @INET_NTOP_LO@ \ + @INET_PTON_LO@ \ + @STRNCASECMP_LO@ \ + @STRPTIME_LO@ if SSE42_SUPPORTED wsutil_optional_objects += libwsutil_sse42.la @@ -92,6 +74,7 @@ EXTRA_libwsutil_la_SOURCES= \ inet_pton.c \ inet_v6defs.h \ strncasecmp.c \ + strncasecmp.h \ strptime.c \ strptime.h \ wsgetopt.c \ diff --git a/wsutil/strncasecmp.c b/wsutil/strncasecmp.c index da8b862482..57953b9f04 100644 --- a/wsutil/strncasecmp.c +++ b/wsutil/strncasecmp.c @@ -21,6 +21,8 @@ #include #include +#include "wsutil/strncasecmp.h" + /* Compare no more than N characters of S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less diff --git a/wsutil/strncasecmp.h b/wsutil/strncasecmp.h new file mode 100644 index 0000000000..bfc3b63561 --- /dev/null +++ b/wsutil/strncasecmp.h @@ -0,0 +1,32 @@ +/* strncasecmp.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __STRNCASECMP_H__ +#define __STRNCASECMP_H__ + +#include "ws_symbol_export.h" + +/* + * Version of "strncasecmp()", for the benefit of OSes that don't have it. + */ +WS_DLL_PUBLIC int strncasecmp (const char *, const char *, size_t); + +#endif diff --git a/wsutil/strptime.c b/wsutil/strptime.c index d6603a9d53..7a8fe2a13e 100644 --- a/wsutil/strptime.c +++ b/wsutil/strptime.c @@ -31,6 +31,10 @@ #include #include +#ifndef HAVE_STRNCASECMP +#include "wsutil/strncasecmp.h" +#endif + #ifdef _LIBC # include "../locale/localeinfo.h" #endif