From: Balint Reczey Date: Thu, 28 Feb 2013 14:09:46 +0000 (-0000) Subject: Export libwsutil symbols using WS_DLL_PUBLIC define X-Git-Url: http://git.samba.org/?p=metze%2Fwireshark%2Fwip.git;a=commitdiff_plain;h=45c2884f1bbd9c06f7ba3091d968fcb6649a5f56 Export libwsutil symbols using WS_DLL_PUBLIC define This change replaces *.def and *.sym file usage following the guideline at http://gcc.gnu.org/wiki/Visibility svn path=/trunk/; revision=47938 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e4055895fd..e57fc0b59d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,6 @@ set(WIRESHARK_C_FLAGS -Wcast-align -Wformat-security -fexcess-precision=fast - # -fvisibility=hidden ) set(WIRESHARK_C_ONLY_FLAGS @@ -215,6 +214,14 @@ foreach(THIS_FLAG ${WIRESHARK_C_ONLY_FLAGS}) endforeach() message(STATUS "C-Flags: ${CMAKE_C_FLAGS}\nCXX-Flags: ${CMAKE_CXX_FLAGS}") +check_c_compiler_flag(-fvisibility=hidden FVHIDDEN) +if((FVHIDDEN)) + set(COMPILE_HIDE_SYMBOLS -fvisibility=hidden) +else() # TODO add alternate compiler flags for hiding symbols + message(WARNING "Hiding shared library symbols is not supported by the compiler." + " All shared library symbols will be exported.") +endif() + if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS) check_c_compiler_flag(-Werror WERROR) else() diff --git a/configure.ac b/configure.ac index a9dc2827a5..8d0e6169c6 100644 --- a/configure.ac +++ b/configure.ac @@ -519,6 +519,18 @@ if test "x$CC" != "xclang" ; then AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast) fi +CFLAGS_before_fvhidden=$CFLAGS +AC_WIRESHARK_GCC_CFLAGS_CHECK(-fvisibility=hidden) +if test "x$CLFAGS" != "x$CFLAGS_before_fvhidden" +then + # Restore CFLAGS + CFLAGS=$CFLAGS_before_fvhidden + AC_DEFINE(COMPILE_HIDE_SYMBOLS, "-fvisibility=hidden", [Compiler will hide symbols not exported explicitly using -fvisibility=hidden]) +else + AC_DEFINE(COMPILE_HIDE_SYMBOLS, "", [Compiler will export all symbols from shared libraries]) +fi +AC_SUBST(COMPILE_HIDE_SYMBOLS) + AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed]) ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,-M]) ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--cref]) diff --git a/debian/wireshark-dev.header-files b/debian/wireshark-dev.header-files index 2435345852..b6f6491144 100644 --- a/debian/wireshark-dev.header-files +++ b/debian/wireshark-dev.header-files @@ -1,6 +1,7 @@ color.h config.h register.h +ws_symbol_export.h epan/*.h epan/crypt/*.h epan/dfilter/*.h diff --git a/ws_symbol_export.h b/ws_symbol_export.h new file mode 100644 index 0000000000..599ac2e64a --- /dev/null +++ b/ws_symbol_export.h @@ -0,0 +1,54 @@ +/* + * Cross platform defines for exporting symbols from shared libraries + * + * Wireshark - Network traffic analyzer + * By Balint Reczey + * Copyright 2013 Balint Reczey + * + * 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 SYMBOL_EXPORT_H +#define SYMBOL_EXPORT_H + +/* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */ +#if defined _WIN32 || defined __CYGWIN__ + #ifdef WS_BUILD_DLL + #ifdef __GNUC__ +#define WS_DLL_PUBLIC __attribute__ ((dllexport)) + #else /* ! __GNUC__ */ +#define WS_DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also support this syntax. + #endif /* __GNUC__ */ + #else + #ifdef __GNUC__ +#define WS_DLL_PUBLIC __attribute__ ((dllimport)) + #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */ +#define WS_DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also support this syntax. + #else /* ! __GNUC__ && ENABLE_STATIC */ +#define WS_DLL_PUBLIC + #endif /* __GNUC__ */ + #endif /* WS_BUILD_DLL */ + #define WS_DLL_LOCAL +#else + #if __GNUC__ >= 4 +#define WS_DLL_PUBLIC __attribute__ ((visibility ("default"))) +#define WS_DLL_LOCAL __attribute__ ((visibility ("hidden"))) + #else /* ! __GNUC__ >= 4 */ + #define WS_DLL_PUBLIC + #define WS_DLL_LOCAL + #endif /* __GNUC__ >= 4 */ +#endif + +#endif /* SYMBOL_EXPORT_H */ diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 24e35f50e7..e90b487f56 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -63,6 +63,10 @@ add_library(wsutil ${LINK_MODE_LIB} set(FULL_SO_VERSION "0.0.0") +set_target_properties(wsutil PROPERTIES COMPILE_DEFINITIONS "WS_BUILD_DLL") +if(DEFINED COMPILE_HIDE_SYMBOLS) + set_target_properties(wsutil PROPERTIES COMPILE_FLAGS ${COMPILE_HIDE_SYMBOLS}) +endif() set_target_properties(wsutil PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") set_target_properties(wsutil PROPERTIES VERSION ${FULL_SO_VERSION} SOVERSION 0) @@ -79,7 +83,7 @@ configure_file(../abi-descriptor.template abi-descriptor.xml) file(GLOB HEADERS *.h) file(MAKE_DIRECTORY abi-check-headers) -file(COPY ${HEADERS} DESTINATION abi-check-headers) +file(COPY ${HEADERS} ../ws_symbol_export.h DESTINATION abi-check-headers) add_custom_command(OUTPUT libwsutil.abi.tar.gz COMMAND cp ../config.h abi-check-headers/ diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 0781f96af1..1cdfd076d8 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -26,59 +26,43 @@ ACLOCAL_AMFLAGS = `../aclocal-flags` # linked into libwsutil. wsutil_optional_objects = -# filters for symbols to be omitted from libwsutil.sym -# symbols defined only on windows -def_sym_filter_symbols = /^getenv_utf8/ || /^ws_stdio/ || /^ws_init_dll_search_path/ || /^ws_load_library/ || /^ws_module_open/ || /^utf_[168]*to[168]/ || /^arg_list_utf_16to8/ || /^npf_sys_is_running/ || /^create_app_running_mutex/ - if NEED_GETOPT_LO wsutil_optional_objects += @GETOPT_LO@ -else -def_sym_filter_symbols += || /^getopt/ || /^optarg/ || /^optind/ || /^opterr/ || /^optopt/ endif if NEED_INET_ATON_LO wsutil_optional_objects += @INET_ATON_LO@ -else -def_sym_filter_symbols += || /^inet_aton/ endif if NEED_INET_NTOP_LO wsutil_optional_objects += @INET_NTOP_LO@ -else -def_sym_filter_symbols += || /^ws_inet_ntop/ endif if NEED_INET_PTON_LO wsutil_optional_objects += @INET_PTON_LO@ -else -def_sym_filter_symbols += || /^ws_inet_pton/ endif if NEED_STRNCASECMP_LO wsutil_optional_objects += @STRNCASECMP_LO@ -else -def_sym_filter_symbols += || /^strncasecmp/ endif if NEED_STRPTIME_LO wsutil_optional_objects += @STRPTIME_LO@ -else -def_sym_filter_symbols += || /^strptime/ endif -def_sym_filter_symbols += {next;}; - include ../Makefile.am.inc include Makefile.common +AM_CFLAGS =-DWS_BUILD_DLL @COMPILE_HIDE_SYMBOLS@ + if HAVE_WARNINGS_AS_ERRORS -AM_CFLAGS = -Werror +AM_CFLAGS += -Werror endif lib_LTLIBRARIES = libwsutil.la # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -libwsutil_la_LDFLAGS = -version-info 0:0:0 -export-symbols libwsutil.sym @LDFLAGS_SHAREDLIB@ +libwsutil_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@ INCLUDES = -I$(srcdir)/.. @@ -100,8 +84,7 @@ EXTRA_libwsutil_la_SOURCES= \ wsgetopt_int.h libwsutil_la_DEPENDENCIES= \ - $(wsutil_optional_objects) \ - libwsutil.sym + $(wsutil_optional_objects) libwsutil_la_LIBADD = \ @GLIB_LIBS@ \ @@ -112,7 +95,6 @@ EXTRA_DIST = \ Makefile.nmake \ file_util.c \ file_util.h \ - libwsutil.def \ unicode-utils.c \ unicode-utils.h \ wsgcrypt.h @@ -120,7 +102,6 @@ EXTRA_DIST = \ CLEANFILES = \ libwsutil.a \ libwsutil.la \ - libwsutil.sym \ *~ MAINTAINERCLEANFILES = \ @@ -132,7 +113,7 @@ MAINTAINERCLEANFILES = \ dumpabi-libwsutil: all abi-descriptor.xml rm -rf abi-check-headers abi_dumps .libs/*.abi.tar.gz mkdir abi-check-headers - cp ../config.h *.h abi-check-headers/ + cp ../config.h ../ws_symbol_export.h *.h abi-check-headers/ abi-compliance-checker -l libwsutil -v1 `readlink .libs/libwsutil.so | sed 's/.*\.so\.//'` \ -relpath $(abs_srcdir) -dump-abi abi-descriptor.xml || \ cat logs/libwsutil/[0-9]*/log.txt diff --git a/wsutil/Makefile.nmake b/wsutil/Makefile.nmake index 7be40f6d7b..503c7713bb 100644 --- a/wsutil/Makefile.nmake +++ b/wsutil/Makefile.nmake @@ -13,7 +13,7 @@ include Makefile.common CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \ /I. /I.. $(GLIB_CFLAGS) \ - /I$(PCAP_DIR)\include + /I$(PCAP_DIR)\include -DWS_BUILD_DLL .c.obj:: $(CC) $(CFLAGS) -Fd.\ -c $< @@ -34,10 +34,10 @@ OBJECTS = file_util.obj \ libwsutil.lib: libwsutil.dll libwsutil.exp: libwsutil.dll -libwsutil.dll : $(OBJECTS) libwsutil.def ..\image\libwsutil.res +libwsutil.dll : $(OBJECTS) ..\image\libwsutil.res $(link) $(dlllflags) $(conlibsdll) shell32.lib \ $(LOCAL_LDFLAGS) $(DLL_LDFLAGS) \ - /DEF:libwsutil.def /OUT:libwsutil.dll \ + /OUT:libwsutil.dll \ /IMPLIB:libwsutil.lib \ ..\image\libwsutil.res \ $(OBJECTS) $(libwsutil_LIBS) diff --git a/wsutil/crash_info.h b/wsutil/crash_info.h index 43ccc5c9eb..d19ce6bcc5 100644 --- a/wsutil/crash_info.h +++ b/wsutil/crash_info.h @@ -25,10 +25,13 @@ #ifndef __CRASH_INFO_H__ #define __CRASH_INFO_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif +WS_DLL_PUBLIC extern void ws_add_crash_info(const char *fmt, ...) G_GNUC_PRINTF(1,2); diff --git a/wsutil/crc10.h b/wsutil/crc10.h index f9e50dd476..111763ae83 100644 --- a/wsutil/crc10.h +++ b/wsutil/crc10.h @@ -26,7 +26,10 @@ #ifndef __CRC10_H__ #define __CRC10_H__ +#include "ws_symbol_export.h" + /* update the data block's CRC-10 remainder one byte at a time */ +WS_DLL_PUBLIC extern guint16 update_crc10_by_bytes(guint16 crc10, const guint8 *data_blk_ptr, int data_blk_size); #endif /* __CRC10_H__ */ diff --git a/wsutil/crc11.h b/wsutil/crc11.h index b5113837a1..0971f0726c 100644 --- a/wsutil/crc11.h +++ b/wsutil/crc11.h @@ -2,6 +2,8 @@ #include +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif @@ -19,6 +21,7 @@ extern "C" { * ReflectOut = False * Algorithm = table-driven *****************************************************************************/ +WS_DLL_PUBLIC guint16 crc11_307_noreflect_noxor(const guint8 *data, guint64 data_len); #ifdef __cplusplus diff --git a/wsutil/crc16-plain.h b/wsutil/crc16-plain.h index 155ec6cc66..178a6ef0fc 100644 --- a/wsutil/crc16-plain.h +++ b/wsutil/crc16-plain.h @@ -20,6 +20,8 @@ #ifndef __CRC____PLAIN_H__ #define __CRC____PLAIN_H__ +#include "ws_symbol_export.h" + #include #include @@ -66,6 +68,7 @@ static inline crc16_plain_t crc16_plain_init(void) * \param data_len Number of bytes in the \a data buffer. * \return The updated crc value. *****************************************************************************/ +WS_DLL_PUBLIC crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len); /** @@ -97,6 +100,7 @@ static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc) * \param data_len Number of bytes in the \a data buffer. * \return The crc value. *****************************************************************************/ +WS_DLL_PUBLIC guint16 crc16_8005_noreflect_noxor(const guint8 *data, guint64 data_len); diff --git a/wsutil/crc16.h b/wsutil/crc16.h index f72a252fa2..09dde4b893 100644 --- a/wsutil/crc16.h +++ b/wsutil/crc16.h @@ -27,6 +27,8 @@ #ifndef __CRC16_H__ #define __CRC16_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -44,12 +46,14 @@ extern "C" { @param buf The buffer containing the data. @param len The number of bytes to include in the computation. @return The CRC16 CCITT checksum. */ +WS_DLL_PUBLIC extern guint16 crc16_ccitt(const guint8 *buf, guint len); /** Compute CRC16 X.25 CCITT checksum of a buffer of data. @param buf The buffer containing the data. @param len The number of bytes to include in the computation. @return The CRC16 X.25 CCITT checksum. */ +WS_DLL_PUBLIC extern guint16 crc16_x25_ccitt(const guint8 *buf, guint len); /** Compute CRC16 CCITT checksum of a buffer of data. If computing the @@ -59,6 +63,7 @@ extern guint16 crc16_x25_ccitt(const guint8 *buf, guint len); @param len The number of bytes to include in the computation. @param seed The seed to use. @return The CRC16 CCITT checksum (using the given seed). */ +WS_DLL_PUBLIC extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed); /** Calculates a CRC16 checksum for the given buffer with the polynom @@ -68,6 +73,7 @@ extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed); * @param seed The seed to use. * @return the CRC16 checksum for the buffer */ +WS_DLL_PUBLIC extern guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed); #ifdef __cplusplus diff --git a/wsutil/crc32.h b/wsutil/crc32.h index 214f73489f..72d3b07b59 100644 --- a/wsutil/crc32.h +++ b/wsutil/crc32.h @@ -25,6 +25,8 @@ #ifndef __CRC32_H__ #define __CRC32_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -44,10 +46,12 @@ extern "C" { /** Lookup the crc value in the crc32_ccitt_table @param pos Position in the table. */ +WS_DLL_PUBLIC extern guint32 crc32_ccitt_table_lookup (guchar pos); /** Lookup the crc value in the crc32c_table @param pos Position in the table. */ +WS_DLL_PUBLIC extern guint32 crc32c_table_lookup (guchar pos); /** Compute CRC32C checksum of a buffer of data. @@ -55,6 +59,7 @@ extern guint32 crc32c_table_lookup (guchar pos); @param len The number of bytes to include in the computation. @param crc The preload value for the CRC32C computation. @return The CRC32C checksum. */ +WS_DLL_PUBLIC extern guint32 crc32c_calculate(const void *buf, int len, guint32 crc); /** Compute CRC32C checksum of a buffer of data without swapping seed crc @@ -63,12 +68,14 @@ extern guint32 crc32c_calculate(const void *buf, int len, guint32 crc); @param len The number of bytes to include in the computation. @param crc The preload value for the CRC32C computation. @return The CRC32C checksum. */ +WS_DLL_PUBLIC extern guint32 crc32c_calculate_no_swap(const void *buf, int len, guint32 crc); /** Compute CRC32 CCITT checksum of a buffer of data. @param buf The buffer containing the data. @param len The number of bytes to include in the computation. @return The CRC32 CCITT checksum. */ +WS_DLL_PUBLIC extern guint32 crc32_ccitt(const guint8 *buf, guint len); /** Compute CRC32 CCITT checksum of a buffer of data. If computing the @@ -78,6 +85,7 @@ extern guint32 crc32_ccitt(const guint8 *buf, guint len); @param len The number of bytes to include in the computation. @param seed The seed to use. @return The CRC32 CCITT checksum (using the given seed). */ +WS_DLL_PUBLIC extern guint32 crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed); /** Compute MPEG-2 CRC32 checksum of a buffer of data. @@ -85,9 +93,10 @@ extern guint32 crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed); @param len The number of bytes to include in the computation. @param seed The seed to use. @return The CRC32 MPEG-2 checksum (using the given seed). */ +WS_DLL_PUBLIC extern guint32 crc32_mpeg2_seed(const guint8 *buf, guint len, guint32 seed); -int AirPDcapWepDecrypt( +WS_DLL_PUBLIC int AirPDcapWepDecrypt( const guchar *seed, const size_t seed_len, guchar *cypher_text, diff --git a/wsutil/crc6.h b/wsutil/crc6.h index d90853cf2e..9320a9a494 100644 --- a/wsutil/crc6.h +++ b/wsutil/crc6.h @@ -25,6 +25,9 @@ #ifndef __CRC6_H__ #define __CRC6_H__ +#include "ws_symbol_export.h" + +WS_DLL_PUBLIC extern guint16 update_crc6_by_bytes(guint16 crc6, guint8 byte1, guint8 byte2); #endif /* __CRC6_H__ */ diff --git a/wsutil/crc7.h b/wsutil/crc7.h index 8189dd80ca..68259e8146 100644 --- a/wsutil/crc7.h +++ b/wsutil/crc7.h @@ -38,6 +38,8 @@ #ifndef __CRC7__H__ #define __CRC7__H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif @@ -67,6 +69,7 @@ static inline guint8 crc7init(void) * \param data_len Number of bytes in the \a data buffer. * \return The updated crc value. *****************************************************************************/ +WS_DLL_PUBLIC extern guint8 crc7update(guint8 crc, const unsigned char *data, int data_len); diff --git a/wsutil/crc8.h b/wsutil/crc8.h index 77da290264..28c790fd91 100644 --- a/wsutil/crc8.h +++ b/wsutil/crc8.h @@ -27,6 +27,9 @@ #ifndef __CRC8_H__ #define __CRC8_H__ + +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -38,6 +41,7 @@ extern "C" { * @param seed The seed to use. * @return the CRC8 checksum for the buffer */ +WS_DLL_PUBLIC extern guint8 crc8_0x2F(guint8 *buf, guint32 len, guint8 seed); #ifdef __cplusplus diff --git a/wsutil/crcdrm.h b/wsutil/crcdrm.h index 9f606a7192..30e336f5a2 100644 --- a/wsutil/crcdrm.h +++ b/wsutil/crcdrm.h @@ -26,6 +26,10 @@ #ifndef __CRCDRM_H__ #define __CRCDRM_H__ + +#include "ws_symbol_export.h" + +WS_DLL_PUBLIC unsigned long crc_drm(const char *data, size_t bytesize, unsigned short num_crc_bits, unsigned long crc_gen, int invert); diff --git a/wsutil/file_util.h b/wsutil/file_util.h index af5f94d996..a39e82461d 100644 --- a/wsutil/file_util.h +++ b/wsutil/file_util.h @@ -25,6 +25,8 @@ #ifndef __FILE_UTIL_H__ #define __FILE_UTIL_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -65,14 +67,22 @@ extern "C" { #include +WS_DLL_PUBLIC extern int ws_stdio_open (const gchar *filename, int flags, int mode); +WS_DLL_PUBLIC extern int ws_stdio_rename (const gchar *oldfilename, const gchar *newfilename); +WS_DLL_PUBLIC extern int ws_stdio_mkdir (const gchar *filename, int mode); +WS_DLL_PUBLIC extern int ws_stdio_stat64 (const gchar *filename, ws_statb64 *buf); +WS_DLL_PUBLIC extern int ws_stdio_unlink (const gchar *filename); +WS_DLL_PUBLIC extern int ws_stdio_remove (const gchar *filename); +WS_DLL_PUBLIC extern FILE * ws_stdio_fopen (const gchar *filename, const gchar *mode); +WS_DLL_PUBLIC extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE *stream); #define ws_open ws_stdio_open @@ -103,6 +113,7 @@ extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE * * * @return TRUE if we were able to call SetDllDirectory, FALSE otherwise. */ +WS_DLL_PUBLIC gboolean ws_init_dll_search_path(); /** Load a DLL using LoadLibrary. @@ -112,6 +123,7 @@ gboolean ws_init_dll_search_path(); * @return A handle to the DLL if found, NULL on failure. */ +WS_DLL_PUBLIC void *ws_load_library(gchar *library_name); /** Load a DLL using g_module_open. @@ -121,17 +133,20 @@ void *ws_load_library(gchar *library_name); * @param flags Flags to be passed to g_module_open. * @return A handle to the DLL if found, NULL on failure. */ +WS_DLL_PUBLIC GModule *ws_module_open(gchar *module_name, GModuleFlags flags); /* * utf8 version of getenv, needed to get win32 filename paths */ +WS_DLL_PUBLIC extern char *getenv_utf8(const char *varname); /** Create or open a "Wireshark is running" mutex. * Create or open a mutex which signals that Wireshark or its associated * executables is running. Used by the installer to test for a running application. */ +WS_DLL_PUBLIC extern void create_app_running_mutex(); #else /* _WIN32 */ diff --git a/wsutil/inet_aton.h b/wsutil/inet_aton.h index 670898124c..05ce348556 100644 --- a/wsutil/inet_aton.h +++ b/wsutil/inet_aton.h @@ -28,7 +28,10 @@ #ifndef __INET_ATON_H__ #define __INET_ATON_H__ +#include "ws_symbol_export.h" + struct in_addr; +WS_DLL_PUBLIC extern int inet_aton(const char* cp_arg, struct in_addr *addr); #endif diff --git a/wsutil/inet_v6defs.h b/wsutil/inet_v6defs.h index 891f92294e..04abecb872 100644 --- a/wsutil/inet_v6defs.h +++ b/wsutil/inet_v6defs.h @@ -24,6 +24,8 @@ #ifndef __INET_V6DEFS_H__ #define __INET_V6DEFS_H__ +#include "ws_symbol_export.h" + /* * Versions of "inet_pton()" and "inet_ntop()", for the benefit of OSes that * don't have it. @@ -39,8 +41,10 @@ #define inet_ntop ws_inet_ntop #endif +WS_DLL_PUBLIC extern int inet_pton(int af, const char *src, void *dst); #ifndef HAVE_INET_NTOP_PROTO +WS_DLL_PUBLIC extern const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif diff --git a/wsutil/libwsutil.def b/wsutil/libwsutil.def deleted file mode 100644 index bc30c3ab36..0000000000 --- a/wsutil/libwsutil.def +++ /dev/null @@ -1,122 +0,0 @@ -; wsutil.def -; $Id$ - -; Add symbols that should be exported out of libwsutil.dll -; -; DATA symbols must be declared WS_VAR_IMPORT in the header file! -; -; NOTE: TABS DON'T WORK IN THIS FILE, USE SPACES INSTEAD!!! -; -EXPORTS -; airpdcap.c -AirPDcapWepDecrypt - -; crash_info.c -ws_add_crash_info - -; crc6.c -update_crc6_by_bytes - -; crc7.c -crc7update - -; crc10.c -update_crc10_by_bytes - -; crc8.c -crc8_0x2F - -; crc11.c -crc11_307_noreflect_noxor - -; crc16.c -crc16_0x5935 -crc16_ccitt -crc16_ccitt_seed -crc16_x25_ccitt - -; crc16-plain.c -crc16_plain_update -crc16_8005_noreflect_noxor - -; crc32.c -crc32_ccitt -crc32_ccitt_seed -crc32_ccitt_table_lookup -crc32c_calculate -crc32c_calculate_no_swap -crc32c_table_lookup -crc32_mpeg2_seed - -; crcdrm.c -crc_drm - -; file_util.c -create_app_running_mutex -getenv_utf8 -ws_stdio_fopen -ws_stdio_freopen -ws_stdio_mkdir -ws_stdio_open -ws_stdio_remove -ws_stdio_rename -ws_stdio_stat64 -ws_stdio_unlink -ws_init_dll_search_path -ws_load_library -ws_module_open - -; inet_aton.c -inet_aton - -; inet_ntop.c -; Note: inet_v6defs.h renames this function for Windows (only) -ws_inet_ntop - -; inet_pton.c -; Note: inet_v6defs.h renames this function for Windows (only) -ws_inet_pton - -; mpeg-audio.c -mpa_bitrate -mpa_frequency -mpa_layer -mpa_padding -mpa_samples -mpa_version - -; privileges.c -init_process_policies -get_cur_groupname -get_cur_username -npf_sys_is_running -relinquish_special_privs_perm -running_with_special_privs -started_with_special_privs - -; strptime.c -strptime - -; str_util.c -ascii_strdown_inplace -ascii_strup_inplace -format_size -isprint_string -isdigit_string - -; type_util.c -type_util_gdouble_to_guint64 -type_util_guint64_to_gdouble - -; unicode-utils.c -utf_16to8 -utf_8to16 -utf_8to16_snprintf -arg_list_utf_16to8 - -; wsgetopt.c -getopt -optarg DATA -optind DATA -opterr DATA -optopt DATA diff --git a/wsutil/mpeg-audio.h b/wsutil/mpeg-audio.h index 23ee3465da..4d3ad68bc0 100644 --- a/wsutil/mpeg-audio.h +++ b/wsutil/mpeg-audio.h @@ -25,6 +25,8 @@ #ifndef MPA_H #define MPA_H 1 +#include "ws_symbol_export.h" + struct mpa { unsigned int emphasis :2; unsigned int original :1; @@ -71,11 +73,17 @@ struct mpa { (mpa)->emphasis = MPA_UNMARSHAL_EMPHASIS(n); \ } while (0) +WS_DLL_PUBLIC int mpa_version(const struct mpa *); +WS_DLL_PUBLIC int mpa_layer(const struct mpa *); +WS_DLL_PUBLIC unsigned int mpa_samples(const struct mpa *); +WS_DLL_PUBLIC unsigned int mpa_bitrate(const struct mpa *); +WS_DLL_PUBLIC unsigned int mpa_frequency(const struct mpa *); +WS_DLL_PUBLIC unsigned int mpa_padding(const struct mpa *); #define MPA_DATA_BYTES(mpa) (mpa_bitrate(mpa) * mpa_samples(mpa) \ diff --git a/wsutil/privileges.h b/wsutil/privileges.h index 9d7474d878..231f3e34bc 100644 --- a/wsutil/privileges.h +++ b/wsutil/privileges.h @@ -25,6 +25,8 @@ #ifndef __PRIVILEGES_H__ #define __PRIVILEGES_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif @@ -33,6 +35,7 @@ extern "C" { * Called when the program starts, to enable security features and save * whatever credential information we'll need later. */ +WS_DLL_PUBLIC extern void init_process_policies(void); /** @@ -41,6 +44,7 @@ extern void init_process_policies(void); * @return TRUE if the program was started with special privileges, * FALSE otherwise. */ +WS_DLL_PUBLIC extern gboolean started_with_special_privs(void); /** @@ -49,12 +53,14 @@ extern gboolean started_with_special_privs(void); * @return TRUE if the program is running with special privileges, * FALSE otherwise. */ +WS_DLL_PUBLIC extern gboolean running_with_special_privs(void); /** * Permanently relinquish special privileges. get_credential_info() * MUST be called before calling this. */ +WS_DLL_PUBLIC extern void relinquish_special_privs_perm(void); /** @@ -62,6 +68,7 @@ extern void relinquish_special_privs_perm(void); * @return A freshly g_alloc()ed string containing the username, * or "UNKNOWN" on failure. */ +WS_DLL_PUBLIC extern gchar *get_cur_username(void); /** @@ -69,6 +76,7 @@ extern gchar *get_cur_username(void); * @return A freshly g_alloc()ed string containing the group, * or "UNKNOWN" on failure. */ +WS_DLL_PUBLIC extern gchar *get_cur_groupname(void); #ifdef _WIN32 @@ -77,6 +85,7 @@ extern gchar *get_cur_groupname(void); * @return TRUE if npf.sys is running, FALSE if it's not or if there was * an error checking its status. */ +WS_DLL_PUBLIC extern gboolean npf_sys_is_running(); #endif diff --git a/wsutil/str_util.h b/wsutil/str_util.h index 120fc00820..3762009ef7 100644 --- a/wsutil/str_util.h +++ b/wsutil/str_util.h @@ -25,6 +25,8 @@ #ifndef __STR_UTIL_H__ #define __STR_UTIL_H__ +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -44,6 +46,7 @@ extern "C" { * @param str The string to be lower-cased. * @return ptr to the string */ +WS_DLL_PUBLIC gchar *ascii_strdown_inplace(gchar *str); /** Convert all lower-case ASCII letters to their ASCII upper-case @@ -61,6 +64,7 @@ gchar *ascii_strdown_inplace(gchar *str); * @param str The string to be upper-cased. * @return ptr to the string */ +WS_DLL_PUBLIC gchar *ascii_strup_inplace(gchar *str); /** Check if an entire string consists of printable characters @@ -68,6 +72,7 @@ gchar *ascii_strup_inplace(gchar *str); * @param str The string to be checked * @return TRUE if the entire string is printable, otherwise FALSE */ +WS_DLL_PUBLIC gboolean isprint_string(const gchar *string); /** Check if an entire string consists of digits @@ -75,6 +80,7 @@ gboolean isprint_string(const gchar *string); * @param str The string to be checked * @return TRUE if the entire string is digits, otherwise FALSE */ +WS_DLL_PUBLIC gboolean isdigit_string(guchar *string); typedef enum { @@ -102,6 +108,7 @@ extern format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_ * SI vs IEC, etc). Unit and prefix flags may be ORed together. * @return A newly-allocated string representing the value. */ +WS_DLL_PUBLIC gchar *format_size(gint64 size, format_size_flags_e flags); diff --git a/wsutil/strptime.h b/wsutil/strptime.h index d10ff5f302..b11d29e715 100644 --- a/wsutil/strptime.h +++ b/wsutil/strptime.h @@ -24,9 +24,12 @@ #ifndef __STRPTIME_H__ #define __STRPTIME_H__ +#include "ws_symbol_export.h" + /* * Version of "strptime()", for the benefit of OSes that don't have it. */ +WS_DLL_PUBLIC extern char *strptime(const char *, const char *, struct tm *); #endif diff --git a/wsutil/type_util.h b/wsutil/type_util.h index 6b7c5db839..cc7106c995 100644 --- a/wsutil/type_util.h +++ b/wsutil/type_util.h @@ -25,6 +25,7 @@ #ifndef __TYPE_UTIL_H__ #define __TYPE_UTIL_H__ +#include "ws_symbol_export.h" /* * guint64 to gdouble conversions taken from gstutils.h of GStreamer project @@ -40,7 +41,9 @@ * */ +WS_DLL_PUBLIC guint64 type_util_gdouble_to_guint64(gdouble value); +WS_DLL_PUBLIC gdouble type_util_guint64_to_gdouble(guint64 value); #ifdef _WIN32 diff --git a/wsutil/unicode-utils.h b/wsutil/unicode-utils.h index 1abe7d4106..c907eda2de 100644 --- a/wsutil/unicode-utils.h +++ b/wsutil/unicode-utils.h @@ -25,6 +25,8 @@ #ifndef __UNICODEUTIL_H__ #define __UNICODEUTIL_H__ +#include "ws_symbol_export.h" + #ifdef _WIN32 #include "config.h" @@ -45,6 +47,7 @@ * @return The string converted to UTF-16. If utf8str is NULL, returns * NULL. The return value should NOT be freed by the caller. */ +WS_DLL_PUBLIC wchar_t * utf_8to16(const char *utf8str); /** Create a UTF-16 string (in place) according to the format string. @@ -53,6 +56,7 @@ wchar_t * utf_8to16(const char *utf8str); * @param utf16buf_len The size of the 'utf16buf' parameter * @param fmt A standard g_printf() format string */ +WS_DLL_PUBLIC void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...); /** Given a UTF-16 string, convert it to UTF-8. This is meant to be used @@ -62,6 +66,7 @@ void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, .. * @return The string converted to UTF-8. If utf16str is NULL, returns * NULL. The return value should NOT be freed by the caller. */ +WS_DLL_PUBLIC gchar * utf_16to8(const wchar_t *utf16str); /** Convert the program argument list from UTF-16 to UTF-8 and @@ -73,6 +78,7 @@ gchar * utf_16to8(const wchar_t *utf16str); * @param argv The argument values (vector). You should simply pass * the second argument from main(). */ +WS_DLL_PUBLIC void arg_list_utf_16to8(int argc, char *argv[]); diff --git a/wsutil/wsgetopt.h b/wsutil/wsgetopt.h index c65fd7c05b..eaebe65a96 100644 --- a/wsutil/wsgetopt.h +++ b/wsutil/wsgetopt.h @@ -24,6 +24,8 @@ # define _GETOPT_H 1 #endif +#include "ws_symbol_export.h" + /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but @@ -56,7 +58,7 @@ extern "C" { Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -WS_VAR_IMPORT char *optarg; +WS_DLL_PUBLIC char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -70,16 +72,16 @@ WS_VAR_IMPORT char *optarg; Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ -WS_VAR_IMPORT int optind; +WS_DLL_PUBLIC int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ -WS_VAR_IMPORT int opterr; +WS_DLL_PUBLIC int opterr; /* Set to an option character which was unrecognized. */ -WS_VAR_IMPORT int optopt; +WS_DLL_PUBLIC int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. @@ -149,6 +151,7 @@ struct option /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ +WS_DLL_PUBLIC extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) __THROW; @@ -168,6 +171,7 @@ extern int __posix_getopt (int ___argc, char *const *___argv, # endif # endif #else /* not __GNU_LIBRARY__ */ +WS_DLL_PUBLIC extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); #endif /* __GNU_LIBRARY__ */