From 92a326c1dae71348b24e1e832fd55bc5c1c5a3e3 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 1 Mar 2006 06:25:56 +0000 Subject: [PATCH] add curl and teletone to mod_spidermonkey. fix /tmp/ dir for windows, added global temp dir var. Multiple type fixes. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@713 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/libteletone/src/libteletone_detect.h | 2 + src/include/switch_ivr.h | 2 +- src/include/switch_platform.h | 6 +- src/include/switch_types.h | 3 +- .../mod_spidermonkey/mod_spidermonkey.c | 14 +- .../mod_spidermonkey/mod_spidermonkey.vcproj | 16 +- src/switch_core.c | 17 +- src/switch_ivr.c | 14 +- w32/vsnet/Freeswitch.sln | 1 + w32/vsnet/GetLibs.vbs | 23 + w32/vsnet/Tools/curl/curllib.vcproj | 1649 +++++++++++++++++ 11 files changed, 1722 insertions(+), 25 deletions(-) create mode 100644 w32/vsnet/Tools/curl/curllib.vcproj diff --git a/libs/libteletone/src/libteletone_detect.h b/libs/libteletone/src/libteletone_detect.h index db60b2dd4d..327f406d17 100644 --- a/libs/libteletone/src/libteletone_detect.h +++ b/libs/libteletone/src/libteletone_detect.h @@ -65,7 +65,9 @@ extern "C" { */ #define FALSE 0 +#ifndef TRUE #define TRUE (!FALSE) +#endif /* Basic DTMF specs: * diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index d4a908f488..e71379a836 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -140,7 +140,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session char *tts_name, char *voice_name, char *timer_name, - unsigned int rate, + size_t rate, switch_dtmf_callback_function dtmf_callback, char *text, void *buf, diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 73031831e4..4b99a680a7 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -77,6 +77,11 @@ typedef __int64 int64_t; typedef unsigned long in_addr_t; #endif #define PACKED +#include +#define write _write +#define open _open +#define close _close +#define read _read #else /* packed attribute */ #ifndef PACKED @@ -88,7 +93,6 @@ typedef unsigned long in_addr_t; #include #include #endif - #endif // _MSC_VER diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 60f79998e4..39d96b9545 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -78,10 +78,11 @@ struct switch_directories { char *log_dir; char *db_dir; char *script_dir; + char *temp_dir; }; typedef struct switch_directories switch_directories; -extern switch_directories SWITCH_GLOBAL_dirs; +SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs; #define SWITCH_RECCOMMENDED_BUFFER_SIZE 131072 #define SWITCH_MAX_CODECS 30 diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index eb4e1bae4e..5e9bb1d918 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -29,7 +29,11 @@ * mod_spidermonkey.c -- Javascript Module * */ +#ifndef HAVE_CURL #define HAVE_CURL +#endif + +#include #include "jstypes.h" #include "jsarena.h" @@ -48,7 +52,6 @@ #include "jsscope.h" #include "jsscript.h" #include -#include #ifdef HAVE_CURL #include #endif @@ -572,7 +575,7 @@ struct config_data { static size_t realtime_callback(void *ptr, size_t size, size_t nmemb, void *data) { - register int realsize = size * nmemb; + register size_t realsize = size * nmemb; char *line, lineb[2048], *nextline = NULL, *val = NULL, *p = NULL; jsval rval; struct config_data *config_data = data; @@ -1025,7 +1028,7 @@ static const char c64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy static int write_buf(int fd, char *buf) { - size_t len = strlen(buf); + int len = (int)strlen(buf); if (fd && write(fd, buf, len) != len) { close(fd); return 0; @@ -1056,9 +1059,8 @@ static JSBool js_email(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js ) { if ( argc > 4) file = JS_GetStringBytes(JS_ValueToString(cx, argv[4])); - - - snprintf(filename, 80, "/tmp/mail.%ld", switch_time_now()); + + snprintf(filename, 80, "%smail.%ld", SWITCH_GLOBAL_dirs.temp_dir, switch_time_now()); if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) { if (file) { diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj index 34c6111b4c..4a0dae01db 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj @@ -42,8 +42,8 @@ = timeout) { break; } @@ -474,7 +474,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session char *tts_name, char *voice_name, char *timer_name, - unsigned int rate, + size_t rate, switch_dtmf_callback_function dtmf_callback, char *text, void *buf, @@ -484,7 +484,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session short abuf[960]; char dtmf[128]; int interval = 0; - unsigned int samples = 0; + size_t samples = 0; size_t len = 0; size_t ilen = 0; switch_frame write_frame; @@ -511,7 +511,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session if (switch_core_speech_open(&sh, tts_name, voice_name, - rate, + (unsigned int)rate, flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid TTS module!\n"); @@ -534,7 +534,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session if (switch_core_codec_init(&codec, codec_name, - rate, + (int)rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, @@ -550,7 +550,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session } if (timer_name) { - if (switch_core_timer_init(&timer, timer_name, interval, samples, pool) != SWITCH_STATUS_SUCCESS) { + if (switch_core_timer_init(&timer, timer_name, interval, (int)samples, pool) != SWITCH_STATUS_SUCCESS) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "setup timer failed!\n"); switch_core_codec_destroy(&codec); flags = 0; @@ -562,7 +562,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session flags = 0; switch_core_speech_feed_tts(&sh, text, &flags); - write_frame.rate = rate; + write_frame.rate = (int)rate; memset(write_frame.data, 0, len); write_frame.datalen = len; diff --git a/w32/vsnet/Freeswitch.sln b/w32/vsnet/Freeswitch.sln index 3efea681ef..993b816942 100644 --- a/w32/vsnet/Freeswitch.sln +++ b/w32/vsnet/Freeswitch.sln @@ -152,6 +152,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey", "..\..\src\mod\languages\mod_spidermonkey\mod_spidermonkey.vcproj", "{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}" ProjectSection(ProjectDependencies) = postProject {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} + {89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C} EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ASR-TTS", "ASR-TTS", "{4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0}" diff --git a/w32/vsnet/GetLibs.vbs b/w32/vsnet/GetLibs.vbs index 820cb9ef62..8fc80c66b9 100644 --- a/w32/vsnet/GetLibs.vbs +++ b/w32/vsnet/GetLibs.vbs @@ -204,6 +204,7 @@ End If If BuildModSpiderMonkey Then BuildLibs_SpiderMonkey BuildDebug, BuildRelease + BuildLibs_curl BuildDebug, BuildRelease End If WScript.Echo "Complete" @@ -656,6 +657,28 @@ Sub BuildLibs_pcre(BuildDebug, BuildRelease) End If End Sub +Sub BuildLibs_curl(BuildDebug, BuildRelease) + If Not FSO.FolderExists(LibDestDir & "curl") Then + WgetUnTarGz LibsBase & "curl-7.15.2.tar.gz", LibDestDir + RenameFolder LibDestDir & "curl-7.15.2", "curl" + FSO.CopyFile Utilsdir & "curl\curllib.vcproj", LibDestDir & "curl\lib\", True + End If + If FSO.FolderExists(LibDestDir & "curl") Then + If BuildDebug Then + If Not FSO.FileExists(LibDestDir & "curl\lib\Debug\curllib.lib") Then + BuildViaVCBuild LibDestDir & "curl\lib\curllib.vcproj", "Debug" + End If + End If + If BuildRelease Then + If Not FSO.FileExists(LibDestDir & "curl\lib\Release\curllib.lib") Then + BuildViaVCBuild LibDestDir & "curl\lib\curllib.vcproj", "Release" + End If + End If + Else + Wscript.echo "Unable to download curl" + End If +End Sub + Sub BuildLibs_ldap(BuildDebug, BuildRelease) If Not FSO.FolderExists(LibDestDir & "openldap") Then WgetUnTarGz LibsBase & "openldap-2.3.19.tar.gz", LibDestDir diff --git a/w32/vsnet/Tools/curl/curllib.vcproj b/w32/vsnet/Tools/curl/curllib.vcproj new file mode 100644 index 0000000000..65195ec0b1 --- /dev/null +++ b/w32/vsnet/Tools/curl/curllib.vcproj @@ -0,0 +1,1649 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +