From f7ed3201a8800ff1d1eae83958f782c3ccbc787f Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Tue, 10 Mar 2009 15:49:27 +0000
Subject: [PATCH] add macros for api visibility to openzap

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@688 a93c3328-9c30-0410-af19-c9cd2b2d52af
---
 libs/openzap/msvc/openzap.2005.vcproj         |  32 ++-
 libs/openzap/msvc/openzap.2008.vcproj         |  26 ++-
 libs/openzap/src/include/libteletone.h        |  28 ++-
 libs/openzap/src/include/libteletone_detect.h |  14 +-
 .../src/include/libteletone_generate.h        |  18 +-
 libs/openzap/src/include/openzap.h            | 186 ++++++++++--------
 libs/openzap/src/include/zap_buffer.h         |  26 +--
 libs/openzap/src/include/zap_threadmutex.h    |  16 +-
 libs/openzap/src/include/zap_types.h          |   2 +-
 libs/openzap/src/libteletone_detect.c         |  16 +-
 libs/openzap/src/libteletone_generate.c       |  20 +-
 libs/openzap/src/zap_buffer.c                 |  26 +--
 libs/openzap/src/zap_callerid.c               |  26 +--
 libs/openzap/src/zap_io.c                     | 122 ++++++------
 libs/openzap/src/zap_threadmutex.c            |  16 +-
 15 files changed, 328 insertions(+), 246 deletions(-)

diff --git a/libs/openzap/msvc/openzap.2005.vcproj b/libs/openzap/msvc/openzap.2005.vcproj
index d02a4ada41..59419ea8e9 100644
--- a/libs/openzap/msvc/openzap.2005.vcproj
+++ b/libs/openzap/msvc/openzap.2005.vcproj
@@ -19,7 +19,7 @@
 			Name="Debug|Win32"
 			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			CharacterSet="2"
 			BuildLogFile="$(IntDir)\BuildLog-openzap.htm"
 			>
@@ -42,7 +42,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="../src/include;../src/isdn/include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;OPENZAP_EXPORTS;TELETONE_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -52,7 +52,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 				CompileAs="1"
 			/>
 			<Tool
@@ -65,11 +65,14 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
 			<Tool
 				Name="VCXDCMakeTool"
 			/>
@@ -79,6 +82,12 @@
 			<Tool
 				Name="VCFxCopTool"
 			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
 			<Tool
 				Name="VCPostBuildEventTool"
 			/>
@@ -87,7 +96,7 @@
 			Name="Release|Win32"
 			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			CharacterSet="2"
 			WholeProgramOptimization="1"
 			BuildLogFile="$(IntDir)\BuildLog-openzap.htm"
@@ -110,7 +119,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="../src/include;../src/isdn/include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;OPENZAP_EXPORTS;TELETONE_EXPORTS"
 				RuntimeLibrary="2"
 				DisableLanguageExtensions="false"
 				RuntimeTypeInfo="false"
@@ -131,11 +140,14 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
 			<Tool
 				Name="VCXDCMakeTool"
 			/>
@@ -145,6 +157,12 @@
 			<Tool
 				Name="VCFxCopTool"
 			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
 			<Tool
 				Name="VCPostBuildEventTool"
 			/>
diff --git a/libs/openzap/msvc/openzap.2008.vcproj b/libs/openzap/msvc/openzap.2008.vcproj
index a0d6c2b4b6..70e20bd2f4 100644
--- a/libs/openzap/msvc/openzap.2008.vcproj
+++ b/libs/openzap/msvc/openzap.2008.vcproj
@@ -20,7 +20,7 @@
 			Name="Debug|Win32"
 			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			CharacterSet="2"
 			BuildLogFile="$(IntDir)\BuildLog-openzap.htm"
 			>
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="../src/include;../src/isdn/include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;OPENZAP_EXPORTS;TELETONE_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -53,7 +53,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="false"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 				CompileAs="1"
 			/>
 			<Tool
@@ -66,11 +66,14 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
 			<Tool
 				Name="VCXDCMakeTool"
 			/>
@@ -80,6 +83,9 @@
 			<Tool
 				Name="VCFxCopTool"
 			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
 			<Tool
 				Name="VCPostBuildEventTool"
 			/>
@@ -88,7 +94,7 @@
 			Name="Release|Win32"
 			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			CharacterSet="2"
 			WholeProgramOptimization="1"
 			BuildLogFile="$(IntDir)\BuildLog-openzap.htm"
@@ -111,7 +117,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="../src/include;../src/isdn/include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;OPENZAP_EXPORTS;TELETONE_EXPORTS"
 				RuntimeLibrary="2"
 				DisableLanguageExtensions="false"
 				RuntimeTypeInfo="false"
@@ -132,11 +138,14 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
 			<Tool
 				Name="VCXDCMakeTool"
 			/>
@@ -146,6 +155,9 @@
 			<Tool
 				Name="VCFxCopTool"
 			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
 			<Tool
 				Name="VCPostBuildEventTool"
 			/>
diff --git a/libs/openzap/src/include/libteletone.h b/libs/openzap/src/include/libteletone.h
index db6accb97e..4029facce8 100644
--- a/libs/openzap/src/include/libteletone.h
+++ b/libs/openzap/src/include/libteletone.h
@@ -110,6 +110,32 @@ typedef __int16 int16_t;
 #define teletone_assert(expr) assert(expr)
 #endif
 
+#ifdef _MSC_VER
+#if defined(TT_DECLARE_STATIC)
+#define TELETONE_API(type)			type __stdcall
+#define TELETONE_API_NONSTD(type)		type __cdecl
+#define TELETONE_API_DATA
+#elif defined(TELETONE_EXPORTS)
+#define TELETONE_API(type)			__declspec(dllexport) type __stdcall
+#define TELETONE_API_NONSTD(type)		__declspec(dllexport) type __cdecl
+#define TELETONE_API_DATA				__declspec(dllexport)
+#else
+#define TELETONE_API(type)			__declspec(dllimport) type __stdcall
+#define TELETONE_API_NONSTD(type)		__declspec(dllimport) type __cdecl
+#define TELETONE_API_DATA				__declspec(dllimport)
+#endif
+#else
+#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY)
+#define TELETONE_API(type)		__attribute__((visibility("default"))) type
+#define TELETONE_API_NONSTD(type)	__attribute__((visibility("default"))) type
+#define TELETONE_API_DATA		__attribute__((visibility("default")))
+#else
+#define TELETONE_API(type)		type
+#define TELETONE_API_NONSTD(type)	type
+#define TELETONE_API_DATA
+#endif
+#endif
+
 #include <libteletone_generate.h>
 #include <libteletone_detect.h>
 
@@ -131,5 +157,5 @@ typedef __int16 int16_t;
  * c-basic-offset:4
  * End:
  * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
  */
diff --git a/libs/openzap/src/include/libteletone_detect.h b/libs/openzap/src/include/libteletone_detect.h
index 3c44d480ee..3d0a5130ec 100644
--- a/libs/openzap/src/include/libteletone_detect.h
+++ b/libs/openzap/src/include/libteletone_detect.h
@@ -169,7 +169,7 @@ extern "C" {
 	  \param mt the multi-frequency tone descriptor
 	  \param map a representation of the multi-frequency tone
 	*/
-	void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
+TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
 
 	/*! 
 	  \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
@@ -178,7 +178,7 @@ extern "C" {
 	  \param samples the number of samples present in sample_buffer
 	  \return true when the tone was detected or false when it is not
 	*/
-	int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
+TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt,
 									int16_t sample_buffer[],
 									int samples);
 
@@ -187,7 +187,7 @@ extern "C" {
 	  \param dtmf_detect_state the DTMF detection state to initilize
 	  \param sample_rate the desired sample rate
 	*/
-	void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
+TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
 
 	/*! 
 	  \brief Check a sample buffer for the presence of DTMF digits
@@ -196,7 +196,7 @@ extern "C" {
 	  \param samples the number of samples present in sample_buffer
 	  \return true when DTMF was detected or false when it is not
 	*/
-	int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API(int) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
 							  int16_t sample_buffer[],
 							  int samples);
 	/*! 
@@ -206,7 +206,7 @@ extern "C" {
 	  \param max the maximum length of buf
 	  \return the number of characters written to buf
 	*/
-	int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
 						   char *buf,
 						   int max);
 
@@ -216,7 +216,7 @@ extern "C" {
 	  \param sample_buffer an array aof 16 bit signed linear samples
 	  \param samples the number of samples present in sample_buffer
 	*/
-	void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
 								  int16_t sample_buffer[],
 								  int samples);
 
