aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-07-06 14:02:39 -0700
committerGuy Harris <guy@alum.mit.edu>2014-07-06 21:03:09 +0000
commit5bfc21cf9e42af13a8d1ad6eb545ab82cb7dbe9d (patch)
tree89a9afacd2d37d3eadc22165a0256a14b089da1e /wsutil
parente64942068632fc01b6a1211bfb90df8265e41fe7 (diff)
Clean up handling of missing functions.
With autotools, CMake, and nmake, if we have a function, #define HAVE_{function_name_in_all_caps}, otherwise don't #define it. If we provide our own version of a function in libwsutil, make sure we have a header that declares it, and *ONLY* include that header if HAVE_{function_name_in_all_caps} is *NOT* defined, so that we don't have the system declaration and our declaration colliding. Check for inet_aton, strncasecmp, and strptime with CMake, just as we do with autotools. Simplify the addition of {function_name_in_all_caps}_LO to libwsutil in autotools. Change-Id: Id5be5c73f79f81919a3a865324e400eca7b88889 Reviewed-on: https://code.wireshark.org/review/2903 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/Makefile.am35
-rw-r--r--wsutil/strncasecmp.c2
-rw-r--r--wsutil/strncasecmp.h32
-rw-r--r--wsutil/strptime.c4
4 files changed, 47 insertions, 26 deletions
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 <string.h>
#include <ctype.h>
+#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 <gerald@wireshark.org>
+ * 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 <string.h>
#include <time.h>
+#ifndef HAVE_STRNCASECMP
+#include "wsutil/strncasecmp.h"
+#endif
+
#ifdef _LIBC
# include "../locale/localeinfo.h"
#endif