From ea72f97b966f77725c6c345162c5b7599d1dd0d6 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 6 Mar 2009 18:17:15 +0000 Subject: [PATCH] build: get base of windows build for openzap going again (OPENZAP-55) git-svn-id: http://svn.openzap.org/svn/openzap/trunk@682 a93c3328-9c30-0410-af19-c9cd2b2d52af --- ...openzap.vcproj => mod_openzap.2005.vcproj} | 10 +- .../mod_openzap/mod_openzap.2008.vcproj | 200 +++++++ libs/freetdm/mod_openzap/mod_openzap.c | 8 +- libs/freetdm/msvc/openzap.2005.vcproj | 283 +++++++++ libs/freetdm/msvc/openzap.2008.vcproj | 284 +++++++++ libs/freetdm/msvc/openzap.vcproj | 557 ------------------ ...stanalog.vcproj => testanalog.2005.vcproj} | 0 .../msvc/testanalog/testanalog.2008.vcproj | 190 ++++++ .../{testisdn.vcproj => testisdn.2005.vcproj} | 0 .../msvc/testisdn/testisdn.2008.vcproj | 190 ++++++ .../freetdm/{openzap.sln => openzap.2005.sln} | 14 +- libs/freetdm/openzap.2008.sln | 47 ++ libs/freetdm/src/hashtable.c | 6 +- libs/freetdm/src/include/hashtable_private.h | 2 +- libs/freetdm/src/include/openzap.h | 4 + libs/freetdm/src/isdn/Q921.c | 15 +- libs/freetdm/src/zap_buffer.c | 2 +- libs/freetdm/src/zap_callerid.c | 2 +- libs/freetdm/src/zap_config.c | 2 +- libs/freetdm/src/zap_dso.c | 45 ++ libs/freetdm/src/zap_io.c | 55 +- 21 files changed, 1317 insertions(+), 599 deletions(-) rename libs/freetdm/mod_openzap/{mod_openzap.vcproj => mod_openzap.2005.vcproj} (89%) create mode 100644 libs/freetdm/mod_openzap/mod_openzap.2008.vcproj create mode 100644 libs/freetdm/msvc/openzap.2005.vcproj create mode 100644 libs/freetdm/msvc/openzap.2008.vcproj delete mode 100644 libs/freetdm/msvc/openzap.vcproj rename libs/freetdm/msvc/testanalog/{testanalog.vcproj => testanalog.2005.vcproj} (100%) create mode 100644 libs/freetdm/msvc/testanalog/testanalog.2008.vcproj rename libs/freetdm/msvc/testisdn/{testisdn.vcproj => testisdn.2005.vcproj} (100%) create mode 100644 libs/freetdm/msvc/testisdn/testisdn.2008.vcproj rename libs/freetdm/{openzap.sln => openzap.2005.sln} (79%) create mode 100644 libs/freetdm/openzap.2008.sln diff --git a/libs/freetdm/mod_openzap/mod_openzap.vcproj b/libs/freetdm/mod_openzap/mod_openzap.2005.vcproj similarity index 89% rename from libs/freetdm/mod_openzap/mod_openzap.vcproj rename to libs/freetdm/mod_openzap/mod_openzap.2005.vcproj index a1ebe71e9a..800fea482c 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.vcproj +++ b/libs/freetdm/mod_openzap/mod_openzap.2005.vcproj @@ -41,7 +41,7 @@ - @@ -174,9 +171,6 @@ - diff --git a/libs/freetdm/mod_openzap/mod_openzap.2008.vcproj b/libs/freetdm/mod_openzap/mod_openzap.2008.vcproj new file mode 100644 index 0000000000..68be586a01 --- /dev/null +++ b/libs/freetdm/mod_openzap/mod_openzap.2008.vcproj @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index 590c22112a..f8a987449f 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -617,7 +617,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } *frame = &tech_pvt->read_frame; - tech_pvt->read_frame.datalen = len; + tech_pvt->read_frame.datalen = (uint32_t)len; tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen; if (tech_pvt->zchan->effective_codec == ZAP_CODEC_SLIN) { @@ -2185,7 +2185,7 @@ SWITCH_STANDARD_API(oz_function) stream->write_function(stream, "-ERR Usage: oz dump []\n"); goto end; } else { - int32_t span_id, chan_id = 0; + uint32_t span_id, chan_id = 0; zap_span_t *span; span_id = atoi(argv[1]); @@ -2204,7 +2204,7 @@ SWITCH_STANDARD_API(oz_function) dump_chan(span, chan_id, stream); } } else { - int j; + uint32_t j; stream->write_function(stream, "+OK\n"); for (j = 1; j <= span->chan_count; j++) { @@ -2271,7 +2271,7 @@ SWITCH_STANDARD_API(oz_function) if (chan_id) { zap_log(ZAP_LOG_INFO,"Bounce span: %d, chan: %d\n", span_id, chan_id); } else { - int j; + uint32_t j; stream->write_function(stream, "+OK\n"); for (j = 1; j <= span->chan_count; j++) { diff --git a/libs/freetdm/msvc/openzap.2005.vcproj b/libs/freetdm/msvc/openzap.2005.vcproj new file mode 100644 index 0000000000..d02a4ada41 --- /dev/null +++ b/libs/freetdm/msvc/openzap.2005.vcproj @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/msvc/openzap.2008.vcproj b/libs/freetdm/msvc/openzap.2008.vcproj new file mode 100644 index 0000000000..a0d6c2b4b6 --- /dev/null +++ b/libs/freetdm/msvc/openzap.2008.vcproj @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/msvc/openzap.vcproj b/libs/freetdm/msvc/openzap.vcproj deleted file mode 100644 index c3af23614f..0000000000 --- a/libs/freetdm/msvc/openzap.vcproj +++ /dev/null @@ -1,557 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testanalog/testanalog.vcproj b/libs/freetdm/msvc/testanalog/testanalog.2005.vcproj similarity index 100% rename from libs/freetdm/msvc/testanalog/testanalog.vcproj rename to libs/freetdm/msvc/testanalog/testanalog.2005.vcproj diff --git a/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj b/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj new file mode 100644 index 0000000000..7400debad0 --- /dev/null +++ b/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/msvc/testisdn/testisdn.vcproj b/libs/freetdm/msvc/testisdn/testisdn.2005.vcproj similarity index 100% rename from libs/freetdm/msvc/testisdn/testisdn.vcproj rename to libs/freetdm/msvc/testisdn/testisdn.2005.vcproj diff --git a/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj b/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj new file mode 100644 index 0000000000..32893d6ac7 --- /dev/null +++ b/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/openzap.sln b/libs/freetdm/openzap.2005.sln similarity index 79% rename from libs/freetdm/openzap.sln rename to libs/freetdm/openzap.2005.sln index 2e05fb4136..5c34eb2878 100644 --- a/libs/freetdm/openzap.sln +++ b/libs/freetdm/openzap.2005.sln @@ -1,25 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openzap", "msvc\openzap.vcproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openzap", "msvc\openzap.2005.vcproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Unix Makefiles", "Unix Makefiles", "{214C60D6-6E30-4912-B919-DB76A20CC682}" - ProjectSection(SolutionItems) = preProject - general.makefile = general.makefile - Makefile = Makefile - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.vcproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2005.vcproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" ProjectSection(ProjectDependencies) = postProject {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.vcproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2005.vcproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" ProjectSection(ProjectDependencies) = postProject {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_openzap", "mod_openzap\mod_openzap.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_openzap", "mod_openzap\mod_openzap.2005.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" ProjectSection(ProjectDependencies) = postProject {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} EndProjectSection diff --git a/libs/freetdm/openzap.2008.sln b/libs/freetdm/openzap.2008.sln new file mode 100644 index 0000000000..aaeda35ecb --- /dev/null +++ b/libs/freetdm/openzap.2008.sln @@ -0,0 +1,47 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openzap", "msvc\openzap.2008.vcproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2008.vcproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" + ProjectSection(ProjectDependencies) = postProject + {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2008.vcproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" + ProjectSection(ProjectDependencies) = postProject + {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_openzap", "mod_openzap\mod_openzap.2008.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" + ProjectSection(ProjectDependencies) = postProject + {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.ActiveCfg = Debug|Win32 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.Build.0 = Debug|Win32 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.Build.0 = Debug|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.Build.0 = Debug|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.Build.0 = Release|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.Build.0 = Debug|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/freetdm/src/hashtable.c b/libs/freetdm/src/hashtable.c index d9e0a30a9f..e1deb8912f 100644 --- a/libs/freetdm/src/hashtable.c +++ b/libs/freetdm/src/hashtable.c @@ -268,7 +268,7 @@ struct hashtable_iterator *hashtable_next(struct hashtable_iterator *i) { if (i->e) { - if ((i->e = i->e->next)) { + if ((i->e = i->e->next) != 0) { return i; } else { i->pos++; @@ -283,7 +283,7 @@ struct hashtable_iterator *hashtable_next(struct hashtable_iterator *i) return NULL; } - if ((i->e = i->h->table[i->pos])) { + if ((i->e = i->h->table[i->pos]) != 0) { return i; } @@ -307,7 +307,7 @@ void hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, v *key = i->e->k; } if (klen) { - *klen = strlen(i->e->k); + *klen = (int)strlen(i->e->k); } if (val) { *val = i->e->v; diff --git a/libs/freetdm/src/include/hashtable_private.h b/libs/freetdm/src/include/hashtable_private.h index 0a20c214fd..0f329ca3a6 100644 --- a/libs/freetdm/src/include/hashtable_private.h +++ b/libs/freetdm/src/include/hashtable_private.h @@ -17,7 +17,7 @@ struct entry }; struct hashtable_iterator { - int pos; + unsigned int pos; struct entry *e; struct hashtable *h; }; diff --git a/libs/freetdm/src/include/openzap.h b/libs/freetdm/src/include/openzap.h index e35daf1543..399518ba27 100644 --- a/libs/freetdm/src/include/openzap.h +++ b/libs/freetdm/src/include/openzap.h @@ -239,6 +239,10 @@ else zap_log(ZAP_LOG_WARNING, "VETO Changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(st), zap_channel_state2str(s)); \ } +#ifdef _MSC_VER +/* The while(0) below throws a conditional expression is constant warning */ +#pragma warning(disable:4127) +#endif #define zap_set_state_locked_wait(obj, s) \ do { \ int __safety = 100; \ diff --git a/libs/freetdm/src/isdn/Q921.c b/libs/freetdm/src/isdn/Q921.c index 7667203227..0496e09f5c 100644 --- a/libs/freetdm/src/isdn/Q921.c +++ b/libs/freetdm/src/isdn/Q921.c @@ -83,6 +83,9 @@ #include "Q921priv.h" #include "mfifo.h" +#ifdef WIN32 +#pragma warning(disable:4100 4244) +#endif /****************************************************************************************************** * Actual code below this line @@ -650,7 +653,7 @@ static int Q921LogMesg(L2TRUNK trunk, Q921LogLevel_t level, L2UCHAR received, L2 if(tei != link->tei) { APPEND_MSG(pbuf, poffset, pleft, " CONTENT:\n"); - len = print_hex(pbuf + poffset, pleft, &pmes[4], size - (trunk->Q921HeaderSpace + 4)); + len = print_hex(pbuf + poffset, (int)pleft, &pmes[4], size - (trunk->Q921HeaderSpace + 4)); poffset += len; pleft -= len; } @@ -775,7 +778,7 @@ static int Q921LogMesg(L2TRUNK trunk, Q921LogLevel_t level, L2UCHAR received, L2 else { APPEND_MSG(pbuf, poffset, pleft, " ENT ID: %d (%s), MESSAGE CONTENT:\n", pmes[3], type); - len = print_hex(pbuf + poffset, pleft, &pmes[3], size - (trunk->Q921HeaderSpace + 3)); + len = print_hex(pbuf + poffset, (int)pleft, &pmes[3], size - (trunk->Q921HeaderSpace + 3)); poffset += len; pleft -= len; } @@ -822,7 +825,7 @@ static int Q921LogMesg(L2TRUNK trunk, Q921LogLevel_t level, L2UCHAR received, L2 out: buf[sizeof(buf) - 1] = '\0'; - return trunk->Q921LogProc(trunk->PrivateDataLog, level, buf, strlen(buf)); + return trunk->Q921LogProc(trunk->PrivateDataLog, level, buf, (int)strlen(buf)); } /***************************************************************************** @@ -3108,7 +3111,11 @@ static int Q921TeiSendAssignRequest(L2TRUNK trunk) if (!Q921_IS_PTMP_TE(trunk)) /* only ptmp te mode*/ return 0; - link->ri = (L2USHORT)(random() % 0xffff); +#ifndef WIN32 + link->ri = (L2USHORT)(random() % 0xffff); +#else + link->ri = (L2USHORT)(rand() % 0xffff); //todo +#endif /* send TEI assign request */ res = Q921TeiSend(trunk, Q921_TEI_ID_REQUEST, link->ri, Q921_TEI_BCAST); diff --git a/libs/freetdm/src/zap_buffer.c b/libs/freetdm/src/zap_buffer.c index 1051f716cc..777151d8b9 100644 --- a/libs/freetdm/src/zap_buffer.c +++ b/libs/freetdm/src/zap_buffer.c @@ -164,7 +164,7 @@ zap_size_t zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t dat } buffer->head = buffer->data; buffer->used = buffer->actually_used; - len = zap_buffer_read(buffer, data + len, datalen - len); + len = zap_buffer_read(buffer, (char*)data + len, datalen - len); buffer->loops--; } return len; diff --git a/libs/freetdm/src/zap_callerid.c b/libs/freetdm/src/zap_callerid.c index 97c0f87223..967b80a40c 100644 --- a/libs/freetdm/src/zap_callerid.c +++ b/libs/freetdm/src/zap_callerid.c @@ -83,7 +83,7 @@ zap_status_t zap_fsk_data_add_checksum(zap_fsk_data_state_t *state) check = check + state->buf[i]; } - state->checksum = state->buf[state->bpos] = 256 - check; + state->checksum = state->buf[state->bpos] = (uint8_t)(256 - check); state->bpos++; state->dlen = state->bpos; diff --git a/libs/freetdm/src/zap_config.c b/libs/freetdm/src/zap_config.c index b1f6bd90c4..ab622dd7d3 100644 --- a/libs/freetdm/src/zap_config.c +++ b/libs/freetdm/src/zap_config.c @@ -213,6 +213,7 @@ int zap_config_get_cas_bits(char *strvalue, unsigned char *outbits) { char cas_bits[5]; unsigned char bit = 0x8; + int x = 0; char *double_colon = strchr(strvalue, ':'); if (!double_colon) { zap_log(ZAP_LOG_ERROR, "No CAS bits specified: %s, :xxxx definition expected, where x is 1 or 0\n", double_colon); @@ -226,7 +227,6 @@ int zap_config_get_cas_bits(char *strvalue, unsigned char *outbits) return -1; } zap_log(ZAP_LOG_DEBUG, "CAS bits specification found: %s\n", cas_bits); - int x = 0; for (; cas_bits[x]; x++) { if ('1' == cas_bits[x]) { *outbits |= bit; diff --git a/libs/freetdm/src/zap_dso.c b/libs/freetdm/src/zap_dso.c index 07c25f29fd..ead40e7c4b 100644 --- a/libs/freetdm/src/zap_dso.c +++ b/libs/freetdm/src/zap_dso.c @@ -21,6 +21,50 @@ #include #include +#ifdef WIN32 +#include +#include + + +void zap_dso_destroy(zap_dso_lib_t *lib) { + if (lib && *lib) { + FreeLibrary(*lib); + *lib = NULL; + } +} + +zap_dso_lib_t zap_dso_open(const char *path, char **err) { + HINSTANCE lib; + + lib = LoadLibraryEx(path, NULL, 0); + + if (!lib) { + LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + + if (!lib) { + DWORD error = GetLastError(); + char tmp[80]; + sprintf(tmp, "dll open error [%ul]\n", error); + *err = _strdup(tmp); + } + + return lib; +} + +void* zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, char **err) { + FARPROC func = GetProcAddress(lib, sym); + if (!func) { + DWORD error = GetLastError(); + char tmp[80]; + sprintf(tmp, "dll sym error [%ul]\n", error); + *err = _strdup(tmp); + } + return (void *)(intptr_t)func; // this should really be addr - zap_dso_func_data +} + +#else + /* ** {======================================================================== ** This is an implementation of loadlib based on the dlfcn interface. @@ -55,6 +99,7 @@ void *zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, char **err) { } return func; } +#endif /* }====================================================== */ diff --git a/libs/freetdm/src/zap_io.c b/libs/freetdm/src/zap_io.c index 0f6bf94bf5..88d800a47f 100644 --- a/libs/freetdm/src/zap_io.c +++ b/libs/freetdm/src/zap_io.c @@ -1707,7 +1707,7 @@ zap_status_t zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf) static zap_status_t handle_dtmf(zap_channel_t *zchan, zap_size_t datalen) { zap_buffer_t *buffer = NULL; - zap_size_t dblen; + zap_size_t dblen = 0; if (zchan->gen_dtmf_buffer && (dblen = zap_buffer_inuse(zchan->gen_dtmf_buffer))) { char digits[128] = ""; @@ -2362,6 +2362,7 @@ int zap_load_module(const char *name) #ifdef WIN32 const char *ext = ".dll"; //const char *EXT = ".DLL"; +#define ZAP_MOD_DIR "." //todo #elif defined (MACOSX) || defined (DARWIN) const char *ext = ".dylib"; //const char *EXT = ".DYLIB"; @@ -2389,18 +2390,18 @@ int zap_load_module(const char *name) } if (mod->io_load) { - zap_io_interface_t *interface = NULL; + zap_io_interface_t *interface1 = NULL; /* name conflict w/windows here */ - if (mod->io_load(&interface) != ZAP_SUCCESS || !interface || !interface->name) { + if (mod->io_load(&interface1) != ZAP_SUCCESS || !interface1 || !interface1->name) { zap_log(ZAP_LOG_ERROR, "Error loading %s\n", path); } else { - zap_log(ZAP_LOG_INFO, "Loading IO from %s [%s]\n", path, interface->name); + zap_log(ZAP_LOG_INFO, "Loading IO from %s [%s]\n", path, interface1->name); zap_mutex_lock(globals.mutex); - if (hashtable_search(globals.interface_hash, (void *)interface->name)) { - zap_log(ZAP_LOG_ERROR, "Interface %s already loaded!\n", interface->name); + if (hashtable_search(globals.interface_hash, (void *)interface1->name)) { + zap_log(ZAP_LOG_ERROR, "Interface %s already loaded!\n", interface1->name); } else { - hashtable_insert(globals.interface_hash, (void *)interface->name, interface, HASHTABLE_FLAG_NONE); - process_module_config(interface); + hashtable_insert(globals.interface_hash, (void *)interface1->name, interface1, HASHTABLE_FLAG_NONE); + process_module_config(interface1); x++; } zap_mutex_unlock(globals.mutex); @@ -2844,6 +2845,42 @@ 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 */ +{ +#ifdef HAVE_VASPRINTF + return vasprintf(ret, fmt, ap); +#else + char *buf; + int len; + size_t buflen; + va_list ap2; + char *tmp = NULL; + +#ifdef _MSC_VER +#if _MSC_VER >= 1500 + /* hack for incorrect assumption in msvc header files for code analysis */ + __analysis_assume(tmp); +#endif + ap2 = ap; +#else + va_copy(ap2, ap); +#endif + + len = vsnprintf(tmp, 0, fmt, ap2); + + if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) { + len = vsnprintf(buf, buflen, fmt, ap); + *ret = buf; + } else { + *ret = NULL; + len = -1; + } + + va_end(ap2); + return len; +#endif +} + zap_status_t zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...) { va_list ap; @@ -2857,7 +2894,7 @@ zap_status_t zap_console_stream_write(zap_stream_handle_t *handle, const char *f } va_start(ap, fmt); - ret = vasprintf(&data, fmt, ap); + ret = zap_vasprintf(&data, fmt, ap); va_end(ap); if (data) {