@@ -236,5 +236,5 @@ extern "C" {
  * c-basic-offset:4
  * End:
  * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
  */
diff --git a/libs/openzap/src/include/libteletone_generate.h b/libs/openzap/src/include/libteletone_generate.h
index d538fdc90a..fce19e7255 100644
--- a/libs/openzap/src/include/libteletone_generate.h
+++ b/libs/openzap/src/include/libteletone_generate.h
@@ -71,7 +71,7 @@ typedef __int8 int8_t;
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <math.h>
-#if !defined(powf)
+#if !defined(powf) && !defined(_WIN64)
 extern float powf (float, float);
 #endif
 #include <string.h>
@@ -102,7 +102,7 @@ typedef struct teletone_dds_state teletone_dds_state_t;
 /* 3.02 represents twice the power */
 #define DBM0_MAX_POWER (3.14f + 3.02f)
 
-extern int16_t TELETONE_SINES[SINE_TABLE_MAX];
+TELETONE_API_DATA extern int16_t TELETONE_SINES[SINE_TABLE_MAX];
 
 static __inline__ int32_t teletone_dds_phase_rate(teletone_process_t tone, uint32_t rate)
 {
@@ -220,7 +220,7 @@ typedef struct teletone_generation_session teletone_generation_session_t;
   \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
   \return 0
 */
-int teletone_set_tone(teletone_generation_session_t *ts, int index, ...);
+TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...);
 
 /*! 
   \brief Assign a set of tones to a single tone map
@@ -228,7 +228,7 @@ int teletone_set_tone(teletone_generation_session_t *ts, int index, ...);
   \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
   \return 0
 */
-int teletone_set_map(teletone_tone_map_t *map, ...);
+TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...);
 
 /*! 
   \brief Initilize a tone generation session
@@ -238,14 +238,14 @@ int teletone_set_map(teletone_tone_map_t *map, ...);
   \param user_data optional user data to send
   \return 0
 */
-int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data);
+TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data);
 
 /*! 
   \brief Free the buffer allocated by a tone generation session
   \param ts the tone generation session to destroy
   \return 0
 */
-int teletone_destroy_session(teletone_generation_session_t *ts);
+TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts);
 
 /*! 
   \brief Execute a single tone generation instruction
@@ -253,7 +253,7 @@ int teletone_destroy_session(teletone_generation_session_t *ts);
   \param map the tone mapping to use for the frequencies
   \return 0
 */
-int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map);
+TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map);
 
 /*! 
   \brief Execute a tone generation script and call callbacks after each instruction
@@ -261,7 +261,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
   \param cmd the script to execute
   \return 0
 */
-int teletone_run(teletone_generation_session_t *ts, const char *cmd);
+TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd);
 
 #ifdef __cplusplus
 }
@@ -277,5 +277,5 @@ int teletone_run(teletone_generation_session_t *ts, const char *cmd);
  * c-basic-offset:4
  * End:
  * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
  */
diff --git a/libs/openzap/src/include/openzap.h b/libs/openzap/src/include/openzap.h
index 9397766bf5..ed4308be07 100644
--- a/libs/openzap/src/include/openzap.h
+++ b/libs/openzap/src/include/openzap.h
@@ -47,11 +47,37 @@
 #endif
 
 #ifndef __WINDOWS__
-#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
+#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) || defined(_WIN64)
 #define __WINDOWS__
 #endif
 #endif
 
+#ifdef _MSC_VER
+#if defined(OZ_DECLARE_STATIC)
+#define OZ_DECLARE(type)			type __stdcall
+#define OZ_DECLARE_NONSTD(type)		type __cdecl
+#define OZ_DECLARE_DATA
+#elif defined(OPENZAP_EXPORTS)
+#define OZ_DECLARE(type)			__declspec(dllexport) type __stdcall
+#define OZ_DECLARE_NONSTD(type)		__declspec(dllexport) type __cdecl
+#define OZ_DECLARE_DATA				__declspec(dllexport)
+#else
+#define OZ_DECLARE(type)			__declspec(dllimport) type __stdcall
+#define OZ_DECLARE_NONSTD(type)		__declspec(dllimport) type __cdecl
+#define OZ_DECLARE_DATA				__declspec(dllimport)
+#endif
+#else
+#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY)
+#define OZ_DECLARE(type)		__attribute__((visibility("default"))) type
+#define OZ_DECLARE_NONSTD(type)	__attribute__((visibility("default"))) type
+#define OZ_DECLARE_DATA		__attribute__((visibility("default")))
+#else
+#define OZ_DECLARE(type)		type
+#define OZ_DECLARE_NONSTD(type)	type
+#define OZ_DECLARE_DATA
+#endif
+#endif
+
 #ifdef _MSC_VER
 #ifndef __inline__
 #define __inline__ __inline
@@ -89,9 +115,9 @@
 
 #define ZAP_THREAD_STACKSIZE 240 * 1024
 #define ZAP_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL };
-#define ZAP_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type);
+#define ZAP_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) OZ_DECLARE(_TYPE) _FUNC1 (const char *name); OZ_DECLARE(const char *) _FUNC2 (_TYPE type);
 #define ZAP_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX)	\
-	_TYPE _FUNC1 (const char *name)							\
+	OZ_DECLARE(_TYPE) _FUNC1 (const char *name)							\
 	{														\
 		int i;												\
 		_TYPE t = _MAX ;									\
@@ -105,7 +131,7 @@
 															\
 		return t;											\
 	}														\
-	const char * _FUNC2 (_TYPE type)						\
+	OZ_DECLARE(const char *) _FUNC2 (_TYPE type)						\
 	{														\
 		if (type > _MAX) {									\
 			type = _MAX;									\
@@ -123,7 +149,7 @@
 
 
 #include <time.h>
-#ifndef WIN32
+#ifndef __WINDOWS__
 #include <sys/time.h>
 #endif
 
@@ -146,7 +172,7 @@
 
 #define XX if (0)
 
-#ifdef WIN32
+#ifdef __WINDOWS__
 #define zap_sleep(x) Sleep(x)
 #else
 #define zap_sleep(x) usleep(x * 1000)
@@ -304,8 +330,8 @@ struct zap_stream_handle {
 };
 
 
-zap_status_t zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen);
-zap_status_t zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...);
+OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen);
+OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...);
 
 #define ZAP_CMD_CHUNK_LEN 1024
 #define ZAP_STANDARD_STREAM(s) memset(&s, 0, sizeof(s)); s.data = malloc(ZAP_CMD_CHUNK_LEN); \
@@ -526,7 +552,7 @@ struct zap_span {
 };
 
 
-extern zap_logger_t zap_log;
+OZ_DECLARE_DATA extern zap_logger_t zap_log;
 
 struct zap_io_interface {
 	const char *name;
@@ -547,16 +573,16 @@ struct zap_io_interface {
 };
 
 
-zap_size_t zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen);
-int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits);
-void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans);
-void zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans);
+OZ_DECLARE(zap_size_t) zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen);
+OZ_DECLARE(int32_t) zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits);
+OZ_DECLARE(void) zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans);
+OZ_DECLARE(void) zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans);
 #define zap_fsk_modulator_send_all(_it) zap_fsk_modulator_generate_chan_sieze(_it); \
 	zap_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_start); \
 	zap_fsk_modulator_send_data(_it); \
 	zap_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_stop)
 
-zap_status_t zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
+OZ_DECLARE(zap_status_t) zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
 									fsk_modem_types_t modem_type,
 									uint32_t sample_rate,
 									zap_fsk_data_state_t *fsk_data,
@@ -566,72 +592,72 @@ zap_status_t zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
 									uint32_t chan_sieze_bits,
 									zap_fsk_write_sample_t write_sample_callback,
 									void *user_data);
-int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp);
-void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss);
-zap_status_t zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len);
-zap_status_t zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, size_t samples);
-zap_status_t zap_fsk_demod_destroy(zap_fsk_data_state_t *state);
-int zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize);
-zap_status_t zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint32_t datalen);
-zap_status_t zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t type, const uint8_t *data, uint32_t datalen);
-zap_status_t zap_fsk_data_add_checksum(zap_fsk_data_state_t *state);
-zap_status_t zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date, char *number);
-zap_status_t zap_channel_outgoing_call(zap_channel_t *zchan);
-void zap_channel_rotate_tokens(zap_channel_t *zchan);
-void zap_channel_clear_detected_tones(zap_channel_t *zchan);
-void zap_channel_clear_needed_tones(zap_channel_t *zchan);
-zap_status_t zap_channel_get_alarms(zap_channel_t *zchan);
-zap_status_t zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level);
-zap_status_t zap_channel_clear_token(zap_channel_t *zchan, const char *token);
-zap_status_t zap_channel_add_token(zap_channel_t *zchan, char *token, int end);
-zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock);
-zap_status_t zap_span_load_tones(zap_span_t *span, const char *mapname);
-zap_size_t zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len);
-zap_status_t zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf);
-void zap_channel_flush_dtmf(zap_channel_t *zchan);
-zap_time_t zap_current_time_in_ms(void);
-zap_status_t zap_span_poll_event(zap_span_t *span, uint32_t ms);
-zap_status_t zap_span_next_event(zap_span_t *span, zap_event_t **event);
-zap_status_t zap_span_find(uint32_t id, zap_span_t **span);
-zap_status_t zap_span_create(zap_io_interface_t *zio, zap_span_t **span);
-zap_status_t zap_span_close_all(void);
-zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan);
-zap_status_t zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback);
-zap_status_t zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback);
-zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan);
-zap_status_t zap_channel_open_chan(zap_channel_t *zchan);
-zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
-zap_status_t zap_channel_close(zap_channel_t **zchan);
-zap_status_t zap_channel_done(zap_channel_t *zchan);
-zap_status_t zap_channel_use(zap_channel_t *zchan);
-zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, void *obj);
-zap_status_t zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to);
-zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen);
-zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t datasize, zap_size_t *datalen);
-zap_status_t zap_channel_add_var(zap_channel_t *zchan, const char *var_name, const char *value);
-const char * zap_channel_get_var(zap_channel_t *zchan, const char *var_name);
-zap_status_t zap_channel_clear_vars(zap_channel_t *zchan);
-zap_status_t zap_global_init(void);
-zap_status_t zap_global_destroy(void);
-void zap_global_set_logger(zap_logger_t logger);
-void zap_global_set_default_logger(int level);
-uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen);
-void print_bits(uint8_t *b, int bl, char *buf, int blen, int e, uint8_t ss);
-void print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen);
-int zap_hash_equalkeys(void *k1, void *k2);
-uint32_t zap_hash_hashfromstring(void *ky);
-uint32_t zap_running(void);
-zap_status_t zap_channel_complete_state(zap_channel_t *zchan);
-zap_status_t zap_channel_init(zap_channel_t *zchan);
-int zap_load_modules(void);
-zap_status_t zap_unload_modules(void);
-zap_status_t zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...);
-zap_status_t zap_span_start(zap_span_t *span);
-int zap_load_module(const char *name);
-int zap_load_module_assume(const char *name);
-zap_status_t zap_span_find_by_name(const char *name, zap_span_t **span);
-char *zap_api_execute(const char *type, const char *cmd);
-int zap_vasprintf(char **ret, const char *fmt, va_list ap);
+OZ_DECLARE(int8_t) zap_bitstream_get_bit(zap_bitstream_t *bsp);
+OZ_DECLARE(void) zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss);
+OZ_DECLARE(zap_status_t) zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len);
+OZ_DECLARE(zap_status_t) zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, size_t samples);
+OZ_DECLARE(zap_status_t) zap_fsk_demod_destroy(zap_fsk_data_state_t *state);
+OZ_DECLARE(int) zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize);
+OZ_DECLARE(zap_status_t) zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint32_t datalen);
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t type, const uint8_t *data, uint32_t datalen);
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_checksum(zap_fsk_data_state_t *state);
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date, char *number);
+OZ_DECLARE(zap_status_t) zap_channel_outgoing_call(zap_channel_t *zchan);
+OZ_DECLARE(void) zap_channel_rotate_tokens(zap_channel_t *zchan);
+OZ_DECLARE(void) zap_channel_clear_detected_tones(zap_channel_t *zchan);
+OZ_DECLARE(void) zap_channel_clear_needed_tones(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_get_alarms(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level);
+OZ_DECLARE(zap_status_t) zap_channel_clear_token(zap_channel_t *zchan, const char *token);
+OZ_DECLARE(zap_status_t) zap_channel_add_token(zap_channel_t *zchan, char *token, int end);
+OZ_DECLARE(zap_status_t) zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock);
+OZ_DECLARE(zap_status_t) zap_span_load_tones(zap_span_t *span, const char *mapname);
+OZ_DECLARE(zap_size_t) zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len);
+OZ_DECLARE(zap_status_t) zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf);
+OZ_DECLARE(void) zap_channel_flush_dtmf(zap_channel_t *zchan);
+OZ_DECLARE(zap_time_t) zap_current_time_in_ms(void);
+OZ_DECLARE(zap_status_t) zap_span_poll_event(zap_span_t *span, uint32_t ms);
+OZ_DECLARE(zap_status_t) zap_span_next_event(zap_span_t *span, zap_event_t **event);
+OZ_DECLARE(zap_status_t) zap_span_find(uint32_t id, zap_span_t **span);
+OZ_DECLARE(zap_status_t) zap_span_create(zap_io_interface_t *zio, zap_span_t **span);
+OZ_DECLARE(zap_status_t) zap_span_close_all(void);
+OZ_DECLARE(zap_status_t) zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan);
+OZ_DECLARE(zap_status_t) zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback);
+OZ_DECLARE(zap_status_t) zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback);
+OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan);
+OZ_DECLARE(zap_status_t) zap_channel_open_chan(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_open_any(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
+OZ_DECLARE(zap_status_t) zap_channel_close(zap_channel_t **zchan);
+OZ_DECLARE(zap_status_t) zap_channel_done(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_use(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_command(zap_channel_t *zchan, zap_command_t command, void *obj);
+OZ_DECLARE(zap_status_t) zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to);
+OZ_DECLARE(zap_status_t) zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen);
+OZ_DECLARE(zap_status_t) zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t datasize, zap_size_t *datalen);
+OZ_DECLARE(zap_status_t) zap_channel_add_var(zap_channel_t *zchan, const char *var_name, const char *value);
+OZ_DECLARE(const char *) zap_channel_get_var(zap_channel_t *zchan, const char *var_name);
+OZ_DECLARE(zap_status_t) zap_channel_clear_vars(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_global_init(void);
+OZ_DECLARE(zap_status_t) zap_global_destroy(void);
+OZ_DECLARE(void) zap_global_set_logger(zap_logger_t logger);
+OZ_DECLARE(void) zap_global_set_default_logger(int level);
+OZ_DECLARE(uint32_t) zap_separate_string(char *buf, char delim, char **array, int arraylen);
+OZ_DECLARE(void) print_bits(uint8_t *b, int bl, char *buf, int blen, int e, uint8_t ss);
+OZ_DECLARE(void) print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen);
+OZ_DECLARE_NONSTD(int) zap_hash_equalkeys(void *k1, void *k2);
+OZ_DECLARE_NONSTD(uint32_t) zap_hash_hashfromstring(void *ky);
+OZ_DECLARE(uint32_t) zap_running(void);
+OZ_DECLARE(zap_status_t) zap_channel_complete_state(zap_channel_t *zchan);
+OZ_DECLARE(zap_status_t) zap_channel_init(zap_channel_t *zchan);
+OZ_DECLARE(int) zap_load_modules(void);
+OZ_DECLARE(zap_status_t) zap_unload_modules(void);
+OZ_DECLARE(zap_status_t) zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...);
+OZ_DECLARE(zap_status_t) zap_span_start(zap_span_t *span);
+OZ_DECLARE(int) zap_load_module(const char *name);
+OZ_DECLARE(int) zap_load_module_assume(const char *name);
+OZ_DECLARE(zap_status_t) zap_span_find_by_name(const char *name, zap_span_t **span);
+OZ_DECLARE(char *) zap_api_execute(const char *type, const char *cmd);
+OZ_DECLARE(int) zap_vasprintf(char **ret, const char *fmt, va_list ap);
 
 ZIO_CODEC_FUNCTION(zio_slin2ulaw);
 ZIO_CODEC_FUNCTION(zio_ulaw2slin);
diff --git a/libs/openzap/src/include/zap_buffer.h b/libs/openzap/src/include/zap_buffer.h
index 958d2fc8e7..2824c7938a 100644
--- a/libs/openzap/src/include/zap_buffer.h
+++ b/libs/openzap/src/include/zap_buffer.h
@@ -53,25 +53,25 @@ typedef struct zap_buffer zap_buffer_t;
  * \param max_len length the buffer is allowed to grow to
  * \return status
  */
-zap_status_t zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_size_t start_len, zap_size_t max_len);
+OZ_DECLARE(zap_status_t) zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_size_t start_len, zap_size_t max_len);
 
 /*! \brief Get the length of a zap_buffer_t 
  * \param buffer any buffer of type zap_buffer_t
  * \return int size of the buffer.
  */
-zap_size_t zap_buffer_len(zap_buffer_t *buffer);
+OZ_DECLARE(zap_size_t) zap_buffer_len(zap_buffer_t *buffer);
 
 /*! \brief Get the freespace of a zap_buffer_t 
  * \param buffer any buffer of type zap_buffer_t
  * \return int freespace in the buffer.
  */
-zap_size_t zap_buffer_freespace(zap_buffer_t *buffer);
+OZ_DECLARE(zap_size_t) zap_buffer_freespace(zap_buffer_t *buffer);
 
 /*! \brief Get the in use amount of a zap_buffer_t 
  * \param buffer any buffer of type zap_buffer_t
  * \return int ammount of buffer curently in use
  */
-zap_size_t zap_buffer_inuse(zap_buffer_t *buffer);
+OZ_DECLARE(zap_size_t) zap_buffer_inuse(zap_buffer_t *buffer);
 
 /*! \brief Read data from a zap_buffer_t up to the ammount of datalen if it is available.  Remove read data from buffer. 
  * \param buffer any buffer of type zap_buffer_t
@@ -79,7 +79,7 @@ zap_size_t zap_buffer_inuse(zap_buffer_t *buffer);
  * \param datalen amount of data to be returned
  * \return int ammount of data actually read
  */
-zap_size_t zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen);
 
 /*! \brief Read data endlessly from a zap_buffer_t 
  * \param buffer any buffer of type zap_buffer_t
@@ -88,13 +88,13 @@ zap_size_t zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen)
  * \return int ammount of data actually read
  * \note Once you have read all the data from the buffer it will loop around.
  */
-zap_size_t zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t datalen);
 
 /*! \brief Assign a number of loops to read
  * \param buffer any buffer of type zap_buffer_t
  * \param loops the number of loops (-1 for infinite)
  */
-void zap_buffer_set_loops(zap_buffer_t *buffer, int32_t loops);
+OZ_DECLARE(void) zap_buffer_set_loops(zap_buffer_t *buffer, int32_t loops);
 
 /*! \brief Write data into a zap_buffer_t up to the length of datalen
  * \param buffer any buffer of type zap_buffer_t
@@ -102,36 +102,36 @@ void zap_buffer_set_loops(zap_buffer_t *buffer, int32_t loops);
  * \param datalen amount of data to be written
  * \return int amount of buffer used after the write, or 0 if no space available
  */
-zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t datalen);
 
 /*! \brief Remove data from the buffer
  * \param buffer any buffer of type zap_buffer_t
  * \param datalen amount of data to be removed
  * \return int size of buffer, or 0 if unable to toss that much data
  */
-zap_size_t zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen);
 
 /*! \brief Remove all data from the buffer
  * \param buffer any buffer of type zap_buffer_t
  */
-void zap_buffer_zero(zap_buffer_t *buffer);
+OZ_DECLARE(void) zap_buffer_zero(zap_buffer_t *buffer);
 
 /*! \brief Destroy the buffer
  * \param buffer buffer to destroy
  * \note only neccessary on dynamic buffers (noop on pooled ones)
  */
-void zap_buffer_destroy(zap_buffer_t **buffer);
+OZ_DECLARE(void) zap_buffer_destroy(zap_buffer_t **buffer);
 
 /*! \brief Seek to offset from the beginning of the buffer
  * \param buffer buffer to seek
  * \param datalen offset in bytes
  * \return new position
  */
-zap_size_t zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen);
 
 /** @} */
 
-zap_size_t zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_size_t datalen);
+OZ_DECLARE(zap_size_t) zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_size_t datalen);
 
 #endif
 /* For Emacs:
diff --git a/libs/openzap/src/include/zap_threadmutex.h b/libs/openzap/src/include/zap_threadmutex.h
index f187bc516f..8639027ab7 100644
--- a/libs/openzap/src/include/zap_threadmutex.h
+++ b/libs/openzap/src/include/zap_threadmutex.h
@@ -27,14 +27,14 @@ typedef struct zap_mutex zap_mutex_t;
 typedef struct zap_thread zap_thread_t;
 typedef void *(*zap_thread_function_t) (zap_thread_t *, void *);
 
-zap_status_t zap_thread_create_detached(zap_thread_function_t func, void *data);
-zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *data, zap_size_t stack_size);
-void zap_thread_override_default_stacksize(zap_size_t size);
-zap_status_t zap_mutex_create(zap_mutex_t **mutex);
-zap_status_t zap_mutex_destroy(zap_mutex_t **mutex);
-zap_status_t _zap_mutex_lock(zap_mutex_t *mutex);
-zap_status_t _zap_mutex_trylock(zap_mutex_t *mutex);
-zap_status_t _zap_mutex_unlock(zap_mutex_t *mutex);
+OZ_DECLARE(zap_status_t) zap_thread_create_detached(zap_thread_function_t func, void *data);
+OZ_DECLARE(zap_status_t) zap_thread_create_detached_ex(zap_thread_function_t func, void *data, zap_size_t stack_size);
+OZ_DECLARE(void) zap_thread_override_default_stacksize(zap_size_t size);
+OZ_DECLARE(zap_status_t) zap_mutex_create(zap_mutex_t **mutex);
+OZ_DECLARE(zap_status_t) zap_mutex_destroy(zap_mutex_t **mutex);
+OZ_DECLARE(zap_status_t) _zap_mutex_lock(zap_mutex_t *mutex);
+OZ_DECLARE(zap_status_t) _zap_mutex_trylock(zap_mutex_t *mutex);
+OZ_DECLARE(zap_status_t) _zap_mutex_unlock(zap_mutex_t *mutex);
 
 #endif
 
diff --git a/libs/openzap/src/include/zap_types.h b/libs/openzap/src/include/zap_types.h
index fee42a14c0..09ea5fa4ac 100644
--- a/libs/openzap/src/include/zap_types.h
+++ b/libs/openzap/src/include/zap_types.h
@@ -461,7 +461,7 @@ typedef zap_status_t (*zio_api_t) ZIO_API_ARGS ;
 #define ZIO_SPAN_NEXT_EVENT_FUNCTION(name) zap_status_t name ZIO_SPAN_NEXT_EVENT_ARGS
 #define ZIO_SIGNAL_CB_FUNCTION(name) zap_status_t name ZIO_SIGNAL_CB_ARGS
 #define ZIO_EVENT_CB_FUNCTION(name) zap_status_t name ZIO_EVENT_CB_ARGS
-#define ZIO_CODEC_FUNCTION(name) zap_status_t name ZIO_CODEC_ARGS
+#define ZIO_CODEC_FUNCTION(name) OZ_DECLARE_NONSTD(zap_status_t) name ZIO_CODEC_ARGS
 #define ZIO_CONFIGURE_SPAN_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_SPAN_ARGS
 #define ZIO_CONFIGURE_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_ARGS
 #define ZIO_OPEN_FUNCTION(name) zap_status_t name ZIO_OPEN_ARGS
diff --git a/libs/openzap/src/libteletone_detect.c b/libs/openzap/src/libteletone_detect.c
index 79875a0ade..b41a04ae42 100644
--- a/libs/openzap/src/libteletone_detect.c
+++ b/libs/openzap/src/libteletone_detect.c
@@ -83,7 +83,7 @@ static void goertzel_init(teletone_goertzel_state_t *goertzel_state, teletone_de
 	goertzel_state->fac = tdesc->fac;
 }
 
-void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
 							  int16_t sample_buffer[],
 							  int samples)
 {
@@ -102,7 +102,7 @@ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
 
 #define teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac))
 
-void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate)
+TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate)
 {
 	int i;
 	float theta;
@@ -136,7 +136,7 @@ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state,
 	dtmf_detect_state->mhit = 0;
 }
 
-void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map)
+TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map)
 {
 	float theta = 0;
 	int x = 0;
@@ -145,7 +145,7 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
 		mt->sample_rate = 8000;
 	}
 
-	if(!mt->min_samples) {
+	if (!mt->min_samples) {
 		mt->min_samples = 102;
 	}
 
@@ -176,7 +176,7 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
 
 }
 
-int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
+TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt,
 								int16_t sample_buffer[],
 								int samples)
 {
@@ -266,7 +266,7 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
 }
 
 
-int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API(int) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
 						  int16_t sample_buffer[],
 						  int samples)
 {
@@ -397,7 +397,7 @@ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
 }
 
 
-int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
 					   char *buf,
 					   int max)
 {
@@ -423,5 +423,5 @@ int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
  * c-basic-offset:4
  * End:
  * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
  */
diff --git a/libs/openzap/src/libteletone_generate.c b/libs/openzap/src/libteletone_generate.c
index 84de06853c..1d5d696af2 100644
--- a/libs/openzap/src/libteletone_generate.c
+++ b/libs/openzap/src/libteletone_generate.c
@@ -43,7 +43,7 @@
 #pragma warning(disable:4706)
 #endif
 
-int16_t TELETONE_SINES[SINE_TABLE_MAX] = {
+TELETONE_API_DATA int16_t TELETONE_SINES[SINE_TABLE_MAX] = {
 	0x00c9, 0x025b, 0x03ed, 0x057f, 0x0711, 0x08a2, 0x0a33, 0x0bc4,
 	0x0d54, 0x0ee4, 0x1073, 0x1201, 0x138f, 0x151c, 0x16a8, 0x1833,
 	0x19be, 0x1b47, 0x1cd0, 0x1e57, 0x1fdd, 0x2162, 0x22e5, 0x2467,
@@ -63,7 +63,7 @@ int16_t TELETONE_SINES[SINE_TABLE_MAX] = {
 };
 
 
-int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
+TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
 {
 	va_list ap;
 	int i = 0;
@@ -79,7 +79,7 @@ int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
 	
 }
 
-int teletone_set_map(teletone_tone_map_t *map, ...)
+TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...)
 {
 	va_list ap;
 	int i = 0;
@@ -95,7 +95,7 @@ int teletone_set_map(teletone_tone_map_t *map, ...)
 	
 }
 
-int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
+TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
 {
 	memset(ts, 0, sizeof(*ts));
 	ts->rate = 8000;
@@ -138,7 +138,7 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
 	return 0;
 }
 
-int teletone_destroy_session(teletone_generation_session_t *ts)
+TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts)
 {
 	if (ts->buffer) {
 		free(ts->buffer);
@@ -167,7 +167,7 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need)
 	return 0;
 }
 
-int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
+TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
 {
 	/*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/
 	int i, c;
@@ -185,7 +185,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
 	wait = (ts->tmp_wait > -1) ? ts->tmp_wait : ts->wait;
 
 	if (map->freqs[0] > 0) {
-		for (freqlen = 0; map->freqs[freqlen] && freqlen < TELETONE_MAX_TONES; freqlen++) {
+		for (freqlen = 0; freqlen < TELETONE_MAX_TONES && map->freqs[freqlen]; freqlen++) {
 			teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, 0);
 			teletone_dds_state_set_tx_level(&tones[freqlen], vol);
 		}
@@ -207,7 +207,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
 
 				if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) {
 					vol = nvol;
-					for (j = 0; map->freqs[j] && j < TELETONE_MAX_TONES; j++) {					
+					for (j = 0; j < TELETONE_MAX_TONES && map->freqs[j]; j++) {					
 						teletone_dds_state_set_tx_level(&tones[j], vol);
 					}
 					dc = 0;
@@ -282,7 +282,7 @@ static char *my_strdup (const char *s)
 	return (char *) memcpy (new, s, len);
 }
 
-int teletone_run(teletone_generation_session_t *ts, const char *cmd)
+TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd)
 {
 	char *data = NULL, *cur = NULL, *end = NULL;
 	int var = 0, LOOPING = 0;
@@ -460,5 +460,5 @@ int teletone_run(teletone_generation_session_t *ts, const char *cmd)
  * c-basic-offset:4
  * End:
  * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
  */
diff --git a/libs/openzap/src/zap_buffer.c b/libs/openzap/src/zap_buffer.c
index 777151d8b9..8315825ff7 100644
--- a/libs/openzap/src/zap_buffer.c
+++ b/libs/openzap/src/zap_buffer.c
@@ -49,7 +49,7 @@ struct zap_buffer {
 };
 
 
-zap_status_t zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_size_t start_len, zap_size_t max_len)
+OZ_DECLARE(zap_status_t) zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_size_t start_len, zap_size_t max_len)
 {
 	zap_buffer_t *new_buffer;
 
@@ -79,7 +79,7 @@ zap_status_t zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_
 	return ZAP_MEMERR;
 }
 
-zap_size_t zap_buffer_len(zap_buffer_t *buffer)
+OZ_DECLARE(zap_size_t) zap_buffer_len(zap_buffer_t *buffer)
 {
 
 	assert(buffer != NULL);
@@ -89,7 +89,7 @@ zap_size_t zap_buffer_len(zap_buffer_t *buffer)
 }
 
 
-zap_size_t zap_buffer_freespace(zap_buffer_t *buffer)
+OZ_DECLARE(zap_size_t) zap_buffer_freespace(zap_buffer_t *buffer)
 {
 	assert(buffer != NULL);
 
@@ -101,14 +101,14 @@ zap_size_t zap_buffer_freespace(zap_buffer_t *buffer)
 
 }
 
-zap_size_t zap_buffer_inuse(zap_buffer_t *buffer)
+OZ_DECLARE(zap_size_t) zap_buffer_inuse(zap_buffer_t *buffer)
 {
 	assert(buffer != NULL);
 
 	return buffer->used;
 }
 
-zap_size_t zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen)
 {
 	zap_size_t reading = 0;
 
@@ -129,7 +129,7 @@ zap_size_t zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen)
 	return reading;
 }
 
-zap_size_t zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen)
 {
 	zap_size_t reading = 0;
 
@@ -150,12 +150,12 @@ zap_size_t zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen)
 	return buffer->used;
 }
 
-void zap_buffer_set_loops(zap_buffer_t *buffer, int loops)
+OZ_DECLARE(void) zap_buffer_set_loops(zap_buffer_t *buffer, int loops)
 {
 	buffer->loops = loops;
 }
 
-zap_size_t zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t datalen)
 {
 	zap_size_t len;
 	if ((len = zap_buffer_read(buffer, data, datalen)) < datalen) {
@@ -170,7 +170,7 @@ zap_size_t zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t dat
 	return len;
 }
 
-zap_size_t zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen)
 {
 	zap_size_t reading = 0;
 
@@ -195,7 +195,7 @@ zap_size_t zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen)
 	return reading;
 }
 
-zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t datalen)
 {
 	zap_size_t freespace, actual_freespace;
 
@@ -258,7 +258,7 @@ zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t d
 	return buffer->used;
 }
 
-void zap_buffer_zero(zap_buffer_t *buffer)
+OZ_DECLARE(void) zap_buffer_zero(zap_buffer_t *buffer)
 {
 	assert(buffer != NULL);
 	assert(buffer->data != NULL);
@@ -268,7 +268,7 @@ void zap_buffer_zero(zap_buffer_t *buffer)
 	buffer->head = buffer->data;
 }
 
-zap_size_t zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_size_t datalen)
+OZ_DECLARE(zap_size_t) zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_size_t datalen)
 {
 	zap_size_t w;
 	
@@ -280,7 +280,7 @@ zap_size_t zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_size_t
 	return w;
 }
 
-void zap_buffer_destroy(zap_buffer_t **buffer)
+OZ_DECLARE(void) zap_buffer_destroy(zap_buffer_t **buffer)
 {
 	if (*buffer) {
 		free((*buffer)->data);
diff --git a/libs/openzap/src/zap_callerid.c b/libs/openzap/src/zap_callerid.c
index 967b80a40c..7a6e658261 100644
--- a/libs/openzap/src/zap_callerid.c
+++ b/libs/openzap/src/zap_callerid.c
@@ -37,7 +37,7 @@ static void fsk_byte_handler (void *x, int data)
 	}
 }
 
-zap_status_t zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint32_t datalen)
+OZ_DECLARE(zap_status_t) zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint32_t datalen)
 {
 	memset(state, 0, sizeof(*state));
 	state->buf = data;
@@ -47,7 +47,7 @@ zap_status_t zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint3
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date, char *number)
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date, char *number)
 {
 	size_t dlen = strlen(date);
 	size_t nlen = strlen(number);
@@ -61,7 +61,7 @@ zap_status_t zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t type, const uint8_t *data, uint32_t datalen)
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t type, const uint8_t *data, uint32_t datalen)
 {
 	state->buf[0] = ZAP_CID_TYPE_MDMF;
 	state->buf[state->bpos++] = type;
@@ -72,7 +72,7 @@ zap_status_t zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t
 }
 
 
-zap_status_t zap_fsk_data_add_checksum(zap_fsk_data_state_t *state)
+OZ_DECLARE(zap_status_t) zap_fsk_data_add_checksum(zap_fsk_data_state_t *state)
 {
 	uint32_t i;
 	uint8_t check = 0;
@@ -93,7 +93,7 @@ zap_status_t zap_fsk_data_add_checksum(zap_fsk_data_state_t *state)
 }
 
 
-zap_status_t zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len)
+OZ_DECLARE(zap_status_t) zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len)
 {
 
 	zap_size_t i;
@@ -146,7 +146,7 @@ zap_status_t zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, c
 	return ZAP_FAIL;
 }
 
-zap_status_t zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, zap_size_t samples)
+OZ_DECLARE(zap_status_t) zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, zap_size_t samples)
 {
 	uint32_t x;
 	int16_t *sp = data;
@@ -166,14 +166,14 @@ zap_status_t zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, zap_
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_fsk_demod_destroy(zap_fsk_data_state_t *state)
+OZ_DECLARE(zap_status_t) zap_fsk_demod_destroy(zap_fsk_data_state_t *state)
 {
 	dsp_fsk_destroy(&state->fsk1200_handle);
 	memset(state, 0, sizeof(*state));
 	return ZAP_SUCCESS;
 }
 
-int zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, zap_size_t bufsize)
+OZ_DECLARE(int) zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, zap_size_t bufsize)
 {
 
 	dsp_fsk_attr_t fsk1200_attr;
@@ -199,7 +199,7 @@ int zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, zap_
 	return ZAP_SUCCESS;
 }
 
-zap_size_t zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen)
+OZ_DECLARE(zap_size_t) zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen)
 {
 	zap_size_t i;
 		
@@ -217,7 +217,7 @@ zap_size_t zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t
 }
 
 
-int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits)
+OZ_DECLARE(int32_t) zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits)
 {
 	uint32_t i = 0;
 	zap_size_t r = 0;
@@ -237,7 +237,7 @@ int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans,
 }
 
 
-void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans)
+OZ_DECLARE(void) zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans)
 {
 	uint32_t i = 0;
 	zap_size_t r = 0;
@@ -258,7 +258,7 @@ void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans)
 }
 
 
-void zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans)
+OZ_DECLARE(void) zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans)
 {
 	zap_size_t r = 0;
 	int8_t bit = 0;
@@ -275,7 +275,7 @@ void zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans)
 }
 
 
-zap_status_t zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
+OZ_DECLARE(zap_status_t) zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
 									fsk_modem_types_t modem_type,
 									uint32_t sample_rate,
 									zap_fsk_data_state_t *fsk_data,
diff --git a/libs/openzap/src/zap_io.c b/libs/openzap/src/zap_io.c
index a9f6e57fa8..e10928a427 100644
--- a/libs/openzap/src/zap_io.c
+++ b/libs/openzap/src/zap_io.c
@@ -63,7 +63,7 @@ static void time_end(void)
 	time_is_init = 0;
 }
 
-zap_time_t zap_current_time_in_ms(void)
+OZ_DECLARE(zap_time_t) zap_current_time_in_ms(void)
 {
 #ifdef WIN32
 	return timeGetTime();
@@ -175,9 +175,9 @@ static void default_logger(const char *file, const char *func, int line, int lev
 
 }
 
-zap_logger_t zap_log = null_logger;
+OZ_DECLARE_DATA zap_logger_t zap_log = null_logger;
 
-void zap_global_set_logger(zap_logger_t logger)
+OZ_DECLARE(void) zap_global_set_logger(zap_logger_t logger)
 {
 	if (logger) {
 		zap_log = logger;
@@ -186,7 +186,7 @@ void zap_global_set_logger(zap_logger_t logger)
 	}
 }
 
-void zap_global_set_default_logger(int level)
+OZ_DECLARE(void) zap_global_set_default_logger(int level)
 {
 	if (level < 0 || level > 7) {
 		level = 7;
@@ -196,12 +196,12 @@ void zap_global_set_default_logger(int level)
 	zap_log_level = level;
 }
 
-int zap_hash_equalkeys(void *k1, void *k2)
+OZ_DECLARE_NONSTD(int) zap_hash_equalkeys(void *k1, void *k2)
 {
     return strcmp((char *) k1, (char *) k2) ? 0 : 1;
 }
 
-uint32_t zap_hash_hashfromstring(void *ky)
+OZ_DECLARE_NONSTD(uint32_t) zap_hash_hashfromstring(void *ky)
 {
 	unsigned char *str = (unsigned char *) ky;
 	uint32_t hash = 0;
@@ -270,7 +270,7 @@ static zap_status_t zap_channel_destroy(zap_channel_t *zchan)
 
 
 
-zap_status_t zap_channel_get_alarms(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_get_alarms(zap_channel_t *zchan)
 {
 	zap_status_t status = ZAP_FAIL;
 
@@ -304,7 +304,7 @@ zap_status_t zap_channel_get_alarms(zap_channel_t *zchan)
 	return status;
 }
 
-zap_status_t zap_span_create(zap_io_interface_t *zio, zap_span_t **span)
+OZ_DECLARE(zap_status_t) zap_span_create(zap_io_interface_t *zio, zap_span_t **span)
 {
 	zap_span_t *new_span = NULL;
 	zap_status_t status = ZAP_FAIL;
@@ -343,7 +343,7 @@ done:
 	return status;
 }
 
-zap_status_t zap_span_close_all(void)
+OZ_DECLARE(zap_status_t) zap_span_close_all(void)
 {
 	zap_span_t *span;
 	uint32_t i, j;
@@ -362,7 +362,7 @@ zap_status_t zap_span_close_all(void)
 	return i ? ZAP_SUCCESS : ZAP_FAIL;
 }
 
-zap_status_t zap_span_load_tones(zap_span_t *span, const char *mapname)
+OZ_DECLARE(zap_status_t) zap_span_load_tones(zap_span_t *span, const char *mapname)
 {
 	zap_config_t cfg;
 	char *var, *val;
@@ -428,7 +428,7 @@ zap_status_t zap_span_load_tones(zap_span_t *span, const char *mapname)
 	
 }
 
-zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan)
+OZ_DECLARE(zap_status_t) zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan)
 {
 	if (span->chan_count < ZAP_MAX_CHANNELS_SPAN) {
 		zap_channel_t *new_chan = span->channels[++span->chan_count];
@@ -473,7 +473,7 @@ zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_cha
 	return ZAP_FAIL;
 }
 
-zap_status_t zap_span_find_by_name(const char *name, zap_span_t **span)
+OZ_DECLARE(zap_status_t) zap_span_find_by_name(const char *name, zap_span_t **span)
 {
 	zap_status_t status = ZAP_FAIL;
 
@@ -486,7 +486,7 @@ zap_status_t zap_span_find_by_name(const char *name, zap_span_t **span)
 	return status;
 }
 
-zap_status_t zap_span_find(uint32_t id, zap_span_t **span)
+OZ_DECLARE(zap_status_t) zap_span_find(uint32_t id, zap_span_t **span)
 {
 	zap_span_t *fspan;
 
@@ -508,7 +508,7 @@ zap_status_t zap_span_find(uint32_t id, zap_span_t **span)
 	
 }
 
-zap_status_t zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback)
+OZ_DECLARE(zap_status_t) zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback)
 {
 	zap_mutex_lock(span->mutex);
 	span->event_callback = event_callback;
@@ -517,7 +517,7 @@ zap_status_t zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_
 }
 
 
-zap_status_t zap_span_poll_event(zap_span_t *span, uint32_t ms)
+OZ_DECLARE(zap_status_t) zap_span_poll_event(zap_span_t *span, uint32_t ms)
 {
 	assert(span->zio != NULL);
 
@@ -530,7 +530,7 @@ zap_status_t zap_span_poll_event(zap_span_t *span, uint32_t ms)
 	return ZAP_NOTIMPL;
 }
 
-zap_status_t zap_span_next_event(zap_span_t *span, zap_event_t **event)
+OZ_DECLARE(zap_status_t) zap_span_next_event(zap_span_t *span, zap_event_t **event)
 {
 	assert(span->zio != NULL);
 
@@ -550,7 +550,7 @@ static zap_status_t zchan_fsk_write_sample(int16_t *buf, zap_size_t buflen, void
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level)
+OZ_DECLARE(zap_status_t) zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level)
 {
 	struct zap_fsk_modulator fsk_trans;
 
@@ -573,7 +573,7 @@ zap_status_t zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_
 }
 
 
-zap_status_t zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback)
+OZ_DECLARE(zap_status_t) zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback)
 {
 	zap_mutex_lock(zchan->mutex);
 	zchan->event_callback = event_callback;
@@ -581,7 +581,7 @@ zap_status_t zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_clear_token(zap_channel_t *zchan, const char *token)
+OZ_DECLARE(zap_status_t) zap_channel_clear_token(zap_channel_t *zchan, const char *token)
 {
 	zap_status_t status = ZAP_FAIL;
 	
@@ -610,7 +610,7 @@ zap_status_t zap_channel_clear_token(zap_channel_t *zchan, const char *token)
 	return status;
 }
 
-void zap_channel_rotate_tokens(zap_channel_t *zchan)
+OZ_DECLARE(void) zap_channel_rotate_tokens(zap_channel_t *zchan)
 {
 	if (zchan->token_count) {
 		memmove(zchan->tokens[1], zchan->tokens[0], zchan->token_count * ZAP_TOKEN_STRLEN);
@@ -619,7 +619,7 @@ void zap_channel_rotate_tokens(zap_channel_t *zchan)
 	}
 }
 
-zap_status_t zap_channel_add_token(zap_channel_t *zchan, char *token, int end)
+OZ_DECLARE(zap_status_t) zap_channel_add_token(zap_channel_t *zchan, char *token, int end)
 {
 	zap_status_t status = ZAP_FAIL;
 
@@ -640,7 +640,7 @@ zap_status_t zap_channel_add_token(zap_channel_t *zchan, char *token, int end)
 }
 
 
-zap_status_t zap_channel_complete_state(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_complete_state(zap_channel_t *zchan)
 {
 	zap_channel_state_t state = zchan->state;
 
@@ -704,7 +704,7 @@ static int zap_parse_state_map(zap_channel_t *zchan, zap_channel_state_t state,
 	return ok;
 }
 
-zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock)
+OZ_DECLARE(zap_status_t) zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock)
 {
 	int ok = 1;
 	
@@ -830,7 +830,7 @@ zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t sta
 	return ok ? ZAP_SUCCESS : ZAP_FAIL;
 }
 
-zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan)
+OZ_DECLARE(zap_status_t) zap_channel_open_any(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan)
 {
 	zap_status_t status = ZAP_FAIL;
 	zap_channel_t *check;
@@ -997,7 +997,7 @@ static zap_status_t zap_channel_reset(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_init(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_init(zap_channel_t *zchan)
 {
 
 	if (zchan->init_state != ZAP_CHANNEL_STATE_DOWN) {
@@ -1008,7 +1008,7 @@ zap_status_t zap_channel_init(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_open_chan(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_open_chan(zap_channel_t *zchan)
 {
 	zap_status_t status = ZAP_FAIL;
 
@@ -1039,7 +1039,7 @@ zap_status_t zap_channel_open_chan(zap_channel_t *zchan)
 	return status;
 }
 
-zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan)
+OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan)
 {
 	zap_channel_t *check;
 	zap_status_t status = ZAP_FAIL;
@@ -1089,7 +1089,7 @@ zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t
 	return status;
 }
 
-zap_status_t zap_channel_outgoing_call(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_outgoing_call(zap_channel_t *zchan)
 {
 	zap_status_t status;
 
@@ -1107,7 +1107,7 @@ zap_status_t zap_channel_outgoing_call(zap_channel_t *zchan)
 	return ZAP_FAIL;
 }
 
-zap_status_t zap_channel_done(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_done(zap_channel_t *zchan)
 {
 	assert(zchan != NULL);
 
@@ -1134,7 +1134,7 @@ zap_status_t zap_channel_done(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_use(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_use(zap_channel_t *zchan)
 {
 
 	assert(zchan != NULL);
@@ -1144,7 +1144,7 @@ zap_status_t zap_channel_use(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_close(zap_channel_t **zchan)
+OZ_DECLARE(zap_status_t) zap_channel_close(zap_channel_t **zchan)
 {
 	zap_channel_t *check;
 	zap_status_t status = ZAP_FAIL;
@@ -1206,7 +1206,7 @@ static zap_status_t zchan_activate_dtmf_buffer(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, void *obj)
+OZ_DECLARE(zap_status_t) zap_channel_command(zap_channel_t *zchan, zap_command_t command, void *obj)
 {
 	zap_status_t status = ZAP_FAIL;
 	
@@ -1467,7 +1467,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
 
 }
 
-zap_status_t zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to)
+OZ_DECLARE(zap_status_t) zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to)
 {
 	assert(zchan != NULL);
 	assert(zchan->zio != NULL);
@@ -1617,17 +1617,17 @@ ZIO_CODEC_FUNCTION(zio_alaw2ulaw)
 
 /******************************/
 
-void zap_channel_clear_detected_tones(zap_channel_t *zchan)
+OZ_DECLARE(void) zap_channel_clear_detected_tones(zap_channel_t *zchan)
 {
 	memset(zchan->detected_tones, 0, sizeof(zchan->detected_tones[0]) * ZAP_TONEMAP_INVALID);
 }
 
-void zap_channel_clear_needed_tones(zap_channel_t *zchan)
+OZ_DECLARE(void) zap_channel_clear_needed_tones(zap_channel_t *zchan)
 {
 	memset(zchan->needed_tones, 0, sizeof(zchan->needed_tones[0]) * ZAP_TONEMAP_INVALID);
 }
 
-zap_size_t zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len)
+OZ_DECLARE(zap_size_t) zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len)
 {
 	zap_size_t bytes = 0;
 
@@ -1648,7 +1648,7 @@ zap_size_t zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t
 	return bytes;
 }
 
-void zap_channel_flush_dtmf(zap_channel_t *zchan)
+OZ_DECLARE(void) zap_channel_flush_dtmf(zap_channel_t *zchan)
 {
 	if (zchan->digit_buffer && zap_buffer_inuse(zchan->digit_buffer)) {
 		zap_mutex_lock(zchan->mutex);
@@ -1657,7 +1657,7 @@ void zap_channel_flush_dtmf(zap_channel_t *zchan)
 	}
 }
 
-zap_status_t zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf)
+OZ_DECLARE(zap_status_t) zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf)
 {
 	zap_status_t status;
 	register zap_size_t len, inuse;
@@ -1785,7 +1785,7 @@ static zap_status_t handle_dtmf(zap_channel_t *zchan, zap_size_t datalen)
 
 
 
-zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen)
+OZ_DECLARE(zap_status_t) zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen)
 {
 	zap_status_t status = ZAP_FAIL;
 	zio_codec_t codec_func = NULL;
@@ -1983,7 +1983,7 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
 }
 
 
-zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t datasize, zap_size_t *datalen)
+OZ_DECLARE(zap_status_t) zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t datasize, zap_size_t *datalen)
 {
 	zap_status_t status = ZAP_FAIL;
 	zio_codec_t codec_func = NULL;
@@ -2042,7 +2042,7 @@ zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t data
 	return status;
 }
 
-zap_status_t zap_channel_clear_vars(zap_channel_t *zchan)
+OZ_DECLARE(zap_status_t) zap_channel_clear_vars(zap_channel_t *zchan)
 {
 	if(zchan->variable_hash) {
 		hashtable_destroy(zchan->variable_hash);
@@ -2055,7 +2055,7 @@ zap_status_t zap_channel_clear_vars(zap_channel_t *zchan)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_channel_add_var(zap_channel_t *zchan, const char *var_name, const char *value)
+OZ_DECLARE(zap_status_t) zap_channel_add_var(zap_channel_t *zchan, const char *var_name, const char *value)
 {
 	char *t_name = 0, *t_val = 0;
 
@@ -2073,7 +2073,7 @@ zap_status_t zap_channel_add_var(zap_channel_t *zchan, const char *var_name, con
 	return ZAP_FAIL;
 }
 
-const char * zap_channel_get_var(zap_channel_t *zchan, const char *var_name)
+OZ_DECLARE(const char *) zap_channel_get_var(zap_channel_t *zchan, const char *var_name)
 {
 	if(!zchan->variable_hash || !var_name)
 	{
@@ -2087,7 +2087,7 @@ static struct {
 } interfaces;
 
 
-char *zap_api_execute(const char *type, const char *cmd)
+OZ_DECLARE(char *) zap_api_execute(const char *type, const char *cmd)
 {
 	zap_io_interface_t *zio = NULL;
 	char *dup = NULL, *p;
@@ -2351,7 +2351,7 @@ static zap_status_t process_module_config(zap_io_interface_t *zio)
 	return ZAP_SUCCESS;
 }
 
-int zap_load_module(const char *name)
+OZ_DECLARE(int) zap_load_module(const char *name)
 {
 	zap_dso_lib_t lib;
 	int count = 0, x = 0;
@@ -2445,7 +2445,7 @@ int zap_load_module(const char *name)
 	return count;
 }
 
-int zap_load_module_assume(const char *name)
+OZ_DECLARE(int) zap_load_module_assume(const char *name)
 {
 	char buf[256] = "";
 
@@ -2453,7 +2453,7 @@ int zap_load_module_assume(const char *name)
 	return zap_load_module(buf);
 }
 
-int zap_load_modules(void)
+OZ_DECLARE(int) zap_load_modules(void)
 {
 	char cfg_name[] = "modules.conf";
 	zap_config_t cfg;
@@ -2475,7 +2475,7 @@ int zap_load_modules(void)
 	return count;
 }
 
-zap_status_t zap_unload_modules(void)
+OZ_DECLARE(zap_status_t) zap_unload_modules(void)
 {
 	zap_hash_iterator_t *i;
 	zap_dso_lib_t lib;
@@ -2520,7 +2520,7 @@ zap_status_t zap_unload_modules(void)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...)
+OZ_DECLARE(zap_status_t) zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...)
 {
 	zap_module_t *mod = (zap_module_t *) hashtable_search(globals.module_hash, (void *)type);
 	zap_status_t status = ZAP_FAIL;
@@ -2545,7 +2545,7 @@ zap_status_t zap_configure_span(const char *type, zap_span_t *span, zio_signal_c
 	return status;
 }
 
-zap_status_t zap_span_start(zap_span_t *span)
+OZ_DECLARE(zap_status_t) zap_span_start(zap_span_t *span)
 {
 	if (span->start) {
 		return span->start(span);
@@ -2555,7 +2555,7 @@ zap_status_t zap_span_start(zap_span_t *span)
 }
 
 
-zap_status_t zap_global_init(void)
+OZ_DECLARE(zap_status_t) zap_global_init(void)
 {
 	int modcount;
 
@@ -2584,13 +2584,13 @@ zap_status_t zap_global_init(void)
 	return ZAP_FAIL;
 }
 
-uint32_t zap_running(void)
+OZ_DECLARE(uint32_t) zap_running(void)
 {
 	return globals.running;
 }
 
 
-zap_status_t zap_global_destroy(void)
+OZ_DECLARE(zap_status_t) zap_global_destroy(void)
 {
 	unsigned int i,j;
 	time_end();
@@ -2650,7 +2650,7 @@ zap_status_t zap_global_destroy(void)
 }
 
 
-uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen)
+OZ_DECLARE(uint32_t) zap_separate_string(char *buf, char delim, char **array, int arraylen)
 {
 	int argc;
 	char *ptr;
@@ -2707,7 +2707,7 @@ uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen)
 	return argc;
 }
 
-void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss)
+OZ_DECLARE(void) zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss)
 {
 	memset(bsp, 0, sizeof(*bsp));
 	bsp->data = data;
@@ -2725,7 +2725,7 @@ void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, z
 
 }
 
-int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp)
+OZ_DECLARE(int8_t) zap_bitstream_get_bit(zap_bitstream_t *bsp)
 {
 	int8_t bit = -1;
 	
@@ -2771,7 +2771,7 @@ int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp)
 	return bit;
 }
 
-void print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen)
+OZ_DECLARE(void) print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen)
 {
 	char *bp = buf;
 	uint8_t *byte = data;
@@ -2794,7 +2794,7 @@ void print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen)
 
 }
 
-void print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, uint8_t ss)
+OZ_DECLARE(void) print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, uint8_t ss)
 {
 	zap_bitstream_t bs;
 	int j = 0, c = 0;
@@ -2823,7 +2823,7 @@ void print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, uint8_t
 
 
 
-zap_status_t zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen)
+OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen)
 {
 	zap_size_t need = handle->data_len + datalen;
 	
@@ -2847,7 +2847,7 @@ zap_status_t zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *
 	return ZAP_SUCCESS;
 }
 
-int zap_vasprintf(char **ret, const char *fmt, va_list ap) /* code from switch_apr.c */
+OZ_DECLARE(int) zap_vasprintf(char **ret, const char *fmt, va_list ap) /* code from switch_apr.c */
 {
 #ifdef HAVE_VASPRINTF
 	return vasprintf(ret, fmt, ap);
@@ -2883,7 +2883,7 @@ int zap_vasprintf(char **ret, const char *fmt, va_list ap) /* code from switch_a
 #endif
 }
 
-zap_status_t zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...)
+OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...)
 {
 	va_list ap;
 	char *buf = handle->data;
diff --git a/libs/openzap/src/zap_threadmutex.c b/libs/openzap/src/zap_threadmutex.c
index abeaa1f9b5..2dc4763068 100644
--- a/libs/openzap/src/zap_threadmutex.c
+++ b/libs/openzap/src/zap_threadmutex.c
@@ -62,7 +62,7 @@ struct zap_thread {
 
 zap_size_t thread_default_stacksize = 0;
 
-void zap_thread_override_default_stacksize(zap_size_t size)
+OZ_DECLARE(void) zap_thread_override_default_stacksize(zap_size_t size)
 {
 	thread_default_stacksize = size;
 }
@@ -80,12 +80,12 @@ static void * ZAP_THREAD_CALLING_CONVENTION thread_launch(void *args)
 	return exit_val;
 }
 
-zap_status_t zap_thread_create_detached(zap_thread_function_t func, void *data)
+OZ_DECLARE(zap_status_t) zap_thread_create_detached(zap_thread_function_t func, void *data)
 {
 	return zap_thread_create_detached_ex(func, data, thread_default_stacksize);
 }
 
-zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *data, zap_size_t stack_size)
+OZ_DECLARE(zap_status_t) zap_thread_create_detached_ex(zap_thread_function_t func, void *data, zap_size_t stack_size)
 {
 	zap_thread_t *thread = NULL;
 	zap_status_t status = ZAP_FAIL;
@@ -132,7 +132,7 @@ zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *dat
 }
 
 
-zap_status_t zap_mutex_create(zap_mutex_t **mutex)
+OZ_DECLARE(zap_status_t) zap_mutex_create(zap_mutex_t **mutex)
 {
 	zap_status_t status = ZAP_FAIL;
 #ifndef WIN32
@@ -170,7 +170,7 @@ zap_status_t zap_mutex_create(zap_mutex_t **mutex)
 	return status;
 }
 
-zap_status_t zap_mutex_destroy(zap_mutex_t **mutex)
+OZ_DECLARE(zap_status_t) zap_mutex_destroy(zap_mutex_t **mutex)
 {
 	zap_mutex_t *mp = *mutex;
 	*mutex = NULL;
@@ -187,7 +187,7 @@ zap_status_t zap_mutex_destroy(zap_mutex_t **mutex)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t _zap_mutex_lock(zap_mutex_t *mutex)
+OZ_DECLARE(zap_status_t) _zap_mutex_lock(zap_mutex_t *mutex)
 {
 #ifdef WIN32
 	EnterCriticalSection(&mutex->mutex);
@@ -198,7 +198,7 @@ zap_status_t _zap_mutex_lock(zap_mutex_t *mutex)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t _zap_mutex_trylock(zap_mutex_t *mutex)
+OZ_DECLARE(zap_status_t) _zap_mutex_trylock(zap_mutex_t *mutex)
 {
 #ifdef WIN32
 	if (!TryEnterCriticalSection(&mutex->mutex))
@@ -210,7 +210,7 @@ zap_status_t _zap_mutex_trylock(zap_mutex_t *mutex)
 	return ZAP_SUCCESS;
 }
 
-zap_status_t _zap_mutex_unlock(zap_mutex_t *mutex)
+OZ_DECLARE(zap_status_t) _zap_mutex_unlock(zap_mutex_t *mutex)
 {
 #ifdef WIN32
 	LeaveCriticalSection(&mutex->mutex);