diff --git a/.gitignore b/.gitignore index 514e756904..da9e275130 100644 --- a/.gitignore +++ b/.gitignore @@ -169,6 +169,10 @@ Release/ /src/mod/say/mod_say_nl/Makefile /src/mod/say/mod_say_th/Makefile /src/mod/say/mod_say_zh/Makefile +/src/mod/languages/mod_v8/Makefile +/src/mod/languages/mod_v8/Makefile.in +/src/mod/languages/mod_v8/mod_v8.log +/src/mod/legacy/languages/mod_lua/Makefile BuildLog.htm @@ -192,3 +196,31 @@ ipch/ *.aps /w32/Library/switch_version.inc /w32/Setup/Fragments + +/libs/portaudio/build/msvc/Win32/Debug DirectSound/portaudio.*.log +/libs/portaudio/build/msvc/Win32/Release DirectSound/portaudio.*.log +/libs/win32/mpg123/Win32/Debug_Generic/libmpg123.*.log +/libs/win32/mpg123/Win32/Release_Generic/libmpg123.*.log +/libs/win32/pthread/Win32/Debug DLL/pthread.*.log +/libs/win32/pthread/Win32/Release DLL/pthread.*.log +/src/mod/codecs/mod_amr/Win32/Debug Passthrough/mod_amr.*.log +/src/mod/codecs/mod_amr/Win32/Release Passthrough/mod_amr.*.log +/src/mod/codecs/mod_g723_1/Win32/Debug Passthrough/mod_g723_1.*.log +/src/mod/codecs/mod_g723_1/Win32/Release Passthrough/mod_g723_1.*.log +/src/mod/codecs/mod_g729/Win32/Debug Passthrough/mod_g729.*.log +/src/mod/codecs/mod_g729/Win32/Release Passthrough/mod_g729.*.log +/src/mod/directories/mod_ldap/Win32/Debug MS-LDAP/mod_ldap.*.log +/src/mod/directories/mod_ldap/Win32/Release MS-LDAP/mod_ldap.*.log +/src/mod/languages/mod_managed/Win32/Debug_CLR/mod_managed.*.log +/src/mod/languages/mod_managed/Win32/Release_CLR/mod_managed.*.log + +libs/libsndfile/Scripts/build-test-tarball.mk +libs/libsndfile/doc/libsndfile.css +libs/libsndfile/echo-install-dirs +libs/libsndfile/src/ALAC/.dirstamp +libs/libsndfile/src/G72x/.dirstamp +libs/libsndfile/src/GSM610/.dirstamp +libs/libsndfile/src/Symbols.gnu-binutils +libs/libsndfile/src/Symbols.static +libs/libsndfile/src/version-metadata.rc +libs/libsndfile/tests/pedantic-header-test.sh diff --git a/Freeswitch.2010.express.sln b/Freeswitch.2010.express.sln index 419e84e6c7..0b4eb265dd 100644 --- a/Freeswitch.2010.express.sln +++ b/Freeswitch.2010.express.sln @@ -11,8 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sndfile", "src\mod\form EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_PortAudio", "src\mod\endpoints\mod_portaudio\mod_PortAudio.2010.vcxproj", "{5FD31A25-5D83-4794-8BEE-904DAD84CE71}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_speex", "src\mod\codecs\mod_speex\mod_speex.2010.vcxproj", "{5580D60E-0F77-4716-9CD4-B8E5986FA375}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "docs\docs.2010.vcxproj", "{1A1FF289-4FD6-4285-A422-D31DD67A4723}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.2010.vcxproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" @@ -154,6 +152,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmlparse", "libs\win32\xmlrpc-c\xmlparse.2010.vcxproj", "{0D108721-EAE8-4BAF-8102-D8960EC93647}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmltok", "libs\win32\xmlrpc-c\xmltok.2010.vcxproj", "{B535402E-38D2-4D54-8360-423ACBD17192}" + ProjectSection(ProjectDependencies) = postProject + {CEE544A9-0303-44C2-8ECE-EFA7D7BCBBBA} = {CEE544A9-0303-44C2-8ECE-EFA7D7BCBBBA} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download sphinxbase", "libs\win32\Download sphinxbase.2010.vcxproj", "{4F92B672-DADB-4047-8D6A-4BB3796733FD}" EndProject @@ -413,17 +414,6 @@ Global {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|Win32.Build.0 = Release|Win32 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64.ActiveCfg = Release|x64 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|Win32.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.ActiveCfg = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.Build.0 = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.ActiveCfg = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.Build.0 = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.ActiveCfg = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.Build.0 = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.Build.0 = Release|x64 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|Win32.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|x64.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.Debug|Win32.ActiveCfg = Debug|Win32 diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln index 37ba5cfac0..7d9f9b71d4 100644 --- a/Freeswitch.2010.sln +++ b/Freeswitch.2010.sln @@ -88,6 +88,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa conf\vanilla\autoload_configs\spidermonkey.conf.xml = conf\vanilla\autoload_configs\spidermonkey.conf.xml conf\vanilla\autoload_configs\switch.conf.xml = conf\vanilla\autoload_configs\switch.conf.xml conf\vanilla\autoload_configs\syslog.conf.xml = conf\vanilla\autoload_configs\syslog.conf.xml + conf\vanilla\autoload_configs\v8.conf.xml = conf\vanilla\autoload_configs\v8.conf.xml conf\vanilla\autoload_configs\voicemail.conf.xml = conf\vanilla\autoload_configs\voicemail.conf.xml conf\vanilla\autoload_configs\wanpipe.conf.xml = conf\vanilla\autoload_configs\wanpipe.conf.xml conf\vanilla\autoload_configs\woomera.conf.xml = conf\vanilla\autoload_configs\woomera.conf.xml @@ -180,8 +181,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sndfile", "src\mod\form EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_PortAudio", "src\mod\endpoints\mod_portaudio\mod_PortAudio.2010.vcxproj", "{5FD31A25-5D83-4794-8BEE-904DAD84CE71}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_speex", "src\mod\codecs\mod_speex\mod_speex.2010.vcxproj", "{5580D60E-0F77-4716-9CD4-B8E5986FA375}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "docs\docs.2010.vcxproj", "{1A1FF289-4FD6-4285-A422-D31DD67A4723}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.2010.vcxproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" @@ -196,6 +195,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libteletone", "libs\libtele EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey", "src\mod\languages\mod_spidermonkey\mod_spidermonkey.2010.vcxproj", "{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_v8", "src\mod\languages\mod_v8\mod_v8.2010.vcxproj", "{9B9D2551-D6BD-4F20-8BE5-DE30E154A064}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_v8_skel", "src\mod\languages\mod_v8\mod_v8_skel.2010.vcxproj", "{8B754330-A434-4791-97E5-1EE67060BAC0}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_cepstral", "src\mod\asr_tts\mod_cepstral\mod_cepstral.2010.vcxproj", "{692F6330-4D87-4C82-81DF-40DB5892636E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_ilbc", "src\mod\codecs\mod_ilbc\mod_ilbc.2010.vcxproj", "{D3EC0AFF-76FC-4210-A825-9A17410660A3}" @@ -510,6 +513,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "w32\Setup\Setup.wi EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_pt", "src\mod\say\mod_say_pt\mod_say_pt.2010.vcxproj", "{7C22BDFF-CC09-400C-8A09-660733980028}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_sv", "src\mod\say\mod_say_sv\mod_say_sv.2010.vcxproj", "{8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2010.vcxproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_callcenter", "src\mod\applications\mod_callcenter\mod_callcenter.2010.vcxproj", "{47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}" @@ -572,6 +577,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcbt", "libs\win32\libcbt EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2010.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download V8", "libs\win32\Download V8.2010.vcxproj", "{13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libv8", "libs\win32\v8\libv8.2010.vcxproj", "{AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download OPUS", "libs\win32\Download OPUS.2010.vcxproj", "{092124C9-09ED-43C7-BD6D-4AE5D6B3C547}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "opus", "opus", "{ED2CA8B5-8E91-4296-A120-02BB0B674652}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "libs\win32\opus\opus.2010.vcxproj", "{FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.celt", "libs\win32\opus\opus.celt.2010.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_common", "libs\win32\opus\opus.silk_common.2010.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_fixed", "libs\win32\opus\opus.silk_fixed.2010.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_float", "libs\win32\opus\opus.silk_float.2010.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_opus", "src\mod\codecs\mod_opus\mod_opus.2010.vcxproj", "{64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_t43_gray_code_tables", "libs\spandsp\src\msvc\make_t43_gray_code_tables.2010.vcxproj", "{EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}" EndProject Global @@ -680,24 +705,6 @@ Global {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64.Build.0 = Release|x64 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64 Setup.ActiveCfg = Release|x64 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x86 Setup.ActiveCfg = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|Win32.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64 Setup.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x86 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.ActiveCfg = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.Build.0 = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.ActiveCfg = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.Build.0 = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64 Setup.ActiveCfg = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x86 Setup.ActiveCfg = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.ActiveCfg = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.Build.0 = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x86 Setup.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|Win32.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|x64.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|x64 Setup.ActiveCfg = Release|Win32 @@ -818,6 +825,38 @@ Global {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.Build.0 = Release|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64 Setup.ActiveCfg = Release|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x86 Setup.ActiveCfg = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|Win32.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64 Setup.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x86 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|Win32.ActiveCfg = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|Win32.Build.0 = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64.ActiveCfg = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64.Build.0 = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|Win32.ActiveCfg = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|Win32.Build.0 = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|Win32.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64.Build.0 = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64 Setup.Build.0 = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x86 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|Win32.ActiveCfg = Debug|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x64.ActiveCfg = Debug|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|Win32.ActiveCfg = Release|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x64.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x64 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x86 Setup.ActiveCfg = Release|Win32 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|Win32.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.Build.0 = Release|x64 @@ -3463,6 +3502,24 @@ Global {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.Build.0 = Release|x64 {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64 Setup.ActiveCfg = Release|x64 {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|Win32.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|Win32.Build.0 = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64.ActiveCfg = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64.Build.0 = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x86 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|Win32.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|Win32.Build.0 = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64.ActiveCfg = Debug|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64.Build.0 = Debug|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|Win32.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|Win32.Build.0 = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64.ActiveCfg = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64.Build.0 = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x86 Setup.ActiveCfg = Release|Win32 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.Build.0 = Release|x64 @@ -3812,6 +3869,166 @@ Global {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.Build.0 = All|Win32 {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64 Setup.ActiveCfg = All|Win32 {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x86 Setup.ActiveCfg = All|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|Win32.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|Win32.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x64.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x64 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x86 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|Win32.Build.0 = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64.Build.0 = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|Win32.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|Win32.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x86 Setup.ActiveCfg = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|Win32.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64 Setup.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x86 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|Win32.ActiveCfg = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|Win32.Build.0 = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|Win32.ActiveCfg = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|Win32.Build.0 = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64.ActiveCfg = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64.Build.0 = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64 Setup.ActiveCfg = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x86 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|Win32.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|Win32.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x64.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x64 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x86 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|Win32.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|Win32.Build.0 = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64.Build.0 = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|Win32.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|Win32.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x86 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|Win32.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|Win32.Build.0 = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64.ActiveCfg = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64.Build.0 = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x86 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|Win32.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|Win32.Build.0 = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64.ActiveCfg = Debug|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64.Build.0 = Debug|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|Win32.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|Win32.Build.0 = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64.ActiveCfg = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64.Build.0 = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x86 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|Win32.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|Win32.Build.0 = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64.ActiveCfg = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64.Build.0 = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x86 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.Build.0 = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64.ActiveCfg = Debug|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64.Build.0 = Debug|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.Build.0 = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64.ActiveCfg = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64.Build.0 = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x86 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|Win32.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|Win32.Build.0 = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64.ActiveCfg = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64.Build.0 = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x86 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.Build.0 = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64.ActiveCfg = Debug|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64.Build.0 = Debug|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.Build.0 = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64.ActiveCfg = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64.Build.0 = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|Win32.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|Win32.Build.0 = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64.ActiveCfg = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64.Build.0 = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x86 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.Build.0 = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64.ActiveCfg = Debug|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64.Build.0 = Debug|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|Win32.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|Win32.Build.0 = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64.ActiveCfg = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64.Build.0 = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x86 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|Win32.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|Win32.Build.0 = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64.ActiveCfg = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64.Build.0 = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x86 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|Win32.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|Win32.Build.0 = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64.ActiveCfg = Debug|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64.Build.0 = Debug|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.Build.0 = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64.ActiveCfg = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64.Build.0 = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x86 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|Win32.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|Win32.Build.0 = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64.ActiveCfg = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64.Build.0 = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x86 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|Win32.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|Win32.Build.0 = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64.ActiveCfg = Debug|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64.Build.0 = Debug|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|Win32.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|Win32.Build.0 = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64.ActiveCfg = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64.Build.0 = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x86 Setup.ActiveCfg = Release|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|Win32.ActiveCfg = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|Win32.Build.0 = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|x64.ActiveCfg = All|Win32 @@ -3835,7 +4052,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} - {5580D60E-0F77-4716-9CD4-B8E5986FA375} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {D3EC0AFF-76FC-4210-A825-9A17410660A3} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {FEA1EEF7-876F-48DE-88BF-C0E3E606D758} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} @@ -3845,6 +4061,7 @@ Global {D5C87B19-150D-4EF3-A671-96589BD2D14A} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {4D418176-3B33-47E6-A63E-01BA34ADD21C} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {AFA983D6-4569-4F88-BA94-555ED00FD9A8} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {5FD31A25-5D83-4794-8BEE-904DAD84CE71} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {0DF3ABD0-DDC0-4265-B778-07C66780979B} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} @@ -3946,9 +4163,13 @@ Global {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {ED2CA8B5-8E91-4296-A120-02BB0B674652} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC} {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000} + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064} = {0C808854-54D1-4230-BFF5-77B5FD905000} + {8B754330-A434-4791-97E5-1EE67060BAC0} = {0C808854-54D1-4230-BFF5-77B5FD905000} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} {8F992C49-6C51-412F-B2A3-34EAB708EB65} = {0C808854-54D1-4230-BFF5-77B5FD905000} {0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF} = {0C808854-54D1-4230-BFF5-77B5FD905000} @@ -3986,6 +4207,8 @@ Global {B808178B-82F0-4CF4-A2B1-921939FA24D0} = {C120A020-773F-4EA3-923F-B67AF28B750D} {D578E676-7EC8-4548-BD8B-845C635F14AD} = {C120A020-773F-4EA3-923F-B67AF28B750D} {652AD5F7-8488-489F-AAD0-7FBE064703B6} = {C120A020-773F-4EA3-923F-B67AF28B750D} + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} = {C120A020-773F-4EA3-923F-B67AF28B750D} + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547} = {C120A020-773F-4EA3-923F-B67AF28B750D} {988CACF7-3FCB-4992-BE69-77872AE67DC8} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {5BC072DB-3826-48EA-AF34-FE32AA01E83B} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {FA429E98-8B03-45E6-A096-A4BC5E821DE4} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} @@ -3995,6 +4218,7 @@ Global {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {0382E8FD-CFDC-41C0-8B03-792C7C84FC31} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {7C22BDFF-CC09-400C-8A09-660733980028} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} = {57D119DC-484F-420F-B9E9-8589FD9A8DF8} {3C90CCF0-2CDD-4A7A-ACFF-208C1E271692} = {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} {C7E2382E-2C22-4D18-BF93-80C6A1FFA7AC} = {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} @@ -4034,5 +4258,10 @@ Global {0D108721-EAE8-4BAF-8102-D8960EC93647} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} {CEE544A9-0303-44C2-8ECE-EFA7D7BCBBBA} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} {B535402E-38D2-4D54-8360-423ACBD17192} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {245603E3-F580-41A5-9632-B25FE3372CBF} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {8484C90D-1561-402F-A91D-2DB10F8C5171} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} EndGlobalSection EndGlobal diff --git a/Freeswitch.2012.sln b/Freeswitch.2012.sln index be88964420..7223a3dc9d 100644 --- a/Freeswitch.2012.sln +++ b/Freeswitch.2012.sln @@ -87,6 +87,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa conf\vanilla\autoload_configs\spidermonkey.conf.xml = conf\vanilla\autoload_configs\spidermonkey.conf.xml conf\vanilla\autoload_configs\switch.conf.xml = conf\vanilla\autoload_configs\switch.conf.xml conf\vanilla\autoload_configs\syslog.conf.xml = conf\vanilla\autoload_configs\syslog.conf.xml + conf\vanilla\autoload_configs\v8.conf.xml = conf\vanilla\autoload_configs\v8.conf.xml conf\vanilla\autoload_configs\voicemail.conf.xml = conf\vanilla\autoload_configs\voicemail.conf.xml conf\vanilla\autoload_configs\wanpipe.conf.xml = conf\vanilla\autoload_configs\wanpipe.conf.xml conf\vanilla\autoload_configs\woomera.conf.xml = conf\vanilla\autoload_configs\woomera.conf.xml @@ -179,8 +180,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sndfile", "src\mod\form EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_PortAudio", "src\mod\endpoints\mod_portaudio\mod_PortAudio.2012.vcxproj", "{5FD31A25-5D83-4794-8BEE-904DAD84CE71}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_speex", "src\mod\codecs\mod_speex\mod_speex.2012.vcxproj", "{5580D60E-0F77-4716-9CD4-B8E5986FA375}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "docs\docs.2012.vcxproj", "{1A1FF289-4FD6-4285-A422-D31DD67A4723}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.2012.vcxproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" @@ -195,6 +194,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libteletone", "libs\libtele EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey", "src\mod\languages\mod_spidermonkey\mod_spidermonkey.2012.vcxproj", "{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_v8", "src\mod\languages\mod_v8\mod_v8.2012.vcxproj", "{9B9D2551-D6BD-4F20-8BE5-DE30E154A064}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_v8_skel", "src\mod\languages\mod_v8\mod_v8_skel.2012.vcxproj", "{8B754330-A434-4791-97E5-1EE67060BAC0}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_cepstral", "src\mod\asr_tts\mod_cepstral\mod_cepstral.2012.vcxproj", "{692F6330-4D87-4C82-81DF-40DB5892636E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_ilbc", "src\mod\codecs\mod_ilbc\mod_ilbc.2012.vcxproj", "{D3EC0AFF-76FC-4210-A825-9A17410660A3}" @@ -513,6 +516,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_distributor", "src\mod\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_pt", "src\mod\say\mod_say_pt\mod_say_pt.2012.vcxproj", "{7C22BDFF-CC09-400C-8A09-660733980028}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_sv", "src\mod\say\mod_say_sv\mod_say_sv.2012.vcxproj", "{8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2012.vcxproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_callcenter", "src\mod\applications\mod_callcenter\mod_callcenter.2012.vcxproj", "{47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}" @@ -577,8 +582,30 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcbt", "libs\win32\libcbt EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2012.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download V8", "libs\win32\Download V8.2012.vcxproj", "{13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libv8", "libs\win32\v8\libv8.2012.vcxproj", "{AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download OPUS", "libs\win32\Download OPUS.2012.vcxproj", "{092124C9-09ED-43C7-BD6D-4AE5D6B3C547}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "opus", "opus", "{ED2CA8B5-8E91-4296-A120-02BB0B674652}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "libs\win32\opus\opus.2012.vcxproj", "{FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.celt", "libs\win32\opus\opus.celt.2012.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_common", "libs\win32\opus\opus.silk_common.2012.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_fixed", "libs\win32\opus\opus.silk_fixed.2012.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus.silk_float", "libs\win32\opus\opus.silk_float.2012.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_opus", "src\mod\codecs\mod_opus\mod_opus.2012.vcxproj", "{64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_t43_gray_code_tables", "libs\spandsp\src\msvc\make_t43_gray_code_tables.2012.vcxproj", "{EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "winFailToBan", "src\mod\languages\mod_managed\managed\examples\winFailToBan\winFailToBan.csproj", "{5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -685,24 +712,6 @@ Global {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64.Build.0 = Release|x64 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x64 Setup.ActiveCfg = Release|x64 {5FD31A25-5D83-4794-8BEE-904DAD84CE71}.Release|x86 Setup.ActiveCfg = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|Win32.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x64 Setup.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.All|x86 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.ActiveCfg = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|Win32.Build.0 = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.ActiveCfg = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64.Build.0 = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x64 Setup.ActiveCfg = Debug|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Debug|x86 Setup.ActiveCfg = Debug|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.ActiveCfg = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|Win32.Build.0 = Release|Win32 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64.Build.0 = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x64 Setup.ActiveCfg = Release|x64 - {5580D60E-0F77-4716-9CD4-B8E5986FA375}.Release|x86 Setup.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|Win32.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|x64.ActiveCfg = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.All|x64 Setup.ActiveCfg = Release|Win32 @@ -823,6 +832,38 @@ Global {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.Build.0 = Release|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64 Setup.ActiveCfg = Release|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x86 Setup.ActiveCfg = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|Win32.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x64 Setup.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.All|x86 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|Win32.ActiveCfg = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|Win32.Build.0 = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64.ActiveCfg = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64.Build.0 = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|Win32.ActiveCfg = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|Win32.Build.0 = Release|Win32 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64.Build.0 = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x64 Setup.ActiveCfg = Release|x64 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|Win32.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64.Build.0 = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x64 Setup.Build.0 = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.All|x86 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|Win32.ActiveCfg = Debug|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x64.ActiveCfg = Debug|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|Win32.ActiveCfg = Release|Win32 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x64.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x64 Setup.ActiveCfg = Release|x64 + {8B754330-A434-4791-97E5-1EE67060BAC0}.Release|x86 Setup.ActiveCfg = Release|Win32 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|Win32.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.Build.0 = Release|x64 @@ -3451,6 +3492,24 @@ Global {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.Build.0 = Release|x64 {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64 Setup.ActiveCfg = Release|x64 {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|Win32.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|Win32.Build.0 = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64.ActiveCfg = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64.Build.0 = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x64 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.All|x86 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|Win32.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|Win32.Build.0 = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64.ActiveCfg = Debug|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64.Build.0 = Debug|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|Win32.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|Win32.Build.0 = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64.ActiveCfg = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64.Build.0 = Release|x64 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x64 Setup.ActiveCfg = Release|Win32 + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15}.Release|x86 Setup.ActiveCfg = Release|Win32 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.Build.0 = Release|x64 @@ -3822,6 +3881,166 @@ Global {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.Build.0 = All|Win32 {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64 Setup.ActiveCfg = All|Win32 {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x86 Setup.ActiveCfg = All|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|Win32.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|Win32.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x64.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x64 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.All|x86 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|Win32.Build.0 = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64.Build.0 = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|Win32.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|Win32.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64.Build.0 = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x64 Setup.ActiveCfg = Release|Win32 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}.Release|x86 Setup.ActiveCfg = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|Win32.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x64 Setup.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.All|x86 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|Win32.ActiveCfg = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|Win32.Build.0 = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64.Build.0 = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|Win32.ActiveCfg = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|Win32.Build.0 = Release|Win32 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64.ActiveCfg = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64.Build.0 = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x64 Setup.ActiveCfg = Release|x64 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}.Release|x86 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|Win32.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|Win32.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x64.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x64 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.All|x86 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|Win32.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|Win32.Build.0 = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64.Build.0 = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|Win32.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|Win32.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64.Build.0 = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x64 Setup.ActiveCfg = Release|Win32 + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547}.Release|x86 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|Win32.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|Win32.Build.0 = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64.ActiveCfg = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64.Build.0 = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x64 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.All|x86 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|Win32.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|Win32.Build.0 = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64.ActiveCfg = Debug|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64.Build.0 = Debug|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|Win32.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|Win32.Build.0 = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64.ActiveCfg = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64.Build.0 = Release|x64 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x64 Setup.ActiveCfg = Release|Win32 + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E}.Release|x86 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|Win32.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|Win32.Build.0 = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64.ActiveCfg = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64.Build.0 = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x64 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.All|x86 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.Build.0 = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64.ActiveCfg = Debug|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64.Build.0 = Debug|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.Build.0 = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64.ActiveCfg = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64.Build.0 = Release|x64 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x64 Setup.ActiveCfg = Release|Win32 + {245603E3-F580-41A5-9632-B25FE3372CBF}.Release|x86 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|Win32.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|Win32.Build.0 = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64.ActiveCfg = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64.Build.0 = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x64 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.All|x86 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.Build.0 = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64.ActiveCfg = Debug|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64.Build.0 = Debug|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.Build.0 = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64.ActiveCfg = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64.Build.0 = Release|x64 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x64 Setup.ActiveCfg = Release|Win32 + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|x86 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|Win32.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|Win32.Build.0 = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64.ActiveCfg = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64.Build.0 = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x64 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.All|x86 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.Build.0 = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64.ActiveCfg = Debug|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64.Build.0 = Debug|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|Win32.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|Win32.Build.0 = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64.ActiveCfg = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64.Build.0 = Release|x64 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x64 Setup.ActiveCfg = Release|Win32 + {8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|x86 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|Win32.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|Win32.Build.0 = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64.ActiveCfg = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64.Build.0 = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x64 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.All|x86 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|Win32.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|Win32.Build.0 = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64.ActiveCfg = Debug|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64.Build.0 = Debug|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.Build.0 = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64.ActiveCfg = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64.Build.0 = Release|x64 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x64 Setup.ActiveCfg = Release|Win32 + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|x86 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|Win32.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|Win32.Build.0 = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64.ActiveCfg = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64.Build.0 = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x64 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.All|x86 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|Win32.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|Win32.Build.0 = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64.ActiveCfg = Debug|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64.Build.0 = Debug|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|Win32.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|Win32.Build.0 = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64.ActiveCfg = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64.Build.0 = Release|x64 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x64 Setup.ActiveCfg = Release|Win32 + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB}.Release|x86 Setup.ActiveCfg = Release|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|Win32.ActiveCfg = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|Win32.Build.0 = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.All|x64.ActiveCfg = All|Win32 @@ -3839,13 +4058,24 @@ Global {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.Release|x64.Build.0 = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.Release|x64 Setup.ActiveCfg = All|Win32 {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5}.Release|x86 Setup.ActiveCfg = All|Win32 + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.All|Win32.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.All|x64.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.All|x64 Setup.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.All|x86 Setup.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Debug|Win32.ActiveCfg = Debug|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Debug|x64.ActiveCfg = Debug|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Debug|x64 Setup.ActiveCfg = Debug|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Debug|x86 Setup.ActiveCfg = Debug|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Release|Win32.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Release|x64.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Release|x64 Setup.ActiveCfg = Release|Any CPU + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0}.Release|x86 Setup.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} - {5580D60E-0F77-4716-9CD4-B8E5986FA375} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {D3EC0AFF-76FC-4210-A825-9A17410660A3} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {FEA1EEF7-876F-48DE-88BF-C0E3E606D758} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} @@ -3855,6 +4085,7 @@ Global {D5C87B19-150D-4EF3-A671-96589BD2D14A} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {4D418176-3B33-47E6-A63E-01BA34ADD21C} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {AFA983D6-4569-4F88-BA94-555ED00FD9A8} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {5FD31A25-5D83-4794-8BEE-904DAD84CE71} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {0DF3ABD0-DDC0-4265-B778-07C66780979B} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} @@ -3956,9 +4187,13 @@ Global {2386B892-35F5-46CF-A0F0-10394D2FBF9B} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {ED2CA8B5-8E91-4296-A120-02BB0B674652} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EDDB8AB9-C53E-44C0-A620-0E86C2CBD5D5} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC} {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000} + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064} = {0C808854-54D1-4230-BFF5-77B5FD905000} + {8B754330-A434-4791-97E5-1EE67060BAC0} = {0C808854-54D1-4230-BFF5-77B5FD905000} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} {8F992C49-6C51-412F-B2A3-34EAB708EB65} = {0C808854-54D1-4230-BFF5-77B5FD905000} {0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF} = {0C808854-54D1-4230-BFF5-77B5FD905000} @@ -3967,6 +4202,7 @@ Global {7B077E7F-1BE7-4291-AB86-55E527B25CAC} = {0C808854-54D1-4230-BFF5-77B5FD905000} {7B42BDA1-72C0-4378-A9B6-5C530F8CD61E} = {0C808854-54D1-4230-BFF5-77B5FD905000} {834E2B2F-5483-4B80-8FE3-FE48FF76E5C0} = {0C808854-54D1-4230-BFF5-77B5FD905000} + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0} = {0C808854-54D1-4230-BFF5-77B5FD905000} {692F6330-4D87-4C82-81DF-40DB5892636E} = {4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0} {2286DA73-9FC5-45BC-A508-85994C3317AB} = {4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0} {66444AEE-554C-11DD-A9F0-8C5D56D89593} = {4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0} @@ -3996,6 +4232,8 @@ Global {B808178B-82F0-4CF4-A2B1-921939FA24D0} = {C120A020-773F-4EA3-923F-B67AF28B750D} {D578E676-7EC8-4548-BD8B-845C635F14AD} = {C120A020-773F-4EA3-923F-B67AF28B750D} {652AD5F7-8488-489F-AAD0-7FBE064703B6} = {C120A020-773F-4EA3-923F-B67AF28B750D} + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} = {C120A020-773F-4EA3-923F-B67AF28B750D} + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547} = {C120A020-773F-4EA3-923F-B67AF28B750D} {988CACF7-3FCB-4992-BE69-77872AE67DC8} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {5BC072DB-3826-48EA-AF34-FE32AA01E83B} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {FA429E98-8B03-45E6-A096-A4BC5E821DE4} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} @@ -4005,6 +4243,7 @@ Global {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {0382E8FD-CFDC-41C0-8B03-792C7C84FC31} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {7C22BDFF-CC09-400C-8A09-660733980028} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} + {8CDA2B34-FA44-49CC-9EC2-B8F35856CD15} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} = {57D119DC-484F-420F-B9E9-8589FD9A8DF8} {3C90CCF0-2CDD-4A7A-ACFF-208C1E271692} = {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} {C7E2382E-2C22-4D18-BF93-80C6A1FFA7AC} = {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} @@ -4044,5 +4283,10 @@ Global {0D108721-EAE8-4BAF-8102-D8960EC93647} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} {CEE544A9-0303-44C2-8ECE-EFA7D7BCBBBA} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} {B535402E-38D2-4D54-8360-423ACBD17192} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {245603E3-F580-41A5-9632-B25FE3372CBF} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {8484C90D-1561-402F-A91D-2DB10F8C5171} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} = {ED2CA8B5-8E91-4296-A120-02BB0B674652} EndGlobalSection EndGlobal diff --git a/Freeswitch.2012.sln.bat b/Freeswitch.2012.sln.bat new file mode 100644 index 0000000000..342dbadb1c --- /dev/null +++ b/Freeswitch.2012.sln.bat @@ -0,0 +1,88 @@ +@REM this script builds freeswitch using VS2012 +@REM only one platform/configuration will be built +@REM runs (probably only) from the commandline +@REM usage: Freeswitch.2012.sln [[[.*]ebug] [[.*]elease] [[.*]64] [[.*]32]] +@REM e.g. Freeswitch.2012.sln Debug x64 +@REM Freeswitch.2012.sln x64 +@REM Freeswitch.2012.sln Debug +@REM Freeswitch.2012.sln + +@setlocal +@echo on + +@REM default build +@REM change these variables if you want to build differently by default +@set configuration=Release +@set platform=Win32 + + +@REM if commandline parameters contain "ebug" and/or "64 and/or 32" +@REM set the configuration/platform to Debug and/or x64 and/or 32 +@if "%1"=="" ( + @goto :paramsset +) + +@set params=%* +@set xparams=x%params: =% +@if not y%xparams:ebug=%==y%xparams% ( + set configuration=Debug +) + +@if not x%xparams:64=%==x%xparams% ( + set platform=x64 +) + +@if not x%xparams:32=%==x%xparams% ( + set platform=Win32 +) + +@if not y%xparams:elease=%==y%xparams% ( + set configuration=Debug +) + +:paramsset + +@REM use all processors minus 1 when building +@REM hmm, this doesn't seem to work as I expected as all my procs are used during the build +@set procs=%NUMBER_OF_PROCESSORS% +@set /a procs -= 1 + +@REM check and set VS2012 environment +@REM vcvars32.bat calls exit and will also exit whilie running this bat file ... +@REM so you have to run it again if the VS2012 env is not yet set +@if "%VS110COMNTOOLS%"=="" ( + goto :error_no_VS110COMNTOOLSDIR +) + +@if "%VSINSTALLDIR%"=="" ( + goto :setvcvars +) + +:build + +msbuild Freeswitch.2012.sln /m:%procs% /verbosity:normal /property:Configuration=%configuration% /property:Platform=%platform% /fl /flp:logfile=vs2012%platform%%configuration%.log;verbosity=normal +@goto :end + +@REM ----------------------------------------------------------------------- +:setvcvars + @endlocal + @echo Now setting Visual Studio 2012 Environment + @call "%VS110COMNTOOLS%vsvars32" + @REM in order to prevent running vsvars32 multiple times and at the same time not + @REM cluttering up the environment variables proc/configuration/platform + @REM it is necessary to start the script again + @echo Run the script %0 again (and/or open a command prompt) + @goto :end + +:error_no_VS110COMNTOOLSDIR + @echo ERROR: Cannot determine the location of the VS2012 Common Tools folder. + @echo ERROR: Note this script will not work in a git bash environment + @goto :end + +:end +@pause + +@REM ------ terminate :end with LF otherwise the label is not recognized by the command processor ----- + + + diff --git a/Makefile.am b/Makefile.am index 21b83bad2f..ff89b8b79d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,9 +3,17 @@ SUBDIRS = . src AUTOMAKE_OPTIONS = foreign NAME = freeswitch +AM_LIBAPR_CFLAGS := $(shell ./libs/apr/apr-1-config --cflags) +AM_LIBAPR_CPPFLAGS := $(shell ./libs/apr/apr-1-config --cppflags --includes) +AM_LIBAPR_LDFLAGS := $(shell ./libs/apr/apr-1-config --ldflags) +AM_LIBAPR_LIBS := $(subst $(switch_srcdir)/,,$(shell ./libs/apr/apr-1-config \--libs)) +AM_LIBAPU_CPPFLAGS := $(shell ./libs/apr-util/apu-1-config --includes) +AM_LIBAPU_LDFLAGS := $(shell ./libs/apr-util/apu-1-config --ldflags) +AM_LIBAPU_LIBS := $(subst $(switch_srcdir)/,,$(shell ./libs/apr-util/apu-1-config \--libs)) + AM_CFLAGS = $(SWITCH_AM_CFLAGS) $(SWITCH_ANSI_CFLAGS) AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS) -Ilibs/sofia-sip/libsofia-sip-ua/sdp -Ilibs/sofia-sip/libsofia-sip-ua/su -AM_LDFLAGS = $(SWITCH_AM_LDFLAGS) +AM_LDFLAGS = $(SWITCH_AM_LDFLAGS) $(AM_LIBAPR_LDFLAGS) $(AM_LIBAPU_LDFLAGS) DEFAULT_SOUNDS=en-us-callie-8000 @@ -101,8 +109,8 @@ $(RECURSIVE_TARGETS): freeswitch exit 1; \ fi ; -CORE_CFLAGS = `$(switch_builddir)/libs/apr/apr-1-config --cflags --cppflags --includes` -CORE_CFLAGS += `$(switch_builddir)/libs/apr-util/apu-1-config --includes` +CORE_CFLAGS = $(AM_LIBAPR_CFLAGS) $(AM_LIBAPR_CPPFLAGS) +CORE_CFLAGS += $(AM_LIBAPU_CPPFLAGS) CORE_CFLAGS += -I$(switch_srcdir)/libs/libtpl-1.5/src CORE_CFLAGS += -I$(switch_srcdir)/libs/stfu CORE_CFLAGS += -I$(switch_builddir)/libs/sqlite @@ -112,8 +120,9 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include -Ilibs/srtp/crypto/include CORE_CFLAGS += -I$(switch_srcdir)/libs/spandsp/src -I$(switch_srcdir)/libs/tiff-4.0.2/libtiff +APR_LIBS = $(AM_LIBAPU_LIBS) $(AM_LIBAPR_LIBS) CORE_LIBS = libs/apr-util/libaprutil-1.la libs/apr/libapr-1.la -CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la +CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la libs/speex/libspeex/libspeex.la if ENABLE_SRTP CORE_CFLAGS += -DENABLE_SRTP @@ -147,7 +156,7 @@ endif lib_LTLIBRARIES = libfreeswitch.la libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS) libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -libfreeswitch_la_LIBADD = $(CORE_LIBS) $(PLATFORM_CORE_LIBS) +libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(PLATFORM_CORE_LIBS) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) if HAVE_ODBC @@ -202,6 +211,7 @@ library_include_HEADERS = \ src/include/switch_xml.h \ src/include/switch_xml_config.h \ src/include/switch_cpp.h \ + src/include/switch_curl.h \ src/include/switch_json.h \ libs/stfu/stfu.h \ libs/libteletone/src/libteletone_detect.h \ @@ -242,6 +252,7 @@ libfreeswitch_la_SOURCES = \ src/switch_core_rwlock.c \ src/switch_core_port_allocator.c \ src/switch_core.c \ + src/switch_version.c \ src/switch_core_media.c \ src/switch_sdp.c \ src/switch_scheduler.c \ @@ -272,6 +283,7 @@ libfreeswitch_la_SOURCES = \ src/switch_limit.c \ src/g711.c \ src/switch_pcm.c \ + src/switch_speex.c \ src/switch_profile.c \ src/switch_json.c \ src/switch_curl.c \ @@ -298,8 +310,6 @@ if ENABLE_CPP libfreeswitch_la_SOURCES += src/switch_cpp.cpp endif -$(top_builddir)/libfreeswitch_la-switch_console.lo: src/include/switch_version.h - $(libfreeswitch_la_SOURCES): $(CORE_LIBS) $(switch_builddir)/quiet_libtool $(switch_builddir)/modules.conf src/include/switch_swigable_cpp.h: $(switch_srcdir)/src/include/switch_cpp.h @@ -334,7 +344,7 @@ endif fs_encode_SOURCES = src/fs_encode.c fs_encode_CFLAGS = $(AM_CFLAGS) fs_encode_LDFLAGS = $(AM_LDFLAGS) -fs_encode_LDADD = libfreeswitch.la $(CORE_LIBS) +fs_encode_LDADD = libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) if HAVE_ODBC fs_encode_LDADD += $(ODBC_LIB_FLAGS) @@ -347,7 +357,7 @@ endif tone2wav_SOURCES = src/tone2wav.c tone2wav_CFLAGS = $(AM_CFLAGS) tone2wav_LDFLAGS = $(AM_LDFLAGS) -tone2wav_LDADD = libfreeswitch.la $(CORE_LIBS) +tone2wav_LDADD = libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) if HAVE_ODBC tone2wav_LDADD += $(ODBC_LIB_FLAGS) @@ -429,6 +439,8 @@ $(switch_builddir)/quiet_libtool: $(switch_builddir)/libtool build/print_git_revision: build/print_git_revision.c $(CC) -o $@ $< +src/switch_version.lo: src/include/switch_version.h + src/include/switch_version.h: src/include/switch_version.h.in Makefile build/print_git_revision $(libfreeswitch_la_SOURCES) $(library_include_HEADERS) @cat $< > $@; \ if [ -d .git ] && [ -n "$$(which git)" ]; then \ @@ -469,18 +481,17 @@ libs/apr/Makefile: libs/apr/Makefile.in libs/apr/config.status libs/apr libs/apr @$(TOUCH_TARGET) libs/apr/libapr-1.la: libs/apr/Makefile libs/apr/.update - touch src/include/switch.h - @cd libs/apr && $(MAKE) - @$(TOUCH_TARGET) + @if [ $(MAKELEVEL) = 0 -o -z "`echo "$(MAKEARGS)" | grep "j"`" ] ; then touch src/include/switch.h; cd libs/apr && $(MAKE) $(MFLAGS) && touch libapr-1.la; fi -libs/apr-util/libaprutil-1.la: libs/apr-util libs/apr-util/.update libs/apr/libapr-1.la - touch src/include/switch.h - @cd libs/apr-util && $(MAKE) - @$(TOUCH_TARGET) +libs/apr-util/libaprutil-1.la: libs/apr/libapr-1.la libs/apr-util libs/apr-util/.update + @if [ $(MAKELEVEL) = 0 -o -z "`echo "$(MAKEARGS)" | grep "j"`" ] ; then touch src/include/switch.h; cd libs/apr-util && $(MAKE) $(MFLAGS) && touch libaprutil-1.la; fi + +libs/speex/libspeex/libspeex.la: + @echo libs/speex/libspeex/libspeexdsp.la: libs/speex/.update touch src/include/switch.h - @cd libs/speex && $(MAKE) + @if [ $(MAKELEVEL) = 0 -o -z "`echo "$(MAKEARGS)" | grep "j"`" ] ; then cd libs/speex && $(MAKE) $(MFLAGS); fi @$(TOUCH_TARGET) libs/sqlite/libsqlite3.la: libs/sqlite libs/sqlite/Makefile libs/sqlite/.update @@ -595,7 +606,7 @@ nodepends: .nodepends yesdepends: rm .nodepends -core: $(switch_builddir)/modules.conf $(CORE_LIBS) +core: $(switch_builddir)/modules.conf src/include/switch_version.h $(CORE_LIBS) $(MAKE) $(AM_MAKEFLAGS) libfreeswitch.la distclean: clean @@ -641,13 +652,14 @@ pristine: git clean -fdx git reset --hard -update-clean: clean libs/openzap/Makefile python-reconf +update-clean: clean libs/openzap/Makefile python-reconf lua-reconf spandsp-reconf srtp-reconf cd libs/sofia-sip && $(MAKE) clean cd libs/openzap && $(MAKE) clean cd libs/portaudio && $(MAKE) clean cd libs/speex && $(MAKE) clean cd libs/esl && $(MAKE) clean cd libs/sqlite && $(MAKE) clean + cd libs/srtp && $(MAKE) clean swigall: @echo reswigging all @@ -677,6 +689,10 @@ pa-reconf: cd libs/portaudio && sh ./configure.gnu $(MAKE) mod_portaudio-clean +srtp-reconf: + cd libs/srtp && $(MAKE) clean + cd libs/srtp && sh ./configure.gnu + oz-reconf: cd libs/openzap && $(MAKE) clean cd libs/openzap && autoreconf -fi @@ -700,6 +716,10 @@ sofia-reconf: cd libs/sofia-sip && $(MAKE) clean cd libs/sofia-sip && ./configure --prefix=$(prefix) --with-pic --with-glib=no --disable-shared +lua-reconf: + cd src/mod/languages/mod_lua/lua && make clean + cd src/mod/languages/mod_lua && make clean + cluecon: @clear @echo Thank you for updating. This is going to take a while so relax. @@ -761,6 +781,7 @@ eclean: clean rm -f *.tar *.tgz *.gz megaclean: eclean modclean + rm -f `find ./libs -name \*.o` rm -f `find ./libs -name \*.la` libclean: diff --git a/build/Makefile.am b/build/Makefile.am index 3feb22157d..024c78984f 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -70,7 +70,7 @@ install: @echo " + +" @echo " +-------------------------------------------------+" @cat ../cluecon2.tmpl - + @sh modcheck.sh $(modulesdir) .PHONY: check dvi html info install-data \ install-dvi install-exec install-html install-info install-pdf install-ps installcheck installdirs pdf \ diff --git a/build/build_patch.sh b/build/build_patch.sh new file mode 100755 index 0000000000..fc91b00e2f --- /dev/null +++ b/build/build_patch.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e -o pipefail + +usage () { + printf "usage: %s [-u ] [-r ] [ ...]\n" "$0" >&2 +} + +err () { + printf "error: %s\n" "$1" >&2 + exit 1 +} + +remote=origin +ref=origin/master +dopull=true +while getopts "hnr:u:" o; do + case "$o" in + h) usage; exit 0 ;; + n) dopull=false ;; + r) ref="$OPTARG" ;; + u) remote="$OPTARG" ;; + esac +done +shift $(($OPTIND-1)) + +if ! which git >/dev/null; then + printf "error: please install git\n">&2 + exit 1; fi +if ! which wget >/dev/null; then + printf "error: please install wget\n">&2 + exit 1; fi + +now=$(date -u +%Y%m%dT%H%M%SZ) +git clean -fdx || err "failed" +git reset --hard "$ref" \ + || err "reset failed" +$dopull && (git pull "$remote" || err "failed to pull") +for patch in "$@"; do + wget -O - "$patch" | git am +done +printf '# Building FreeSWITCH %s\n' "$(git describe HEAD)" \ + > ${now}-fsbuild.log +(./bootstrap.sh && ./configure -C && make VERBOSE=1) 2>&1 \ + | tee -a ${now}-fsbuild.log diff --git a/build/ignore_helper.pl b/build/ignore_helper.pl index 154afc7d4c..9cb02f7ec4 100644 --- a/build/ignore_helper.pl +++ b/build/ignore_helper.pl @@ -1,6 +1,6 @@ ################################################################################ # ignore_helper.pl -# Copyright (c) 2007-2012 Anthony Minessale II +# Copyright (c) 2007-2014 Anthony Minessale II # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation diff --git a/build/modcheck.sh b/build/modcheck.sh new file mode 100644 index 0000000000..85c2b169e1 --- /dev/null +++ b/build/modcheck.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +PATH=$PATH:/bin:/usr/bin +mods=$1 + +if [ -z $mods ] ; then + mods="/usr/local/freeswitch/mod" +fi + + +echo "Checking module integrity in target [$mods]" +echo + + +here=`pwd` + +cd $mods +files=`ls *.dylib *.so 2>/dev/null` +cd $here + +alert() { + on='' + off='' + echo -n $on + echo WARNING: $1 + echo -n $off +} + +for i in $files ; do + mod=${i%%.*} + + infile=`grep ^.*$mod\$ ../modules.conf` + commented=`grep ^\#.*$mod\$ ../modules.conf` + + if [ -z "$infile" ] ; then + alert "installed module: $i was not installed by this build. It is not present in modules.conf." + elif [ -n "$commented" ] ; then + alert "installed module: $i was not installed by this build. It is commented from modules.conf. [$commented]" + fi + +done + + +echo diff --git a/build/modmake.rules.in b/build/modmake.rules.in index 00d72f050c..3a27af690a 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -27,7 +27,6 @@ INSTALL=@INSTALL@ GETLIB=@GETLIB@ LIBTOOL=@LIBTOOL@ AR=@AR@ -LIBGNUTLS_LIBS=@LIBGNUTLS_LIBS@ LTINSTALL=$(LIBTOOL) --quiet --mode=install $(INSTALL) LTUNINSTALL=$(LIBTOOL) --mode=uninstall rm -f CCLD = $(CC) diff --git a/build/modules.conf.in b/build/modules.conf.in index f7b36831cc..512775b1ae 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -72,7 +72,6 @@ codecs/mod_vp8 #codecs/mod_sangoma_codec #codecs/mod_silk #codecs/mod_siren -codecs/mod_speex #codecs/mod_theora dialplans/mod_dialplan_asterisk #dialplans/mod_dialplan_directory @@ -118,7 +117,8 @@ languages/mod_lua #languages/mod_managed #languages/mod_perl #languages/mod_python -languages/mod_spidermonkey +#languages/mod_spidermonkey +languages/mod_v8 #languages/mod_yaml loggers/mod_console loggers/mod_logfile @@ -139,6 +139,7 @@ say/mod_say_en #say/mod_say_ru #say/mod_say_th #say/mod_say_zh +#say/mod_say_sv #timers/mod_posix_timer #timers/mod_timerfd xml_int/mod_xml_cdr diff --git a/build/swigall.sh b/build/swigall.sh index 0525faf073..b36c1c6152 100755 --- a/build/swigall.sh +++ b/build/swigall.sh @@ -3,6 +3,11 @@ make swigclean make lua_wrap cd ../../../.. +cd src/mod/legacy/languages/mod_lua +make swigclean +make lua_wrap +cd ../../../../.. + cd src/mod/languages/mod_perl make swigclean make mod_perl_wrap.cpp diff --git a/conf/curl/autoload_configs/v8.conf.xml b/conf/curl/autoload_configs/v8.conf.xml new file mode 100644 index 0000000000..01c9e2bd99 --- /dev/null +++ b/conf/curl/autoload_configs/v8.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/conf/insideout/autoload_configs/modules.conf.xml b/conf/insideout/autoload_configs/modules.conf.xml index 692a362977..bf71e799a4 100644 --- a/conf/insideout/autoload_configs/modules.conf.xml +++ b/conf/insideout/autoload_configs/modules.conf.xml @@ -62,7 +62,6 @@ - @@ -79,7 +78,8 @@ - + + @@ -95,5 +95,6 @@ + diff --git a/conf/insideout/autoload_configs/v8.conf.xml b/conf/insideout/autoload_configs/v8.conf.xml new file mode 100644 index 0000000000..01c9e2bd99 --- /dev/null +++ b/conf/insideout/autoload_configs/v8.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/conf/rayo/autoload_configs/conference.conf.xml b/conf/rayo/autoload_configs/conference.conf.xml index 826f6fb9be..6e89e1260a 100644 --- a/conf/rayo/autoload_configs/conference.conf.xml +++ b/conf/rayo/autoload_configs/conference.conf.xml @@ -207,6 +207,7 @@ + diff --git a/conf/rayo/autoload_configs/distributor.conf.xml b/conf/rayo/autoload_configs/distributor.conf.xml deleted file mode 100644 index a03b1ee810..0000000000 --- a/conf/rayo/autoload_configs/distributor.conf.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/conf/rayo/autoload_configs/hash.conf.xml b/conf/rayo/autoload_configs/hash.conf.xml deleted file mode 100644 index 95b7928775..0000000000 --- a/conf/rayo/autoload_configs/hash.conf.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/conf/rayo/autoload_configs/lua.conf.xml b/conf/rayo/autoload_configs/lua.conf.xml deleted file mode 100644 index 1eb594f0b5..0000000000 --- a/conf/rayo/autoload_configs/lua.conf.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/conf/rayo/autoload_configs/memcache.conf.xml b/conf/rayo/autoload_configs/memcache.conf.xml deleted file mode 100644 index dc0173f986..0000000000 --- a/conf/rayo/autoload_configs/memcache.conf.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/conf/rayo/autoload_configs/modules.conf.xml b/conf/rayo/autoload_configs/modules.conf.xml index 604bc4e12c..fcf7f5fb15 100644 --- a/conf/rayo/autoload_configs/modules.conf.xml +++ b/conf/rayo/autoload_configs/modules.conf.xml @@ -18,8 +18,6 @@ - - @@ -30,9 +28,10 @@ - + + @@ -45,9 +44,6 @@ - - - @@ -69,6 +65,7 @@ + diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml index 35419319bc..50af0f7ecd 100644 --- a/conf/rayo/autoload_configs/rayo.conf.xml +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -16,6 +16,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -43,20 +109,27 @@ - - + + + + ]]> + ]]> + ]]> ]]> + ]]> ]]> ]]> - ]]> - ]]> - ]]> - ]]> + ]]> + ]]> + ]]> + ]]> + ]]> ]]> + ]]> ]]> ]]> ]]> @@ -65,6 +138,8 @@ ]]> ]]> ]]> + ]]> + ]]> ]]> ]]> ]]> diff --git a/conf/rayo/freeswitch.xml b/conf/rayo/freeswitch.xml index 49bd41fec2..f38983ebcb 100644 --- a/conf/rayo/freeswitch.xml +++ b/conf/rayo/freeswitch.xml @@ -63,6 +63,7 @@ + diff --git a/conf/rayo/lang/sv/sv.xml b/conf/rayo/lang/sv/sv.xml new file mode 100644 index 0000000000..f77e0221f6 --- /dev/null +++ b/conf/rayo/lang/sv/sv.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/conf/rayo/lang/sv/vm/sounds.xml b/conf/rayo/lang/sv/vm/sounds.xml new file mode 100644 index 0000000000..aaee3c0b6b --- /dev/null +++ b/conf/rayo/lang/sv/vm/sounds.xml @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/sbc/autoload_configs/modules.conf.xml b/conf/sbc/autoload_configs/modules.conf.xml index c6c0273a93..20a8718a6b 100644 --- a/conf/sbc/autoload_configs/modules.conf.xml +++ b/conf/sbc/autoload_configs/modules.conf.xml @@ -41,7 +41,6 @@ - diff --git a/conf/sbc/autoload_configs/sofia.conf.xml b/conf/sbc/autoload_configs/sofia.conf.xml index 24252d08ce..c41758beed 100644 --- a/conf/sbc/autoload_configs/sofia.conf.xml +++ b/conf/sbc/autoload_configs/sofia.conf.xml @@ -6,13 +6,8 @@ - - + diff --git a/conf/sbc/dialplan/default.xml b/conf/sbc/dialplan/default.xml index 2beb54e27b..5bc2df37f3 100644 --- a/conf/sbc/dialplan/default.xml +++ b/conf/sbc/dialplan/default.xml @@ -9,7 +9,6 @@ will build the domains acl using this value. --> - diff --git a/conf/sbc/freeswitch.xml b/conf/sbc/freeswitch.xml index e449978c76..ad7fd08b1c 100644 --- a/conf/sbc/freeswitch.xml +++ b/conf/sbc/freeswitch.xml @@ -1,4 +1,4 @@ - + - -
- -
- - -
- - - -
-
+ diff --git a/conf/sbc/vars.xml b/conf/sbc/vars.xml index 0fbcda17b8..52efb0683a 100644 --- a/conf/sbc/vars.xml +++ b/conf/sbc/vars.xml @@ -1,3 +1,4 @@ + @@ -150,3 +151,4 @@ + diff --git a/conf/softphone/freeswitch.xml b/conf/softphone/freeswitch.xml index 66e7c2a923..3d5faa240c 100644 --- a/conf/softphone/freeswitch.xml +++ b/conf/softphone/freeswitch.xml @@ -86,7 +86,6 @@ - diff --git a/conf/vanilla/autoload_configs/distributor.conf.xml b/conf/vanilla/autoload_configs/distributor.conf.xml index a03b1ee810..99a4c9d942 100644 --- a/conf/vanilla/autoload_configs/distributor.conf.xml +++ b/conf/vanilla/autoload_configs/distributor.conf.xml @@ -2,7 +2,7 @@ - + diff --git a/conf/vanilla/autoload_configs/event_socket.conf.xml b/conf/vanilla/autoload_configs/event_socket.conf.xml index 5ea2e09788..28e0f46837 100644 --- a/conf/vanilla/autoload_configs/event_socket.conf.xml +++ b/conf/vanilla/autoload_configs/event_socket.conf.xml @@ -5,5 +5,6 @@ + diff --git a/conf/vanilla/autoload_configs/logfile.conf.xml b/conf/vanilla/autoload_configs/logfile.conf.xml index 65bea552bd..546db4abaf 100644 --- a/conf/vanilla/autoload_configs/logfile.conf.xml +++ b/conf/vanilla/autoload_configs/logfile.conf.xml @@ -13,8 +13,8 @@ - - + + - @@ -109,7 +108,8 @@ - + + @@ -126,6 +126,7 @@ + diff --git a/conf/vanilla/autoload_configs/mongo.conf.xml b/conf/vanilla/autoload_configs/mongo.conf.xml index 8423645e95..72fffafbb7 100644 --- a/conf/vanilla/autoload_configs/mongo.conf.xml +++ b/conf/vanilla/autoload_configs/mongo.conf.xml @@ -7,8 +7,9 @@ foo/server:port,server:port SET --> - + + + + + diff --git a/conf/vanilla/autoload_configs/syslog.conf.xml b/conf/vanilla/autoload_configs/syslog.conf.xml index 636a12c8c1..7a06e8f3b0 100644 --- a/conf/vanilla/autoload_configs/syslog.conf.xml +++ b/conf/vanilla/autoload_configs/syslog.conf.xml @@ -12,7 +12,7 @@ - - + + diff --git a/conf/vanilla/autoload_configs/v8.conf.xml b/conf/vanilla/autoload_configs/v8.conf.xml new file mode 100644 index 0000000000..01c9e2bd99 --- /dev/null +++ b/conf/vanilla/autoload_configs/v8.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/conf/vanilla/freeswitch.xml b/conf/vanilla/freeswitch.xml index b067d986c4..51b93f8a70 100644 --- a/conf/vanilla/freeswitch.xml +++ b/conf/vanilla/freeswitch.xml @@ -67,5 +67,6 @@ + diff --git a/conf/vanilla/lang/sv/sv.xml b/conf/vanilla/lang/sv/sv.xml new file mode 100644 index 0000000000..f77e0221f6 --- /dev/null +++ b/conf/vanilla/lang/sv/sv.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/conf/vanilla/lang/sv/vm/sounds.xml b/conf/vanilla/lang/sv/vm/sounds.xml new file mode 100644 index 0000000000..aaee3c0b6b --- /dev/null +++ b/conf/vanilla/lang/sv/vm/sounds.xml @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index c813d99c67..d2af883b9d 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -37,6 +37,7 @@ when you press the hold button. --> + + + @@ -204,9 +207,12 @@ - + + + + diff --git a/conf/vanilla/vars.xml b/conf/vanilla/vars.xml index 1abbb240f7..8ea964e2f5 100644 --- a/conf/vanilla/vars.xml +++ b/conf/vanilla/vars.xml @@ -270,10 +270,19 @@ - + SIP and TLS settings. http://wiki.freeswitch.org/wiki/Tls + + valid options: sslv2,sslv3,sslv23,tlsv1,tlsv1.1,tlsv1.2 + default: tlsv1,tlsv1.1,tlsv1.2 + --> + + + + + diff --git a/conf/vanilla/voicemail.tpl b/conf/vanilla/voicemail.tpl index 2774b78a9e..782607778d 100644 --- a/conf/vanilla/voicemail.tpl +++ b/conf/vanilla/voicemail.tpl @@ -1,6 +1,6 @@ From: "${voicemail_caller_id_name}" <${voicemail_caller_id_number}@${voicemail_domain}> Date: ${RFC2822_DATE} -To: <${voicemail_email}> +To: ${voicemail_email} Subject: Voicemail from "${voicemail_caller_id_name}" <${voicemail_caller_id_number}> ${voicemail_message_len} X-Priority: ${voicemail_priority} X-Mailer: FreeSWITCH diff --git a/configure.in b/configure.in index 27f3645ff7..a7a273cc82 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.5.6b], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.5.8b], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [5]) -AC_SUBST(SWITCH_VERSION_MICRO, [6b]) +AC_SUBST(SWITCH_VERSION_MICRO, [8b]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) @@ -162,8 +162,6 @@ if test "${enable_optimizer}" = "yes" ; then AX_CC_MAXOPT fi -AX_PATH_LIBGNUTLS() - # set defaults for use on all platforms SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/include -I${switch_srcdir}/libs/libteletone/src -I${switch_srcdir}/libs/stfu" SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/include -I${switch_srcdir}/libs/libteletone/src -I${switch_srcdir}/libs/stfu" @@ -178,7 +176,7 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then SOLINK="-dynamic -force-flat-namespace" ;; *) - AC_ERROR([Please update configure.in with SOLINK values for your compiler]) + SOLINK="-shared -Xlinker -x" ;; esac @@ -402,14 +400,17 @@ AM_CONDITIONAL([ENABLE_ZRTP],[test "x$enable_zrtp" != "xno"]) AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"]) -AC_ARG_ENABLE(core-odbc-support, - [AS_HELP_STRING([--enable-core-odbc-support], [Compile with ODBC Support])],,[enable_core_odbc_support="no"]) -AX_LIB_ODBC -if test "$ac_cv_found_odbc" = "yes" ; then - enable_core_odbc_support="yes" -fi -if test "x$enable_core_odbc_support" != "xno"; then - AC_CHECK_LIB([odbc], [SQLDisconnect],, AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent])) +AC_ARG_ENABLE(core-odbc-support, + [AS_HELP_STRING([--enable-core-odbc-support], [Compile with ODBC Support (default is optional)])],,[enable_core_odbc_support="optional"]) +if ! test "$enable_core_odbc_support" = "no"; then + AX_LIB_ODBC + if test "$ac_cv_found_odbc" = "yes" ; then + enable_core_odbc_support="yes" + elif test "$enable_core_odbc_support" = "yes"; then + AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent]) + else + enable_core_odbc_support="no" + fi fi CHECK_LIBUUID @@ -424,39 +425,47 @@ AC_ARG_ENABLE(core-pgsql-pkgconfig, if test x"$enable_core_pgsql_support" = x"yes" ; then AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) - if test "$PG_CONFIG" = "no"; then - AC_MSG_RESULT([no]) - AC_MSG_FAILURE([Unabled to find pg_config in PATH. Is PostgreSQL installed?]) - else if test "$PKG_CONFIG" = "no" \ || test x"$enable_core_pgsql_pkgconfig" = x"no" \ || ! pkg-config libpq; then - AC_MSG_CHECKING([for PostgreSQL libraries]) - POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" - POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" - POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` - POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'` - POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'` - POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'` + if test "$PG_CONFIG" != "no"; then + AC_MSG_CHECKING([for PostgreSQL libraries via pg_config]) + POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`" + POSTGRESQL_LIBDIR="-L`$PG_CONFIG --libdir`" + POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq" + POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` + POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.?[0-9]+?#\1#'` + POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.([0-9]+).?[0-9]+?#\1#'` + POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -e 's/devel//' | sed -re 's#PostgreSQL [0-9]+.[0-9]+.?([0-9]+)?#\1#'` + else + AC_MSG_ERROR([no usable pkg-config or pg_config; please install libpq devel package or equivalent]) + fi else - AC_MSG_CHECKING([for PostgreSQL libraries]) - POSTGRESQL_CXXFLAGS="`$PKG_CONFIG --cflags libpq`" + AC_MSG_CHECKING([for PostgreSQL libraries via pkg_config]) + POSTGRESQL_CFLAGS="`$PKG_CONFIG --cflags libpq`" + POSTGRESQL_LIBDIR="`$PKG_CONFIG libpq --libs-only-L`" POSTGRESQL_LDFLAGS="`$PKG_CONFIG --libs libpq`" POSTGRESQL_VERSION="`$PKG_CONFIG --modversion libpq`" POSTGRESQL_MAJOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f1`" POSTGRESQL_MINOR_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f2`" POSTGRESQL_PATCH_VERSION="`echo $POSTGRESQL_VERSION | cut -d. -f3`" fi + save_LIBS="$LIBS" + LIBS="$POSTGRESQL_LIBDIR $LIBS" + AC_MSG_RESULT([$POSTGRESQL_LIBDIR]) + AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available]) AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent])) AC_MSG_RESULT([yes]) - SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS" + SWITCH_AM_CXXFLAGS="$POSTGRESQL_CFLAGS $SWITCH_AM_CXXFLAGS" SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS" - fi + + LIBS="$save_LIBS" fi AC_ARG_ENABLE(deprecated-core-db-events, @@ -470,10 +479,81 @@ AC_ARG_ENABLE(timerfd-wrapper, [AC_HELP_STRING([--enable-timerfd-wrapper],[timerfd is in the kernel but not in your libc])],[enable_timer_fd_wrapper="$enableval"],[enable_timer_fd_wrapper="no"]) AM_CONDITIONAL([ENABLE_TIMERFD_WRAPPER],[test "x$enable_timer_fd_wrapper" != "xno"]) +ESL_LDFLAGS= +PLATFORM_CORE_LDFLAGS= +PLATFORM_CORE_LIBS= + +# tweak platform specific flags +case "$host" in + *darwin12.*|*darwin11.*) + APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) + APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp -Wno-deprecated-declarations -I/usr/local/opt/openssl/include) + APR_ADDTO(LDFLAGS, -pipe -bind_at_load -L/usr/local/opt/openssl/lib) + APR_ADDTO(CXXFLAGS, -pipe) + APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) + if test "x$enable_core_odbc_support" != "xno"; then + APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) + fi + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) + ;; + *darwin10.*) + APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) + APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp -I/usr/local/opt/openssl/include) + APR_ADDTO(LDFLAGS, -pipe -bind_at_load -L/usr/local/opt/openssl/lib) + APR_ADDTO(CXXFLAGS, -pipe) + APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) + if test "x$enable_core_odbc_support" != "xno"; then + APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) + fi + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) + ;; + *darwin*) + APR_ADDTO(CFLAGS, -I/usr/local/opt/openssl/include) + APR_ADDTO(LDFLAGS, -L/usr/local/opt/openssl/lib) + APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) + APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) + if test "x$enable_core_odbc_support" != "xno"; then + APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) + fi + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) + ;; + *-solaris2*) + APR_ADDTO(SWITCH_AM_CFLAGS, -DPATH_MAX=2048 -D__EXTENSIONS__) + APR_ADDTO(SWITCH_AM_LDFLAGS, -lsendfile -lresolv -lsocket -lnsl -luuid) + APR_ADDTO(ESL_LDFLAGS, -lnsl -lsocket) + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt -lsendfile -lresolv -lsocket -lnsl -luuid]) + ;; + *dragonfly*) + APR_ADDTO(CFLAGS, -I/usr/local/include) + APR_ADDTO(LDFLAGS, -L/usr/local/lib) + APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include) + ;; + *openbsd*) + APR_ADDTO(CFLAGS, -I/usr/local/include) + APR_ADDTO(LDFLAGS, -L/usr/local/lib) + APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include) + ;; + *netbsd*) + APR_ADDTO(CFLAGS, -I/usr/pkg/include) + APR_ADDTO(LDFLAGS, -L/usr/pkg/lib) + APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/pkg/include) + ;; + *bsd*) + APR_ADDTO(CFLAGS, -I/usr/local/include) + APR_ADDTO(LDFLAGS, -L/usr/local/lib) + APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include) + APR_ADDTO([PLATFORM_CORE_LIBS], [-lcrypt -lrt]) + ;; + *linux*) + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) + ;; +esac + +APR_REMOVEFROM(SWITCH_AM_CXXFLAGS, -std=c99) AC_CHECK_LIB(z, inflateReset, have_libz=yes, AC_MSG_ERROR([no usable zlib; please install zlib devel package or equivalent])) if test "x$have_libz" = "xyes" ; then -APR_ADDTO(SWITCH_AM_LDFLAGS, -lz) +APR_ADDTO([PLATFORM_CORE_LIBS], [-lz]) fi AC_CHECK_LIB(jpeg, jpeg_std_error,, AC_MSG_ERROR([no usable libjpeg; please install libjpeg devel package or equivalent])) @@ -495,58 +575,6 @@ if test "x$have_libresolv" = "xyes" ; then APR_ADDTO(SWITCH_AM_LDFLAGS, -lresolv) fi -ESL_LDFLAGS= -PLATFORM_CORE_LDFLAGS= -PLATFORM_CORE_LIBS= -# tweak platform specific flags -case "$host" in - *darwin12.*|*darwin11.*) - APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) - APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp -Wno-deprecated-declarations) - APR_ADDTO(LDFLAGS, -pipe -bind_at_load) - APR_ADDTO(CXXFLAGS, -pipe) - APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) - if test "x$enable_core_odbc_support" != "xno"; then - APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) - fi - APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) - ;; - *darwin10.*) - APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) - APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp) - APR_ADDTO(LDFLAGS, -pipe -bind_at_load) - APR_ADDTO(CXXFLAGS, -pipe) - APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) - if test "x$enable_core_odbc_support" != "xno"; then - APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) - fi - APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) - ;; - *darwin*) - APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) - APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) - if test "x$enable_core_odbc_support" != "xno"; then - APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) - fi - APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl]) - ;; - *-solaris2*) - APR_ADDTO(SWITCH_AM_CFLAGS, -DPATH_MAX=2048 -D__EXTENSIONS__) - APR_ADDTO(SWITCH_AM_LDFLAGS, -lsendfile -lresolv -lsocket -lnsl -luuid) - APR_ADDTO(ESL_LDFLAGS, -lnsl -lsocket) - APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt -lsendfile -lresolv -lsocket -lnsl -luuid]) - ;; - *bsd*) - APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include) - APR_ADDTO([PLATFORM_CORE_LIBS], [-lcrypt -lrt]) - ;; - *linux*) - APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) - ;; -esac - -APR_REMOVEFROM(SWITCH_AM_CXXFLAGS, -std=c99) - AC_SUBST(SWITCH_AM_CFLAGS) AC_SUBST(SWITCH_ANSI_CFLAGS) AC_SUBST(SWITCH_AM_CXXFLAGS) @@ -811,6 +839,8 @@ elif test "$ac_cv_sizeof_long" = "8"; then int64_value="long" long_value=long case "$host" in + *pc-solaris2*) + ;; *-solaris2*|*apple-darwin*|*-openbsd*) if test "$ac_cv_sizeof_long_long" = "8"; then int64_t_fmt='#define SWITCH_INT64_T_FMT "lld"' @@ -1005,14 +1035,18 @@ SAC_OPENSSL if test x$HAVE_OPENSSL = x1; then openssl_CFLAGS="$openssl_CFLAGS -DHAVE_OPENSSL"; APR_ADDTO(SWITCH_AM_CFLAGS, -DHAVE_OPENSSL) - AC_CHECK_LIB(ssl, SSL_CTX_set_tlsext_use_srtp, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS_SRTP, 1, HAVE_OPENSSL_DTLS_SRTP)) - AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS), AC_MSG_WARN([OpenSSL version < 1.0.1e you might want to upgrade])) + AC_CHECK_LIB(ssl, SSL_CTX_set_tlsext_use_srtp, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS_SRTP, 1, HAVE_OPENSSL_DTLS_SRTP), AC_MSG_ERROR([OpenSSL >= 1.0.1e and associaed developement headers required])) + AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS), AC_MSG_ERROR([OpenSSL >= 1.0.1e and associaed developement headers required])) else - AC_MSG_ERROR([OpenSSL and associaed developement headers required]) + AC_MSG_ERROR([OpenSSL >= 1.0.1e and associaed developement headers required]) fi AX_CHECK_JAVA +# Option to enable static linking of Google's V8 inside mod_v8 +AC_ARG_ENABLE(static-v8, +[AS_HELP_STRING([--enable-static-v8], [Statically link V8 into mod_v8])], [enable_static_v8="$enableval"], [enable_static_v8="no"]) +AM_CONDITIONAL([ENABLE_STATIC_V8],[test "x$enable_static_v8" != "xno"]) AM_CONDITIONAL([HAVE_ODBC],[test "x$enable_core_odbc_support" != "xno"]) AM_CONDITIONAL([HAVE_LIBEDIT],[test "x$enable_core_libedit_support" != "xno"]) @@ -1159,8 +1193,10 @@ AC_CONFIG_FILES([Makefile src/mod/asr_tts/mod_unimrcp/Makefile src/mod/languages/mod_java/Makefile src/mod/languages/mod_lua/Makefile + src/mod/legacy/languages/mod_lua/Makefile src/mod/languages/mod_python/Makefile src/mod/languages/mod_spidermonkey/Makefile + src/mod/languages/mod_v8/Makefile src/mod/event_handlers/mod_erlang_event/Makefile src/include/switch_am_config.h build/getsounds.sh @@ -1177,6 +1213,7 @@ AC_CONFIG_FILES([Makefile AM_CONDITIONAL(ISLINUX, [test `uname -s` = Linux]) AM_CONDITIONAL(ISMAC, [test `uname -s` = Darwin]) +AM_CONDITIONAL(ISFREEBSD, [test `uname -s` = FreeBSD]) AM_CONDITIONAL(IS64BITLINUX, [test `uname -m` = x86_64]) #some vars to sub into the Makefile.am's @@ -1227,7 +1264,9 @@ AC_CONFIG_SUBDIRS([libs/pcre]) AC_CONFIG_SUBDIRS([libs/apr]) AC_CONFIG_SUBDIRS([libs/apr-util]) AC_CONFIG_SUBDIRS([libs/ilbc]) -AC_CONFIG_SUBDIRS([libs/curl]) +if test "$ac_cv_use_system_curl" != "yes"; then + AC_CONFIG_SUBDIRS([libs/curl]) +fi AC_CONFIG_SUBDIRS([libs/iksemel]) AC_CONFIG_SUBDIRS([libs/js/nsprpub]) AC_CONFIG_SUBDIRS([libs/js]) @@ -1272,14 +1311,7 @@ echo $ECHO_N ".$ECHO_C" 1>&6 sleep 1 echo $ECHO_N ".$ECHO_C" 1>&6 sleep 1 -echo $ECHO_N ".$ECHO_C" 1>&6 -sleep 1 -echo $ECHO_N ".$ECHO_C" 1>&6 -sleep 1 -echo $ECHO_N ".$ECHO_C" 1>&6 -sleep 1 AC_MSG_RESULT([ See you in August. ;-)]) -sleep 2 echo "" fi diff --git a/debian/AUTHORS b/debian/AUTHORS index 2145c58864..838dabde3c 100644 --- a/debian/AUTHORS +++ b/debian/AUTHORS @@ -23,4 +23,3 @@ Thanks-to: Steven Ayre Thanks-to: William King # for moral support and small tweaks - diff --git a/debian/README.Debian b/debian/README.Debian index 99bf84c567..2714821859 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,5 +1,5 @@ FreeSWITCH for Debian ---------------------- +===================== This debian packaging breaks out every module of freeswitch into a separate package, so be sure to verify that you are actually @@ -18,9 +18,9 @@ to /etc/freeswitch. If you just want to get a working demo system up quickly, I'd recommend doing the following: - aptitude install -y -r -o APT::Install-Suggests=true freeswitch-meta-vanilla - cp -a /usr/share/freeswitch/conf/vanilla /etc/freeswitch - /etc/init.d/freeswitch start - fs_cli + aptitude install -y -r -o APT::Install-Suggests=true freeswitch-meta-vanilla + cp -a /usr/share/freeswitch/conf/vanilla /etc/freeswitch + /etc/init.d/freeswitch start + fs_cli - -- Travis Cross , Wed, 3 Oct 2012 02:15:32 +0000 + -- Travis Cross , Sun, 23 Feb 2014 17:10:49 +0000 diff --git a/debian/README.source b/debian/README.source index 5119f1817b..0adc4ed2c2 100644 --- a/debian/README.source +++ b/debian/README.source @@ -1,9 +1,8 @@ FreeSWITCH for Debian ---------------------- +===================== -You may be reading this because you're wondering where all the files -are in debian/, such as control. You may also be here looking for the -sound or music packages. Read on. +Introduction +------------ Because FreeSWITCH has so many modules it was necessary to create a system to autogenerate the majority of the packaging. This in done @@ -11,6 +10,96 @@ mostly in the file debian/bootstrap.sh. This bootstrap needs to run before any other step of the packaging, though we do try to autogenerate it when possible. +Getting the FreeSWITCH sources +------------------------------ + +Everything that follows will assume that you're in the base directory +of a FreeSWITCH git repository. You can achieve this with: + + aptitude update && aptitude install -y git + mkdir -p /usr/src/freeswitch + git clone git://git.freeswitch.org/freeswitch /usr/src/freeswitch/src + cd /usr/src/freeswitch/src + +Ensuring you have a clean build directory +----------------------------------------- + +Every time you start over, you should make sure your build directory +is perfectly clean and clear of untracked files. You can accomplish +this with: + + git clean -fdx && git reset --hard origin/master + +Using the packaging to do a normal build +---------------------------------------- + +Let's say you don't want to build the Debian packages; you just want +to build FS. You'll need certain dependencies installed on your +system to do this. And you probably want to configure FS in the same +way we do for the packaging. You can let the packaging files do this +work for you so you don't have to manually keep track of which +dependencies are required to build FS. Build as follows: + + aptitude update && aptitude install -y devscripts equivs build-essential + my_release=$(awk '/deb .*\/debian/{print $3; exit}' /etc/apt/sources.list) + (cd debian && ./bootstrap.sh -c $my_release) + sed -i debian/control -e '/^#/d' && sed -i debian/control -e '/^$/N;/^\n$/D' + mk-build-deps -i + make -f debian/rules .stamp-configure && make + +The debian/modules.conf file +---------------------------- + +If the file debian/modules.conf is present, we read that file and only +build and package the files listed there. Otherwise, we build every +module except the ones that either should not be packaged, or for +which we don't yet have good packaging. + +The format of debian/modules.conf is: + + ## comments should start with two hash characters + / + +Building the Debian packaging +----------------------------- + +If you want actualy Debian binary or source packages to upload to your +own repository, you'll need to build them as described here. We have +some fancy automatic tools to accomplish this. The tools allow you to +start from a very bare Debian image and generate working packages. +Building in this manner is only supported on Debian sid, though it +will generate packages for all supported Debian releases. Simply run: + + ./debian/util.sh build-all -ibn -z9 + +Building only some modules +-------------------------- + +If you don't need all the modules to build, create a modules.conf file +outside of your source tree and pass the -f option to build-all. e.g.: + + echo "applications/mod_commands" > /tmp/modules.conf + ./debian/util.sh build-all -ibn -z9 -f /tmp/modules.conf + +Testing a particular module under packaging +------------------------------------------- + +If you need to build a small set of modules for compile testing in the +pbuilder environment, you can run: + + ./debian/util.sh build-all -dni -z1 -a amd64 -c sid -l "applications/mod_commands" + +Getting help with debian/util.sh +-------------------------------- + +The debian/util.sh has many options. You can see the documentation +for these options by running: + + ./debian/util.sh -h + +The debian/control-modules file +------------------------------- + The build dependencies, runtime dependencies, and other details about modules can be configured in the debian/control-modules file. Even though this file looks a bit like a debian control file and has a @@ -19,78 +108,55 @@ bit more restricted. debian/control-modules currently supports the following fields: - # lines that begin with the hash character are comments - # - # every block must start with a Module field - Module: / - Description: - # empty lines with "."s are not yet supported - Build-Depends: - Depends: - Recommends: - Suggests: - Distro-Conflicts: # not yet implemented + # lines that begin with the hash character are comments + # + # every block must start with a Module field + Module: / + Description: + # empty lines with "."s are not yet supported + Build-Depends: + Depends: + Recommends: + Suggests: + Distro-Conflicts: # not yet implemented During bootstrap we build a file control-modules.gen. If the control-modules file is properly formatted, this generated file should be identical. This is a sanity check mechanism for our parsing, as well as a way to automatically reorganize the file. -If the file debian/modules.conf is present, we read that file and only -build and package the files listed there. Otherwise, we build every -module except the ones that either should not be packaged, or for -which we don't yet have good packaging. +Building Debian packages without util.sh +---------------------------------------- -The format of debian/modules.conf is: +Building the packages without util.sh is not recommended as util.sh +takes care of many non-trivial details. If needed, however, the +packages can be built: - ## comments should start with two hash characters - / - -To build this package, I recommend running the following from the root -directory of your FS git working tree: - - distro=sid - ver="$(cat build/next-release.txt | sed -e 's/-/~/g')~n$(date +%Y%m%dT%H%M%SZ)-1~${distro}+1" - git clean -fdx && git reset --hard HEAD - ./build/set-fs-version.sh "$ver" - git add configure.in && git commit -m "bump to custom v$ver" - (cd debian && ./bootstrap.sh -c $distro) - dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." - dpkg-buildpackage -b -us -uc -Zxz -z9 - git reset --hard HEAD^ + distro=sid + ver="$(cat build/next-release.txt | sed -e 's/-/~/g')~n$(date +%Y%m%dT%H%M%SZ)-1~${distro}+1" + git clean -fdx && git reset --hard origin/master + ./build/set-fs-version.sh "$ver" + git add configure.in && git commit -m "bump to custom v$ver" + (cd debian && ./bootstrap.sh -c $distro) + dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." + dpkg-buildpackage -b -us -uc -Zxz -z9 + git reset --hard HEAD^ To build for a stable branch, do this: - distro=sid # update as needed - stable_ver="1.2.1" # update as needed - # if you only want to build some modules, put them one per line here, e.g.: - #echo "applications/mod_commands" >> debian/modules.conf - ver="$(echo "$stable_ver" | sed -e 's/-/~/g')~n$(date +%Y%m%dT%H%M%SZ)-1~${distro}+1" - git clean -fdx && git reset --hard refs/tags/v${stable_ver} - ./build/set-fs-version.sh "$ver" - git add configure.in && git commit -m "bump to custom v$ver" - (cd debian && ./bootstrap.sh -c $distro) - dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." - dpkg-buildpackage -b -us -uc -Zxz -z9 - git reset --hard origin/master + distro=sid # update as needed + stable_ver="1.2.1" # update as needed + ver="$(echo "$stable_ver" | sed -e 's/-/~/g')~n$(date +%Y%m%dT%H%M%SZ)-1~${distro}+1" + git clean -fdx && git reset --hard refs/tags/v${stable_ver} + ./build/set-fs-version.sh "$ver" + git add configure.in && git commit -m "bump to custom v$ver" + (cd debian && ./bootstrap.sh -c $distro) + dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." + dpkg-buildpackage -b -us -uc -Zxz -z9 + git reset --hard origin/master -Alternatively, you can build using our automated tools. To build the -source packages and all supported binary packages for sid, wheezy, -squeeze on i386 and amd64, run the following as root from a clean -Debian sid 'buildd' image: - - aptitude update && aptitude upgrade - aptitude install -y \ - rsync git less cowbuilder ccache \ - devscripts equivs build-essential - mkdir /usr/src/freeswitch - git clone git://git.freeswitch.org/freeswitch /usr/src/freeswitch/src - cd /usr/src/freeswitch/src - # if you only want to build some modules, create a modules.conf - # outside the source tree and add -f ../path/to/modules.conf to the - # command below. See ./debian/util.sh -h for further usage - # information. - ./debian/util.sh build-all -bn -z9 +Building the freeswitch-sounds and freeswitch-music packages +------------------------------------------------------------ The source packages for sounds and music on hold are maintained in a separate repository. Each set of sounds has a separate version number @@ -101,7 +167,7 @@ and the sounds and music would be a mess. To build the Debian packages for freeswitch-sounds-* and freeswitch-music-*: - git clone https://github.com/traviscross/freeswitch-sounds.git - cd freeswitch-sounds && cat debian/README.source + git clone https://github.com/traviscross/freeswitch-sounds.git + cd freeswitch-sounds && cat debian/README.source - -- Travis Cross , Fri, 29 Mar 2013 22:07:26 +0000 + -- Travis Cross , Sun, 23 Feb 2014 18:08:08 +0000 diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index b9776f14ac..499ccd6f55 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -28,7 +28,6 @@ avoid_mods=( endpoints/mod_opal endpoints/mod_reference endpoints/mod_unicall - formats/mod_shout languages/mod_managed languages/mod_spidermonkey sdk/autotools @@ -36,6 +35,7 @@ avoid_mods=( xml_int/mod_xml_radius ) avoid_mods_sid=( + languages/mod_java ) avoid_mods_jessie=( ) @@ -45,6 +45,29 @@ avoid_mods_squeeze=( formats/mod_vlc languages/mod_managed ) +manual_pkgs=( +freeswitch-all +freeswitch +libfreeswitch1 +freeswitch-meta-bare +freeswitch-meta-default +freeswitch-meta-vanilla +freeswitch-meta-sorbet +freeswitch-meta-all +freeswitch-meta-codecs +freeswitch-meta-conf +freeswitch-meta-lang +freeswitch-meta-mod-say +freeswitch-all-dbg +freeswitch-dbg +libfreeswitch1-dbg +libfreeswitch-dev +freeswitch-doc +freeswitch-init +freeswitch-sysvinit +freeswitch-systemd +freeswitch-lang +) err () { echo "$0 error: $1" >&2 @@ -60,6 +83,31 @@ xread () { return $ret } +intersperse () { + local sep="$1" + awk " + BEGIN { + first=1; + sep=\"${sep}\"; + }"' + /.*/ { + if (first == 0) { + printf "%s%s", sep, $0; + } else { + printf "%s", $0; + } + first=0; + } + END { printf "\n"; }' +} + +postfix () { + local px="$1" + awk " + BEGIN { px=\"${px}\"; }"' + /.*/ { printf "%s%s\n", $0, px; }' +} + avoid_mod_filter () { local x="avoid_mods_$codename[@]" local -a mods=("${avoid_mods[@]}" "${!x}") @@ -97,20 +145,20 @@ mod_filter_show () { map_fs_modules () { local filterfn="$1" percatfns="$2" permodfns="$3" for x in $mod_dir/*; do - if test -d $x; then - category=${x##*/} category_path=$x - for f in $percatfns; do $f; done - for y in $x/*; do - module_name=${y##*/} module_path=$y - module=$category/$module_name - if $filterfn $category/$module; then - [ -f ${y}/module ] && . ${y}/module - for f in $permodfns; do $f; done - fi - unset module_name module_path module - done - unset category category_path - fi + test -d $x || continue + test ! ${x##*/} = legacy || continue + category=${x##*/} category_path=$x + for f in $percatfns; do $f; done + for y in $x/*; do + module_name=${y##*/} module_path=$y + module=$category/$module_name + if $filterfn $category/$module; then + [ -f ${y}/module ] && . ${y}/module + for f in $permodfns; do $f; done + fi + unset module_name module_path module + done + unset category category_path done } @@ -167,6 +215,60 @@ map_langs () { done } +map_pkgs () { + local fsx="$1" + for x in "${manual_pkgs[@]}"; do + $fsx $x + done + map_pkgs_confs () { $fsx "freeswitch-conf-${conf//_/-}"; } + map_confs map_pkgs_confs + map_pkgs_langs () { $fsx "freeswitch-lang-${lang//_/-}"; } + map_langs map_pkgs_langs + map_pkgs_mods () { + $fsx "freeswitch-${module//_/-}" + $fsx "freeswitch-${module//_/-}-dbg"; } + map_modules map_pkgs_mods +} + +list_pkgs () { + list_pkgs_thunk () { printf '%s\n' "$1"; } + map_pkgs list_pkgs_thunk +} + +list_freeswitch_all_pkgs () { + list_pkgs \ + | grep -v '^freeswitch-all$' \ + | grep -v -- '-dbg$' +} + +list_freeswitch_all_provides () { + list_freeswitch_all_pkgs \ + | intersperse ',\n ' +} + +list_freeswitch_all_replaces () { + list_freeswitch_all_pkgs \ + | postfix ' (<= ${binary:Version})' \ + | intersperse ',\n ' +} + +list_freeswitch_all_dbg_pkgs () { + list_pkgs \ + | grep -v '^freeswitch-all-dbg$' \ + | grep -- '-dbg$' +} + +list_freeswitch_all_dbg_provides () { + list_freeswitch_all_dbg_pkgs \ + | intersperse ',\n ' +} + +list_freeswitch_all_dbg_replaces () { + list_freeswitch_all_dbg_pkgs \ + | postfix ' (<= ${binary:Version})' \ + | intersperse ',\n ' +} + print_source_control () { cat <= 1.15.8.12), gcc (>= 4:4.4.5), g++ (>= 4:4.4.5), libc6-dev (>= 2.11.3), make (>= 3.81), wget, pkg-config, +# core codecs + libogg-dev, # configure options libssl-dev, unixodbc-dev, libpq-dev, libncurses5-dev, libjpeg62-dev | libjpeg8-dev, @@ -206,17 +310,9 @@ print_core_control () { cat <= 1.0.8), freeswitch-sounds-en-us-callie (>= 1.0.25) | freeswitch-sounds, @@ -259,8 +355,8 @@ Recommends: freeswitch-mod-commands (= \${binary:Version}), freeswitch-init (= \${binary:Version}), freeswitch-lang (= \${binary:Version}), - freeswitch-music (= \${binary:Version}), - freeswitch-sounds (= \${binary:Version}) + freeswitch-music, + freeswitch-sounds Suggests: Description: Cross-Platform Scalable Multi-Protocol Soft Switch $(debian_wrap "${fs_description}") @@ -293,8 +389,8 @@ Recommends: freeswitch-init (= \${binary:Version}), freeswitch-lang (= \${binary:Version}), freeswitch-meta-codecs (= \${binary:Version}), - freeswitch-music (= \${binary:Version}), - freeswitch-sounds (= \${binary:Version}) + freeswitch-music, + freeswitch-sounds Suggests: freeswitch-mod-cidlookup (= \${binary:Version}), freeswitch-mod-curl (= \${binary:Version}), @@ -337,7 +433,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-g723-1 (= \${binary:Version}), freeswitch-mod-g729 (= \${binary:Version}), freeswitch-mod-amr (= \${binary:Version}), - freeswitch-mod-speex (= \${binary:Version}), freeswitch-mod-h26x (= \${binary:Version}), freeswitch-mod-sndfile (= \${binary:Version}), freeswitch-mod-native-file (= \${binary:Version}), @@ -348,8 +443,8 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), Recommends: freeswitch-init (= \${binary:Version}), freeswitch-lang (= \${binary:Version}), - freeswitch-music (= \${binary:Version}), - freeswitch-sounds (= \${binary:Version}), + freeswitch-music, + freeswitch-sounds, freeswitch-conf-vanilla (= \${binary:Version}), Suggests: freeswitch-mod-spidermonkey (= \${binary:Version}), @@ -366,8 +461,8 @@ Recommends: freeswitch-init (= \${binary:Version}), freeswitch-lang (= \${binary:Version}), freeswitch-meta-codecs (= \${binary:Version}), - freeswitch-music (= \${binary:Version}), - freeswitch-sounds (= \${binary:Version}), + freeswitch-music, + freeswitch-sounds, freeswitch-mod-abstraction (= \${binary:Version}), freeswitch-mod-avmd (= \${binary:Version}), freeswitch-mod-blacklist (= \${binary:Version}), @@ -452,8 +547,8 @@ Recommends: freeswitch-meta-conf (= \${binary:Version}), freeswitch-meta-lang (= \${binary:Version}), freeswitch-meta-mod-say (= \${binary:Version}), - freeswitch-music (= \${binary:Version}), - freeswitch-sounds (= \${binary:Version}), + freeswitch-music, + freeswitch-sounds, freeswitch-mod-abstraction (= \${binary:Version}), freeswitch-mod-avmd (= \${binary:Version}), freeswitch-mod-blacklist (= \${binary:Version}), @@ -575,7 +670,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-opus (= \${binary:Version}), freeswitch-mod-silk (= \${binary:Version}), freeswitch-mod-spandsp (= \${binary:Version}), - freeswitch-mod-speex (= \${binary:Version}), freeswitch-mod-theora (= \${binary:Version}), freeswitch-mod-vp8 (= \${binary:Version}) Suggests: @@ -646,7 +740,10 @@ Package: freeswitch-all-dbg Section: debug Priority: extra Architecture: any -Depends: \${misc:Depends}, freeswitch (= \${binary:Version}) +Provides: $(list_freeswitch_all_dbg_provides) +Replaces: $(list_freeswitch_all_dbg_replaces) +Breaks: $(list_freeswitch_all_dbg_replaces) +Depends: \${misc:Depends}, freeswitch-all (= \${binary:Version}) Description: debugging symbols for FreeSWITCH $(debian_wrap "${fs_description}") . @@ -732,48 +829,6 @@ Description: Language files for FreeSWITCH This is a metapackage which depends on the default language packages for FreeSWITCH. -## sounds - -Package: freeswitch-music -Architecture: all -Depends: \${misc:Depends}, - freeswitch-music-default (>= 1.0.8) -Description: Music on hold audio for FreeSWITCH - $(debian_wrap "${fs_description}") - . - This is a metapackage which depends on the default music on hold - packages for FreeSWITCH. - -Package: freeswitch-sounds -Architecture: all -Depends: \${misc:Depends}, - freeswitch-sounds-en (= \${binary:Version}) -Description: Sounds for FreeSWITCH - $(debian_wrap "${fs_description}") - . - This is a metapackage which depends on the default sound packages for - FreeSWITCH. - -Package: freeswitch-sounds-en -Architecture: all -Depends: \${misc:Depends}, - freeswitch-sounds-en-us (= \${binary:Version}) -Description: English sounds for FreeSWITCH - $(debian_wrap "${fs_description}") - . - This is a metapackage which depends on the default English sound - packages for FreeSWITCH. - -Package: freeswitch-sounds-en-us -Architecture: all -Depends: \${misc:Depends}, - freeswitch-sounds-en-us-callie (>= 1.0.18) -Description: US English sounds for FreeSWITCH - $(debian_wrap "${fs_description}") - . - This is a metapackage which depends on the default US/English sound - packages for FreeSWITCH. - EOF } @@ -896,7 +951,7 @@ print_lang_control () { Package: freeswitch-lang-${lang//_/-} Architecture: all Depends: \${misc:Depends} -Recommends: freeswitch-sounds-${lang} (= \${binary:Version}) +Recommends: freeswitch-sounds-${lang} Description: ${lang_name} language files for FreeSWITCH $(debian_wrap "${fs_description}") . @@ -916,7 +971,7 @@ print_edit_warning () { } gencontrol_per_mod () { - print_mod_control "$module_name" "$description" "$long_description" >> control + print_mod_control "$module_name" "$description" "$long_description" >> control } gencontrol_per_cat () { @@ -936,12 +991,11 @@ genoverrides_per_mod () { test -f $f.tmpl && cat $f.tmpl >> $f } -genmodules_per_cat () { - echo "## $category" >> modules_.conf -} - -genmodules_per_mod () { - echo "$module" >> modules_.conf +genmodulesconf () { + genmodules_per_cat () { echo "## $category"; } + genmodules_per_mod () { echo "$module"; } + print_edit_warning + map_modules 'mod_filter' 'genmodules_per_cat' 'genmodules_per_mod' } genconf () { @@ -1141,6 +1195,18 @@ set_modules_non_dfsg () { done } +conf_merge () { + local of="$1" if="$2" + if [ -s $if ]; then + grep -v '^##\|^$' $if | while xread x; do + touch $of + if ! grep -e "$x" $of >/dev/null; then + printf '%s\n' "$x" >> $of + fi + done + fi +} + codename="sid" modulelist_opt="" while getopts "c:m:" o; do @@ -1164,6 +1230,8 @@ echo "Parsing control-modules..." >&2 parse_mod_control echo "Displaying includes/excludes..." >&2 map_modules 'mod_filter_show' '' '' +echo "Generating modules_.conf..." >&2 +genmodulesconf > modules_.conf echo "Generating control-modules.gen as sanity check..." >&2 (echo "# -*- mode:debian-control -*-"; \ echo "##### Author: Travis Cross "; echo; \ @@ -1186,21 +1254,13 @@ echo "Generating debian/ (lang)..." >&2 map_langs 'genlang' echo "Generating debian/ (modules)..." >&2 (echo "### modules"; echo) >> control -print_edit_warning > modules_.conf map_modules "mod_filter" \ - "gencontrol_per_cat genmodules_per_cat" \ - "gencontrol_per_mod geninstall_per_mod genoverrides_per_mod genmodules_per_mod" + "gencontrol_per_cat" \ + "gencontrol_per_mod geninstall_per_mod genoverrides_per_mod" echo "Generating debian/ (-all package)..." >&2 grep -e '^Package:' control | grep -v '^freeswitch-all$' | while xread l; do m="${l#*: }" - f=$m.install - if [ -s $f ]; then - grep -v '^##\|^$' $f | while xread x; do - if ! grep -e "$x" freeswitch-all.install >/dev/null; then - printf '%s\n' "$x" >> freeswitch-all.install - fi - done - fi + conf_merge freeswitch-all.install $m.install done for x in postinst postrm preinst prerm; do cp -a freeswitch.$x freeswitch-all.$x diff --git a/debian/control-modules b/debian/control-modules index cd7acb2c73..bc3bb57c0b 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -29,6 +29,7 @@ Description: Caller ID name lookup Module: applications/mod_cluechoo Description: Clue Choo This demo module renders a Clue Choo train on the FreeSWITCH console. +Build-Depends: libncurses5-dev Module: applications/mod_commands Description: Command module @@ -337,11 +338,6 @@ Module: codecs/mod_skel_codec Description: mod_skel_codec Adds mod_skel_codec. -Module: codecs/mod_speex -Description: mod_speex - Adds mod_speex. -Build-Depends: libogg-dev - Module: codecs/mod_theora Description: mod_theora Adds mod_theora. @@ -540,6 +536,8 @@ Module: formats/mod_vlc Description: VLC streaming This module provides VLC streaming. Build-Depends: libvlc-dev (>= 2.0.0) +Depends: vlc-nox +Suggests: vlc-dbg Distro-Conflicts: squeeze ## mod/languages @@ -573,6 +571,10 @@ Description: mod_spidermonkey Adds mod_spidermonkey. Build-Depends: unixodbc-dev +Module: languages/mod_v8 +Description: mod_v8 + Adds mod_v8. + Module: languages/mod_yaml Description: mod_yaml Adds mod_yaml. @@ -650,6 +652,10 @@ Module: say/mod_say_ru Description: mod_say_ru Adds mod_say_ru. +Module: say/mod_say_sv +Description: mod_say_sv + Adds mod_say_sv. + Module: say/mod_say_th Description: mod_say_th Adds mod_say_th. diff --git a/debian/copyright b/debian/copyright index d7ea35053f..3fe3844e28 100644 --- a/debian/copyright +++ b/debian/copyright @@ -3,8 +3,8 @@ Upstream-Name: freeswitch Source: http://freeswitch.org/ Files: * -Copyright: 2005-2012 Anthony Minessale II - 2005-2012 Anthony Minessale II +Copyright: 2005-2014 Anthony Minessale II + 2005-2014 Anthony Minessale II License: MPL-1.1 MOZILLA PUBLIC LICENSE Version 1.1 @@ -1262,8 +1262,8 @@ License: ISC OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Files: libs/freetdm/* -Copyright: 2005-2012, Anthony Minessale II - 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II + 2005-2014, Anthony Minessale II 2009,2010 Moises Silva David Yat Sin 2007, Jan Vidar Berger, Case Labs, Ltd. @@ -1284,7 +1284,7 @@ License: BSD-3-clause Files: libs/freetdm/src/priserver.c libs/freetdm/src/sangoma_pri.? -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II Nenad Corbic License: GPL-2+ @@ -1296,8 +1296,8 @@ Files: libs/freetdm/src/libteletone_detect.c libs/freetdm/src/libteletone_generate.c libs/libteletone/src/libteletone_detect.[ch] src/mod/applications/mod_spandsp/udptl.[ch] -Copyright: 2005-2012, Anthony Minessale II - 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II + 2005-2014, Anthony Minessale II 2001-2009, Steve Underwood License: MPL-1.1 @@ -1427,7 +1427,7 @@ Files: libs/js/nsprpub/pr/tests/tmocon.c libs/js/nsprpub/pr/src/md/unix/os_ReliantUNIX.s libs/js/nsprpub/pr/src/md/unix/os_Darwin_ppc.s libs/js/nsprpub/pr/src/md/unix/os_SunOS_ultrasparc.s - libs/js/nsprpub/pr/src/md/unix/os_Linux_ia64.s + libs/js/nsprpub/pr/src/md/unix/os_Linux_ia64.s libs/js/nsprpub/pr/tests/testfile.c libs/js/nsprpub/pr/src/md/unix/os_Darwin_x86.s libs/js/nsprpub/pr/src/md/unix/os_AIX.s @@ -1538,7 +1538,7 @@ Copyright: 2005-2010, James Martelletti License: MPL-1.1 Files: src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II License: MPL-1.1 Files: src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.[ch] @@ -1552,7 +1552,7 @@ License: MPL-1.1 Files: src/mod/say/mod_say_??/mod_say_??.c scripts/c/socket2me/socket2me.c src/mod/xml_int/mod_xml_scgi/xml_scgi_server.pl -Copyright: 2007-2012, Anthony Minessale II +Copyright: 2007-2014, Anthony Minessale II 2007-2013, Anthony Minessale II 2011-2012, Shahar Hadas License: BSD-3-clause @@ -1595,7 +1595,7 @@ Copyright: 2002-2003 the Icecast team License: LGPL-2+ Files: */switch_xml.[ch] -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II 2004-2006 Aaron Voisine License: MPL-1.1 or BSD-like @@ -1722,7 +1722,7 @@ Copyright: 2007-2010 Khomp Ind. & Com. License: MPL-1.1 or LGPL-2.1+ Files: src/mod/endpoints/mod_khomp/mod_khomp.cpp -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II License: MPL-1.1 Files: src/mod/endpoints/mod_khomp/commons/base/atomic.hpp @@ -1795,11 +1795,11 @@ License: Perl Files: src/mod/endpoints/mod_portaudio/* Copyright: 1999-2000 Ross Bencina and Phil Burk - 2005-2012, Anthony Minessale II + 2005-2014, Anthony Minessale II License: MIT/X11 (BSD like) Files: src/mod/endpoints/mod_portaudio/mod_portaudio.c -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II License: MPL-1.1 Files: src/mod/endpoints/mod_sofia/sip-dig.c @@ -1834,7 +1834,7 @@ Copyright: 2006-2011, Skype Limited. License: BSD-2-clause Files: libs/libdingaling/* -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II 2001-2003 Allan Saddi License: MPL-1.1 @@ -1870,7 +1870,7 @@ Copyright: 2011-2012 The WebRTC project authors License: BSD-3-clause Files: src/mod/codecs/mod_isac/mod_isac.c -Copyright: 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II License: MPL-1.1 Files: libs/srtp/* @@ -1958,7 +1958,7 @@ License: LGPL Files: libs/libwebsockets/win32port/zlib/* Copyright: 1995-2010 Jean-loup Gailly - 1995-2010 Mark Adler + 1995-2010 Mark Adler 1995-2010 Jean-loup Gailly and Mark Adler 1995-2010 Jean-loup Gailly and Mark Adler "; License: zlib/libpng @@ -1989,7 +1989,7 @@ License: ISC Files: libs/esl/* Copyright: 2007 Michael Jerris 2002 Todd C. Miller - 2007-2012, Anthony Minessale II + 2007-2014, Anthony Minessale II 2000 The NetBSD Foundation, Inc. License: BSD-3-clause @@ -2052,7 +2052,7 @@ Copyright: 1995 Abandoned Colin Plumb License: public-domain Files: libs/stfu/* -Copyright: 2007-2012 Anthony Minessale II +Copyright: 2007-2014 Anthony Minessale II License: MIT/X11 (BSD like) Files: libs/sqlite/* @@ -2070,9 +2070,9 @@ Copyright: 1997-2008 University of Cambridge License: BSD-3-clause Files: libs/openzap/* -Copyright: 2005-2012, Anthony Minessale II - 2007-2012, Anthony Minessale II, Nenad Corbic - 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II + 2007-2014, Anthony Minessale II, Nenad Corbic + 2005-2014, Anthony Minessale II 2006 Nenad Corbic 2007 Jan Vidar Berger, Case Labs, Ltd. 2007,2008 Michael Jerris @@ -2098,13 +2098,13 @@ License: BSD-2-clause Files: libs/openzap/src/include/libteletone.h libs/openzap/mod_openzap/mod_openzap.c -Copyright: 2005-2012, Anthony Minessale II - 2005-2012, Anthony Minessale II +Copyright: 2005-2014, Anthony Minessale II + 2005-2014, Anthony Minessale II License: MPL-1.1 Files: libs/openzap/src/sangoma_pri.[ch] libs/openzap/src/priserver.c -Copyright: 2005-2012 Anthony Minessale II +Copyright: 2005-2014 Anthony Minessale II 2006 Nenad Corbic License: GPL-2+ diff --git a/debian/freeswitch-systemd.freeswitch.service b/debian/freeswitch-systemd.freeswitch.service index 1e7d2fcad1..3a734e3b37 100644 --- a/debian/freeswitch-systemd.freeswitch.service +++ b/debian/freeswitch-systemd.freeswitch.service @@ -32,4 +32,3 @@ UMask=0007 [Install] WantedBy=multi-user.target - diff --git a/debian/freeswitch-sysvinit.freeswitch.init b/debian/freeswitch-sysvinit.freeswitch.init index 920428adf6..fda8c4bd3e 100644 --- a/debian/freeswitch-sysvinit.freeswitch.init +++ b/debian/freeswitch-sysvinit.freeswitch.init @@ -4,6 +4,8 @@ # Provides: freeswitch # Required-Start: $network $remote_fs $local_fs # Required-Stop: $network $remote_fs $local_fs +# Should-Start: postgresql mysql memcached mongodb +# Should-Stop: postgresql mysql memcached mongodb # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: FreeSWITCH Softswitch diff --git a/debian/rules b/debian/rules index 7d7d50fd71..352ca36b59 100755 --- a/debian/rules +++ b/debian/rules @@ -2,19 +2,22 @@ # -*- mode:makefile -*- ##### Author: Travis Cross -#export DH_VERBOSE=1 +export DH_VERBOSE=1 +export VERBOSE=1 FS_CC?=gcc FS_CXX?=g++ -FS_CFLAGS?=-g3 -O2 -fPIC -FS_CPPFLAGS?= +FS_CPPFLAGS?=-D_FORTIFY_SOURCE=2 +FS_CFLAGS?=-g3 -O2 -fPIC -fstack-protector --param=ssp-buffer-size=4 FS_CXXFLAGS?=$(FS_CFLAGS) +FS_LDFLAGS?=-Wl,-z,relro export PATH?=/usr/lib/ccache:/usr/sbin:/usr/bin:/sbin:/bin -export CC=$(FS_CC) -export CXX=$(FS_CXX) -export CFLAGS=$(FS_CFLAGS) -export CPPFLAGS=$(FS_CPPFLAGS) -export CXXFLAGS=$(FS_CXXFLAGS) +export CC:=$(FS_CC) +export CXX:=$(FS_CXX) +export CPPFLAGS:=$(FS_CPPFLAGS) +export CFLAGS:=$(FS_CFLAGS) +export CXXFLAGS:=$(FS_CXXFLAGS) +export LDFLAGS:=$(FS_LDFLAGS) show_vars= \ echo; \ @@ -22,9 +25,10 @@ show_vars= \ echo "PATH='$(PATH)'"; \ echo "CC='$(CC)'"; \ echo "CXX='$(CXX)'"; \ - echo "CFLAGS='$(CFLAGS)'"; \ echo "CPPFLAGS='$(CPPFLAGS)'"; \ + echo "CFLAGS='$(CFLAGS)'"; \ echo "CXXFLAGS='$(CXXFLAGS)'"; \ + echo "LDFLAGS='$(LDFLAGS)'"; \ echo "CCACHE_DIR='$(CCACHE_DIR)'"; \ echo; @@ -78,7 +82,8 @@ override_dh_auto_clean: --with-grammardir=/usr/share/freeswitch/grammar \ --with-certsdir=/etc/freeswitch/tls \ --with-scriptdir=/usr/share/freeswitch/scripts \ - --with-recordingsdir=/var/lib/freeswitch/recordings + --with-recordingsdir=/var/lib/freeswitch/recordings \ + --enable-static-v8 touch $@ override_dh_auto_configure: .stamp-configure @@ -106,6 +111,12 @@ override_dh_installinit: dh_installinit -pfreeswitch-sysvinit --name=freeswitch dh_installinit -pfreeswitch-all --name=freeswitch +override_dh_makeshlibs: + dh_makeshlibs + sed \ + -e '/^libfreeswitch 1/{s/freeswitch-all/libfreeswitch1/g}' \ + -i debian/freeswitch-all/DEBIAN/shlibs + debian-bootstrap: debian/.stamp-bootstrap debian/.stamp-bootstrap: (cd debian && ./bootstrap.sh) @@ -127,4 +138,3 @@ binary-quicktest: echo "applications/mod_commands" > debian/modules.conf (cd debian && ./bootstrap.sh) dh binary - diff --git a/debian/util.sh b/debian/util.sh index 7825e13d54..4d69992697 100755 --- a/debian/util.sh +++ b/debian/util.sh @@ -101,13 +101,13 @@ getlibs () { getlib http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-v1.8-latest.tgz getlib http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz getlib http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz - getlib http://files.freeswitch.org/downloads/libs/soundtouch-1.6.0.tar.gz + getlib http://files.freeswitch.org/downloads/libs/soundtouch-1.7.1.tar.gz getlib http://files.freeswitch.org/downloads/libs/flite-1.5.4-current.tar.bz2 getlib http://files.freeswitch.org/downloads/libs/sphinxbase-0.7.tar.gz getlib http://files.freeswitch.org/downloads/libs/pocketsphinx-0.7.tar.gz getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz getlib http://files.freeswitch.org/downloads/libs/celt-0.10.0.tar.gz - getlib http://files.freeswitch.org/downloads/libs/opus-1.0.2.tar.gz + getlib http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz getlib http://files.freeswitch.org/downloads/libs/openldap-2.4.19.tar.gz getlib http://download.zeromq.org/zeromq-2.1.9.tar.gz \ || getlib http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz @@ -115,6 +115,7 @@ getlibs () { getlib http://files.freeswitch.org/downloads/libs/lame-3.98.4.tar.gz getlib http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz getlib http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz + getlib http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 # cleanup mongo ( cd mongo-cxx-driver-v1.8 @@ -208,12 +209,13 @@ EOF create_dsc () { { set -e - local OPTIND OPTARG modules_conf="" modules_list="" speed="normal" zl=9 - while getopts 'f:m:s:z:' o "$@"; do + local OPTIND OPTARG modules_conf="" modules_list="" speed="normal" suite_postfix="" suite_postfix_p=false zl=9 + while getopts 'f:m:s:u:z:' o "$@"; do case "$o" in f) modules_conf="$OPTARG";; m) modules_list="$OPTARG";; s) speed="$OPTARG";; + u) suite_postfix="$OPTARG"; suite_postfix_p=true; ;; z) zl="$OPTARG";; esac done @@ -222,6 +224,7 @@ create_dsc () { local suite="$(find_suite $distro)" local orig_ver="$(echo "$orig" | sed -e 's/^.*_//' -e 's/\.orig\.tar.*$//')" local dver="${orig_ver}-1~${distro}+1" + $suite_postfix_p && { suite="${distro}${suite_postfix}"; } [ -x "$(which dch)" ] \ || err "package devscripts isn't installed" if [ -n "$modules_conf" ]; then @@ -317,33 +320,46 @@ build_debs () { build_all () { local OPTIND OPTARG - local orig_opts="" dsc_opts="" deb_opts="" - local archs="" distros="" orig="" par=false - while getopts 'a:bc:df:jm:no:s:v:z:' o "$@"; do + local orig_opts="" dsc_opts="" deb_opts="" modlist="" + local archs="" distros="" orig="" depinst=false par=false + while getopts 'a:bc:df:ijl:m:no:s:u:v:z:' o "$@"; do case "$o" in a) archs="$archs $OPTARG";; b) orig_opts="$orig_opts -b";; c) distros="$distros $OPTARG";; d) deb_opts="$deb_opts -d";; f) dsc_opts="$dsc_opts -f$OPTARG";; + i) depinst=true;; j) par=true;; + l) modlist="$OPTARG";; m) orig_opts="$orig_opts -m$OPTARG"; dsc_opts="$dsc_opts -m$OPTARG";; n) orig_opts="$orig_opts -n";; o) orig="$OPTARG";; s) dsc_opts="$dsc_opts -s$OPTARG";; + u) dsc_opts="$dsc_opts -u$OPTARG";; v) orig_opts="$orig_opts -v$OPTARG";; z) orig_opts="$orig_opts -z$OPTARG"; dsc_opts="$dsc_opts -z$OPTARG";; esac done shift $(($OPTIND-1)) [ -n "$archs" ] || archs="amd64 i386" - [ -n "$distros" ] || distros="sid jessie wheezy squeeze" + [ -n "$distros" ] || distros="sid jessie wheezy" + ! $depinst || aptitude install -y \ + rsync git less cowbuilder ccache \ + devscripts equivs build-essential + [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" + if [ -n "$modlist" ]; then + local modtmp="$(mktemp /tmp/modules-XXXXXXXXXX.conf)" + > $modtmp + for m in "$modlist"; do printf '%s\n' "$m" >> $modtmp; done + dsc_opts="$dsc_opts -f${modtmp}"; fi [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" mkdir -p ../log > ../log/changes echo; echo; echo; echo trap 'echo "Killing children...">&2; for x in $(jobs -p); do kill $x; done' EXIT if [ "${orig:0:2}" = ".." ]; then + echo "true" > ../log/builds-ok for distro in $distros; do echo "Creating $distro dsc..." >&2 local dsc="$(create_dsc $dsc_opts $distro $orig 2>../log/$distro | tail -n1)" @@ -357,6 +373,8 @@ build_all () { echo "Done building $distro-$arch debs." >&2 if [ "${changes:0:2}" = ".." ]; then echo "$changes" >> ../log/changes + else + echo "false" > ../log/builds-ok fi } & $par || wait @@ -366,8 +384,10 @@ build_all () { done ! $par || wait fi + [ -z "$modlist" ] || rm -f $modtmp trap - EXIT cat ../log/changes + test "$(cat ../log/builds-ok)" = true || exit 1 } usage () { @@ -392,7 +412,9 @@ commands: -d Enable cowbuilder debug hook -f Build only modules listed in this file + -i Auto install build deps on host system -j Build debs in parallel + -l -m [ quicktest | non-dfsg ] Choose custom list of modules to build -n Nightly build @@ -400,6 +422,8 @@ commands: Specify existing .orig.tar.xz file -s [ paranoid | reckless ] Set FS bootstrap/build -j flags + -u + Specify a custom suite postfix -v Set version -z Set compression level @@ -421,6 +445,8 @@ commands: Choose custom list of modules to build -s [ paranoid | reckless ] Set FS bootstrap/build -j flags + -u + Specify a custom suite postfix -z Set compression level create-orig @@ -455,4 +481,3 @@ case "$cmd" in create-orig) create_orig "$@" ;; *) usage ;; esac - diff --git a/docs/AUTHORS b/docs/AUTHORS index 6e51a00585..93964dc388 100644 --- a/docs/AUTHORS +++ b/docs/AUTHORS @@ -38,6 +38,7 @@ that much better: Juan Jose Comellas - Patch to switch_utils for arg parsing. Dale Thatcher - Additions to mod_conference. Simon Perreault & Marc Blanchet from Viagenie.ca - IPv6 Support. + Peter Olsson - mod_v8, and other various patches. A big THANK YOU goes to: diff --git a/docs/Debugging b/docs/Debugging new file mode 100644 index 0000000000..078faf8691 --- /dev/null +++ b/docs/Debugging @@ -0,0 +1,19 @@ +How to Debug FreeSWITCH Issues +============================== + +Dumping a core file +------------------- + +Run: + + sysctl -w kernel.core_pattern=/tmp/core.%t_%e_s%s + sysctl -w fs.suid_dumpable=1 + ulimit -c unlimited + freeswitch -core + +Getting a backtrace from a core file +------------------------------------ + +Run: + + ./debian/scripts/backtrace-from-corefile /tmp/ diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches index e839ff128d..3ac732d349 100644 --- a/docs/SubmittingPatches +++ b/docs/SubmittingPatches @@ -108,10 +108,9 @@ submitted to JIRA. You can also reach us on freenode.net at: > #freeswitch-dev - + Finally, feel free to join us in our weekly conference call. Many of the core developers are often on the call and you'll have an opportunity at the beginning or end of the call to ask your questions: > http://wiki.freeswitch.org/wiki/Weekly_Conference_Call - diff --git a/docs/man/.gitignore b/docs/man/.gitignore new file mode 100644 index 0000000000..79a0cd25ae --- /dev/null +++ b/docs/man/.gitignore @@ -0,0 +1,2 @@ +*.1 +*.html diff --git a/docs/man/freeswitch.1.ronn b/docs/man/freeswitch.1.ronn new file mode 100644 index 0000000000..8022c93414 --- /dev/null +++ b/docs/man/freeswitch.1.ronn @@ -0,0 +1,155 @@ +freeswitch(1) -- scalable multi-protocol softswitch +=================================================== + +## SYNOPSIS + +`freeswitch` [] + +## DESCRIPTION + +`freeswitch` is a high-performance softswitch that supports many kinds +of telephony applications. It's commonly used as a PBX with SIP +endpoints. + +`freeswitch` expects a set of configuration files to exist in +/etc/freeswitch. Example configurations can be found in +/usr/share/freeswitch/conf. + +`freeswitch` is a modular system and modules can be loaded at runtime. + +`freeswitch` is started in the foreground by default but can also be +started as a daemon. + +## OPTIONS + + * `-h`: + Show inline help. + + * `-version`: + Print the version and exit. + + * `-nf`: + Stay in the foreground (default unless `-nc` is specified). + + * `-reincarnate`: + Restart the switch in the event of an uncontrolled exit. + + * `-reincarnate-reexec`: + Like `-reincarnate` but cause the switch binary to be run again + with execv. + + * `-u` : + Run setuid after starting the switch. + + * `-g` : + Run setgid after starting the switch. + + * `-core`: + Cause the switch to dump a core when crashing; you'll need to + ensure your system ulimits allow this, and if you've set `-u` or + `-g` you may also need to run: + + sysctl -w fs.suid_dumpable=1 + + * `-rp`: + Enable realtime priority. + + * `-lp`: + Enable low priority. + + * `-np`: + Enable normal priority. + + * `-vg`: + Run under Valgrind. + + * `-nosql`: + Disable the use of SQL for internal switch operations. + + * `-heavy-timer`: + Use a more expensive system timer that may be more accurate, but + note this may also impose heavier loads on your system. + + * `-nonat`: + When the switch starts, it runs checks to determine if it is + behind NAT; this flag disables these checks. + + * `-nonatmap`: + Disable automatic NAT port mapping. + + * `-nocal`: + When the switch starts, it calibrates itself to deviations in the + system clock; this flag disables this calibration. + + * `-nort`: + Disable use of clock_realtime. + + * `-stop`: + Stop the switch if running in the background. + + * `-nc`: + Disable the interactive console and cause the switch to go into + the background unless `-nf` is also specified. + + * `-ncwait`: + Like `-nc` but cause the parent process to wait until the switch + is started before exiting. + + * `-c`: + Enable the interactive console and stay in the foreground (this is + the default). + + * `-base` : + Set the prefix directory. + + * `-cfgname` : + Set the pathname to the main configuration file. + + * `-conf` : + Set the directory for configuration files. + + * `-log` : + Set the directory for log files. + + * `-run` : + Set the directory for temporary runtime files. + + * `-db` : + Set the directory for internal database files. + + * `-mod` : + Set the directory for runtime modules. + + * `-htdocs` : + Set the directory for htdocs. + + * `-scripts` : + Set the directory for call control scripts. + + * `-temp` : + Set the directory for temporary files. + + * `-grammar` : + Set the directory for grammar files. + + * `-recordings` : + Set the directory for call recordings. + + * `-storage` : + Set the directory for voicemail storage. + + * `-sounds` : + Set the directory for sound files. + +## AUTHORS + +FreeSWITCH was originally developed by `Anthony Minessale II +` with continued development by Anthony and a +team of active contributors. + +This man page and the packaging for Debian was written by `Travis +Cross `. + +## SEE ALSO + +sysctl(8), ulimit(1posix) diff --git a/docs/phrase/phrase_es_ES.xml b/docs/phrase/phrase_es_ES.xml index 791088697b..9a7521a065 100644 --- a/docs/phrase/phrase_es_ES.xml +++ b/docs/phrase/phrase_es_ES.xml @@ -35,6 +35,8 @@ + + @@ -186,13 +188,13 @@ - + - - + + @@ -222,34 +224,60 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + + @@ -264,16 +292,22 @@ - + + + + + + + - - + + @@ -338,7 +372,7 @@ - + @@ -346,7 +380,7 @@ - + @@ -368,9 +402,8 @@ - - + @@ -385,66 +418,46 @@ - + - - - - - - + - + - - - + + + - - + + - - - - + - + - - + + - + - - - - - - - - - - - - - + @@ -458,6 +471,12 @@ + + + + + + @@ -975,11 +994,11 @@ - + - - - + + + diff --git a/docs/phrase/phrase_es_MX.xml b/docs/phrase/phrase_es_MX.xml index 188b5c68b1..edabd9f45c 100644 --- a/docs/phrase/phrase_es_MX.xml +++ b/docs/phrase/phrase_es_MX.xml @@ -35,6 +35,8 @@ + + @@ -182,7 +184,7 @@ - + @@ -228,27 +230,53 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + + @@ -267,6 +295,12 @@ + + + + + + @@ -314,8 +348,8 @@ - - + + @@ -326,7 +360,7 @@ - + @@ -337,39 +371,38 @@ - + - + - + - - - + + + - + - - + + - + - - + @@ -384,66 +417,46 @@ - + - - - - - - + - + - - - + + + - - + + - - - - + - + - - + + - + - - - - - - - - - - - - - + @@ -457,6 +470,12 @@ + + + + + + @@ -974,11 +993,11 @@ - + - - - + + + diff --git a/docs/phrase/phrase_pt_BR.xml b/docs/phrase/phrase_pt_BR.xml index 9cc400c76b..b97472aa3f 100644 --- a/docs/phrase/phrase_pt_BR.xml +++ b/docs/phrase/phrase_pt_BR.xml @@ -1,987 +1,1007 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + + + + - - - - - - - - + + + + + + + + - + - - - + + + - - - - - + + + + + - + - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/phrase/phrase_pt_PT.xml b/docs/phrase/phrase_pt_PT.xml index a0e59deb85..6eacc8f6cb 100644 --- a/docs/phrase/phrase_pt_PT.xml +++ b/docs/phrase/phrase_pt_PT.xml @@ -34,6 +34,8 @@ + + @@ -224,10 +226,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -243,6 +270,7 @@ + @@ -261,6 +289,12 @@ + + + + + + @@ -273,7 +307,7 @@ - + @@ -285,7 +319,7 @@ - + @@ -361,9 +395,8 @@ - - + @@ -384,16 +417,11 @@ - - - - - @@ -408,10 +436,7 @@ - - - @@ -424,20 +449,8 @@ - - - - - - - - - - - - - + @@ -451,6 +464,12 @@ + + + + + + @@ -972,7 +991,7 @@ - + diff --git a/freeswitch-config-rayo.spec b/freeswitch-config-rayo.spec new file mode 100644 index 0000000000..92f504c058 --- /dev/null +++ b/freeswitch-config-rayo.spec @@ -0,0 +1,178 @@ +###################################################################################################################### +# +# freeswitch-config-rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application +# Copyright (C) 2013, Grasshopper +# +# Version: MPL 1.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is freeswitch-config-rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application +# +# The Initial Developer of the Original Code is Grasshopper +# Portions created by the Initial Developer are Copyright (C) +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chris Rienzo +# +# freeswitch-rayo-config -- RPM packaging for Rayo Server configuration +# +###################################################################################################################### + +%define version %{VERSION_NUMBER} +%define release %{BUILD_NUMBER} + +%define fsname freeswitch + +%define PREFIX %{_prefix} +%define EXECPREFIX %{_exec_prefix} +%define BINDIR %{_bindir} +%define SBINDIR %{_sbindir} +%define LIBEXECDIR %{_libexecdir}/%fsname +%define SYSCONFDIR %{_sysconfdir}/%fsname +%define SHARESTATEDIR %{_sharedstatedir}/%fsname +%define LOCALSTATEDIR %{_localstatedir}/lib/%fsname +%define LIBDIR %{_libdir} +%define INCLUDEDIR %{_includedir} +%define _datarootdir %{_prefix}/share +%define DATAROOTDIR %{_datarootdir} +%define DATADIR %{_datadir} +%define INFODIR %{_infodir} +%define LOCALEDIR %{_datarootdir}/locale +%define MANDIR %{_mandir} +%define DOCDIR %{_defaultdocdir}/%fsname +%define HTMLDIR %{_defaultdocdir}/%fsname/html +%define DVIDIR %{_defaultdocdir}/%fsname/dvi +%define PDFDIR %{_defaultdocdir}/%fsname/pdf +%define PSDIR %{_defaultdocdir}/%fsname/ps +%define LOGFILEDIR /var/log/%fsname +%define MODINSTDIR %{_libdir}/%fsname/mod +%define RUNDIR %{_localstatedir}/run/%fsname +%define DBDIR %{LOCALSTATEDIR}/db +%define HTDOCSDIR %{_datarootdir}/%fsname/htdocs +%define SOUNDSDIR %{_datarootdir}/%fsname/sounds +%define GRAMMARDIR %{_datarootdir}/%fsname/grammar +%define SCRIPTDIR %{_datarootdir}/%fsname/scripts +%define RECORDINGSDIR %{LOCALSTATEDIR}/recordings +%define PKGCONFIGDIR %{_datarootdir}/%fsname/pkgconfig +%define HOMEDIR %{LOCALSTATEDIR} + +Name: freeswitch-config-rayo +Version: %{version} +Release: %{release}%{?dist} +License: MPL1.1 +Summary: Rayo configuration for the FreeSWITCH Open Source telephone platform. +Group: System/Libraries +Packager: Chris Rienzo +URL: http://www.freeswitch.org/ +Source0: freeswitch-%{version}.tar.bz2 +Requires: freeswitch = %{version} +Requires: freeswitch-application-conference +Requires: freeswitch-application-esf +Requires: freeswitch-application-expr +Requires: freeswitch-application-fsv +Requires: freeswitch-application-http-cache +Requires: freeswitch-asrtts-flite +Requires: freeswitch-asrtts-pocketsphinx +Requires: freeswitch-codec-celt +Requires: freeswitch-codec-h26x +Requires: freeswitch-codec-ilbc +Requires: freeswitch-codec-opus +Requires: freeswitch-codec-vp8 +Requires: freeswitch-event-rayo +Requires: freeswitch-format-local-stream +Requires: freeswitch-format-mod-shout +Requires: freeswitch-format-shell-stream +Requires: freeswitch-format-ssml +Requires: freeswitch-sounds-music-8000 +Requires: freeswitch-sounds-music-16000 +Requires: freeswitch-sounds-music-32000 +Requires: freeswitch-sounds-music-48000 +Requires: freeswitch-lang-en +Requires: freeswitch-sounds-en-us-callie-8000 +Requires: freeswitch-sounds-en-us-callie-16000 +Requires: freeswitch-sounds-en-us-callie-32000 +Requires: freeswitch-sounds-en-us-callie-48000 +BuildRequires: bash +BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%description +FreeSWITCH rayo server implementation. + +%prep +%setup -b0 -q -n freeswitch-%{version} + +%build + +%install +%{__rm} -rf %{buildroot} +%{__install} -d -m 0750 %{buildroot}/%{SYSCONFDIR} +%{__install} -d -m 0750 %{buildroot}/%{SYSCONFDIR}/autoload_configs +%{__install} -d -m 0750 %{buildroot}/%{SYSCONFDIR}/dialplan +%{__install} -d -m 0750 %{buildroot}/%{SYSCONFDIR}/sip_profiles +%{__install} -d -m 0750 %{buildroot}/%{SYSCONFDIR}/directory +%{__cp} -prv ./conf/rayo/*.{xml,types,pem} %{buildroot}/%{SYSCONFDIR}/ +%{__cp} -prv ./conf/rayo/{autoload_configs,dialplan} %{buildroot}/%{SYSCONFDIR}/ +%{__cp} -prv ./conf/rayo/sip_profiles/external.xml %{buildroot}/%{SYSCONFDIR}/sip_profiles +%{__cp} -prv ./conf/rayo/sip_profiles/external %{buildroot}/%{SYSCONFDIR}/sip_profiles +%{__cp} -prv ./conf/rayo/directory %{buildroot}/%{SYSCONFDIR}/ + +%postun + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-,freeswitch,daemon) +%dir %attr(0750, freeswitch, daemon) %{SYSCONFDIR} +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/cacert.pem +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/*.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/mime.types +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/acl.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/cdr_csv.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/conference.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/console.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/event_socket.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/http_cache.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/local_stream.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/logfile.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/modules.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/pocketsphinx.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/post_load_modules.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/presence_map.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/rayo.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/shout.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/sofia.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/spandsp.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/ssml.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/switch.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/autoload_configs/timezones.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/dialplan/public.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/directory/default.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/directory/default/*.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/sip_profiles/*.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{SYSCONFDIR}/sip_profiles/external/*.xml + +### END OF config-rayo + +###################################################################################################################### +# +# Changelog +# +###################################################################################################################### +%changelog +* Mon Jun 03 2013 - crienzo@grasshopper.com +- Added users and internal profile for softphone testing +* Wed May 08 2013 - crienzo@grasshopper.com +- Initial revision + diff --git a/freeswitch-sounds-sv-se-jakob.spec b/freeswitch-sounds-sv-se-jakob.spec new file mode 100644 index 0000000000..06f91becb7 --- /dev/null +++ b/freeswitch-sounds-sv-se-jakob.spec @@ -0,0 +1,377 @@ +############################################################################## +# Copyright and license +############################################################################## +# +# Spec file for package freeswitch-sounds-sv-se-jakob (version 1.0.18-1) +# +# Copyright (c) 2009 Patrick Laimbock +# Some fixes and additions (c) 2011 Michal Bielicki +# Copied and modified for mod_say_sv (c) 2013 Jakob Sundberg +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# + +############################################################################## +# Determine distribution +############################################################################## + +# %define is_rhel5 %(test -f /etc/redhat-release && egrep -q 'release 5' /etc/redhat-release && echo 1 || echo 0) + +############################################################################## +# Set variables +############################################################################## + +%define version %{VERSION_NUMBER} +%define release %{BUILD_NUMBER} + +%define fsname freeswitch +# you could add a version number to be more strict + +%define PREFIX %{_prefix} +%define EXECPREFIX %{_exec_prefix} +%define BINDIR %{_bindir} +%define SBINDIR %{_sbindir} +%define LIBEXECDIR %{_libexecdir}/%{fsname} +%define SYSCONFDIR %{_sysconfdir}/%{fsname} +%define SHARESTATEDIR %{_sharedstatedir}/%{fsname} +%define LOCALSTATEDIR %{_localstatedir}/lib/%{fsname} +%define LIBDIR %{_libdir} +%define INCLUDEDIR %{_includedir} +%define _datarootdir %{_prefix}/share +%define DATAROOTDIR %{_datarootdir} +%define DATADIR %{_datadir} +%define INFODIR %{_infodir} +%define LOCALEDIR %{_datarootdir}/locale +%define MANDIR %{_mandir} +%define DOCDIR %{_defaultdocdir}/%{fsname} +%define HTMLDIR %{_defaultdocdir}/%{fsname}/html +%define DVIDIR %{_defaultdocdir}/%{fsname}/dvi +%define PDFDIR %{_defaultdocdir}/%{fsname}/pdf +%define PSDIR %{_defaultdocdir}/%{fsname}/ps +%define LOGFILEDIR /var/log/%{fsname} +%define MODINSTDIR %{_libdir}/%{fsname}/mod +%define RUNDIR %{_localstatedir}/run/%{fsname} +%define DBDIR %{LOCALSTATEDIR}/db +%define HTDOCSDIR %{_datarootdir}/%{fsname}/htdocs +%define SOUNDSDIR %{_datarootdir}/%{fsname}/sounds +%define GRAMMARDIR %{_datarootdir}/%{fsname}/grammar +%define SCRIPTDIR %{_datarootdir}/%{fsname}/scripts +%define RECORDINGSDIR %{LOCALSTATEDIR}/recordings +%define PKGCONFIGDIR %{_datarootdir}/%{fsname}/pkgconfig +%define HOMEDIR %{LOCALSTATEDIR} + + +############################################################################## +# General +############################################################################## + +Summary: FreeSWITCH sv-se Jakob prompts +Name: freeswitch-sounds-sv-se-jakob +Version: %{version} +Release: %{release}%{?dist} +License: MPL +Group: Applications/Communications +Packager: Patrick Laimbock +URL: http://www.freeswitch.org +Source0:http://files.freeswitch.org/%{name}-48000-%{version}.tar.bz2 +BuildArch: noarch +BuildRequires: sox +Requires: freeswitch +Requires: freeswitch-sounds-sv-se-jakob-48000 +Requires: sox +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%description +FreeSWITCH 48kHz sv-se jakob prompts plus, during the installation, +it will also install locally generated 8KHz, 16KHz and 32KHz prompts + +%package -n freeswitch-sounds-sv-se-jakob-8000 +Summary: FreeSWITCH 8kHz sv-se jakob prompts +Group: Applications/Communications +BuildArch: noarch +Requires: %{fsname} + +%description -n freeswitch-sounds-sv-se-jakob-8000 +FreeSWITCH 8kHz sv-se jakob prompts + +%package -n freeswitch-sounds-sv-se-jakob-16000 +Summary: FreeSWITCH 16kHz sv-se jakob prompts +Group: Applications/Communications +BuildArch: noarch +Requires: %{fsname} + +%description -n freeswitch-sounds-sv-se-jakob-16000 +FreeSWITCH 16kHz sv-se jakob prompts + +%package -n freeswitch-sounds-sv-se-jakob-32000 +Summary: FreeSWITCH 32kHz sv-se jakob prompts +Group: Applications/Communications +BuildArch: noarch +Requires: %{fsname} + +%description -n freeswitch-sounds-sv-se-jakob-32000 +FreeSWITCH 32kHz sv-se jakob prompts + +%package -n freeswitch-sounds-sv-se-jakob-48000 +Summary: FreeSWITCH 48kHz sv-se jakob prompts +Group: Applications/Communications +BuildArch: noarch +Requires: %{fsname} + +%description -n freeswitch-sounds-sv-se-jakob-48000 +FreeSWITCH 48kHz sv-se jakob prompts + +%package -n freeswitch-sounds-sv-se-jakob-all +Summary: FreeSWITCH sv-se jakob prompts +Group: Applications/Communications +BuildArch: noarch +Requires: %{fsname} +Requires: freeswitch-sounds-sv-se-jakob-8000 = %{version} +Requires: freeswitch-sounds-sv-se-jakob-16000 = %{version} +Requires: freeswitch-sounds-sv-se-jakob-32000 = %{version} +Requires: freeswitch-sounds-sv-se-jakob-48000 = %{version} + +%description -n freeswitch-sounds-sv-se-jakob-all +FreeSWITCH jakob prompts package that pulls in the 8KHz, 16KHz, +32KHz and 48KHz RPMs + +############################################################################## +# Prep +############################################################################## + +%prep +%setup -b0 -q -n en +mkdir -p ./usr/jakob +# create buildsounds-jakob.sh script in working dir +echo '#!/bin/bash + +sounds_location=$1 +for rate in 32000 16000 8000 +do + for i in ascii base256 conference currency digits directory ivr misc phonetic-ascii time voicemail zrtp + do + mkdir -p $sounds_location/$i/$rate + for f in `find $sounds_location/$i/48000 -name \*.wav` + do + echo "generating" $sounds_location/$i/$rate/`basename $f` + sox $f -r $rate $sounds_location/$i/$rate/`basename $f` + done + done +done' > ./sv/jakob/buildsounds-jakob.sh +%{__chmod} 0750 ./sv/jakob/buildsounds-jakob.sh + +############################################################################## +# Build +############################################################################## + +%build +# nothing to do here + +############################################################################## +# Install +############################################################################## + +%install +[ "%{buildroot}" != '/' ] && rm -rf %{buildroot} + +# create the sounds directories +%{__install} -d -m 0750 %{buildroot}%{SOUNDSDIR}/sv/se/jakob + +pushd sv/jakob +# first install the 48KHz sounds +%{__cp} -prv ./* %{buildroot}%{SOUNDSDIR}/sv/se/jakob +# now resample the 48KHz ones to 8KHz, 16KHz and 32KHz +./buildsounds-jakob.sh %{buildroot}%{SOUNDSDIR}/sv/se/jakob +popd + +############################################################################## +# Clean +############################################################################## + +%clean +[ "%{buildroot}" != '/' ] && rm -rf %{buildroot} + +############################################################################## +# Post +############################################################################## + +%post +# generate the 8KHz, 16KHz and 32KHz prompts from the 48KHz ones +cd %{SOUNDSDIR}/sv/se/jakob +./buildsounds-jakob.sh %{SOUNDSDIR}/sv/se/jakob + +############################################################################## +# Postun +############################################################################## + +%postun +# you could check if there are sound files in 8000/ or +# 16000/ or 32000/ and remove them *only* if the files +# do not belong to an rpm + +############################################################################## +# Files +############################################################################## + +%files +%defattr(-,root,root) +%attr(0750,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/buildsounds-jakob.sh + +%files -n freeswitch-sounds-sv-se-jakob-8000 +%defattr(-,root,root,-) +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ascii/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/base256/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/conference/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/currency/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/digits/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/directory/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ivr/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/misc/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/time/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/voicemail/8000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/zrtp/8000 +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ascii/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/base256/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/conference/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/currency/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/digits/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/directory/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ivr/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/misc/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/time/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/voicemail/8000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/zrtp/8000/*.wav + +%files -n freeswitch-sounds-sv-se-jakob-16000 +%defattr(-,root,root,-) +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ascii/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/base256/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/conference/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/currency/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/digits/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/directory/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ivr/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/misc/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/time/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/voicemail/16000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/zrtp/16000 +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ascii/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/base256/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/conference/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/currency/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/digits/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/directory/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ivr/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/misc/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/time/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/voicemail/16000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/zrtp/16000/*.wav + +%files -n freeswitch-sounds-sv-se-jakob-32000 +%defattr(-,root,root,-) +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ascii/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/base256/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/conference/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/currency/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/digits/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/directory/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ivr/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/misc/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/time/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/voicemail/32000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/zrtp/32000 +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ascii/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/base256/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/conference/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/currency/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/digits/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/directory/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ivr/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/misc/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/time/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/voicemail/32000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/zrtp/32000/*.wav + +%files -n freeswitch-sounds-sv-se-jakob-48000 +%defattr(-,root,root,-) +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ascii/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/base256/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/conference/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/currency/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/digits/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/directory/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/ivr/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/misc/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/time/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/voicemail/48000 +%attr(0750,freeswitch,daemon) %dir %{SOUNDSDIR}/sv/se/jakob/zrtp/48000 +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ascii/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/base256/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/conference/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/currency/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/digits/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/directory/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/ivr/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/misc/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/phonetic-ascii/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/time/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/voicemail/48000/*.wav +%attr(0640,freeswitch,daemon) %{SOUNDSDIR}/sv/se/jakob/zrtp/48000/*.wav + +%files -n freeswitch-sounds-sv-se-jakob-all + +############################################################################## +# Changelog +############################################################################## + +%changelog +* Sun Mar 05 2012 Ken Rice - 1.0.18-1 +- update to FHS Layout for FreeSWITCH +- bump up version +* Sun May 22 2011 Michal Bielicki - 1.0.16-1 +- bump up version +* Tue Jan 18 2011 Michal Bielicki - 1.0.14-1 +- bump up version +- include script into freeswitch core +- include specfile into freeswitch core +- runtime does not require sox, only building + +* Thu Dec 17 2009 Patrick Laimbock - 1.0.12-8 +- update perms and user/group to sync with the old situation + +* Wed Dec 16 2009 Patrick Laimbock - 1.0.12-7 +- make main package require freeswitch-sounds-sv-se-jakob-48000 and +- generate the 8KHz, 16KHz and 32KHz sounds from there +- add license to spec file + +* Wed Dec 16 2009 Patrick Laimbock - 1.0.12-5 +- put 48KHz in a separate package and let the main package Require 48KHz +- and then use the script to generate the 8KHz, 16KHz and 32KHz sounds + +* Wed Dec 16 2009 Patrick Laimbock - 1.0.12-4 +- add freeswitch-sounds-sv-se-jakob-all package that pulls in the 8KHz, +- 16KHz, 32KHz and 48KHz RPM packages + +* Tue Dec 15 2009 Patrick Laimbock - 1.0.12-3 +- override subpackage name with -n so it no longer builds an empty main RPM +- rework spec file +- add sox as a requirement +- run buildsounds-jakob.sh in post to generate 8KHz, 16KHz and 32KHz prompts + +* Tue Dec 15 2009 Patrick Laimbock - 1.0.12-2 +- can't override Name in subpackage so put all versions in RPM subpackages +- with an empty main RPM package + +* Tue Dec 15 2009 Patrick Laimbock - 1.0.12-1 +- create spec file with the following requirement: +- source only contains the 48KHz sound prompts +- during build the 48KHz sound prompts are resampled to 8KHz, 16KHz and 32KHz +- the 8KHz, 16KHz, 32KHz and 48KHz sound prompts are packaged separately + diff --git a/freeswitch.spec b/freeswitch.spec index 1454aa6779..82cddaf8c0 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -3,14 +3,14 @@ # spec file for package freeswitch # # includes module(s): freeswitch-devel freeswitch-codec-passthru-amr freeswitch-codec-passthru-amrwb freeswitch-codec-passthru-g729 -# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-perl freeswitch-python freeswitch-spidermonkey +# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-perl freeswitch-python freeswitch-spidermonkey freeswitch-v8 # freeswitch-lan-de freeswitch-lang-en freeswitch-lang-fr freeswitch-lang-hu freeswitch-lang-ru freeswitch-freetdm # # Initial Version Copyright (C) 2007 Peter Nixon and Michal Bielicki, All Rights Reserved. # # This file is part of: # FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -# Copyright (C) 2005-2012, Anthony Minessale II +# Copyright (C) 2005-2014, Anthony Minessale II # # This file and all modifications and additions to the pristine package are under the same license as the package itself. # @@ -22,6 +22,7 @@ # Marc Olivier Chouinard # Raymond Chandler # Ken Rice +# Chris Rienzo # # Maintainer(s): Ken Rice # @@ -33,6 +34,8 @@ %define build_py26_esl 0 %define build_timerfd 0 %define build_mod_esl 0 +%define build_mod_rayo 1 +%define build_mod_ssml 1 %{?with_sang_tc:%define build_sng_tc 1 } %{?with_sang_isdn:%define build_sng_isdn 1 } @@ -112,18 +115,19 @@ Vendor: http://www.freeswitch.org/ ###################################################################################################################### Source0: http://files.freeswitch.org/%{name}-%{version}.tar.bz2 Source1: http://files.freeswitch.org/downloads/libs/celt-0.10.0.tar.gz -Source2: http://files.freeswitch.org/downloads/libs/flite-1.5.1-current.tar.bz2 -Source3: http://files.freeswitch.org/downloads/libs/lame-3.97.tar.gz +Source2: http://files.freeswitch.org/downloads/libs/flite-1.5.4-current.tar.bz2 +Source3: http://files.freeswitch.org/downloads/libs/lame-3.98.4.tar.gz Source4: http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz Source5: http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz #Source6: http://files.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz Source6: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.7.tar.gz -Source7: http://files.freeswitch.org/downloads/libs/soundtouch-1.6.0.tar.gz +Source7: http://files.freeswitch.org/downloads/libs/soundtouch-1.7.1.tar.gz Source8: http://files.freeswitch.org/downloads/libs/sphinxbase-0.7.tar.gz Source9: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz Source10: http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz Source11: http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz -Source12: http://files.freeswitch.org/downloads/libs/opus-0.9.0.tar.gz +Source12: http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz +Source13: http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 Prefix: %{prefix} @@ -758,14 +762,6 @@ see http://www.polycom.com/usa/en/company/about_us/technology/siren_g7221/siren_ and http://www.polycom.com/usa/en/company/about_us/technology/siren14_g7221c/siren14_g7221c.html At the time of this packaging, Polycom does not charge for licensing. -%package codec-speex -Summary: Speex Codec support for FreeSWITCH open source telephony platform -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description codec-speex -Speex Codec support for FreeSWITCH open source telephony platform. - %package codec-theora Summary: Theora Video Codec support for FreeSWITCH open source telephony platform Group: System/Libraries @@ -977,6 +973,17 @@ Requires: %{name} = %{version}-%{release} %description event-json-cdr JSON CDR Logger for FreeSWITCH. +%if %{build_mod_rayo} +%package event-rayo +Summary: Rayo (XMPP 3PCC) server for the FreeSWITCH open source telephony platform +Group: System/Libraries +Requires: %{name} = %{version}-%{release} + +%description event-rayo +Rayo 3PCC for FreeSWITCH. http://rayo.org http://xmpp.org/extensions/xep-0327.html +Rayo is an XMPP protocol extension for third-party control of telephone calls. +%endif + %package event-snmp Summary: SNMP stats reporter for the FreeSWITCH open source telephony platform Group: System/Libraries @@ -1040,6 +1047,16 @@ Requires: %{name} = %{version}-%{release} Mod Shout is a FreeSWITCH module to allow you to stream audio from MP3s or a i shoutcast stream. +%if %{build_mod_ssml} +%package format-ssml +Summary: Adds Speech Synthesis Markup Language (SSML) parser format for the FreeSWITCH open source telephony platform +Group: System/Libraries +Requires: %{name} = %{version}-%{release} + +%description format-ssml +mod_ssml is a FreeSWITCH module that renders SSML into audio. This module requires a text-to-speech module for speech synthesis. +%endif + %package format-tone-stream Summary: Implements TGML Tone Generation for the FreeSWITCH open source telephony platform Group: System/Libraries @@ -1078,10 +1095,17 @@ Requires: python %package spidermonkey Summary: JavaScript support for the FreeSWITCH open source telephony platform Group: System/Libraries -Requires: %{name} = %{version}-%{release} +Requires: %{name} = %{version}-%{release} %description spidermonkey +%package v8 +Summary: JavaScript support for the FreeSWITCH open source telephony platform, using Google V8 JavaScript engine +Group: System/Libraries +Requires: %{name} = %{version}-%{release} + +%description v8 + ###################################################################################################################### # FreeSWITCH Say Modules ###################################################################################################################### @@ -1140,7 +1164,15 @@ Group: System/Libraries Requires: %{name} = %{version}-%{release} %description lang-pt -Hebrew language phrases module and directory structure for say module and voicemail +Portugese language phrases module and directory structure for say module and voicemail + +%package lang-sv +Summary: Provides Swedish language dependend modules and speech config for the FreeSWITCH Open Source telephone platform. +Group: System/Libraries +Requires: %{name} = %{version}-%{release} + +%description lang-sv +Swedish language phrases module and directory structure for say module and voicemail ###################################################################################################################### # FreeSWITCH Timer Modules @@ -1244,7 +1276,6 @@ Requires: freeswitch-codec-passthru-g729 Requires: freeswitch-codec-h26x Requires: freeswitch-codec-ilbc Requires: freeswitch-codec-siren -Requires: freeswitch-codec-speex Requires: freeswitch-format-local-stream Requires: freeswitch-format-native-file Requires: freeswitch-format-portaudio-stream @@ -1336,7 +1367,7 @@ ASR_TTS_MODULES="asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_comm ###################################################################################################################### CODECS_MODULES="codecs/mod_amr codecs/mod_amrwb codecs/mod_bv codecs/mod_celt codecs/mod_codec2 codecs/mod_g723_1 \ codecs/mod_g729 codecs/mod_h26x codecs/mod_ilbc codecs/mod_isac codecs/mod_mp4v codecs/mod_opus codecs/mod_silk \ - codecs/mod_siren codecs/mod_speex codecs/mod_theora codecs/mod_vp8" + codecs/mod_siren codecs/mod_theora codecs/mod_vp8" # %if %{build_sng_tc} CODECS_MODULES+="codecs/mod_sangoma_codec" @@ -1376,6 +1407,9 @@ EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_cdr_pg_csv event_handlers/mod_cdr_mongodb event_handlers/mod_erlang_event event_handlers/mod_event_multicast \ event_handlers/mod_event_socket event_handlers/mod_json_cdr \ event_handlers/mod_snmp" +%if %{build_mod_rayo} +EVENT_HANDLERS_MODULES+=" event_handlers/mod_rayo" +%endif #### BUILD ISSUES NET RESOLVED FOR RELEASE event_handlers/mod_event_zmq ###################################################################################################################### @@ -1385,13 +1419,17 @@ EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_cdr_pg_csv ###################################################################################################################### FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_portaudio_stream \ formats/mod_shell_stream formats/mod_shout formats/mod_sndfile formats/mod_tone_stream" +%if %{build_mod_ssml} +FORMATS_MODULES+=" formats/mod_ssml" +%endif ###################################################################################################################### # # Embedded Languages # ###################################################################################################################### -LANGUAGES_MODULES="languages/mod_lua languages/mod_perl languages/mod_python languages/mod_spidermonkey" +LANGUAGES_MODULES="languages/mod_lua languages/mod_perl languages/mod_python languages/mod_spidermonkey " +#LANGUAGES_MODULES+="languages/mod_v8" ###################################################################################################################### # @@ -1405,7 +1443,7 @@ LOGGERS_MODULES="loggers/mod_console loggers/mod_logfile loggers/mod_syslog" # Phrase engine language modules # ###################################################################################################################### -SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_he say/mod_say_ru" +SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_he say/mod_say_ru say/mod_say_sv" ###################################################################################################################### # @@ -1606,7 +1644,8 @@ fi # What to install where ... first set default permissions # ###################################################################################################################### -%defattr(-,freeswitch,daemon) +%defattr(-,root,root) + ###################################################################################################################### # # Directories @@ -1618,11 +1657,11 @@ fi %dir %attr(0750, freeswitch, daemon) %{sysconfdir} %dir %attr(0750, freeswitch, daemon) %{LOCALSTATEDIR} %dir %attr(0750, freeswitch, daemon) %{DBDIR} -%dir %attr(0750, freeswitch, daemon) %{GRAMMARDIR} -%dir %attr(0750, freeswitch, daemon) %{HTDOCSDIR} +%dir %attr(0755, -, -) %{GRAMMARDIR} +%dir %attr(0755, -, -) %{HTDOCSDIR} %dir %attr(0750, freeswitch, daemon) %{logfiledir} %dir %attr(0750, freeswitch, daemon) %{runtimedir} -%dir %attr(0750, freeswitch, daemon) %{SCRIPTDIR} +%dir %attr(0755, -, -) %{SCRIPTDIR} # #################################### Config Directory Structure ####################################################### # @@ -1643,19 +1682,15 @@ fi # #################################### Grammar Directory Structure ##################################################### # -%dir %attr(0750, freeswitch, daemon) %{GRAMMARDIR}/model -%dir %attr(0750, freeswitch, daemon) %{GRAMMARDIR}/model/communicator -%ifos linux -%config(noreplace) %attr(0644, freeswitch, daemon) /etc/monit.d/freeswitch.monitrc -%endif - +%dir %attr(0755, -, -) %{GRAMMARDIR}/model +%dir %attr(0755, -, -) %{GRAMMARDIR}/model/communicator ###################################################################################################################### # -# Other Fíles +# Other Files # ###################################################################################################################### -%config(noreplace) %attr(0640, freeswitch, daemon) %{HTDOCSDIR}/* +%config(noreplace) %attr(0644,-,-) %{HTDOCSDIR}/* %ifos linux /etc/rc.d/init.d/freeswitch /etc/sysconfig/freeswitch @@ -1664,14 +1699,16 @@ fi %endif %endif %ifos linux -%dir %attr(0750, root, root) /etc/monit.d +%dir %attr(0750,-,-) /etc/monit.d +%config(noreplace) %attr(0644,-,-) /etc/monit.d/freeswitch.monitrc %endif + ###################################################################################################################### # # Binaries # ###################################################################################################################### -%attr(0755, freeswitch, daemon) %{prefix}/bin/* +%attr(0755,-,-) %{prefix}/bin/* %{LIBDIR}/libfreeswitch*.so* ###################################################################################################################### # @@ -1700,12 +1737,10 @@ fi # ###################################################################################################################### %files devel -%defattr(-, freeswitch, daemon) %{LIBDIR}/*.a %{LIBDIR}/*.la %{PKGCONFIGDIR}/* -%{MODINSTDIR}/*.a -%{MODINSTDIR}/*.la +%{MODINSTDIR}/*.*a %{INCLUDEDIR}/*.h @@ -1743,6 +1778,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/event_socket.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/fax.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/fifo.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/format_cdr.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/hash.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/httapi.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/http_cache.conf.xml @@ -1819,8 +1855,8 @@ fi ###################################################################################################################### # Grammar Files ###################################################################################################################### -%config(noreplace) %attr(0640, freeswitch, daemon) %{GRAMMARDIR}/default.dic -%config(noreplace) %attr(0640, freeswitch, daemon) %{GRAMMARDIR}/model/communicator/* +%config(noreplace) %attr(0644, -, -) %{GRAMMARDIR}/default.dic +%config(noreplace) %attr(0644, -, -) %{GRAMMARDIR}/model/communicator/* ### END OF config-vanilla @@ -1830,170 +1866,130 @@ fi # ###################################################################################################################### %files application-abstraction -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_abstraction.so* %files application-avmd -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_avmd.so* %files application-blacklist -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_blacklist.so* %files application-callcenter -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_callcenter.so* %files application-cidlookup -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_cidlookup.so* %files application-conference -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_conference.so* %files application-curl -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_curl.so* %files application-db -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_db.so* %files application-directory -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_directory.so* %files application-distributor -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_distributor.so* %files application-easyroute -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_easyroute.so* %files application-enum -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_enum.so* %files application-esf -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_esf.so* %if %{build_mod_esl} %files application-esl -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_esl.so* %endif %files application-expr -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_expr.so* %files application-fifo -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_fifo.so* %files application-fsk -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_fsk.so* %files application-fsv -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_fsv.so* %files application-hash -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_hash.so* %files application-httapi -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_httapi.so* %files application-http-cache -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_http_cache.so* %files application-lcr -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_lcr.so* %files application-limit -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_limit.so* %files application-memcache -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_memcache.so* %files application-nibblebill -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_nibblebill.so* %files application-redis -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_redis.so* %files application-rss -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_rss.so* %files application-sms -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_sms.so* %files application-snapshot -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_snapshot.so* %files application-snom -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_snom.so* %files application-soundtouch -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_soundtouch.so* %files application-spy -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_spy.so* %files application-stress -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_stress.so* %files application-valet_parking -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_valet_parking.so* %files application-voicemail -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_voicemail.so* %files application-voicemail-ivr -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_voicemail_ivr.so* ###################################################################################################################### # -# ASR RRS Packages +# ASR TTS Packages # ###################################################################################################################### %files asrtts-flite -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_flite.so* %files asrtts-pocketsphinx -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_pocketsphinx.so* %files asrtts-tts-commandline -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_tts_commandline.so* %files asrtts-unimrcp -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_unimrcp.so* ###################################################################################################################### @@ -2003,78 +1999,58 @@ fi ###################################################################################################################### %files codec-passthru-amr -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_amr.so* %files codec-passthru-amrwb -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_amrwb.so* %files codec-bv -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_bv.so* %files codec-celt -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_celt.so* %files codec-codec2 -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_codec2.so* %files codec-passthru-g723_1 -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_g723_1.so* %files codec-passthru-g729 -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_g729.so* %files codec-h26x -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_h26x.so* %files codec-ilbc -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_ilbc.so* %files codec-isac -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_isac.so* %files codec-mp4v -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_mp4v.so* %files codec-vp8 -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_vp8.so* %files codec-opus -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_opus.so* +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/opus.conf.xml %if %{build_sng_tc} %files sangoma-codec -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_sangoma_codec.so* %endif %files codec-silk -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_silk.so* %files codec-siren -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_siren.so* -%files codec-speex -%defattr(-,freeswitch,daemon) -%{MODINSTDIR}/mod_speex.so* - %files codec-theora -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_theora.so* ###################################################################################################################### @@ -2084,8 +2060,7 @@ fi ###################################################################################################################### #%files directory-ldap -#%defattr(-,freeswitch,daemon) -#%{MODINSTDIR}/mod_theora.so* +#%{MODINSTDIR}/mod_ldap.so* ###################################################################################################################### # @@ -2094,35 +2069,27 @@ fi ###################################################################################################################### %files endpoint-dingaling -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_dingaling.so* #%files endpoint-gsmopen -#%defattr(-,freeswitch,daemon) #%{MODINSTDIR}/mod_gsmopen.so* #%files endpoint-h323 -#%defattr(-,freeswitch,daemon) #%{MODINSTDIR}/mod_h323.so* #%files endpoint-khomp -#%defattr(-,freeswitch,daemon) #%{MODINSTDIR}/mod_khomp.so* %files endpoint-portaudio -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_portaudio.so* %files endpoint-rtmp -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_rtmp.so* %files endpoint-skinny -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_skinny.so* %files endpoint-skypopen -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_skypopen.so* ###################################################################################################################### @@ -2131,7 +2098,6 @@ fi # ###################################################################################################################### %files freetdm -%defattr(-, freeswitch, daemon) %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/tones.conf %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/freetdm.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/pika.conf @@ -2145,13 +2111,11 @@ fi %if %{build_sng_ss7} %files freetdm-sng-ss7 -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/ftmod_sangoma_ss7.so* %endif %if %{build_sng_isdn} %files freetdm-sng-isdn -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/ftmod_sangoma_isdn.so* %endif @@ -2162,35 +2126,32 @@ fi ###################################################################################################################### %files event-cdr-mongodb -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_cdr_mongodb.so* %files event-cdr-pg-csv -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_cdr_pg_csv.so* %files event-cdr-sqlite -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_cdr_sqlite.so* %files event-erlang-event -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_erlang_event.so* %files event-multicast -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_event_multicast.so* #%files event-zmq -#%defattr(-, freeswitch, daemon) #%{MODINSTDIR}/mod_xmq.so* %files event-json-cdr -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_json_cdr.so* +%if %{build_mod_rayo} +%files event-rayo +%{MODINSTDIR}/mod_rayo.so* +%endif + %files event-snmp -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_snmp.so* ###################################################################################################################### @@ -2200,27 +2161,26 @@ fi ###################################################################################################################### %files format-local-stream -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_local_stream.so* %files format-native-file -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_native_file.so* %files format-portaudio-stream -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_portaudio_stream.so* %files format-shell-stream -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_shell_stream.so* %files format-mod-shout -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_shout.so* +%if %{build_mod_ssml} +%files format-ssml +%{MODINSTDIR}/mod_ssml.so* +%endif + %files format-tone-stream -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_tone_stream.so* ###################################################################################################################### @@ -2229,20 +2189,17 @@ fi # ###################################################################################################################### %files lua -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_lua*.so* %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/lua.conf.xml %files perl -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_perl*.so* %{prefix}/perl/* %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/perl.conf.xml %files python -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_python*.so* %attr(0644, root, bin) /usr/lib/python*/site-packages/freeswitch.py* %attr(0755, root, bin) /usr/lib/python*/site-packages/_ESL.so* @@ -2251,7 +2208,6 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/python.conf.xml %files spidermonkey -%defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_spidermonkey*.so* %{LIBDIR}/libjs.so* %{LIBDIR}/libnspr4.so @@ -2260,13 +2216,20 @@ fi %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/spidermonkey.conf.xml +%files v8 +#%{MODINSTDIR}/mod_v8*.so* +#%{LIBDIR}/libv8.so +#%{LIBDIR}/libicui18n.so +#%{LIBDIR}/libicuuc.so +#%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/v8.conf.xml + ###################################################################################################################### # # Language Modules # ###################################################################################################################### %files lang-en -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/en %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/en/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/en/vm @@ -2280,7 +2243,6 @@ fi %{MODINSTDIR}/mod_say_en.so* %files lang-de -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/de %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/de/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/de/vm @@ -2290,7 +2252,6 @@ fi %{MODINSTDIR}/mod_say_de.so* %files lang-fr -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/fr %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/fr/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/fr/vm @@ -2302,7 +2263,6 @@ fi %{MODINSTDIR}/mod_say_fr.so* %files lang-ru -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/ru %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/ru/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/ru/vm @@ -2314,7 +2274,6 @@ fi %{MODINSTDIR}/mod_say_ru.so* %files lang-he -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/he/ %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/he/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/he/vm @@ -2326,7 +2285,6 @@ fi %{MODINSTDIR}/mod_say_he.so* %files lang-es -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/es %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/es/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/es/vm @@ -2338,7 +2296,6 @@ fi %{MODINSTDIR}/mod_say_en.so* %files lang-pt -%defattr(-, freeswitch, daemon) %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/pt %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/pt/demo %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/pt/vm @@ -2349,6 +2306,13 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/pt/dir/*.xml %{MODINSTDIR}/mod_say_en.so* +%files lang-sv +%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/sv +%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/sv/vm +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/sv/*.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/sv/vm/*.xml +%{MODINSTDIR}/mod_say_sv.so* + ###################################################################################################################### # # Timer Modules @@ -2356,12 +2320,10 @@ fi ###################################################################################################################### %files timer-posix -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_posix_timer.so* %if %{build_timerfd} %files timer-timerfd -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_timerfd.so* %endif @@ -2372,11 +2334,9 @@ fi ###################################################################################################################### %files xml-cdr -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_xml_cdr.so* %files xml-curl -%defattr(-, freeswitch, daemon) %{MODINSTDIR}/mod_xml_curl.so* ###################################################################################################################### @@ -2385,6 +2345,17 @@ fi # ###################################################################################################################### %changelog +* Fri Feb 21 2014 - crienzo@grasshopper.com +- change file owner to root +* Wed Feb 19 2014 - crienzo@grasshopper.com +- remove mod_speex +* Sun Feb 02 2014 - jakob@mress.se +- add support for building Swedish say language module +* Mon Jan 13 2014 - peter@olssononline.se +- Add mod_v8 +* Mon Dec 09 2013 - crienzo@grasshopper.com +- Add mod_ssml, mod_rayo +- Fix build on master * Thu Jun 28 2013 - krice@freeswitch.org - Add module for VP8 * Thu Jun 19 2013 - krice@freeswitch.org diff --git a/fscomm/call.cpp b/fscomm/call.cpp index d60084d483..b75727fee0 100644 --- a/fscomm/call.cpp +++ b/fscomm/call.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/call.h b/fscomm/call.h index 72ea93f6de..c7a31844b8 100644 --- a/fscomm/call.h +++ b/fscomm/call.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/debugtools/sortfilterproxymodel.h b/fscomm/debugtools/sortfilterproxymodel.h index d157856bfc..7f14dae10e 100644 --- a/fscomm/debugtools/sortfilterproxymodel.h +++ b/fscomm/debugtools/sortfilterproxymodel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index a113b33958..4fb8d4c062 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/fshost.h b/fscomm/fshost.h index 59cf2024e9..9ce5d6dfa6 100644 --- a/fscomm/fshost.h +++ b/fscomm/fshost.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/main.cpp b/fscomm/main.cpp index 18a97e2757..b76f943a3f 100644 --- a/fscomm/main.cpp +++ b/fscomm/main.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 8f1323b374..87a0f4e933 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/mainwindow.h b/fscomm/mainwindow.h index 33f36b87ba..5a4d404603 100644 --- a/fscomm/mainwindow.h +++ b/fscomm/mainwindow.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/.gitignore b/libs/.gitignore index 8fca0c8c42..4f048d2620 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -980,6 +980,7 @@ opal /zeromq-*/ /jpeg-8d/ +/v8-*/ # build products we should remove !/apr-util/xml/expat/conftools/config.guess diff --git a/libs/apr/atomic/win32/apr_atomic.c b/libs/apr/atomic/win32/apr_atomic.c index 9393fcb008..18a7bcd0ba 100644 --- a/libs/apr/atomic/win32/apr_atomic.c +++ b/libs/apr/atomic/win32/apr_atomic.c @@ -27,6 +27,7 @@ APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) * Remapping function pointer type to accept apr_uint32_t's type-safely * as the arguments for as our apr_atomic_foo32 Functions */ +#if (_MSC_VER < 1800) typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn) (apr_uint32_t volatile *); typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_fn) @@ -38,11 +39,14 @@ typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn) typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_ptr_fn) (volatile void **, void *, const void *); +#endif APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) return InterlockedExchangeAdd(mem, val); +#elif (_MSC_VER >= 1800) + return InterlockedExchangeAdd(mem, val); #else return ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val); #endif @@ -55,6 +59,8 @@ APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) InterlockedExchangeAdd(mem, -val); +#elif (_MSC_VER >= 1800) + InterlockedExchangeAdd(mem, -val); #else ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val); #endif @@ -65,6 +71,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) /* we return old value, win32 returns new value :( */ #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedIncrement(mem) - 1; +#elif (_MSC_VER >= 1800) + return InterlockedIncrement(mem) - 1; #else return ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1; #endif @@ -74,6 +82,8 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedDecrement(mem); +#elif (_MSC_VER >= 1800) + return InterlockedDecrement(mem); #else return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem); #endif @@ -83,6 +93,8 @@ APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) InterlockedExchange(mem, val); +#elif (_MSC_VER >= 1800) + InterlockedExchange(mem, val); #else ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); #endif @@ -98,6 +110,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint3 { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedCompareExchange(mem, with, cmp); +#elif (_MSC_VER >= 1800) + return InterlockedCompareExchange(mem, with, cmp); #else return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp); #endif @@ -107,6 +121,8 @@ APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const voi { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedCompareExchangePointer(mem, with, cmp); +#elif (_MSC_VER >= 1800) + return InterlockedCompareExchangePointer(mem, with, cmp); #else /* Too many VC6 users have stale win32 API files, stub this */ return ((apr_atomic_win32_ptr_ptr_ptr_fn)InterlockedCompareExchange)(mem, with, cmp); @@ -117,6 +133,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedExchange(mem, val); +#elif (_MSC_VER >= 1800) + return InterlockedExchange(mem, val); #else return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); #endif diff --git a/libs/broadvoice/src/libbroadvoice.2012.vcxproj b/libs/broadvoice/src/libbroadvoice.2012.vcxproj index a01905aa7a..bf65fc7163 100644 --- a/libs/broadvoice/src/libbroadvoice.2012.vcxproj +++ b/libs/broadvoice/src/libbroadvoice.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -84,6 +84,7 @@ MultiThreadedDebugDLL Level4 CompileAsC + 4244;%(DisableSpecificWarnings) true @@ -98,6 +99,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;BROADVOICE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 + 4244;%(DisableSpecificWarnings) true @@ -120,6 +122,7 @@ EnableFastChecks MultiThreadedDebugDLL CompileAsC + 4244;%(DisableSpecificWarnings) true @@ -137,6 +140,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;BROADVOICE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 + 4244;%(DisableSpecificWarnings) true diff --git a/libs/curl/lib/config-win32.h b/libs/curl/lib/config-win32.h index 871e6bef6c..837b1a5d65 100644 --- a/libs/curl/lib/config-win32.h +++ b/libs/curl/lib/config-win32.h @@ -296,7 +296,7 @@ /* Define to 'int' if ssize_t is not an available 'typedefed' type */ #if (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || defined(__POCC__) #else -#define ssize_t int +#define ssize_t intptr_t #endif /* Define to 'int' if socklen_t is not an available 'typedefed' type */ diff --git a/libs/curl/lib/strequal.h b/libs/curl/lib/strequal.h index 6ec88d82d7..ce83d48aef 100644 --- a/libs/curl/lib/strequal.h +++ b/libs/curl/lib/strequal.h @@ -38,6 +38,6 @@ char *Curl_strcasestr(const char *haystack, const char *needle); #ifndef HAVE_STRLCAT #define strlcat(x,y,z) Curl_strlcat(x,y,z) #endif -size_t strlcat(char *dst, const char *src, size_t siz); +//size_t strlcat(char *dst, const char *src, size_t siz); #endif diff --git a/libs/esl/.gitignore b/libs/esl/.gitignore new file mode 100644 index 0000000000..8c6f167b4c --- /dev/null +++ b/libs/esl/.gitignore @@ -0,0 +1,3 @@ +eslmake.rules +testserver_fork + diff --git a/libs/esl/Makefile b/libs/esl/Makefile index 727bf3169f..3e59a9dc0c 100644 --- a/libs/esl/Makefile +++ b/libs/esl/Makefile @@ -17,7 +17,7 @@ SOLINK=-shared -Xlinker -x # comment the next line to disable c++ (no swig mods for you then) OBJS += src/esl_oop.o -all: $(MYLIB) fs_cli testclient testserver ivrd +all: $(MYLIB) fs_cli testclient testserver testserver_fork ivrd $(MYLIB): $(OBJS) $(HEADERS) $(SRC) ar rcs $(MYLIB) $(OBJS) @@ -26,6 +26,9 @@ $(MYLIB): $(OBJS) $(HEADERS) $(SRC) testserver: $(MYLIB) testserver.c $(CC) $(CC_CFLAGS) $(CFLAGS) testserver.c -o testserver $(LDFLAGS) $(LIBS) +testserver_fork: $(MYLIB) testserver_fork.c + $(CC) $(CC_CFLAGS) $(CFLAGS) testserver_fork.c -o testserver_fork $(LDFLAGS) $(LIBS) + ivrd: $(MYLIB) ivrd.c $(CC) $(CC_CFLAGS) $(CFLAGS) ivrd.c -o ivrd $(LDFLAGS) $(LIBS) @@ -42,7 +45,7 @@ fs_cli: $(MYLIB) fs_cli.c $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) -c $< -o $@ clean: - rm -f *.o src/*.o testclient testserver ivrd fs_cli libesl.a *~ src/*~ src/include/*~ + rm -f *.o src/*.o testclient testserver testserver_fork ivrd fs_cli libesl.a *~ src/*~ src/include/*~ $(MAKE) -C perl clean $(MAKE) -C php clean $(MAKE) -C lua clean diff --git a/libs/esl/eslmake.rules.in b/libs/esl/eslmake.rules.in index 0a1fe7f624..9eadd41550 100644 --- a/libs/esl/eslmake.rules.in +++ b/libs/esl/eslmake.rules.in @@ -1,2 +1,3 @@ TINFO_LIBS=@TINFO_LIBS@ +CXX=@CXX@ diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 05286ecc49..389772cdda 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -85,7 +85,9 @@ static int running = 1; static int thread_running = 0; static char *filter_uuid; static char *logfilter; -#ifndef WIN32 +static int timeout = 0; +static int connect_timeout = 0; +#ifdef HAVE_EDITLINE static EditLine *el; static History *myhistory; static HistEvent ev; @@ -112,6 +114,7 @@ static void sleep_s(int secs) { _sleep_ns(secs, 0); } static int process_command(esl_handle_t *handle, const char *cmd); +#if defined(HAVE_EDITLINE) || defined(WIN32) static void clear_cli(void) { if (global_profile->batch_mode) return; putchar('\r'); @@ -119,6 +122,7 @@ static void clear_cli(void) { printf("\033[K"); fflush(stdout); } +#endif static void screen_size(int *x, int *y) { @@ -145,6 +149,7 @@ static void screen_size(int *x, int *y) } +#if defined(HAVE_EDITLINE) || defined(WIN32) /* If a fnkey is configured then process the command */ static unsigned char console_fnkey_pressed(int i) { @@ -162,6 +167,7 @@ static unsigned char console_fnkey_pressed(int i) } return CC_REDISPLAY; } +#endif #ifdef HAVE_EDITLINE static char *prompt(EditLine *e) { return prompt_str; } @@ -603,6 +609,7 @@ static const char *usage_str = " -d, --debug=level Debug Level (0 - 7)\n" " -b, --batchmode Batch mode\n" " -t, --timeout Timeout for API commands (in miliseconds)\n" + " -T, --connect-timeout Timeout for socket connection (in miliseconds)\n" " -n, --no-color Disable color\n\n"; static int usage(char *name){ @@ -671,7 +678,7 @@ static void clear_line(void) static void redisplay(void) { -#ifndef WIN32 +#ifdef HAVE_EDITLINE const LineInfo *lf = el_line(el); const char *c = lf->buffer; if (global_profile->batch_mode) return; @@ -807,7 +814,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) } warn_stop = 0; } - sleep_ms(1); + //sleep_ms(1); } thread_running = 0; esl_log(ESL_LOG_DEBUG, "Thread Done\n"); @@ -1063,6 +1070,7 @@ static void set_fn_keys(cli_profile_t *profile) profile->console_fnkeys[11] = "version"; } +#if defined(HAVE_EDITLINE) || defined(WIN32) static char* end_of_str(char *s) { return (*s == '\0' ? s : s + strlen(s) - 1); } static char* _strndup(const char *s, int n) @@ -1151,6 +1159,7 @@ static unsigned char esl_console_complete(const char *buffer, const char *cursor esl_safe_free(dup); return ret; } +#endif /* if defined(HAVE_EDITLINE) || defined(WIN32) */ #ifdef HAVE_EDITLINE static unsigned char complete(EditLine *el, int ch) @@ -1249,6 +1258,10 @@ static void read_config(const char *dft_cfile, const char *cfile) { profiles[pcount-1].console_fnkeys[i - 1] = strdup(val); } } + } else if (!strcasecmp(var, "timeout")) { + timeout = atoi(val); + } else if (!strcasecmp(var, "connect-timeout")) { + connect_timeout = atoi(val); } } esl_config_close_file(&cfg); @@ -1301,6 +1314,7 @@ int main(int argc, char *argv[]) {"interrupt", 0, 0, 'i'}, {"reconnect", 0, 0, 'R'}, {"timeout", 1, 0, 't'}, + {"connect-timeout", 1, 0, 'T'}, {0, 0, 0, 0} }; char temp_host[128]; @@ -1319,7 +1333,7 @@ int main(int argc, char *argv[]) int argv_log_uuid = 0; int argv_quiet = 0; int argv_batch = 0; - int loops = 2, reconnect = 0, timeout = 0; + int loops = 2, reconnect = 0; char *ccheck; #ifdef WIN32 @@ -1354,7 +1368,7 @@ int main(int argc, char *argv[]) esl_global_set_default_logger(6); /* default debug level to 6 (info) */ for(;;) { int option_index = 0; - opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:Ut:qrRhib?n", options, &option_index); + opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:Ut:T:qrRhib?n", options, &option_index); if (opt == -1) break; switch (opt) { case 'H': @@ -1418,6 +1432,9 @@ int main(int argc, char *argv[]) case 't': timeout = atoi(optarg); break; + case 'T': + connect_timeout = atoi(optarg); + break; case 'h': case '?': print_banner(stdout, is_color); @@ -1488,7 +1505,7 @@ int main(int argc, char *argv[]) connected = 0; while (--loops > 0) { memset(&handle, 0, sizeof(handle)); - if (esl_connect(&handle, profile->host, profile->port, profile->user, profile->pass)) { + if (esl_connect_timeout(&handle, profile->host, profile->port, profile->user, profile->pass, connect_timeout)) { esl_global_set_default_logger(7); esl_log(ESL_LOG_ERROR, "Error Connecting [%s]\n", handle.err); if (loops == 1) { diff --git a/libs/esl/ivrd.c b/libs/esl/ivrd.c index 0d1a98ec4f..865016506b 100644 --- a/libs/esl/ivrd.c +++ b/libs/esl/ivrd.c @@ -45,7 +45,7 @@ static void handle_SIGCHLD(int sig) return; } -static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) +static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr, void *user_data) { esl_handle_t handle = {{0}}; char path_buffer[1024] = { 0 }; @@ -91,7 +91,7 @@ static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_so exit(0); } -static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) +static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr, void *user_data) { esl_handle_t handle = {{0}}; const char *path; @@ -162,11 +162,11 @@ int main(int argc, char *argv[]) if (thread) { printf("Starting threaded listener.\n"); fflush(stdout); - esl_listen_threaded(ip, port, mycallback, 100000); + esl_listen_threaded(ip, port, mycallback, NULL, 100000); } else { printf("Starting forking listener.\n"); fflush(stdout); - esl_listen(ip, port, my_forking_callback); + esl_listen(ip, port, my_forking_callback, NULL, NULL); } return 0; diff --git a/libs/esl/java/Makefile b/libs/esl/java/Makefile index 3606edf331..8738ff93f9 100644 --- a/libs/esl/java/Makefile +++ b/libs/esl/java/Makefile @@ -15,7 +15,7 @@ libesljni.so: esl_wrap.o esl.jar: libesljni.so mkdir -p classes - javac -sourcepath org -d classes $(CLASSES) + javac -sourcepath org -d classes -source 6 -target 6 $(CLASSES) jar cf esl.jar -C classes org clean: diff --git a/libs/esl/managed/ESL.2010.vcxproj b/libs/esl/managed/ESL.2010.vcxproj index 1656ddd1db..9da604c219 100644 --- a/libs/esl/managed/ESL.2010.vcxproj +++ b/libs/esl/managed/ESL.2010.vcxproj @@ -184,7 +184,7 @@ - + diff --git a/libs/esl/managed/ESL.2010.vcxproj.filters b/libs/esl/managed/ESL.2010.vcxproj.filters index 0f46492f09..dfdab8436a 100644 --- a/libs/esl/managed/ESL.2010.vcxproj.filters +++ b/libs/esl/managed/ESL.2010.vcxproj.filters @@ -18,7 +18,7 @@ Source Files - + Source Files diff --git a/libs/esl/managed/ESL.2012.vcxproj b/libs/esl/managed/ESL.2012.vcxproj index 8b4f099c26..95e7d3bc11 100644 --- a/libs/esl/managed/ESL.2012.vcxproj +++ b/libs/esl/managed/ESL.2012.vcxproj @@ -188,7 +188,7 @@ - + diff --git a/libs/esl/managed/ESL.2012.vcxproj.filters b/libs/esl/managed/ESL.2012.vcxproj.filters index 0f46492f09..dfdab8436a 100644 --- a/libs/esl/managed/ESL.2012.vcxproj.filters +++ b/libs/esl/managed/ESL.2012.vcxproj.filters @@ -18,7 +18,7 @@ Source Files - + Source Files diff --git a/libs/esl/managed/ESLPINVOKE.2010.cs b/libs/esl/managed/ESLPINVOKE.2010.cs new file mode 100644 index 0000000000..ec6c9637a8 --- /dev/null +++ b/libs/esl/managed/ESLPINVOKE.2010.cs @@ -0,0 +1,331 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + + +using System; +using System.Runtime.InteropServices; + +class ESLPINVOKE { + + protected class SWIGExceptionHelper { + + public delegate void ExceptionDelegate(string message); + public delegate void ExceptionArgumentDelegate(string message, string paramName); + + static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException); + static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException); + static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException); + static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException); + static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException); + static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException); + static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException); + static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException); + static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException); + static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException); + static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException); + + static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException); + static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException); + static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException); + + [DllImport("ESL", EntryPoint="SWIGRegisterExceptionCallbacks_ESL")] + public static extern void SWIGRegisterExceptionCallbacks_ESL( + ExceptionDelegate applicationDelegate, + ExceptionDelegate arithmeticDelegate, + ExceptionDelegate divideByZeroDelegate, + ExceptionDelegate indexOutOfRangeDelegate, + ExceptionDelegate invalidCastDelegate, + ExceptionDelegate invalidOperationDelegate, + ExceptionDelegate ioDelegate, + ExceptionDelegate nullReferenceDelegate, + ExceptionDelegate outOfMemoryDelegate, + ExceptionDelegate overflowDelegate, + ExceptionDelegate systemExceptionDelegate); + + [DllImport("ESL", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_ESL")] + public static extern void SWIGRegisterExceptionCallbacksArgument_ESL( + ExceptionArgumentDelegate argumentDelegate, + ExceptionArgumentDelegate argumentNullDelegate, + ExceptionArgumentDelegate argumentOutOfRangeDelegate); + + static void SetPendingApplicationException(string message) { + SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingArithmeticException(string message) { + SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingDivideByZeroException(string message) { + SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIndexOutOfRangeException(string message) { + SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidCastException(string message) { + SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidOperationException(string message) { + SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIOException(string message) { + SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingNullReferenceException(string message) { + SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOutOfMemoryException(string message) { + SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOverflowException(string message) { + SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingSystemException(string message) { + SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve())); + } + + static void SetPendingArgumentException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); + } + static void SetPendingArgumentNullException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new System.ArgumentNullException(paramName, message)); + } + static void SetPendingArgumentOutOfRangeException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message)); + } + + static SWIGExceptionHelper() { + SWIGRegisterExceptionCallbacks_ESL( + applicationDelegate, + arithmeticDelegate, + divideByZeroDelegate, + indexOutOfRangeDelegate, + invalidCastDelegate, + invalidOperationDelegate, + ioDelegate, + nullReferenceDelegate, + outOfMemoryDelegate, + overflowDelegate, + systemDelegate); + + SWIGRegisterExceptionCallbacksArgument_ESL( + argumentDelegate, + argumentNullDelegate, + argumentOutOfRangeDelegate); + } + } + + protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper(); + + public class SWIGPendingException { + [ThreadStatic] + private static Exception pendingException = null; + private static int numExceptionsPending = 0; + + public static bool Pending { + get { + bool pending = false; + if (numExceptionsPending > 0) + if (pendingException != null) + pending = true; + return pending; + } + } + + public static void Set(Exception e) { + if (pendingException != null) + throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); + pendingException = e; + lock(typeof(ESLPINVOKE)) { + numExceptionsPending++; + } + } + + public static Exception Retrieve() { + Exception e = null; + if (numExceptionsPending > 0) { + if (pendingException != null) { + e = pendingException; + pendingException = null; + lock(typeof(ESLPINVOKE)) { + numExceptionsPending--; + } + } + } + return e; + } + } + + + protected class SWIGStringHelper { + + public delegate string SWIGStringDelegate(string message); + static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString); + + [DllImport("ESL", EntryPoint="SWIGRegisterStringCallback_ESL")] + public static extern void SWIGRegisterStringCallback_ESL(SWIGStringDelegate stringDelegate); + + static string CreateString(string cString) { + return cString; + } + + static SWIGStringHelper() { + SWIGRegisterStringCallback_ESL(stringDelegate); + } + } + + static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper(); + + + static ESLPINVOKE() { + } + + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_Event_set")] + public static extern void ESLevent_Event_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_Event_get")] + public static extern IntPtr ESLevent_Event_get(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_SerializedString_set")] + public static extern void ESLevent_SerializedString_set(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_SerializedString_get")] + public static extern string ESLevent_SerializedString_get(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_Mine_set")] + public static extern void ESLevent_Mine_set(HandleRef jarg1, int jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_Mine_get")] + public static extern int ESLevent_Mine_get(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLevent__SWIG_0")] + public static extern IntPtr new_ESLevent__SWIG_0(string jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLevent__SWIG_1")] + public static extern IntPtr new_ESLevent__SWIG_1(HandleRef jarg1, int jarg2); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLevent__SWIG_2")] + public static extern IntPtr new_ESLevent__SWIG_2(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_delete_ESLevent")] + public static extern void delete_ESLevent(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_Serialize")] + public static extern string ESLevent_Serialize(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_SetPriority")] + public static extern bool ESLevent_SetPriority(HandleRef jarg1, HandleRef jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_GetHeader")] + public static extern string ESLevent_GetHeader(HandleRef jarg1, string jarg2, int jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_GetBody")] + public static extern string ESLevent_GetBody(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_getType")] + public static extern string ESLevent_getType(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_AddBody")] + public static extern bool ESLevent_AddBody(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_AddHeader")] + public static extern bool ESLevent_AddHeader(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_pushHeader")] + public static extern bool ESLevent_pushHeader(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_unshiftHeader")] + public static extern bool ESLevent_unshiftHeader(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_DelHeader")] + public static extern bool ESLevent_DelHeader(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_FirstHeader")] + public static extern string ESLevent_FirstHeader(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLevent_NextHeader")] + public static extern string ESLevent_NextHeader(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_0")] + public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, int jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_1")] + public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, int jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_2")] + public static extern IntPtr new_ESLconnection__SWIG_2(string jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_3")] + public static extern IntPtr new_ESLconnection__SWIG_3(string jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_4")] + public static extern IntPtr new_ESLconnection__SWIG_4(int jarg1); + + [DllImport("ESL", EntryPoint="CSharp_delete_ESLconnection")] + public static extern void delete_ESLconnection(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SocketDescriptor")] + public static extern int ESLconnection_SocketDescriptor(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Connected")] + public static extern int ESLconnection_Connected(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_GetInfo")] + public static extern IntPtr ESLconnection_GetInfo(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Send")] + public static extern int ESLconnection_Send(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SendRecv")] + public static extern IntPtr ESLconnection_SendRecv(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Api")] + public static extern IntPtr ESLconnection_Api(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Bgapi")] + public static extern IntPtr ESLconnection_Bgapi(HandleRef jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SendEvent")] + public static extern IntPtr ESLconnection_SendEvent(HandleRef jarg1, HandleRef jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_sendMSG")] + public static extern int ESLconnection_sendMSG(HandleRef jarg1, HandleRef jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_RecvEvent")] + public static extern IntPtr ESLconnection_RecvEvent(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_RecvEventTimed")] + public static extern IntPtr ESLconnection_RecvEventTimed(HandleRef jarg1, int jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Filter")] + public static extern IntPtr ESLconnection_Filter(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Events")] + public static extern int ESLconnection_Events(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Execute")] + public static extern IntPtr ESLconnection_Execute(HandleRef jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_ExecuteAsync")] + public static extern IntPtr ESLconnection_ExecuteAsync(HandleRef jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SetAsyncExecute")] + public static extern int ESLconnection_SetAsyncExecute(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SetEventLock")] + public static extern int ESLconnection_SetEventLock(HandleRef jarg1, string jarg2); + + [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Disconnect")] + public static extern int ESLconnection_Disconnect(HandleRef jarg1); + + [DllImport("ESL", EntryPoint="CSharp_eslSetLogLevel")] + public static extern void eslSetLogLevel(int jarg1); +} diff --git a/libs/esl/managed/ESLevent.2010.cs b/libs/esl/managed/ESLevent.2010.cs new file mode 100644 index 0000000000..1ec47dfc77 --- /dev/null +++ b/libs/esl/managed/ESLevent.2010.cs @@ -0,0 +1,144 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + + +using System; +using System.Runtime.InteropServices; + +public class ESLevent : IDisposable { + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal ESLevent(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr(ESLevent obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } + + ~ESLevent() { + Dispose(); + } + + public virtual void Dispose() { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + ESLPINVOKE.delete_ESLevent(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + + public SWIGTYPE_p_esl_event_t Event { + set { + ESLPINVOKE.ESLevent_Event_set(swigCPtr, SWIGTYPE_p_esl_event_t.getCPtr(value)); + } + get { + IntPtr cPtr = ESLPINVOKE.ESLevent_Event_get(swigCPtr); + SWIGTYPE_p_esl_event_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_esl_event_t(cPtr, false); + return ret; + } + } + + public string SerializedString { + set { + ESLPINVOKE.ESLevent_SerializedString_set(swigCPtr, value); + } + get { + string ret = ESLPINVOKE.ESLevent_SerializedString_get(swigCPtr); + return ret; + } + } + + public int Mine { + set { + ESLPINVOKE.ESLevent_Mine_set(swigCPtr, value); + } + get { + int ret = ESLPINVOKE.ESLevent_Mine_get(swigCPtr); + return ret; + } + } + + public ESLevent(string type, string subclass_name) : this(ESLPINVOKE.new_ESLevent__SWIG_0(type, subclass_name), true) { + } + + public ESLevent(SWIGTYPE_p_esl_event_t wrap_me, int free_me) : this(ESLPINVOKE.new_ESLevent__SWIG_1(SWIGTYPE_p_esl_event_t.getCPtr(wrap_me), free_me), true) { + } + + public ESLevent(ESLevent me) : this(ESLPINVOKE.new_ESLevent__SWIG_2(ESLevent.getCPtr(me)), true) { + } + + public string Serialize(string format) { + string ret = ESLPINVOKE.ESLevent_Serialize(swigCPtr, format); + return ret; + } + + public bool SetPriority(SWIGTYPE_p_esl_priority_t priority) { + bool ret = ESLPINVOKE.ESLevent_SetPriority(swigCPtr, SWIGTYPE_p_esl_priority_t.getCPtr(priority)); + if (ESLPINVOKE.SWIGPendingException.Pending) throw ESLPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public string GetHeader(string header_name, int idx) { + string ret = ESLPINVOKE.ESLevent_GetHeader(swigCPtr, header_name, idx); + return ret; + } + + public string GetBody() { + string ret = ESLPINVOKE.ESLevent_GetBody(swigCPtr); + return ret; + } + + public string getType() { + string ret = ESLPINVOKE.ESLevent_getType(swigCPtr); + return ret; + } + + public bool AddBody(string value) { + bool ret = ESLPINVOKE.ESLevent_AddBody(swigCPtr, value); + return ret; + } + + public bool AddHeader(string header_name, string value) { + bool ret = ESLPINVOKE.ESLevent_AddHeader(swigCPtr, header_name, value); + return ret; + } + + public bool pushHeader(string header_name, string value) { + bool ret = ESLPINVOKE.ESLevent_pushHeader(swigCPtr, header_name, value); + return ret; + } + + public bool unshiftHeader(string header_name, string value) { + bool ret = ESLPINVOKE.ESLevent_unshiftHeader(swigCPtr, header_name, value); + return ret; + } + + public bool DelHeader(string header_name) { + bool ret = ESLPINVOKE.ESLevent_DelHeader(swigCPtr, header_name); + return ret; + } + + public string FirstHeader() { + string ret = ESLPINVOKE.ESLevent_FirstHeader(swigCPtr); + return ret; + } + + public string NextHeader() { + string ret = ESLPINVOKE.ESLevent_NextHeader(swigCPtr); + return ret; + } + +} diff --git a/libs/esl/managed/ManagedEsl.2010.csproj b/libs/esl/managed/ManagedEsl.2010.csproj index 7be21f44cb..732b707988 100644 --- a/libs/esl/managed/ManagedEsl.2010.csproj +++ b/libs/esl/managed/ManagedEsl.2010.csproj @@ -57,13 +57,13 @@ - - - - + + + + - - + + diff --git a/libs/esl/managed/ManagedEsl.2012.csproj b/libs/esl/managed/ManagedEsl.2012.csproj index 7be21f44cb..732b707988 100644 --- a/libs/esl/managed/ManagedEsl.2012.csproj +++ b/libs/esl/managed/ManagedEsl.2012.csproj @@ -57,13 +57,13 @@ - - - - + + + + - - + + diff --git a/libs/esl/managed/SWIGTYPE_p_esl_event_t.2010.cs b/libs/esl/managed/SWIGTYPE_p_esl_event_t.2010.cs new file mode 100644 index 0000000000..ddf3ec143d --- /dev/null +++ b/libs/esl/managed/SWIGTYPE_p_esl_event_t.2010.cs @@ -0,0 +1,27 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + + +using System; +using System.Runtime.InteropServices; + +public class SWIGTYPE_p_esl_event_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_esl_event_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_esl_event_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_esl_event_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} diff --git a/libs/esl/managed/SWIGTYPE_p_esl_priority_t.2010.cs b/libs/esl/managed/SWIGTYPE_p_esl_priority_t.2010.cs new file mode 100644 index 0000000000..811d460362 --- /dev/null +++ b/libs/esl/managed/SWIGTYPE_p_esl_priority_t.2010.cs @@ -0,0 +1,27 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + + +using System; +using System.Runtime.InteropServices; + +public class SWIGTYPE_p_esl_priority_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_esl_priority_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_esl_priority_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_esl_priority_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} diff --git a/libs/esl/managed/esl.2010.cs b/libs/esl/managed/esl.2010.cs new file mode 100644 index 0000000000..f9ed10a9df --- /dev/null +++ b/libs/esl/managed/esl.2010.cs @@ -0,0 +1,18 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + + +using System; +using System.Runtime.InteropServices; + +public class ESL { + public static void eslSetLogLevel(int level) { + ESLPINVOKE.eslSetLogLevel(level); + } + +} diff --git a/libs/esl/managed/esl_wrap.2010.cpp b/libs/esl/managed/esl_wrap.2010.cpp new file mode 100644 index 0000000000..64536d6987 --- /dev/null +++ b/libs/esl/managed/esl_wrap.2010.cpp @@ -0,0 +1,948 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGCSHARP + + +#ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ +template class SwigValueWrapper { + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); +public: + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } +}; + +template T SwigValueInit() { + return T(); +} +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +#include +#include +#include + + +/* Support for throwing C# exceptions from C/C++. There are two types: + * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ +typedef enum { + SWIG_CSharpApplicationException, + SWIG_CSharpArithmeticException, + SWIG_CSharpDivideByZeroException, + SWIG_CSharpIndexOutOfRangeException, + SWIG_CSharpInvalidCastException, + SWIG_CSharpInvalidOperationException, + SWIG_CSharpIOException, + SWIG_CSharpNullReferenceException, + SWIG_CSharpOutOfMemoryException, + SWIG_CSharpOverflowException, + SWIG_CSharpSystemException +} SWIG_CSharpExceptionCodes; + +typedef enum { + SWIG_CSharpArgumentException, + SWIG_CSharpArgumentNullException, + SWIG_CSharpArgumentOutOfRangeException +} SWIG_CSharpExceptionArgumentCodes; + +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); + +typedef struct { + SWIG_CSharpExceptionCodes code; + SWIG_CSharpExceptionCallback_t callback; +} SWIG_CSharpException_t; + +typedef struct { + SWIG_CSharpExceptionArgumentCodes code; + SWIG_CSharpExceptionArgumentCallback_t callback; +} SWIG_CSharpExceptionArgument_t; + +static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { + { SWIG_CSharpApplicationException, NULL }, + { SWIG_CSharpArithmeticException, NULL }, + { SWIG_CSharpDivideByZeroException, NULL }, + { SWIG_CSharpIndexOutOfRangeException, NULL }, + { SWIG_CSharpInvalidCastException, NULL }, + { SWIG_CSharpInvalidOperationException, NULL }, + { SWIG_CSharpIOException, NULL }, + { SWIG_CSharpNullReferenceException, NULL }, + { SWIG_CSharpOutOfMemoryException, NULL }, + { SWIG_CSharpOverflowException, NULL }, + { SWIG_CSharpSystemException, NULL } +}; + +static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { + { SWIG_CSharpArgumentException, NULL }, + { SWIG_CSharpArgumentNullException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL } +}; + +static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { + SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; + if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + callback = SWIG_csharp_exceptions[code].callback; + } + callback(msg); +} + +static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { + SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; + if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + callback = SWIG_csharp_exceptions_argument[code].callback; + } + callback(msg, param_name); +} + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_ESL( + SWIG_CSharpExceptionCallback_t applicationCallback, + SWIG_CSharpExceptionCallback_t arithmeticCallback, + SWIG_CSharpExceptionCallback_t divideByZeroCallback, + SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, + SWIG_CSharpExceptionCallback_t invalidCastCallback, + SWIG_CSharpExceptionCallback_t invalidOperationCallback, + SWIG_CSharpExceptionCallback_t ioCallback, + SWIG_CSharpExceptionCallback_t nullReferenceCallback, + SWIG_CSharpExceptionCallback_t outOfMemoryCallback, + SWIG_CSharpExceptionCallback_t overflowCallback, + SWIG_CSharpExceptionCallback_t systemCallback) { + SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; + SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; + SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; + SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; + SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; + SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; + SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; + SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; + SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; +} + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_ESL( + SWIG_CSharpExceptionArgumentCallback_t argumentCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; +} + + +/* Callback for returning strings to C# without leaking memory */ +typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); +static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_ESL(SWIG_CSharpStringHelperCallback callback) { + SWIG_csharp_string_callback = callback; +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else + + +#include "esl.h" +#include "esl_oop.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT void SWIGSTDCALL CSharp_ESLevent_Event_set(void * jarg1, void * jarg2) { + ESLevent *arg1 = (ESLevent *) 0 ; + esl_event_t *arg2 = (esl_event_t *) 0 ; + + arg1 = (ESLevent *)jarg1; + arg2 = (esl_event_t *)jarg2; + if (arg1) (arg1)->event = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLevent_Event_get(void * jarg1) { + void * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + esl_event_t *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (esl_event_t *) ((arg1)->event); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_ESLevent_SerializedString_set(void * jarg1, char * jarg2) { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + { + if (arg1->serialized_string) delete [] arg1->serialized_string; + if (arg2) { + arg1->serialized_string = (char *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->serialized_string, (const char *)arg2); + } else { + arg1->serialized_string = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_SerializedString_get(void * jarg1) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (char *) ((arg1)->serialized_string); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_ESLevent_Mine_set(void * jarg1, int jarg2) { + ESLevent *arg1 = (ESLevent *) 0 ; + int arg2 ; + + arg1 = (ESLevent *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->mine = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLevent_Mine_get(void * jarg1) { + int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + int result; + + arg1 = (ESLevent *)jarg1; + result = (int) ((arg1)->mine); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLevent__SWIG_0(char * jarg1, char * jarg2) { + void * jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) NULL ; + ESLevent *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLevent__SWIG_1(void * jarg1, int jarg2) { + void * jresult ; + esl_event_t *arg1 = (esl_event_t *) 0 ; + int arg2 = (int) 0 ; + ESLevent *result = 0 ; + + arg1 = (esl_event_t *)jarg1; + arg2 = (int)jarg2; + result = (ESLevent *)new ESLevent(arg1,arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLevent__SWIG_2(void * jarg1) { + void * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (ESLevent *)new ESLevent(arg1); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_delete_ESLevent(void * jarg1) { + ESLevent *arg1 = (ESLevent *) 0 ; + + arg1 = (ESLevent *)jarg1; + delete arg1; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_Serialize(void * jarg1, char * jarg2) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) NULL ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + result = (char *)(arg1)->serialize((char const *)arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_SetPriority(void * jarg1, void * jarg2) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + esl_priority_t arg2 = (esl_priority_t) ESL_PRIORITY_NORMAL ; + esl_priority_t *argp2 ; + bool result; + + arg1 = (ESLevent *)jarg1; + argp2 = (esl_priority_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null esl_priority_t", 0); + return 0; + } + arg2 = *argp2; + result = (bool)(arg1)->setPriority(arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_GetHeader(void * jarg1, char * jarg2, int jarg3) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) -1 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + arg3 = (int)jarg3; + result = (char *)(arg1)->getHeader((char const *)arg2,arg3); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_GetBody(void * jarg1) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (char *)(arg1)->getBody(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_getType(void * jarg1) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (char *)(arg1)->getType(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_AddBody(void * jarg1, char * jarg2) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + result = (bool)(arg1)->addBody((char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_AddHeader(void * jarg1, char * jarg2, char * jarg3) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_pushHeader(void * jarg1, char * jarg2, char * jarg3) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (bool)(arg1)->pushHeader((char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_unshiftHeader(void * jarg1, char * jarg2, char * jarg3) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (bool)(arg1)->unshiftHeader((char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_ESLevent_DelHeader(void * jarg1, char * jarg2) { + unsigned int jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + arg1 = (ESLevent *)jarg1; + arg2 = (char *)jarg2; + result = (bool)(arg1)->delHeader((char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_FirstHeader(void * jarg1) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (char *)(arg1)->firstHeader(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_NextHeader(void * jarg1) { + char * jresult ; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + arg1 = (ESLevent *)jarg1; + result = (char *)(arg1)->nextHeader(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, int jarg2, char * jarg3, char * jarg4) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, int jarg2, char * jarg3) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(char * jarg1, char * jarg2, char * jarg3, char * jarg4) { + void * jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_3(char * jarg1, char * jarg2, char * jarg3) { + void * jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_4(int jarg1) { + void * jresult ; + int arg1 ; + ESLconnection *result = 0 ; + + arg1 = (int)jarg1; + result = (ESLconnection *)new ESLconnection(arg1); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_delete_ESLconnection(void * jarg1) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + + arg1 = (ESLconnection *)jarg1; + delete arg1; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_SocketDescriptor(void * jarg1) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + result = (int)(arg1)->socketDescriptor(); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_Connected(void * jarg1) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + result = (int)(arg1)->connected(); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_GetInfo(void * jarg1) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + result = (ESLevent *)(arg1)->getInfo(); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_Send(void * jarg1, char * jarg2) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + result = (int)(arg1)->send((char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_SendRecv(void * jarg1, char * jarg2) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Api(void * jarg1, char * jarg2, char * jarg3) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Bgapi(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_SendEvent(void * jarg1, void * jarg2) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (ESLevent *)jarg2; + result = (ESLevent *)(arg1)->sendEvent(arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_sendMSG(void * jarg1, void * jarg2, char * jarg3) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + char *arg3 = (char *) NULL ; + int result; + + arg1 = (ESLconnection *)jarg1; + arg2 = (ESLevent *)jarg2; + arg3 = (char *)jarg3; + result = (int)(arg1)->sendMSG(arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_RecvEvent(void * jarg1) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + result = (ESLevent *)(arg1)->recvEvent(); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_RecvEventTimed(void * jarg1, int jarg2) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int arg2 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (int)jarg2; + result = (ESLevent *)(arg1)->recvEventTimed(arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Filter(void * jarg1, char * jarg2, char * jarg3) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_Events(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Execute(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLevent *)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_ExecuteAsync(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { + void * jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLevent *)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_SetAsyncExecute(void * jarg1, char * jarg2) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + result = (int)(arg1)->setAsyncExecute((char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_SetEventLock(void * jarg1, char * jarg2) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + arg2 = (char *)jarg2; + result = (int)(arg1)->setEventLock((char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_ESLconnection_Disconnect(void * jarg1) { + int jresult ; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + + arg1 = (ESLconnection *)jarg1; + result = (int)(arg1)->disconnect(); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_eslSetLogLevel(int jarg1) { + int arg1 ; + + arg1 = (int)jarg1; + eslSetLogLevel(arg1); +} + + +#ifdef __cplusplus +} +#endif + diff --git a/libs/esl/managed/runswig.2010.cmd b/libs/esl/managed/runswig.2010.cmd new file mode 100644 index 0000000000..2e7999dafa --- /dev/null +++ b/libs/esl/managed/runswig.2010.cmd @@ -0,0 +1,25 @@ +move esl_wrap.cpp esl_wrap.bak +move esl.cs esl.bak +move ESLconnection.cs ESLconnection.bak +move ESLevent.cs ESLevent.bak +move ESLPINVOKE.cs ESLPINVOKE.bak +move SWIGTYPE_p_esl_event_t.cs SWIGTYPE_p_esl_event_t.bak +move SWIGTYPE_p_esl_priority_t.cs SWIGTYPE_p_esl_priority_t.bak + +\dev\swig20\swig.exe -module ESL -csharp -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i + +move esl_wrap.cpp esl_wrap.2010.cpp +move esl.cs esl.2010.cs +move ESLconnection.cs ESLconnection.2010.cs +move ESLevent.cs ESLevent.2010.cs +move ESLPINVOKE.cs ESLPINVOKE.2010.cs +move SWIGTYPE_p_esl_event_t.cs SWIGTYPE_p_esl_event_t.2010.cs +move SWIGTYPE_p_esl_priority_t.cs SWIGTYPE_p_esl_priority_t.2010.cs + +move esl_wrap.bak esl_wrap.cpp +move esl.bak esl.cs +move ESLconnection.bak ESLconnection.cs +move ESLevent.bak ESLevent.cs +move ESLPINVOKE.bak ESLPINVOKE.cs +move SWIGTYPE_p_esl_event_t.bak SWIGTYPE_p_esl_event_t.cs +move SWIGTYPE_p_esl_priority_t.bak SWIGTYPE_p_esl_priority_t.cs \ No newline at end of file diff --git a/libs/esl/php/ESL.php b/libs/esl/php/ESL.php index a35e8feb32..b18fd7d1d4 100644 --- a/libs/esl/php/ESL.php +++ b/libs/esl/php/ESL.php @@ -2,7 +2,7 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,13 +11,12 @@ * ----------------------------------------------------------------------------- */ // Try to load our extension if it's not already loaded. -if (!extension_loaded("ESL")) { +if (!extension_loaded('ESL')) { if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { if (!dl('php_ESL.dll')) return; } else { - // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'. - // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'. - if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') { + // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'. + if (PHP_SHLIB_SUFFIX === 'dylib') { if (!dl('ESL.so')) return; } else { if (!dl('ESL.'.PHP_SHLIB_SUFFIX)) return; @@ -36,28 +35,37 @@ abstract class ESL { /* PHP Proxy Classes */ class ESLevent { public $_cPtr=null; + protected $_pData=array(); function __set($var,$value) { $func = 'ESLevent_'.$var.'_set'; - if (function_exists($func)) call_user_func($func,$this->_cPtr,$value); + if (function_exists($func)) return call_user_func($func,$this->_cPtr,$value); + if ($var === 'thisown') return swig_ESL_alter_newobject($this->_cPtr,$value); + $this->_pData[$var] = $value; } function __isset($var) { - return function_exists('ESLevent_'.$var.'_set'); + if (function_exists('ESLevent_'.$var.'_set')) return true; + if ($var === 'thisown') return true; + return array_key_exists($var, $this->_pData); } function __get($var) { $func = 'ESLevent_'.$var.'_get'; if (function_exists($func)) return call_user_func($func,$this->_cPtr); - return null; + if ($var === 'thisown') return swig_ESL_get_newobject($this->_cPtr); + return $this->_pData[$var]; } function __construct($type_or_wrap_me_or_me,$subclass_name_or_free_me=null) { - switch (func_num_args()) { - case 1: $r=new_ESLevent($type_or_wrap_me_or_me); break; - default: $r=new_ESLevent($type_or_wrap_me_or_me,$subclass_name_or_free_me); + if (is_resource($type_or_wrap_me_or_me) && get_resource_type($type_or_wrap_me_or_me) === '_p_ESLevent') { + $this->_cPtr=$type_or_wrap_me_or_me; + return; + } + switch (func_num_args()) { + case 1: $this->_cPtr=new_ESLevent($type_or_wrap_me_or_me); break; + default: $this->_cPtr=new_ESLevent($type_or_wrap_me_or_me,$subclass_name_or_free_me); } - $this->_cPtr=$r; } function serialize($format=null) { @@ -119,15 +127,34 @@ class ESLevent { class ESLconnection { public $_cPtr=null; + protected $_pData=array(); + + function __set($var,$value) { + if ($var === 'thisown') return swig_ESL_alter_newobject($this->_cPtr,$value); + $this->_pData[$var] = $value; + } + + function __isset($var) { + if ($var === 'thisown') return true; + return array_key_exists($var, $this->_pData); + } + + function __get($var) { + if ($var === 'thisown') return swig_ESL_get_newobject($this->_cPtr); + return $this->_pData[$var]; + } function __construct($host_or_socket,$port=null,$user_or_password=null,$password=null) { - switch (func_num_args()) { - case 1: $r=new_ESLconnection($host_or_socket); break; - case 2: $r=new_ESLconnection($host_or_socket,$port); break; - case 3: $r=new_ESLconnection($host_or_socket,$port,$user_or_password); break; - default: $r=new_ESLconnection($host_or_socket,$port,$user_or_password,$password); + if (is_resource($host_or_socket) && get_resource_type($host_or_socket) === '_p_ESLconnection') { + $this->_cPtr=$host_or_socket; + return; + } + switch (func_num_args()) { + case 1: $this->_cPtr=new_ESLconnection($host_or_socket); break; + case 2: $this->_cPtr=new_ESLconnection($host_or_socket,$port); break; + case 3: $this->_cPtr=new_ESLconnection($host_or_socket,$port,$user_or_password); break; + default: $this->_cPtr=new_ESLconnection($host_or_socket,$port,$user_or_password,$password); } - $this->_cPtr=$r; } function socketDescriptor() { @@ -140,7 +167,12 @@ class ESLconnection { function getInfo() { $r=ESLconnection_getInfo($this->_cPtr); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function send($cmd) { @@ -149,7 +181,12 @@ class ESLconnection { function sendRecv($cmd) { $r=ESLconnection_sendRecv($this->_cPtr,$cmd); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function api($cmd,$arg=null) { @@ -157,7 +194,12 @@ class ESLconnection { case 1: $r=ESLconnection_api($this->_cPtr,$cmd); break; default: $r=ESLconnection_api($this->_cPtr,$cmd,$arg); } - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function bgapi($cmd,$arg=null,$job_uuid=null) { @@ -166,12 +208,22 @@ class ESLconnection { case 2: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); break; default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg,$job_uuid); } - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function sendEvent($send_me) { $r=ESLconnection_sendEvent($this->_cPtr,$send_me); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function sendMSG($send_me,$uuid=null) { @@ -184,17 +236,32 @@ class ESLconnection { function recvEvent() { $r=ESLconnection_recvEvent($this->_cPtr); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function recvEventTimed($ms) { $r=ESLconnection_recvEventTimed($this->_cPtr,$ms); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function filter($header,$value) { $r=ESLconnection_filter($this->_cPtr,$header,$value); - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function events($etype,$value) { @@ -207,7 +274,12 @@ class ESLconnection { case 2: $r=ESLconnection_execute($this->_cPtr,$app,$arg); break; default: $r=ESLconnection_execute($this->_cPtr,$app,$arg,$uuid); } - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function executeAsync($app,$arg=null,$uuid=null) { @@ -216,7 +288,12 @@ class ESLconnection { case 2: $r=ESLconnection_executeAsync($this->_cPtr,$app,$arg); break; default: $r=ESLconnection_executeAsync($this->_cPtr,$app,$arg,$uuid); } - return is_resource($r) ? new ESLevent($r) : $r; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new ESLevent($r); + } + return $r; } function setAsyncExecute($val) { diff --git a/libs/esl/php/Makefile b/libs/esl/php/Makefile index 97674f85be..7cc42d2725 100644 --- a/libs/esl/php/Makefile +++ b/libs/esl/php/Makefile @@ -16,7 +16,7 @@ WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function all: ESL.so esl_wrap.cpp: - swig -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i + swig2.0 -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i sed -e 's/ char \*type_name;/ const char \*type_name;/' -i esl_wrap.cpp esl_wrap.o: esl_wrap.cpp diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index 0389cc2151..83304bb226 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,20 +8,27 @@ * interface file instead. * ----------------------------------------------------------------------------- */ +#define SWIGPHP + +#define SWIG_PREFIX "" +#define SWIG_PREFIX_LEN 0 #ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - T *tt; + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); public: - SwigValueWrapper() : tt(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } - SwigValueWrapper(const T& t) : tt(new T(t)) { } - ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } - operator T&() const { return *tt; } - T *operator&() { return tt; } -private: - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } }; template T SwigValueInit() { @@ -71,6 +78,12 @@ template T SwigValueInit() { # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -135,7 +148,7 @@ template T SwigValueInit() { /* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer + * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ @@ -154,11 +167,11 @@ template T SwigValueInit() { /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. */ #ifndef SWIGRUNTIME @@ -185,14 +198,14 @@ template T SwigValueInit() { /* Flags/methods for returning states. - The swig conversion methods, as ConvertPtr, return and integer + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. - In old swig versions, you usually write code as: + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code @@ -200,7 +213,7 @@ template T SwigValueInit() { //fail code } - Now you can be more explicit as: + Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { @@ -209,7 +222,7 @@ template T SwigValueInit() { // fail code } - that seems to be the same, but now you can also do + which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); @@ -227,7 +240,7 @@ template T SwigValueInit() { I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as + also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { @@ -245,7 +258,7 @@ template T SwigValueInit() { Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. + SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this @@ -259,9 +272,8 @@ template T SwigValueInit() { fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() +*/ - - */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) @@ -286,7 +298,6 @@ template T SwigValueInit() { #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank @@ -309,8 +320,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { #endif - - #include #ifdef __cplusplus @@ -407,40 +416,58 @@ SWIG_TypeCompare(const char *nb, const char *tb) { } -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } -/* Same as previous function, except strcmp is replaced with a pointer comparison */ +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } /* @@ -703,12 +730,9 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * phprun.swg * - * php4run.swg - * - * PHP4 runtime library + * PHP runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus @@ -716,7 +740,10 @@ extern "C" { #endif #include "zend.h" #include "zend_API.h" +#include "zend_exceptions.h" #include "php.h" +#include "ext/standard/php_string.h" +#include /* for abort(), used in generated code. */ #ifdef ZEND_RAW_FENTRY /* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ @@ -728,9 +755,18 @@ extern "C" { # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif +#ifndef Z_SET_ISREF_P +/* For PHP < 5.3 */ +# define Z_SET_ISREF_P(z) (z)->is_ref = 1 +#endif +#ifndef Z_SET_REFCOUNT_P +/* For PHP < 5.3 */ +# define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) +#endif + #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) -#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) +#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_CHAR_CONSTANT(N, V) do {\ static char swig_char = (V);\ zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ @@ -774,12 +810,12 @@ static int default_error_code = E_ERROR; if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else /* Standard SWIG API */ -#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) +#define SWIG_GetModule(clientdata) SWIG_Php_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer) /* used to wrap returned objects in so we know whether they are newobject and need freeing, or not */ -typedef struct _swig_object_wrapper { +typedef struct { void * ptr; int newobject; } swig_object_wrapper; @@ -788,10 +824,10 @@ typedef struct _swig_object_wrapper { static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; } #define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) static void SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { - swig_object_wrapper *value=NULL; /* * First test for Null pointers. Return those as PHP native NULL */ @@ -800,12 +836,56 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject return; } if (type->clientdata) { + swig_object_wrapper *value; if (! (*(int *)(type->clientdata))) zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); value->ptr=ptr; - value->newobject=newobject; - ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + value->newobject=(newobject & 1); + if ((newobject & 2) == 0) { + /* Just register the pointer as a resource. */ + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + } else { + /* + * Wrap the resource in an object, the resource will be accessible + * via the "_cPtr" member. This is currently only used by + * directorin typemaps. + */ + zval *resource; + zend_class_entry **ce = NULL; + const char *type_name = type->name+3; /* +3 so: _p_Foo -> Foo */ + size_t type_name_len; + int result; + const char * p; + + /* Namespace__Foo -> Foo */ + /* FIXME: ugly and goes wrong for classes with __ in their names. */ + while ((p = strstr(type_name, "__")) != NULL) { + type_name = p + 2; + } + type_name_len = strlen(type_name); + + MAKE_STD_ZVAL(resource); + ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); + if (SWIG_PREFIX_LEN > 0) { + char * classname = (char*)emalloc(SWIG_PREFIX_LEN + type_name_len + 1); + strcpy(classname, SWIG_PREFIX); + strcpy(classname + SWIG_PREFIX_LEN, type_name); + result = zend_lookup_class(classname, SWIG_PREFIX_LEN + type_name_len, &ce TSRMLS_CC); + efree(classname); + } else { + result = zend_lookup_class((char *)type_name, type_name_len, &ce TSRMLS_CC); + } + if (result != SUCCESS) { + /* class does not exist */ + object_init(z); + } else { + object_init_ex(z, *ce); + } + Z_SET_REFCOUNT_P(z, 1); + Z_SET_ISREF_P(z); + zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); + } return; } zend_error(E_ERROR, "Type: %s not registered with zend",type->name); @@ -860,7 +940,7 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { const char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); - if ( flags && SWIG_POINTER_DISOWN ) { + if ( flags & SWIG_POINTER_DISOWN ) { value->newobject = 0; } p = value->ptr; @@ -903,7 +983,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC } static char const_name[] = "swig_runtime_data_type_pointer"; -static swig_module_info *SWIG_Php4_GetModule() { +static swig_module_info *SWIG_Php_GetModule() { zval *pointer; swig_module_info *ret = 0; @@ -911,7 +991,7 @@ static swig_module_info *SWIG_Php4_GetModule() { TSRMLS_FETCH(); - if (zend_get_constant(const_name, sizeof(const_name), pointer TSRMLS_CC)) { + if (zend_get_constant(const_name, sizeof(const_name) - 1, pointer TSRMLS_CC)) { if (pointer->type == IS_LONG) { ret = (swig_module_info *) pointer->value.lval; } @@ -920,7 +1000,7 @@ static swig_module_info *SWIG_Php4_GetModule() { return ret; } -static void SWIG_Php4_SetModule(swig_module_info *pointer) { +static void SWIG_Php_SetModule(swig_module_info *pointer) { TSRMLS_FETCH(); REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); } @@ -953,6 +1033,15 @@ ZEND_DECLARE_MODULE_GLOBALS(ESL) #define SWIG_ErrorCode() (ESL_globals.error_code) #endif +#ifdef __GNUC__ +static void SWIG_FAIL() __attribute__ ((__noreturn__)); +#endif + +static void SWIG_FAIL() { + zend_error(SWIG_ErrorCode(), "%s", SWIG_ErrorMsg()); + abort(); +} + static void ESL_init_globals(zend_ESL_globals *globals ) { globals->error_msg = default_error_msg; globals->error_code = default_error_code; @@ -964,6 +1053,38 @@ static void SWIG_ResetError() { SWIG_ErrorMsg() = default_error_msg; SWIG_ErrorCode() = default_error_code; } + +ZEND_NAMED_FUNCTION(_wrap_swig_ESL_alter_newobject) { + zval **args[2]; + swig_object_wrapper *value; + int type; + int thisown; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type); + value->newobject = zval_is_true(*args[1]); + + return; +} +ZEND_NAMED_FUNCTION(_wrap_swig_ESL_get_newobject) { + zval **args[1]; + swig_object_wrapper *value; + int type; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type); + RETVAL_LONG(value->newobject); + + return; +} #define SWIG_name "ESL" #ifdef __cplusplus extern "C" { @@ -1041,17 +1162,16 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_set) { } if (arg1) (arg1)->event = arg2; - return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_get) { ESLevent *arg1 = (ESLevent *) 0 ; - esl_event_t *result = 0 ; zval **args[1]; + esl_event_t *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1065,12 +1185,12 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_get) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); result = (esl_event_t *) ((arg1)->event); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_esl_event_t, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_esl_event_t, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1091,13 +1211,17 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_set) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; { - if (arg1->serialized_string) delete [] arg1->serialized_string; + delete [] arg1->serialized_string; if (arg2) { arg1->serialized_string = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->serialized_string, (const char *)arg2); @@ -1108,14 +1232,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_set) { return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_get) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; zval **args[1]; + char *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1133,12 +1257,12 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_get) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1159,24 +1283,23 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_mine_set) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; if (arg1) (arg1)->mine = arg2; - return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_mine_get) { ESLevent *arg1 = (ESLevent *) 0 ; - int result; zval **args[1]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1195,16 +1318,16 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_mine_get) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_0) { char *arg1 = (char *) 0 ; char *arg2 = (char *) NULL ; - ESLevent *result = 0 ; zval **args[2]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -1213,34 +1336,42 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_0) { WRONG_PARAM_COUNT; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[0]); - arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[0])->type==IS_NULL) { + arg1 = (char *) 0; + } else { + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + } /*@SWIG@*/; if(arg_count > 1) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; } result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_1) { esl_event_t *arg1 = (esl_event_t *) 0 ; int arg2 = (int) 0 ; - ESLevent *result = 0 ; zval **args[2]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -1254,26 +1385,26 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_1) { } } if(arg_count > 1) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; } result = (ESLevent *)new ESLevent(arg1,arg2); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_2) { ESLevent *arg1 = (ESLevent *) 0 ; - ESLevent *result = 0 ; zval **args[1]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1286,12 +1417,12 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent__SWIG_2) { } } result = (ESLevent *)new ESLevent(arg1); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1305,15 +1436,15 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent) { int _v; { void *tmp; - _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_esl_event_t, 0) >= 0); + _v = (SWIG_ConvertPtr(*argv[0], (void**)&tmp, SWIGTYPE_p_esl_event_t, 0) >= 0); } if (_v) { if (argc <= 1) { - return _wrap_new_ESLevent__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLevent__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } _v = (Z_TYPE_PP(argv[1]) == IS_LONG); if (_v) { - return _wrap_new_ESLevent__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLevent__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } @@ -1321,10 +1452,10 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent) { int _v; { void *tmp; - _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_ESLevent, 0) >= 0); + _v = (SWIG_ConvertPtr(*argv[0], (void**)&tmp, SWIGTYPE_p_ESLevent, 0) >= 0); } if (_v) { - return _wrap_new_ESLevent__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLevent__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } if ((argc >= 1) && (argc <= 2)) { @@ -1332,18 +1463,18 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLevent) { _v = (Z_TYPE_PP(argv[0]) == IS_STRING); if (_v) { if (argc <= 1) { - return _wrap_new_ESLevent__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLevent__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } _v = (Z_TYPE_PP(argv[1]) == IS_STRING); if (_v) { - return _wrap_new_ESLevent__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLevent__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } SWIG_ErrorCode() = E_ERROR; SWIG_ErrorMsg() = "No matching function for overloaded 'new_ESLevent'"; - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1360,16 +1491,18 @@ static void __wrap_delete_ESLevent(zend_rsrc_list_entry *rsrc, const char *type_ arg1 = (ESLevent *)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE_p_ESLevent TSRMLS_CC); if (! arg1) zend_error(E_ERROR, "ESLevent resource already free'd"); delete arg1; - + return; +fail: + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialize) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) NULL ; - char *result = 0 ; zval **args[2]; int arg_count; + char *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -1384,9 +1517,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialize) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); if(arg_count > 1) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; } @@ -1395,22 +1532,22 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialize) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_setPriority) { ESLevent *arg1 = (ESLevent *) 0 ; esl_priority_t arg2 = (esl_priority_t) ESL_PRIORITY_NORMAL ; - bool result; esl_priority_t *tmp2 ; zval **args[2]; int arg_count; + bool result; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -1438,7 +1575,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_setPriority) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1446,9 +1583,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_getHeader) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; int arg3 = (int) -1 ; - char *result = 0 ; zval **args[3]; int arg_count; + char *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -1463,13 +1600,17 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_getHeader) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[2]); arg3 = (int) Z_LVAL_PP(args[2]); /*@SWIG@*/; @@ -1480,19 +1621,19 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_getHeader) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_getBody) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; zval **args[1]; + char *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1510,19 +1651,19 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_getBody) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_getType) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; zval **args[1]; + char *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1540,20 +1681,20 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_getType) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_addBody) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; - bool result; zval **args[2]; + bool result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -1567,9 +1708,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addBody) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (bool)(arg1)->addBody((char const *)arg2); @@ -1578,7 +1723,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addBody) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1586,8 +1731,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addHeader) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; zval **args[3]; + bool result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -1601,15 +1746,23 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addHeader) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); @@ -1618,7 +1771,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addHeader) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1626,8 +1779,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_pushHeader) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; zval **args[3]; + bool result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -1641,15 +1794,23 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_pushHeader) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (bool)(arg1)->pushHeader((char const *)arg2,(char const *)arg3); @@ -1658,7 +1819,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_pushHeader) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1666,8 +1827,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_unshiftHeader) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; zval **args[3]; + bool result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -1681,15 +1842,23 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_unshiftHeader) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (bool)(arg1)->unshiftHeader((char const *)arg2,(char const *)arg3); @@ -1698,15 +1867,15 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_unshiftHeader) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; - bool result; zval **args[2]; + bool result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -1720,9 +1889,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (bool)(arg1)->delHeader((char const *)arg2); @@ -1731,14 +1904,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_firstHeader) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; zval **args[1]; + char *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1756,19 +1929,19 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_firstHeader) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLevent_nextHeader) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; zval **args[1]; + char *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1786,12 +1959,12 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_nextHeader) { if(!result) { ZVAL_NULL(return_value); } else { - ZVAL_STRING(return_value,result, 1); + ZVAL_STRING(return_value, (char *)result, 1); } } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1800,8 +1973,8 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) { int arg2 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; - ESLconnection *result = 0 ; zval **args[4]; + ESLconnection *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_array_ex(4, args) != SUCCESS) { @@ -1809,36 +1982,48 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[0]); - arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[0])->type==IS_NULL) { + arg1 = (char *) 0; + } else { + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[3]); - arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[3])->type==IS_NULL) { + arg4 = (char *) 0; + } else { + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + } /*@SWIG@*/; result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1846,8 +2031,8 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { char *arg1 = (char *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; - ESLconnection *result = 0 ; zval **args[3]; + ESLconnection *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -1855,30 +2040,38 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[0]); - arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[0])->type==IS_NULL) { + arg1 = (char *) 0; + } else { + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1887,8 +2080,8 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; - ESLconnection *result = 0 ; zval **args[4]; + ESLconnection *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_array_ex(4, args) != SUCCESS) { @@ -1896,36 +2089,52 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[0]); - arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[0])->type==IS_NULL) { + arg1 = (char *) 0; + } else { + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[3]); - arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[3])->type==IS_NULL) { + arg4 = (char *) 0; + } else { + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + } /*@SWIG@*/; result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -1933,8 +2142,8 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_3) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - ESLconnection *result = 0 ; zval **args[3]; + ESLconnection *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -1942,37 +2151,49 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_3) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[0]); - arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[0])->type==IS_NULL) { + arg1 = (char *) 0; + } else { + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_4) { int arg1 ; - ESLconnection *result = 0 ; zval **args[1]; + ESLconnection *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -1980,18 +2201,18 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_4) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[0]); arg1 = (int) Z_LVAL_PP(args[0]); /*@SWIG@*/; result = (ESLconnection *)new ESLconnection(arg1); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2005,7 +2226,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { int _v; _v = (Z_TYPE_PP(argv[0]) == IS_LONG); if (_v) { - return _wrap_new_ESLconnection__SWIG_4(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLconnection__SWIG_4(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } if (argc == 3) { @@ -2016,7 +2237,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[2]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } @@ -2029,7 +2250,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[2]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_3(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLconnection__SWIG_3(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } @@ -2044,7 +2265,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[3]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } @@ -2060,7 +2281,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[3]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); + _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); return; } } } @@ -2069,7 +2290,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { SWIG_ErrorCode() = E_ERROR; SWIG_ErrorMsg() = "No matching function for overloaded 'new_ESLconnection'"; - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2086,14 +2307,16 @@ static void __wrap_delete_ESLconnection(zend_rsrc_list_entry *rsrc, const char * arg1 = (ESLconnection *)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE_p_ESLconnection TSRMLS_CC); if (! arg1) zend_error(E_ERROR, "ESLconnection resource already free'd"); delete arg1; - + return; +fail: + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_socketDescriptor) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; zval **args[1]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -2112,14 +2335,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_socketDescriptor) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; zval **args[1]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -2138,14 +2361,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_getInfo) { ESLconnection *arg1 = (ESLconnection *) 0 ; - ESLevent *result = 0 ; zval **args[1]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -2159,20 +2382,20 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_getInfo) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); result = (ESLevent *)(arg1)->getInfo(); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_send) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; zval **args[2]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2186,9 +2409,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_send) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (int)(arg1)->send((char const *)arg2); @@ -2197,15 +2424,15 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_send) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendRecv) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - ESLevent *result = 0 ; zval **args[2]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2219,18 +2446,22 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendRecv) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2238,9 +2469,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_api) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; - ESLevent *result = 0 ; zval **args[3]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -2255,25 +2486,33 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_api) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; } result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2282,9 +2521,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; zval **args[4]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -2299,40 +2538,52 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; } if(arg_count > 3) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[3]); - arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[3])->type==IS_NULL) { + arg4 = (char *) 0; + } else { + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + } /*@SWIG@*/; } result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendEvent) { ESLconnection *arg1 = (ESLconnection *) 0 ; ESLevent *arg2 = (ESLevent *) 0 ; - ESLevent *result = 0 ; zval **args[2]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2351,12 +2602,12 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendEvent) { } } result = (ESLevent *)(arg1)->sendEvent(arg2); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2364,9 +2615,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendMSG) { ESLconnection *arg1 = (ESLconnection *) 0 ; ESLevent *arg2 = (ESLevent *) 0 ; char *arg3 = (char *) NULL ; - int result; zval **args[3]; int arg_count; + int result; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -2386,9 +2637,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendMSG) { } } if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; } @@ -2398,14 +2653,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendMSG) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEvent) { ESLconnection *arg1 = (ESLconnection *) 0 ; - ESLevent *result = 0 ; zval **args[1]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -2419,20 +2674,20 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEvent) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); result = (ESLevent *)(arg1)->recvEvent(); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEventTimed) { ESLconnection *arg1 = (ESLconnection *) 0 ; int arg2 ; - ESLevent *result = 0 ; zval **args[2]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2446,18 +2701,18 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEventTimed) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; result = (ESLevent *)(arg1)->recvEventTimed(arg2); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2465,8 +2720,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - ESLevent *result = 0 ; zval **args[3]; + ESLevent *result = 0 ; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -2480,24 +2735,32 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2505,8 +2768,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_events) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - int result; zval **args[3]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { @@ -2520,15 +2783,23 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_events) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); @@ -2537,7 +2808,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_events) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2546,9 +2817,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; zval **args[4]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -2563,32 +2834,44 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; } if(arg_count > 3) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[3]); - arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[3])->type==IS_NULL) { + arg4 = (char *) 0; + } else { + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + } /*@SWIG@*/; } result = (ESLevent *)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2597,9 +2880,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_executeAsync) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; zval **args[4]; int arg_count; + ESLevent *result = 0 ; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); @@ -2614,40 +2897,52 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_executeAsync) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[2])->type==IS_NULL) { + arg3 = (char *) 0; + } else { + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + } /*@SWIG@*/; } if(arg_count > 3) { - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[3]); - arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[3])->type==IS_NULL) { + arg4 = (char *) 0; + } else { + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + } /*@SWIG@*/; } result = (ESLevent *)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); - { - SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); - } + + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); + return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; zval **args[2]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2661,9 +2956,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (int)(arg1)->setAsyncExecute((char const *)arg2); @@ -2672,15 +2971,15 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; zval **args[2]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) { @@ -2694,9 +2993,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock) { } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[1]); - arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/ + if ((*args[1])->type==IS_NULL) { + arg2 = (char *) 0; + } else { + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + } /*@SWIG@*/; result = (int)(arg1)->setEventLock((char const *)arg2); @@ -2705,14 +3008,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; zval **args[1]; + int result; SWIG_ResetError(); if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { @@ -2731,7 +3034,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect) { } return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } @@ -2745,7 +3048,7 @@ ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel) { } - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/share/swig2.0/php/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[0]); arg1 = (int) Z_LVAL_PP(args[0]); /*@SWIG@*/; @@ -2754,23 +3057,21 @@ ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel) { return; fail: - zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); + SWIG_FAIL(); } -/* NEW Destructor style */ static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_esl_priority_t) { /* No destructor for simple type _p_esl_priority_t */ + efree(rsrc->ptr); } -/* NEW Destructor style */ static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_ESLevent) { __wrap_delete_ESLevent(rsrc, SWIGTYPE_p_ESLevent->name TSRMLS_CC); } -/* NEW Destructor style */ static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_esl_event_t) { /* No destructor for simple type _p_esl_event_t */ + efree(rsrc->ptr); } -/* NEW Destructor style */ static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_ESLconnection) { __wrap_delete_ESLconnection(rsrc, SWIGTYPE_p_ESLconnection->name TSRMLS_CC); } @@ -2820,14 +3121,18 @@ static zend_function_entry ESL_functions[] = { SWIG_ZEND_NAMED_FE(eslconnection_seteventlock,_wrap_ESLconnection_setEventLock,NULL) SWIG_ZEND_NAMED_FE(eslconnection_disconnect,_wrap_ESLconnection_disconnect,NULL) SWIG_ZEND_NAMED_FE(eslsetloglevel,_wrap_eslSetLogLevel,NULL) + SWIG_ZEND_NAMED_FE(swig_ESL_alter_newobject,_wrap_swig_ESL_alter_newobject,NULL) + SWIG_ZEND_NAMED_FE(swig_ESL_get_newobject,_wrap_swig_ESL_get_newobject,NULL) {NULL, NULL, NULL} }; /* init section */ -zend_module_entry ESL_module_entry = { -#if ZEND_MODULE_API_NO > 20010900 - STANDARD_MODULE_HEADER, +#if ZEND_MODULE_API_NO <= 20090626 +#undef ZEND_MODULE_BUILD_ID +#define ZEND_MODULE_BUILD_ID (char*)"API" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA #endif +zend_module_entry ESL_module_entry = { + STANDARD_MODULE_HEADER, (char*)"ESL", ESL_functions, PHP_MINIT(ESL), @@ -2835,9 +3140,7 @@ zend_module_entry ESL_module_entry = { PHP_RINIT(ESL), PHP_RSHUTDOWN(ESL), PHP_MINFO(ESL), -#if ZEND_MODULE_API_NO > 20010900 NO_VERSION_YET, -#endif STANDARD_MODULE_PROPERTIES }; zend_module_entry* SWIG_module_entry = &ESL_module_entry; diff --git a/libs/esl/php/php_ESL.h b/libs/esl/php/php_ESL.h index 41056b3dda..50e80578b3 100644 --- a/libs/esl/php/php_ESL.h +++ b/libs/esl/php/php_ESL.h @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,8 +8,6 @@ * interface file instead. * ----------------------------------------------------------------------------- */ - - #ifndef PHP_ESL_H #define PHP_ESL_H diff --git a/libs/esl/php/single_command.php b/libs/esl/php/single_command.php index 76d83bc8de..b96079718b 100755 --- a/libs/esl/php/single_command.php +++ b/libs/esl/php/single_command.php @@ -6,10 +6,9 @@ if ($argc > 1) { array_shift($argv); $command = sprintf('%s', implode(' ', $argv)); printf("Command to run is: %s\n", $command); - - $sock = new ESLconnection('localhost', '8021', 'ClueCon'); - $res = $sock->api($command); - printf("%s\n", $res->getBody()); + $esl = new eslConnection('127.0.0.1', '8021', 'ClueCon'); + $e = $esl->api("$command"); + print $e->getBody(); } else { printf("ERROR: You Need To Pass A Command\nUsage:\n\t%s ", $argv[0]); } diff --git a/libs/esl/php/test.php b/libs/esl/php/test.php index 5c4534118a..ed5956457c 100644 --- a/libs/esl/php/test.php +++ b/libs/esl/php/test.php @@ -5,3 +5,4 @@ $esl = new eslConnection('127.0.0.1', '8021', 'ClueCon'); $e = $esl->sendRecv("api status"); print $e->getBody(); +?> diff --git a/libs/esl/ruby/Makefile b/libs/esl/ruby/Makefile index 227e9f33fa..177b448143 100644 --- a/libs/esl/ruby/Makefile +++ b/libs/esl/ruby/Makefile @@ -1,11 +1,10 @@ -## no idea how to simply ask ruby which one to use -LOCAL_CFLAGS=-I$(shell ruby -e 'require "rbconfig"; puts RbConfig::CONFIG["topdir"]') -LOCAL_LDFLAGS=$(shell ruby -e 'require "rbconfig"; puts RbConfig::CONFIG["LIBS"]') +LOCAL_LDFLAGS=$(shell ruby -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBYARG"]') +LOCAL_CFLAGS=$(shell ruby cflags.rb) all: ESL.so esl_wrap.cpp: - swig -module ESL -ruby -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i + swig2.0 -module ESL -ruby -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i esl_wrap.o: esl_wrap.cpp $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o @@ -20,4 +19,3 @@ swigclean: rm -f esl_wrap.* ESL.so reswig: swigclean esl_wrap.cpp - diff --git a/libs/esl/ruby/cflags.rb b/libs/esl/ruby/cflags.rb new file mode 100644 index 0000000000..45c10b1727 --- /dev/null +++ b/libs/esl/ruby/cflags.rb @@ -0,0 +1,8 @@ +require 'rbconfig' + +cflags = if RUBY_VERSION =~ /1.9/ then + "-I#{RbConfig::CONFIG['rubyhdrdir']} -I#{RbConfig::CONFIG['rubyhdrdir']}/#{RbConfig::CONFIG['arch']}" +else + "-I#{RbConfig::CONFIG["topdir"]}" +end +puts cflags \ No newline at end of file diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 2d7e906402..81dcb73e0e 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -10,19 +10,23 @@ #define SWIGRUBY + #ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - T *tt; + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); public: - SwigValueWrapper() : tt(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } - SwigValueWrapper(const T& t) : tt(new T(t)) { } - ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } - operator T&() const { return *tt; } - T *operator&() { return tt; } -private: - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } }; template T SwigValueInit() { @@ -72,6 +76,12 @@ template T SwigValueInit() { # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -175,6 +185,12 @@ template T SwigValueInit() { # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -239,7 +255,7 @@ template T SwigValueInit() { /* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer + * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ @@ -258,11 +274,11 @@ template T SwigValueInit() { /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. */ #ifndef SWIGRUNTIME @@ -289,14 +305,14 @@ template T SwigValueInit() { /* Flags/methods for returning states. - The swig conversion methods, as ConvertPtr, return and integer + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. - In old swig versions, you usually write code as: + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code @@ -304,7 +320,7 @@ template T SwigValueInit() { //fail code } - Now you can be more explicit as: + Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { @@ -313,7 +329,7 @@ template T SwigValueInit() { // fail code } - that seems to be the same, but now you can also do + which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); @@ -331,7 +347,7 @@ template T SwigValueInit() { I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as + also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { @@ -349,7 +365,7 @@ template T SwigValueInit() { Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. + SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this @@ -363,9 +379,8 @@ template T SwigValueInit() { fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() +*/ - - */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) @@ -390,7 +405,6 @@ template T SwigValueInit() { #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank @@ -413,8 +427,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { #endif - - #include #ifdef __cplusplus @@ -511,40 +523,58 @@ SWIG_TypeCompare(const char *nb, const char *tb) { } -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } -/* Same as previous function, except strcmp is replaced with a pointer comparison */ +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } /* @@ -825,6 +855,15 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #include +/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which + * breaks using rb_intern as an lvalue, as SWIG does. We work around this + * issue for now by disabling this. + * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645 + */ +#ifdef rb_intern +# undef rb_intern +#endif + /* Remove global macros defined in Ruby's win32.h */ #ifdef write # undef write @@ -832,6 +871,15 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifdef read # undef read #endif +#ifdef bind +# undef bind +#endif +#ifdef close +# undef close +#endif +#ifdef connect +# undef connect +#endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ @@ -974,7 +1022,7 @@ static VALUE _mSWIG = Qnil; /* Define custom exceptions for errors that do not map to existing Ruby exceptions. Note this only works for C++ since a global cannot be - initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + initialized by a function in C. For C, fallback to rb_eRuntimeError.*/ SWIGINTERN VALUE getNullReferenceError(void) { @@ -1119,9 +1167,6 @@ void Ruby_Format_OverloadedError( } /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubytracking.swg * * This file contains support for tracking mappings from @@ -1317,9 +1362,6 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubyrun.swg * * This file contains the runtime support for Ruby modules @@ -1363,7 +1405,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) -#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg) #define SWIG_fail goto fail @@ -1418,7 +1460,7 @@ static ID swig_call_id = 0; ++swig_virtual_calls; # define SWIG_RELEASE_STACK --swig_virtual_calls; # define Ruby_DirectorTypeMismatchException(x) \ - rb_raise( rb_eTypeError, x ); return c_result; + rb_raise( rb_eTypeError, "%s", x ); return c_result; static unsigned int swig_virtual_calls = 0; @@ -1510,7 +1552,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) downcast methods. */ if (obj != Qnil) { VALUE value = rb_iv_get(obj, "@__swigtype__"); - char* type_name = RSTRING_PTR(value); + const char* type_name = RSTRING_PTR(value); if (strcmp(type->name, type_name) == 0) { return obj; @@ -1792,7 +1834,7 @@ static VALUE mESL; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x020007 #define SWIG_VERSION SWIGVERSION @@ -1902,7 +1944,7 @@ SWIG_ruby_failed(void) } -/*@SWIG:/usr/local/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/ +/*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) { VALUE obj = args[0]; @@ -1963,7 +2005,7 @@ SWIG_From_bool (bool value) return value ? Qtrue : Qfalse; } -swig_class cESLevent; +static swig_class SwigClassESLevent; SWIGINTERN VALUE _wrap_ESLevent_event_set(int argc, VALUE *argv, VALUE self) { @@ -1988,7 +2030,6 @@ _wrap_ESLevent_event_set(int argc, VALUE *argv, VALUE self) { } arg2 = reinterpret_cast< esl_event_t * >(argp2); if (arg1) (arg1)->event = arg2; - return Qnil; fail: return Qnil; @@ -1998,9 +2039,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_event_get(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - esl_event_t *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + esl_event_t *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2060,9 +2101,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_serialized_string_get(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2104,7 +2145,6 @@ _wrap_ESLevent_mine_set(int argc, VALUE *argv, VALUE self) { } arg2 = static_cast< int >(val2); if (arg1) (arg1)->mine = arg2; - return Qnil; fail: return Qnil; @@ -2114,9 +2154,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_mine_get(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2139,13 +2179,13 @@ SWIGINTERN VALUE _wrap_new_ESLevent__SWIG_0(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) NULL ; - ESLevent *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + ESLevent *result = 0 ; if ((argc < 1) || (argc > 2)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; @@ -2162,8 +2202,8 @@ _wrap_new_ESLevent__SWIG_0(int argc, VALUE *argv, VALUE self) { } arg2 = reinterpret_cast< char * >(buf2); } - result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2);DATA_PTR(self) = result; - + result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); + DATA_PTR(self) = result; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return self; @@ -2178,11 +2218,11 @@ SWIGINTERN VALUE _wrap_new_ESLevent__SWIG_1(int argc, VALUE *argv, VALUE self) { esl_event_t *arg1 = (esl_event_t *) 0 ; int arg2 = (int) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; + ESLevent *result = 0 ; if ((argc < 1) || (argc > 2)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; @@ -2199,8 +2239,8 @@ _wrap_new_ESLevent__SWIG_1(int argc, VALUE *argv, VALUE self) { } arg2 = static_cast< int >(val2); } - result = (ESLevent *)new ESLevent(arg1,arg2);DATA_PTR(self) = result; - + result = (ESLevent *)new ESLevent(arg1,arg2); + DATA_PTR(self) = result; return self; fail: return Qnil; @@ -2227,9 +2267,9 @@ _wrap_ESLevent_allocate(VALUE self) { SWIGINTERN VALUE _wrap_new_ESLevent__SWIG_2(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + ESLevent *result = 0 ; if ((argc < 1) || (argc > 1)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; @@ -2239,8 +2279,8 @@ _wrap_new_ESLevent__SWIG_2(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLevent *","ESLevent", 1, argv[0] )); } arg1 = reinterpret_cast< ESLevent * >(argp1); - result = (ESLevent *)new ESLevent(arg1);DATA_PTR(self) = result; - + result = (ESLevent *)new ESLevent(arg1); + DATA_PTR(self) = result; return self; fail: return Qnil; @@ -2319,12 +2359,12 @@ SWIGINTERN VALUE _wrap_ESLevent_serialize(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) NULL ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 1)) { @@ -2356,11 +2396,11 @@ SWIGINTERN VALUE _wrap_ESLevent_setPriority(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; esl_priority_t arg2 = (esl_priority_t) ESL_PRIORITY_NORMAL ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 ; int res2 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 0) || (argc > 1)) { @@ -2397,7 +2437,6 @@ _wrap_ESLevent_getHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; int arg3 = (int) -1 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2405,6 +2444,7 @@ _wrap_ESLevent_getHeader(int argc, VALUE *argv, VALUE self) { int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 2)) { @@ -2440,9 +2480,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_getBody(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2464,9 +2504,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_getType(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2489,12 +2529,12 @@ SWIGINTERN VALUE _wrap_ESLevent_addBody(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -2525,7 +2565,6 @@ _wrap_ESLevent_addHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2534,6 +2573,7 @@ _wrap_ESLevent_addHeader(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 2) || (argc > 2)) { @@ -2571,7 +2611,6 @@ _wrap_ESLevent_pushHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2580,6 +2619,7 @@ _wrap_ESLevent_pushHeader(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 2) || (argc > 2)) { @@ -2617,7 +2657,6 @@ _wrap_ESLevent_unshiftHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2626,6 +2665,7 @@ _wrap_ESLevent_unshiftHeader(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 2) || (argc > 2)) { @@ -2662,12 +2702,12 @@ SWIGINTERN VALUE _wrap_ESLevent_delHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + bool result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -2696,9 +2736,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_firstHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2720,9 +2760,9 @@ fail: SWIGINTERN VALUE _wrap_ESLevent_nextHeader(int argc, VALUE *argv, VALUE self) { ESLevent *arg1 = (ESLevent *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + char *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -2741,7 +2781,7 @@ fail: } -swig_class cESLconnection; +static swig_class SwigClassESLconnection; SWIGINTERN VALUE _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { @@ -2749,7 +2789,6 @@ _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { int arg2 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; - ESLconnection *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2761,6 +2800,7 @@ _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; + ESLconnection *result = 0 ; if ((argc < 4) || (argc > 4)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; @@ -2785,8 +2825,8 @@ _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","ESLconnection", 4, argv[3] )); } arg4 = reinterpret_cast< char * >(buf4); - result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4);DATA_PTR(self) = result; - + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + DATA_PTR(self) = result; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; if (alloc4 == SWIG_NEWOBJ) delete[] buf4; @@ -2804,7 +2844,6 @@ _wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; - ESLconnection *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2813,6 +2852,7 @@ _wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + ESLconnection *result = 0 ; if ((argc < 3) || (argc > 3)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; @@ -2832,8 +2872,8 @@ _wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); } arg3 = reinterpret_cast< char * >(buf3); - result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3);DATA_PTR(self) = result; - + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + DATA_PTR(self) = result; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return self; @@ -2850,7 +2890,6 @@ _wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; - ESLconnection *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2863,6 +2902,7 @@ _wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; + ESLconnection *result = 0 ; if ((argc < 4) || (argc > 4)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; @@ -2887,8 +2927,8 @@ _wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","ESLconnection", 4, argv[3] )); } arg4 = reinterpret_cast< char * >(buf4); - result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);DATA_PTR(self) = result; - + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + DATA_PTR(self) = result; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; @@ -2908,7 +2948,6 @@ _wrap_new_ESLconnection__SWIG_3(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - ESLconnection *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2918,6 +2957,7 @@ _wrap_new_ESLconnection__SWIG_3(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + ESLconnection *result = 0 ; if ((argc < 3) || (argc > 3)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; @@ -2937,8 +2977,8 @@ _wrap_new_ESLconnection__SWIG_3(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); } arg3 = reinterpret_cast< char * >(buf3); - result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3);DATA_PTR(self) = result; - + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); + DATA_PTR(self) = result; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; @@ -2971,9 +3011,9 @@ _wrap_ESLconnection_allocate(VALUE self) { SWIGINTERN VALUE _wrap_new_ESLconnection__SWIG_4(int argc, VALUE *argv, VALUE self) { int arg1 ; - ESLconnection *result = 0 ; int val1 ; int ecode1 = 0 ; + ESLconnection *result = 0 ; if ((argc < 1) || (argc > 1)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; @@ -2983,8 +3023,8 @@ _wrap_new_ESLconnection__SWIG_4(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","ESLconnection", 1, argv[0] )); } arg1 = static_cast< int >(val1); - result = (ESLconnection *)new ESLconnection(arg1);DATA_PTR(self) = result; - + result = (ESLconnection *)new ESLconnection(arg1); + DATA_PTR(self) = result; return self; fail: return Qnil; @@ -3108,9 +3148,9 @@ free_ESLconnection(ESLconnection *arg1) { SWIGINTERN VALUE _wrap_ESLconnection_socketDescriptor(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -3132,9 +3172,9 @@ fail: SWIGINTERN VALUE _wrap_ESLconnection_connected(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -3156,9 +3196,9 @@ fail: SWIGINTERN VALUE _wrap_ESLconnection_getInfo(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -3181,12 +3221,12 @@ SWIGINTERN VALUE _wrap_ESLconnection_send(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3216,12 +3256,12 @@ SWIGINTERN VALUE _wrap_ESLconnection_sendRecv(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3252,7 +3292,6 @@ _wrap_ESLconnection_api(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3261,6 +3300,7 @@ _wrap_ESLconnection_api(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 2)) { @@ -3301,7 +3341,6 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3313,6 +3352,7 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 3)) { @@ -3360,11 +3400,11 @@ SWIGINTERN VALUE _wrap_ESLconnection_sendEvent(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; ESLevent *arg2 = (ESLevent *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3393,7 +3433,6 @@ _wrap_ESLconnection_sendMSG(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; ESLevent *arg2 = (ESLevent *) 0 ; char *arg3 = (char *) NULL ; - int result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3401,6 +3440,7 @@ _wrap_ESLconnection_sendMSG(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 2)) { @@ -3436,9 +3476,9 @@ fail: SWIGINTERN VALUE _wrap_ESLconnection_recvEvent(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -3461,11 +3501,11 @@ SWIGINTERN VALUE _wrap_ESLconnection_recvEventTimed(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; int arg2 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3494,7 +3534,6 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3503,6 +3542,7 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 2) || (argc > 2)) { @@ -3540,7 +3580,6 @@ _wrap_ESLconnection_events(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3549,6 +3588,7 @@ _wrap_ESLconnection_events(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 2) || (argc > 2)) { @@ -3587,7 +3627,6 @@ _wrap_ESLconnection_execute(int argc, VALUE *argv, VALUE self) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3599,6 +3638,7 @@ _wrap_ESLconnection_execute(int argc, VALUE *argv, VALUE self) { int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 3)) { @@ -3648,7 +3688,6 @@ _wrap_ESLconnection_executeAsync(int argc, VALUE *argv, VALUE self) { char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; char *arg4 = (char *) NULL ; - ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3660,6 +3699,7 @@ _wrap_ESLconnection_executeAsync(int argc, VALUE *argv, VALUE self) { int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; + ESLevent *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 3)) { @@ -3707,12 +3747,12 @@ SWIGINTERN VALUE _wrap_ESLconnection_setAsyncExecute(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3742,12 +3782,12 @@ SWIGINTERN VALUE _wrap_ESLconnection_setEventLock(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { @@ -3776,9 +3816,9 @@ fail: SWIGINTERN VALUE _wrap_ESLconnection_disconnect(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; + int result; VALUE vresult = Qnil; if ((argc < 0) || (argc > 0)) { @@ -4108,57 +4148,57 @@ SWIGEXPORT void Init_ESL(void) { SWIG_RubyInitializeTrackings(); - cESLevent.klass = rb_define_class_under(mESL, "ESLevent", rb_cObject); - SWIG_TypeClientData(SWIGTYPE_p_ESLevent, (void *) &cESLevent); - rb_define_alloc_func(cESLevent.klass, _wrap_ESLevent_allocate); - rb_define_method(cESLevent.klass, "initialize", VALUEFUNC(_wrap_new_ESLevent), -1); - rb_define_method(cESLevent.klass, "event=", VALUEFUNC(_wrap_ESLevent_event_set), -1); - rb_define_method(cESLevent.klass, "event", VALUEFUNC(_wrap_ESLevent_event_get), -1); - rb_define_method(cESLevent.klass, "serialized_string=", VALUEFUNC(_wrap_ESLevent_serialized_string_set), -1); - rb_define_method(cESLevent.klass, "serialized_string", VALUEFUNC(_wrap_ESLevent_serialized_string_get), -1); - rb_define_method(cESLevent.klass, "mine=", VALUEFUNC(_wrap_ESLevent_mine_set), -1); - rb_define_method(cESLevent.klass, "mine", VALUEFUNC(_wrap_ESLevent_mine_get), -1); - rb_define_method(cESLevent.klass, "serialize", VALUEFUNC(_wrap_ESLevent_serialize), -1); - rb_define_method(cESLevent.klass, "setPriority", VALUEFUNC(_wrap_ESLevent_setPriority), -1); - rb_define_method(cESLevent.klass, "getHeader", VALUEFUNC(_wrap_ESLevent_getHeader), -1); - rb_define_method(cESLevent.klass, "getBody", VALUEFUNC(_wrap_ESLevent_getBody), -1); - rb_define_method(cESLevent.klass, "getType", VALUEFUNC(_wrap_ESLevent_getType), -1); - rb_define_method(cESLevent.klass, "addBody", VALUEFUNC(_wrap_ESLevent_addBody), -1); - rb_define_method(cESLevent.klass, "addHeader", VALUEFUNC(_wrap_ESLevent_addHeader), -1); - rb_define_method(cESLevent.klass, "pushHeader", VALUEFUNC(_wrap_ESLevent_pushHeader), -1); - rb_define_method(cESLevent.klass, "unshiftHeader", VALUEFUNC(_wrap_ESLevent_unshiftHeader), -1); - rb_define_method(cESLevent.klass, "delHeader", VALUEFUNC(_wrap_ESLevent_delHeader), -1); - rb_define_method(cESLevent.klass, "firstHeader", VALUEFUNC(_wrap_ESLevent_firstHeader), -1); - rb_define_method(cESLevent.klass, "nextHeader", VALUEFUNC(_wrap_ESLevent_nextHeader), -1); - cESLevent.mark = 0; - cESLevent.destroy = (void (*)(void *)) free_ESLevent; - cESLevent.trackObjects = 0; + SwigClassESLevent.klass = rb_define_class_under(mESL, "ESLevent", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_ESLevent, (void *) &SwigClassESLevent); + rb_define_alloc_func(SwigClassESLevent.klass, _wrap_ESLevent_allocate); + rb_define_method(SwigClassESLevent.klass, "initialize", VALUEFUNC(_wrap_new_ESLevent), -1); + rb_define_method(SwigClassESLevent.klass, "event=", VALUEFUNC(_wrap_ESLevent_event_set), -1); + rb_define_method(SwigClassESLevent.klass, "event", VALUEFUNC(_wrap_ESLevent_event_get), -1); + rb_define_method(SwigClassESLevent.klass, "serialized_string=", VALUEFUNC(_wrap_ESLevent_serialized_string_set), -1); + rb_define_method(SwigClassESLevent.klass, "serialized_string", VALUEFUNC(_wrap_ESLevent_serialized_string_get), -1); + rb_define_method(SwigClassESLevent.klass, "mine=", VALUEFUNC(_wrap_ESLevent_mine_set), -1); + rb_define_method(SwigClassESLevent.klass, "mine", VALUEFUNC(_wrap_ESLevent_mine_get), -1); + rb_define_method(SwigClassESLevent.klass, "serialize", VALUEFUNC(_wrap_ESLevent_serialize), -1); + rb_define_method(SwigClassESLevent.klass, "setPriority", VALUEFUNC(_wrap_ESLevent_setPriority), -1); + rb_define_method(SwigClassESLevent.klass, "getHeader", VALUEFUNC(_wrap_ESLevent_getHeader), -1); + rb_define_method(SwigClassESLevent.klass, "getBody", VALUEFUNC(_wrap_ESLevent_getBody), -1); + rb_define_method(SwigClassESLevent.klass, "getType", VALUEFUNC(_wrap_ESLevent_getType), -1); + rb_define_method(SwigClassESLevent.klass, "addBody", VALUEFUNC(_wrap_ESLevent_addBody), -1); + rb_define_method(SwigClassESLevent.klass, "addHeader", VALUEFUNC(_wrap_ESLevent_addHeader), -1); + rb_define_method(SwigClassESLevent.klass, "pushHeader", VALUEFUNC(_wrap_ESLevent_pushHeader), -1); + rb_define_method(SwigClassESLevent.klass, "unshiftHeader", VALUEFUNC(_wrap_ESLevent_unshiftHeader), -1); + rb_define_method(SwigClassESLevent.klass, "delHeader", VALUEFUNC(_wrap_ESLevent_delHeader), -1); + rb_define_method(SwigClassESLevent.klass, "firstHeader", VALUEFUNC(_wrap_ESLevent_firstHeader), -1); + rb_define_method(SwigClassESLevent.klass, "nextHeader", VALUEFUNC(_wrap_ESLevent_nextHeader), -1); + SwigClassESLevent.mark = 0; + SwigClassESLevent.destroy = (void (*)(void *)) free_ESLevent; + SwigClassESLevent.trackObjects = 0; - cESLconnection.klass = rb_define_class_under(mESL, "ESLconnection", rb_cObject); - SWIG_TypeClientData(SWIGTYPE_p_ESLconnection, (void *) &cESLconnection); - rb_define_alloc_func(cESLconnection.klass, _wrap_ESLconnection_allocate); - rb_define_method(cESLconnection.klass, "initialize", VALUEFUNC(_wrap_new_ESLconnection), -1); - rb_define_method(cESLconnection.klass, "socketDescriptor", VALUEFUNC(_wrap_ESLconnection_socketDescriptor), -1); - rb_define_method(cESLconnection.klass, "connected", VALUEFUNC(_wrap_ESLconnection_connected), -1); - rb_define_method(cESLconnection.klass, "getInfo", VALUEFUNC(_wrap_ESLconnection_getInfo), -1); - rb_define_method(cESLconnection.klass, "send", VALUEFUNC(_wrap_ESLconnection_send), -1); - rb_define_method(cESLconnection.klass, "sendRecv", VALUEFUNC(_wrap_ESLconnection_sendRecv), -1); - rb_define_method(cESLconnection.klass, "api", VALUEFUNC(_wrap_ESLconnection_api), -1); - rb_define_method(cESLconnection.klass, "bgapi", VALUEFUNC(_wrap_ESLconnection_bgapi), -1); - rb_define_method(cESLconnection.klass, "sendEvent", VALUEFUNC(_wrap_ESLconnection_sendEvent), -1); - rb_define_method(cESLconnection.klass, "sendMSG", VALUEFUNC(_wrap_ESLconnection_sendMSG), -1); - rb_define_method(cESLconnection.klass, "recvEvent", VALUEFUNC(_wrap_ESLconnection_recvEvent), -1); - rb_define_method(cESLconnection.klass, "recvEventTimed", VALUEFUNC(_wrap_ESLconnection_recvEventTimed), -1); - rb_define_method(cESLconnection.klass, "filter", VALUEFUNC(_wrap_ESLconnection_filter), -1); - rb_define_method(cESLconnection.klass, "events", VALUEFUNC(_wrap_ESLconnection_events), -1); - rb_define_method(cESLconnection.klass, "execute", VALUEFUNC(_wrap_ESLconnection_execute), -1); - rb_define_method(cESLconnection.klass, "executeAsync", VALUEFUNC(_wrap_ESLconnection_executeAsync), -1); - rb_define_method(cESLconnection.klass, "setAsyncExecute", VALUEFUNC(_wrap_ESLconnection_setAsyncExecute), -1); - rb_define_method(cESLconnection.klass, "setEventLock", VALUEFUNC(_wrap_ESLconnection_setEventLock), -1); - rb_define_method(cESLconnection.klass, "disconnect", VALUEFUNC(_wrap_ESLconnection_disconnect), -1); - cESLconnection.mark = 0; - cESLconnection.destroy = (void (*)(void *)) free_ESLconnection; - cESLconnection.trackObjects = 0; + SwigClassESLconnection.klass = rb_define_class_under(mESL, "ESLconnection", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_ESLconnection, (void *) &SwigClassESLconnection); + rb_define_alloc_func(SwigClassESLconnection.klass, _wrap_ESLconnection_allocate); + rb_define_method(SwigClassESLconnection.klass, "initialize", VALUEFUNC(_wrap_new_ESLconnection), -1); + rb_define_method(SwigClassESLconnection.klass, "socketDescriptor", VALUEFUNC(_wrap_ESLconnection_socketDescriptor), -1); + rb_define_method(SwigClassESLconnection.klass, "connected", VALUEFUNC(_wrap_ESLconnection_connected), -1); + rb_define_method(SwigClassESLconnection.klass, "getInfo", VALUEFUNC(_wrap_ESLconnection_getInfo), -1); + rb_define_method(SwigClassESLconnection.klass, "send", VALUEFUNC(_wrap_ESLconnection_send), -1); + rb_define_method(SwigClassESLconnection.klass, "sendRecv", VALUEFUNC(_wrap_ESLconnection_sendRecv), -1); + rb_define_method(SwigClassESLconnection.klass, "api", VALUEFUNC(_wrap_ESLconnection_api), -1); + rb_define_method(SwigClassESLconnection.klass, "bgapi", VALUEFUNC(_wrap_ESLconnection_bgapi), -1); + rb_define_method(SwigClassESLconnection.klass, "sendEvent", VALUEFUNC(_wrap_ESLconnection_sendEvent), -1); + rb_define_method(SwigClassESLconnection.klass, "sendMSG", VALUEFUNC(_wrap_ESLconnection_sendMSG), -1); + rb_define_method(SwigClassESLconnection.klass, "recvEvent", VALUEFUNC(_wrap_ESLconnection_recvEvent), -1); + rb_define_method(SwigClassESLconnection.klass, "recvEventTimed", VALUEFUNC(_wrap_ESLconnection_recvEventTimed), -1); + rb_define_method(SwigClassESLconnection.klass, "filter", VALUEFUNC(_wrap_ESLconnection_filter), -1); + rb_define_method(SwigClassESLconnection.klass, "events", VALUEFUNC(_wrap_ESLconnection_events), -1); + rb_define_method(SwigClassESLconnection.klass, "execute", VALUEFUNC(_wrap_ESLconnection_execute), -1); + rb_define_method(SwigClassESLconnection.klass, "executeAsync", VALUEFUNC(_wrap_ESLconnection_executeAsync), -1); + rb_define_method(SwigClassESLconnection.klass, "setAsyncExecute", VALUEFUNC(_wrap_ESLconnection_setAsyncExecute), -1); + rb_define_method(SwigClassESLconnection.klass, "setEventLock", VALUEFUNC(_wrap_ESLconnection_setEventLock), -1); + rb_define_method(SwigClassESLconnection.klass, "disconnect", VALUEFUNC(_wrap_ESLconnection_disconnect), -1); + SwigClassESLconnection.mark = 0; + SwigClassESLconnection.destroy = (void (*)(void *)) free_ESLconnection; + SwigClassESLconnection.trackObjects = 0; rb_define_module_function(mESL, "eslSetLogLevel", VALUEFUNC(_wrap_eslSetLogLevel), -1); } diff --git a/libs/esl/ruby/single_command.rb b/libs/esl/ruby/single_command.rb index b763cd8211..783152c390 100644 --- a/libs/esl/ruby/single_command.rb +++ b/libs/esl/ruby/single_command.rb @@ -1,8 +1,14 @@ #! /usr/bin/ruby +require_relative './ESL' -require "ESL" +HOST = '127.0.0.1'.to_s +PORT = '8021'.to_s +PASSWORD = 'ClueCon'.to_s command = ARGV.join(" ") -con = ESL::ESLconnection.new("localhost", "8021", "ClueCon") -e = con.sendRecv("api #{command}") -puts e.getBody() + +con = ESL::ESLconnection.new(HOST,PORT,PASSWORD) +e = con.sendRecv('api ' + command) + +puts e.getBody + diff --git a/libs/esl/src/esl.2012.vcxproj b/libs/esl/src/esl.2012.vcxproj index 90021628b6..a38a6df4cf 100644 --- a/libs/esl/src/esl.2012.vcxproj +++ b/libs/esl/src/esl.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -80,7 +80,7 @@ MultiThreadedDebugDLL Level4 true - 4706;4100;%(DisableSpecificWarnings) + 4267;4244;4706;4100;%(DisableSpecificWarnings) true @@ -97,7 +97,7 @@ MultiThreadedDebugDLL Level4 false - 4706;4100;%(DisableSpecificWarnings) + 4267;4244;4706;4100;%(DisableSpecificWarnings) true @@ -108,7 +108,7 @@ MultiThreadedDLL Level4 true - 4706;4100;%(DisableSpecificWarnings) + 4267;4244;4706;4100;%(DisableSpecificWarnings) true @@ -122,7 +122,7 @@ MultiThreadedDLL Level4 false - 4706;4100;%(DisableSpecificWarnings) + 4267;4244;4706;4100;%(DisableSpecificWarnings) true diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index d186665413..3634169b48 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,6 +59,7 @@ /* These warnings need to be ignored warning in sdk header */ #include #include +#include #ifndef errno #define errno WSAGetLastError() #endif @@ -476,15 +477,14 @@ ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t s esl_send_recv(handle, "connect\n\n"); - if (handle->last_sr_event) { handle->info_event = handle->last_sr_event; handle->last_sr_event = NULL; return ESL_SUCCESS; } - handle->connected = 0; - + esl_disconnect(handle); + return ESL_FAIL; } @@ -645,29 +645,57 @@ struct thread_handler { esl_socket_t server_sock; esl_socket_t client_sock; struct sockaddr_in addr; + void *user_data; }; static void *client_thread(esl_thread_t *me, void *obj) { struct thread_handler *handler = (struct thread_handler *) obj; - handler->callback(handler->server_sock, handler->client_sock, &handler->addr); + handler->callback(handler->server_sock, handler->client_sock, &handler->addr, handler->user_data); free(handler); return NULL; } -ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_listen_callback_t callback) +static int prepare_sock(esl_socket_t sock) +{ + int r = 0; + +#ifdef WIN32 + u_long arg = 1; + if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR) { + r = -1; + } +#else + int fd_flags = fcntl(sock, F_GETFL, 0); + if (fcntl(sock, F_SETFL, fd_flags | O_NONBLOCK)) { + r = -1; + } +#endif + + return r; + +} + + +ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_listen_callback_t callback, void *user_data, esl_socket_t *server_sockP) { esl_socket_t server_sock = ESL_SOCK_INVALID; struct sockaddr_in addr; esl_status_t status = ESL_SUCCESS; + if ((server_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { return ESL_FAIL; } + if (server_sockP) { + *server_sockP = server_sock; + } + + esl_socket_reuseaddr(server_sock); memset(&addr, 0, sizeof(addr)); @@ -700,8 +728,8 @@ ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_list status = ESL_FAIL; goto end; } - - callback(server_sock, client_sock, &echoClntAddr); + prepare_sock(client_sock); + callback(server_sock, client_sock, &echoClntAddr, user_data); } end: @@ -715,7 +743,7 @@ ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_list } -ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, esl_listen_callback_t callback, int max) +ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, esl_listen_callback_t callback, void *user_data, int max) { esl_socket_t server_sock = ESL_SOCK_INVALID; struct sockaddr_in addr; @@ -759,6 +787,8 @@ ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, goto end; } + prepare_sock(client_sock); + handler = malloc(sizeof(*handler)); esl_assert(handler); @@ -767,7 +797,7 @@ ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, handler->server_sock = server_sock; handler->client_sock = client_sock; handler->addr = echoClntAddr; - + handler->user_data = user_data; esl_thread_create_detached(client_thread, handler); } @@ -804,6 +834,10 @@ ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags) fd_set efds; struct timeval tv; + if (sock == ESL_SOCK_INVALID) { + return ESL_SOCK_INVALID; + } + FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); @@ -883,7 +917,11 @@ ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags) { struct pollfd pfds[2] = { { 0 } }; int s = 0, r = 0; - + + if (sock == ESL_SOCK_INVALID) { + return ESL_SOCK_INVALID; + } + pfds[0].fd = sock; if ((flags & ESL_POLL_READ)) { @@ -937,7 +975,7 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char * int err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { snprintf(handle->err, sizeof(handle->err), "WSAStartup Error"); - return ESL_FAIL; + goto fail; } #endif @@ -979,7 +1017,7 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char * if (handle->sock == ESL_SOCK_INVALID) { snprintf(handle->err, sizeof(handle->err), "Socket Error"); - return ESL_FAIL; + goto fail; } if (timeout) { @@ -1078,9 +1116,8 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char * return ESL_SUCCESS; fail: - + handle->connected = 0; - esl_disconnect(handle); return ESL_FAIL; } @@ -1089,41 +1126,53 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle) { esl_mutex_t *mutex = handle->mutex; esl_status_t status = ESL_FAIL; - + esl_event_t *ep; + if (handle->destroyed) { return ESL_FAIL; } - if (mutex) { - esl_mutex_lock(mutex); - } - - handle->destroyed = 1; - handle->connected = 0; - - esl_event_safe_destroy(&handle->race_event); - esl_event_safe_destroy(&handle->last_event); - esl_event_safe_destroy(&handle->last_sr_event); - esl_event_safe_destroy(&handle->last_ievent); - esl_event_safe_destroy(&handle->info_event); - if (handle->sock != ESL_SOCK_INVALID) { closesocket(handle->sock); handle->sock = ESL_SOCK_INVALID; status = ESL_SUCCESS; } - + + if (mutex) { + esl_mutex_lock(mutex); + } + + + handle->connected = 0; + + ep = handle->race_event; + + while(ep) { + esl_event_t *e = ep; + ep = ep->next; + if (e) { + esl_event_destroy(&e); + } + } + + esl_event_safe_destroy(&handle->last_event); + esl_event_safe_destroy(&handle->last_sr_event); + esl_event_safe_destroy(&handle->last_ievent); + esl_event_safe_destroy(&handle->info_event); + if (mutex) { esl_mutex_unlock(mutex); esl_mutex_lock(mutex); esl_mutex_unlock(mutex); esl_mutex_destroy(&mutex); } - + if (handle->packet_buf) { esl_buffer_destroy(&handle->packet_buf); } - + + memset(handle, 0, sizeof(*handle)); + handle->destroyed = 1; return status; } @@ -1150,7 +1199,11 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms esl_mutex_unlock(handle->mutex); } - activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR); + if (handle->packet_buf && esl_buffer_inuse(handle->packet_buf)) { + activity = ESL_POLL_READ; + } else { + activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR); + } if (activity < 0) { handle->connected = 0; @@ -1161,9 +1214,6 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms return ESL_BREAK; } - activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR); - - if (activity < 0) { handle->connected = 0; status = ESL_FAIL; @@ -1183,21 +1233,26 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms static esl_ssize_t handle_recv(esl_handle_t *handle, void *data, esl_size_t datalen) { - int activity; + esl_ssize_t activity = -1; - while (handle->connected) { - activity = esl_wait_sock(handle->sock, 1000, ESL_POLL_READ|ESL_POLL_ERROR); - - if (activity > 0 && (activity & ESL_POLL_READ)) { - return recv(handle->sock, data, datalen, 0); + if (handle->connected) { + if ((activity = esl_wait_sock(handle->sock, 1000, ESL_POLL_READ|ESL_POLL_ERROR)) > 0) { + if (activity < 0) { + activity = -1; + } else if ((activity & ESL_POLL_ERROR)) { + activity = -1; + } else if ((activity & ESL_POLL_READ)) { + if (!(activity = recv(handle->sock, data, datalen, 0))) { + activity = -1; + } else if (activity < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) { + activity = 0; + } + } } - if (activity < 0) { - return errno == EINTR ? 0 : -1; - } } - return -1; + return activity; } ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_event_t **save_event) @@ -1210,7 +1265,6 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ char *col; char *cl; esl_ssize_t len; - int zc = 0; if (!handle || !handle->connected || handle->sock == ESL_SOCK_INVALID) { return ESL_FAIL; @@ -1232,7 +1286,6 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ goto parse_event; } - while(!revent && handle->connected) { esl_size_t len1; @@ -1277,14 +1330,10 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ break; } - - rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1); - *((char *)handle->socket_buf + ESL_CLAMP(0, sizeof(handle->socket_buf) - 1, rrval)) = '\0'; + rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1); + if (rrval == 0) { - if (++zc >= 100) { - goto fail; - } continue; } else if (rrval < 0) { if (!(strerror_r(handle->errnum, handle->err, sizeof(handle->err)))) @@ -1292,7 +1341,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ goto fail; } - zc = 0; + *((char *)handle->socket_buf + ESL_CLAMP(0, sizeof(handle->socket_buf) - 1, rrval)) = '\0'; esl_buffer_write(handle->packet_buf, handle->socket_buf, rrval); } @@ -1317,21 +1366,16 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ sofar = esl_buffer_read(handle->packet_buf, body, len); } else { r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1); - *((char *)handle->socket_buf + ESL_CLAMP(0, sizeof(handle->socket_buf) - 1, r)) = '\0'; - + if (r < 0) { if (!(strerror_r(handle->errnum, handle->err, sizeof(handle->err)))) *(handle->err)=0; goto fail; } else if (r == 0) { - if (++zc >= 100) { - goto fail; - } continue; } - zc = 0; - + *((char *)handle->socket_buf + ESL_CLAMP(0, sizeof(handle->socket_buf) - 1, r)) = '\0'; esl_buffer_write(handle->packet_buf, handle->socket_buf, r); } @@ -1513,6 +1557,10 @@ ESL_DECLARE(esl_status_t) esl_send_recv_timed(esl_handle_t *handle, const char * } recv: + + esl_event_safe_destroy(&handle->last_sr_event); + + *handle->last_sr_reply = '\0'; status = esl_recv_event_timed(handle, ms, 0, &handle->last_sr_event); @@ -1523,7 +1571,7 @@ ESL_DECLARE(esl_status_t) esl_send_recv_timed(esl_handle_t *handle, const char * esl_event_t *ep; for(ep = handle->race_event; ep && ep->next; ep = ep->next); - + if (ep) { ep->next = handle->last_sr_event; } else { diff --git a/libs/esl/src/esl_buffer.c b/libs/esl/src/esl_buffer.c index 40c7252c15..6095a56a21 100644 --- a/libs/esl/src/esl_buffer.c +++ b/libs/esl/src/esl_buffer.c @@ -54,6 +54,7 @@ ESL_DECLARE(esl_status_t) esl_buffer_create(esl_buffer_t **buffer, esl_size_t bl esl_buffer_t *new_buffer; new_buffer = malloc(sizeof(*new_buffer)); + if (new_buffer) { memset(new_buffer, 0, sizeof(*new_buffer)); @@ -335,9 +336,10 @@ ESL_DECLARE(void) esl_buffer_destroy(esl_buffer_t **buffer) { if (*buffer) { free((*buffer)->data); + (*buffer)->data = NULL; free(*buffer); } - + *buffer = NULL; } diff --git a/libs/esl/src/esl_config.c b/libs/esl/src/esl_config.c index 04ffafe4c4..7863735550 100644 --- a/libs/esl/src/esl_config.c +++ b/libs/esl/src/esl_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c index b5a6be4d58..380b122228 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -308,7 +308,7 @@ ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const cha esl_assert(x < 1000000); hash = esl_ci_hashfunc_default(header_name, &hlen); - if ((!hp->hash || hash == hp->hash) && (hp->name && !strcasecmp(header_name, hp->name)) && (esl_strlen_zero(val) || !strcmp(hp->value, val))) { + if ((!hp->hash || hash == hp->hash) && (hp->name && !strcasecmp(header_name, hp->name)) && (esl_strlen_zero(val) || (hp->value && !strcmp(hp->value, val)))) { if (lp) { lp->next = hp->next; } else { diff --git a/libs/esl/src/include/esl.h b/libs/esl/src/include/esl.h index 79c416a6d3..1abdd241f6 100644 --- a/libs/esl/src/include/esl.h +++ b/libs/esl/src/include/esl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -379,7 +379,7 @@ ESL_DECLARE(int) esl_tolower(int c); ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...); -typedef void (*esl_listen_callback_t)(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr); +typedef void (*esl_listen_callback_t)(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr, void *user_data); /*! \brief Attach a handle to an established socket connection \param handle Handle to be attached @@ -394,8 +394,8 @@ ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t s \param callback Callback that will be called upon data received */ -ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_listen_callback_t callback); -ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, esl_listen_callback_t callback, int max); +ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_listen_callback_t callback, void *user_data, esl_socket_t *server_sockP); +ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, esl_listen_callback_t callback, void *user_data, int max); /*! \brief Executes application with sendmsg to a specific UUID. Used for outbound socket. \param handle Handle that the msg will be sent diff --git a/libs/esl/src/include/esl_config.h b/libs/esl/src/include/esl_config.h index 41e64195b1..0a2dffb42a 100644 --- a/libs/esl/src/include/esl_config.h +++ b/libs/esl/src/include/esl_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/esl/src/include/esl_event.h b/libs/esl/src/include/esl_event.h index 44cfd184dc..47c38b6cf7 100644 --- a/libs/esl/src/include/esl_event.h +++ b/libs/esl/src/include/esl_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/esl/src/include/esl_json.h b/libs/esl/src/include/esl_json.h old mode 100755 new mode 100644 diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 93ce487965..33b2440001 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/esl/testserver.c b/libs/esl/testserver.c index f8eb78d1f3..3bf23139e6 100644 --- a/libs/esl/testserver.c +++ b/libs/esl/testserver.c @@ -2,7 +2,7 @@ #include #include -static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) +static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr, void *user_data) { esl_handle_t handle = {{0}}; int done = 0; @@ -48,7 +48,7 @@ static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struc int main(void) { esl_global_set_default_logger(7); - esl_listen_threaded("localhost", 8084, mycallback, 100000); + esl_listen_threaded("localhost", 8040, mycallback, NULL, 100000); return 0; } diff --git a/libs/esl/testserver_fork.c b/libs/esl/testserver_fork.c new file mode 100644 index 0000000000..eb377cc668 --- /dev/null +++ b/libs/esl/testserver_fork.c @@ -0,0 +1,72 @@ +#include +#include +#include + +static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr, void *user_data) +{ + esl_handle_t handle = {{0}}; + int done = 0; + esl_status_t status; + time_t exp = 0; + + if (fork()) { + return; + } + + if (esl_attach_handle(&handle, client_sock, addr) != ESL_SUCCESS) { + return; + } + + + esl_log(ESL_LOG_INFO, "Connected! %d\n", handle.sock); + + esl_filter(&handle, "unique-id", esl_event_get_header(handle.info_event, "caller-unique-id")); + esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "SESSION_HEARTBEAT CHANNEL_ANSWER CHANNEL_ORIGINATE CHANNEL_PROGRESS CHANNEL_HANGUP " + "CHANNEL_BRIDGE CHANNEL_UNBRIDGE CHANNEL_OUTGOING CHANNEL_EXECUTE CHANNEL_EXECUTE_COMPLETE DTMF CUSTOM conference::maintenance"); + + esl_send_recv(&handle, "linger"); + + esl_execute(&handle, "answer", NULL, NULL); + esl_execute(&handle, "conference", "3000@default", NULL); + + while((status = esl_recv_timed(&handle, 1000)) != ESL_FAIL) { + if (done) { + if (time(NULL) >= exp) { + break; + } + } else if (status == ESL_SUCCESS) { + const char *type = esl_event_get_header(handle.last_event, "content-type"); + if (type && !strcasecmp(type, "text/disconnect-notice")) { + const char *dispo = esl_event_get_header(handle.last_event, "content-disposition"); + esl_log(ESL_LOG_INFO, "Got a disconnection notice dispostion: [%s]\n", dispo ? dispo : ""); + if (dispo && !strcmp(dispo, "linger")) { + done = 1; + esl_log(ESL_LOG_INFO, "Waiting 5 seconds for any remaining events.\n"); + exp = time(NULL) + 5; + } + } + } + } + + esl_log(ESL_LOG_INFO, "Disconnected! %d\n", handle.sock); + esl_disconnect(&handle); +} + +static esl_socket_t server_sock = ESL_SOCK_INVALID; + +static void handle_sig(int sig) +{ + shutdown(server_sock, 2); + +} + +int main(void) +{ + signal(SIGINT, handle_sig); + signal(SIGCHLD, SIG_IGN); + + esl_global_set_default_logger(7); + esl_listen("localhost", 8040, mycallback, NULL, &server_sock); + + return 0; +} diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am index 2c277aab6f..7c0e419719 100644 --- a/libs/freetdm/Makefile.am +++ b/libs/freetdm/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2007-2012, Anthony Minessale II +# Copyright (c) 2007-2014, Anthony Minessale II # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/freetdm.2012.sln b/libs/freetdm/freetdm.2012.sln new file mode 100644 index 0000000000..1d4c335a8d --- /dev/null +++ b/libs/freetdm/freetdm.2012.sln @@ -0,0 +1,127 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetdm", "msvc\freetdm.2012.vcxproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2012.vcxproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2012.vcxproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_freetdm", "mod_freetdm\mod_freetdm.2012.vcxproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog", "src\ftmod\ftmod_analog\ftmod_analog.2012.vcxproj", "{37C94798-6E33-4B4F-8EE0-C72A7DC91157}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog_em", "src\ftmod\ftmod_analog_em\ftmod_analog_em.2012.vcxproj", "{B3F49375-2834-4937-9D8C-4AC2EC911010}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_isdn", "src\ftmod\ftmod_isdn\ftmod_isdn.2012.vcxproj", "{729344A5-D5E9-434D-8EE8-AF8C6C795D15}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftmod_pika\ftmod_pika.2012.vcxproj", "{E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2012.vcxproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2012.vcxproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2012.vcxproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + 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}.Debug|x64.ActiveCfg = Debug|x64 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.Build.0 = Debug|x64 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.ActiveCfg = Release|x64 + {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.Build.0 = Release|x64 + {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}.Debug|x64.ActiveCfg = Debug|x64 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.Build.0 = Debug|x64 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.ActiveCfg = Release|x64 + {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.Build.0 = Release|x64 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|x64.ActiveCfg = Debug|x64 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|x64.ActiveCfg = Release|x64 + {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}.Debug|x64.ActiveCfg = Debug|x64 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.Build.0 = Debug|x64 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.ActiveCfg = Release|x64 + {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.Build.0 = Release|x64 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.ActiveCfg = Debug|Win32 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.Build.0 = Debug|Win32 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.ActiveCfg = Debug|x64 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.Build.0 = Debug|x64 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.ActiveCfg = Release|Win32 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.Build.0 = Release|Win32 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.ActiveCfg = Release|x64 + {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.Build.0 = Release|x64 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.Build.0 = Debug|Win32 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.ActiveCfg = Debug|x64 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.Build.0 = Debug|x64 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.ActiveCfg = Release|Win32 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.Build.0 = Release|Win32 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.ActiveCfg = Release|x64 + {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.Build.0 = Release|x64 + {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.ActiveCfg = Debug|Win32 + {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|x64.ActiveCfg = Debug|x64 + {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.ActiveCfg = Release|Win32 + {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|x64.ActiveCfg = Release|x64 + {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|Win32.ActiveCfg = Debug|Win32 + {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|x64.ActiveCfg = Debug|x64 + {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|Win32.ActiveCfg = Release|Win32 + {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|x64.ActiveCfg = Release|x64 + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.ActiveCfg = Debug|Win32 + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.Build.0 = Debug|Win32 + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|x64.ActiveCfg = Debug|x64 + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|Win32.ActiveCfg = Release|Win32 + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|x64.ActiveCfg = Release|x64 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.ActiveCfg = Debug|Win32 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.Build.0 = Debug|Win32 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.ActiveCfg = Debug|x64 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.Build.0 = Debug|x64 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.ActiveCfg = Release|Win32 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.Build.0 = Release|Win32 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.ActiveCfg = Release|x64 + {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.Build.0 = Release|x64 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.ActiveCfg = Debug|Win32 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.Build.0 = Debug|Win32 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.ActiveCfg = Debug|x64 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.Build.0 = Debug|x64 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.ActiveCfg = Release|Win32 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.Build.0 = Release|Win32 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.ActiveCfg = Release|x64 + {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.Build.0 = Release|x64 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.ActiveCfg = Debug|Win32 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.Build.0 = Debug|Win32 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.ActiveCfg = Debug|x64 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.Build.0 = Debug|x64 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.ActiveCfg = Release|Win32 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.Build.0 = Release|Win32 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.ActiveCfg = Release|x64 + {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.Build.0 = Release|x64 + {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|Win32.ActiveCfg = Debug|Win32 + {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|x64.ActiveCfg = Debug|x64 + {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.ActiveCfg = Release|Win32 + {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|x64.ActiveCfg = Release|x64 + {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.ActiveCfg = Debug|Win32 + {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|x64.ActiveCfg = Debug|x64 + {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.ActiveCfg = Release|Win32 + {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj b/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj new file mode 100644 index 0000000000..c89130912f --- /dev/null +++ b/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj @@ -0,0 +1,221 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_freetdm + {FE3540C5-3303-46E0-A69E-D92F775687F1} + mod_freetdm + Win32Proj + + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(PlatformName)\$(Configuration)\mod\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(PlatformName)\$(Configuration)\mod\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(PlatformName)\$(Configuration)\mod\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(PlatformName)\$(Configuration)\mod\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ../../../src/include;../src/include;../../curl/include;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + ProgramDatabase + + + FreeSwitchCore.lib;%(AdditionalDependencies) + ../../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories) + true + $(OutDir)$(TargetName).pdb + Windows + false + + + $(OutDir)mod_freetdm.lib + MachineX86 + + + + + ../../../src/include;../src/include;../../curl/include;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + + + FreeSwitchCore.lib;%(AdditionalDependencies) + ../../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories) + true + $(OutDir)$(TargetName).pdb + Windows + true + true + UseLinkTimeCodeGeneration + false + + + $(OutDir)mod_freetdm.lib + MachineX86 + + + + + X64 + + + Disabled + ../../../src/include;../src/include;../../curl/include;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + ProgramDatabase + + + FreeSwitchCore.lib;%(AdditionalDependencies) + ../../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories) + true + $(OutDir)$(TargetName).pdb + Windows + false + + + $(OutDir)mod_freetdm.lib + MachineX64 + + + + + X64 + + + ../../../src/include;../src/include;../../curl/include;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + + + FreeSwitchCore.lib;%(AdditionalDependencies) + ../../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories) + true + $(OutDir)$(TargetName).pdb + Windows + true + true + UseLinkTimeCodeGeneration + false + + + $(OutDir)mod_freetdm.lib + MachineX64 + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj.filters b/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj.filters new file mode 100644 index 0000000000..92ac5ead47 --- /dev/null +++ b/libs/freetdm/mod_freetdm/mod_freetdm.2012.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 865b52363f..f33720b25a 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -719,14 +719,14 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch name = switch_channel_get_name(channel); if (!tech_pvt->ftdmchan) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); return SWITCH_STATUS_FALSE; } span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan); chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan); if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); return SWITCH_STATUS_FALSE; } @@ -760,7 +760,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } @@ -768,7 +768,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch status = ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, chunk); if (status == FTDM_FAIL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } @@ -776,7 +776,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch if (!switch_test_flag(tech_pvt, TFLAG_HOLD)) { total_to -= chunk; if (total_to <= 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Too many timeouts while waiting I/O in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "Too many timeouts while waiting I/O in channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } } @@ -789,11 +789,16 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch len = tech_pvt->read_frame.buflen; if (ftdm_channel_read(tech_pvt->ftdmchan, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); + if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to read from dead channel %s device %d:%d\n", name, span_id, chan_id); + goto normal_failure; + } + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); if (++tech_pvt->read_error > FTDM_MAX_READ_WRITE_ERRORS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "too many I/O read errors on channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "too many I/O read errors on channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } + } else { tech_pvt->read_error = 0; } @@ -812,7 +817,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch for (p = dtmf; p && *p; p++) { if (is_dtmf(*p)) { _dtmf.digit = *p; - ftdm_log(FTDM_LOG_DEBUG, "Queuing DTMF [%c] in channel %s device %d:%d\n", *p, name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Queuing DTMF [%c] in channel %s device %d:%d\n", *p, name, span_id, chan_id); switch_channel_queue_dtmf(channel, &_dtmf); } } @@ -821,7 +826,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch return SWITCH_STATUS_SUCCESS; fail: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "clearing IO in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "clearing IO in channel %s device %d:%d!\n", name, span_id, chan_id); +normal_failure: switch_clear_flag_locked(tech_pvt, TFLAG_IO); return SWITCH_STATUS_GENERR; } @@ -844,7 +850,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc name = switch_channel_get_name(channel); if (!tech_pvt->ftdmchan) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); return SWITCH_STATUS_FALSE; } @@ -852,7 +858,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan); if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); return SWITCH_STATUS_FALSE; } @@ -861,7 +867,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc } if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } @@ -879,15 +885,15 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 10); if (!(wflags & FTDM_WRITE)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id); return SWITCH_STATUS_SUCCESS; } len = frame->datalen; if (ftdm_channel_write(tech_pvt->ftdmchan, frame->data, frame->buflen, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to write to channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Failed to write to channel %s device %d:%d!\n", name, span_id, chan_id); if (++tech_pvt->write_error > FTDM_MAX_READ_WRITE_ERRORS) { - switch_log_printf(SWITCH_CHANNEL_LOG, + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Too many I/O write errors on channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } @@ -898,7 +904,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc return SWITCH_STATUS_SUCCESS; fail: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error writing to channel %s device %d:%d!\n", name, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Error writing to channel %s device %d:%d!\n", name, span_id, chan_id); switch_clear_flag_locked(tech_pvt, TFLAG_IO); return SWITCH_STATUS_GENERR; @@ -1239,7 +1245,7 @@ static ftdm_status_t on_channel_found(ftdm_channel_t *fchan, ftdm_caller_data_t tech_init(hdata->tech_pvt, hdata->new_session, fchan, caller_data); snprintf(name, sizeof(name), "FreeTDM/%u:%u/%s", span_id, chan_id, caller_data->dnis.digits); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name); switch_channel_set_name(channel, name); switch_channel_set_variable(channel, "freetdm_span_name", ftdm_channel_get_span_name(fchan)); switch_channel_set_variable_printf(channel, "freetdm_span_number", "%d", span_id); @@ -1267,7 +1273,7 @@ static ftdm_status_t on_channel_found(ftdm_channel_t *fchan, ftdm_caller_data_t return FTDM_BREAK; } } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attached session %s to channel %d:%d\n", sess_uuid, span_id, chan_id); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Attached session %s to channel %d:%d\n", sess_uuid, span_id, chan_id); return FTDM_SUCCESS; } @@ -1285,7 +1291,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi int span_id = -1, group_id = -1, chan_id = 0; switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; ftdm_status_t status; - int direction = FTDM_TOP_DOWN; + ftdm_hunt_direction_t direction = FTDM_HUNT_BOTTOM_UP; ftdm_caller_data_t caller_data = {{ 0 }}; char *span_name = NULL; switch_event_header_t *h; @@ -1342,14 +1348,14 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi span_name = argv[0]; } - if (*argv[1] == 'A') { - direction = FTDM_BOTTOM_UP; - } else if (*argv[1] == 'a') { - direction = FTDM_TOP_DOWN; - } else if (*argv[1] == 'r') { - direction = FTDM_RR_DOWN; + if (*argv[1] == 'a') { + direction = FTDM_HUNT_BOTTOM_UP; + } else if (*argv[1] == 'A') { + direction = FTDM_HUNT_TOP_DOWN; } else if (*argv[1] == 'R') { - direction = FTDM_RR_UP; + direction = FTDM_HUNT_RR_DOWN; + } else if (*argv[1] == 'r') { + direction = FTDM_HUNT_RR_UP; } else { chan_id = atoi(argv[1]); } @@ -1384,7 +1390,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi } if (group_id < 0 && chan_id < 0) { - direction = FTDM_BOTTOM_UP; + direction = FTDM_HUNT_BOTTOM_UP; chan_id = 0; } diff --git a/libs/freetdm/msvc/freetdm.2012.vcxproj b/libs/freetdm/msvc/freetdm.2012.vcxproj new file mode 100644 index 0000000000..e07a5ce072 --- /dev/null +++ b/libs/freetdm/msvc/freetdm.2012.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + freetdm + {93B8812C-3EC4-4F78-8970-FFBFC99E167D} + freetdm + Win32Proj + + + + DynamicLibrary + MultiByte + true + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + true + v110 + + + DynamicLibrary + MultiByte + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(IntDir)BuildLog-freetdm.htm + + + Disabled + ../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + false + false + + + Level4 + true + ProgramDatabase + CompileAsC + + + true + + + + + $(IntDir)BuildLog-freetdm.htm + + + ../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions) + MultiThreadedDLL + false + false + + + Level4 + true + ProgramDatabase + CompileAsC + + + + + $(IntDir)BuildLog-freetdm.htm + + + X64 + + + Disabled + ../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + false + false + + + Level4 + true + ProgramDatabase + CompileAsC + + + true + MachineX64 + + + + + $(IntDir)BuildLog-freetdm.htm + + + X64 + + + ../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions) + MultiThreadedDLL + false + false + + + Level4 + true + ProgramDatabase + CompileAsC + + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/freetdm/msvc/freetdm.2012.vcxproj.filters b/libs/freetdm/msvc/freetdm.2012.vcxproj.filters new file mode 100644 index 0000000000..9f15c9c737 --- /dev/null +++ b/libs/freetdm/msvc/freetdm.2012.vcxproj.filters @@ -0,0 +1,137 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj b/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj new file mode 100644 index 0000000000..5276eafa7b --- /dev/null +++ b/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + testanalog + {BB833648-BAFF-4BE2-94DB-F8BB043C588C} + testanalog + Win32Proj + + + + Application + Unicode + true + v110 + + + Application + Unicode + v110 + + + Application + Unicode + true + v110 + + + Application + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(IntDir)BuildLog-testanalog.htm + + + Disabled + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + EditAndContinue + 4100;%(DisableSpecificWarnings) + + + true + Console + false + + + MachineX86 + + + + + $(IntDir)BuildLog-testanalog.htm + + + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + true + true + false + + + MachineX86 + + + + + $(IntDir)BuildLog-testanalog.htm + + + X64 + + + Disabled + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + false + + + MachineX64 + + + + + $(IntDir)BuildLog-testanalog.htm + + + X64 + + + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + true + true + false + + + MachineX64 + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj.filters b/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj.filters new file mode 100644 index 0000000000..7ac3635cc5 --- /dev/null +++ b/libs/freetdm/msvc/testanalog/testanalog.2012.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj b/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj new file mode 100644 index 0000000000..61f4759f1b --- /dev/null +++ b/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + testisdn + {6DA6FD42-641D-4147-92F5-3BC4AAA6589B} + testisdn + Win32Proj + + + + Application + Unicode + true + v110 + + + Application + Unicode + v110 + + + Application + Unicode + true + v110 + + + Application + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(IntDir)BuildLog-testisdn.htm + + + Disabled + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + EditAndContinue + 4100;%(DisableSpecificWarnings) + + + true + Console + false + + + MachineX86 + + + + + $(IntDir)BuildLog-testisdn.htm + + + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + true + true + false + + + MachineX86 + + + + + $(IntDir)BuildLog-testisdn.htm + + + X64 + + + Disabled + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + false + + + MachineX64 + + + + + $(IntDir)BuildLog-testisdn.htm + + + X64 + + + ../../src/include;../../src/isdn/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Console + true + true + false + + + MachineX64 + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj.filters b/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj.filters new file mode 100644 index 0000000000..9d48828d4a --- /dev/null +++ b/libs/freetdm/msvc/testisdn/testisdn.2012.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftdm_buffer.c b/libs/freetdm/src/ftdm_buffer.c index 47dd91d9c4..48e8a36554 100644 --- a/libs/freetdm/src/ftdm_buffer.c +++ b/libs/freetdm/src/ftdm_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftdm_config.c b/libs/freetdm/src/ftdm_config.c index 29c76cb535..9352284edf 100644 --- a/libs/freetdm/src/ftdm_config.c +++ b/libs/freetdm/src/ftdm_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 57d5af1b85..8eabd47db6 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1502,7 +1502,7 @@ static __inline__ int chan_voice_is_avail(ftdm_channel_t *check) } static __inline__ int request_voice_channel(ftdm_channel_t *check, ftdm_channel_t **ftdmchan, - ftdm_caller_data_t *caller_data, ftdm_direction_t direction) + ftdm_caller_data_t *caller_data, ftdm_hunt_direction_t direction) { ftdm_status_t status; if (chan_voice_is_avail(check)) { @@ -1589,13 +1589,13 @@ static ftdm_status_t __inline__ get_best_rated(ftdm_channel_t **fchan, ftdm_chan return FTDM_SUCCESS; } -static uint32_t __inline__ rr_next(uint32_t last, uint32_t min, uint32_t max, ftdm_direction_t direction) +static uint32_t __inline__ rr_next(uint32_t last, uint32_t min, uint32_t max, ftdm_hunt_direction_t direction) { uint32_t next = min; ftdm_log(FTDM_LOG_DEBUG, "last = %d, min = %d, max = %d\n", last, min, max); - if (direction == FTDM_RR_DOWN) { + if (direction == FTDM_HUNT_RR_UP) { next = (last >= max) ? min : ++last; } else { next = (last <= min) ? max : --last; @@ -1615,7 +1615,7 @@ FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan) return availability; } -static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) { ftdm_status_t status = FTDM_FAIL; ftdm_channel_t *check = NULL; @@ -1645,9 +1645,9 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi } - if (direction == FTDM_TOP_DOWN) { + if (direction == FTDM_HUNT_BOTTOM_UP) { i = 0; - } else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) { + } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { i = rr_next(group->last_used_index, 0, group->chan_count - 1, direction); first_channel = i; } else { @@ -1664,7 +1664,7 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi if (request_voice_channel(check, ftdmchan, caller_data, direction)) { status = FTDM_SUCCESS; - if (direction == FTDM_RR_UP || direction == FTDM_RR_DOWN) { + if (direction == FTDM_HUNT_RR_UP || direction == FTDM_HUNT_RR_DOWN) { group->last_used_index = i; } break; @@ -1672,12 +1672,12 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi calculate_best_rate(check, &best_rated, &best_rate); - if (direction == FTDM_TOP_DOWN) { + if (direction == FTDM_HUNT_BOTTOM_UP) { if (i >= (group->chan_count - 1)) { break; } i++; - } else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) { + } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { if (check == best_rated) { group->last_used_index = i; } @@ -1701,7 +1701,7 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi return status; } -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) { ftdm_status_t status; status = _ftdm_channel_open_by_group(group_id, direction, caller_data, ftdmchan); @@ -1734,7 +1734,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_channel_use_count(ftdm_span_t *span, uint32_ } /* Hunt a channel by span, if successful the channel is returned locked */ -static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) { ftdm_status_t status = FTDM_FAIL; ftdm_channel_t *check = NULL; @@ -1773,9 +1773,9 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction ftdm_mutex_lock(span->mutex); - if (direction == FTDM_TOP_DOWN) { + if (direction == FTDM_HUNT_BOTTOM_UP) { i = 1; - } else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) { + } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { i = rr_next(span->last_used_index, 1, span->chan_count, direction); first_channel = i; } else { @@ -1784,7 +1784,7 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction for(;;) { - if (direction == FTDM_TOP_DOWN) { + if (direction == FTDM_HUNT_BOTTOM_UP) { if (i > span->chan_count) { break; } @@ -1801,7 +1801,7 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction if (request_voice_channel(check, ftdmchan, caller_data, direction)) { status = FTDM_SUCCESS; - if (direction == FTDM_RR_UP || direction == FTDM_RR_DOWN) { + if (direction == FTDM_HUNT_RR_UP || direction == FTDM_HUNT_RR_DOWN) { span->last_used_index = i; } break; @@ -1809,9 +1809,9 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction calculate_best_rate(check, &best_rated, &best_rate); - if (direction == FTDM_TOP_DOWN) { + if (direction == FTDM_HUNT_BOTTOM_UP) { i++; - } else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) { + } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { if (check == best_rated) { span->last_used_index = i; } @@ -1833,7 +1833,7 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction return status; } -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) { ftdm_status_t status; status = _ftdm_channel_open_by_span(span_id, direction, caller_data, ftdmchan); diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h b/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h index 9a4046bf3d..ec20070262 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj new file mode 100644 index 0000000000..03589c2300 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj @@ -0,0 +1,202 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_analog + {37C94798-6E33-4B4F-8EE0-C72A7DC91157} + ftmod_analog + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + EditAndContinue + 4100;%(DisableSpecificWarnings) + + + true + Windows + MachineX86 + + + + + MaxSpeed + true + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + true + true + MachineX86 + + + + + X64 + + + Disabled + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + false + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + MachineX64 + + + + + X64 + + + MaxSpeed + true + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + false + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + true + true + MachineX64 + + + + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj.filters new file mode 100644 index 0000000000..b6fed5927a --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2012.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index e342c827d1..0d6caec400 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj new file mode 100644 index 0000000000..14c0021092 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj @@ -0,0 +1,202 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_analog_em + {B3F49375-2834-4937-9D8C-4AC2EC911010} + ftmod_analog_em + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EM_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + EditAndContinue + 4100;%(DisableSpecificWarnings) + + + true + Windows + MachineX86 + + + + + MaxSpeed + true + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EM_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + true + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + true + true + MachineX86 + + + + + X64 + + + Disabled + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EM_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + false + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + MachineX64 + + + + + X64 + + + MaxSpeed + true + ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ANALOG_EM_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + false + ProgramDatabase + 4100;%(DisableSpecificWarnings) + + + true + Windows + true + true + MachineX64 + + + + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj.filters new file mode 100644 index 0000000000..3326f9fd16 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2012.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c index 8cf43bbdfd..8a537bb5e6 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c @@ -291,13 +291,23 @@ static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(analog_em_set_channel_sig_status) return FTDM_FAIL; case FTDM_SIG_STATE_SUSPENDED: if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { + int cas_bits = 0xFF; ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); + if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { + ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); + } ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); } break; case FTDM_SIG_STATE_UP: if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { + int cas_bits = 0x00; ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { + ftdm_channel_command(ftdmchan, FTDM_COMMAND_ONHOOK, NULL); + } if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); } @@ -643,12 +653,9 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj) case FTDM_CHANNEL_STATE_RING: { ftdm_sleep(interval); - if (ftdmchan->state == FTDM_CHANNEL_STATE_UP && cas_answer) { + if (ftdmchan->state == FTDM_CHANNEL_STATE_UP) { cas_bits = 0; ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CAS_BITS, &cas_bits); - if (!(state_counter % 5000)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "CAS bits: 0x%X\n", cas_bits); - } if (cas_bits == 0x0) { cas_hangup += interval; if (cas_hangup >= cas_hangup_ms) { diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj new file mode 100644 index 0000000000..cf2344c4ec --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj @@ -0,0 +1,227 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_isdn + {729344A5-D5E9-434D-8EE8-AF8C6C795D15} + ftmod_isdn + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\isdn\include;..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + EditAndContinue + + + true + Windows + MachineX86 + + + + + MaxSpeed + true + ..\..\isdn\include;..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + true + ProgramDatabase + + + true + Windows + true + true + MachineX86 + + + + + X64 + + + Disabled + ..\..\isdn\include;..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + true + ProgramDatabase + + + true + Windows + MachineX64 + + + + + X64 + + + MaxSpeed + true + ..\..\isdn\include;..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + true + ProgramDatabase + + + true + Windows + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj.filters new file mode 100644 index 0000000000..30824888fc --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2012.vcxproj.filters @@ -0,0 +1,110 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c index 171a673027..548bde6f0c 100644 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h index 23de26f61f..378f901320 100644 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index 471afe080c..a16949fd71 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * Copyright (c) 2010, Stefan Knoblich * Copyright (c) 2012-2013, Stefan Knoblich * All rights reserved. diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h b/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h index c482169473..54c550e8e7 100644 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h +++ b/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj new file mode 100644 index 0000000000..c17deb8795 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj @@ -0,0 +1,202 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_pika + {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF} + ftmod_pika + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + DynamicLibrary + Unicode + true + v110 + + + DynamicLibrary + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\isdn\include;..\..\include;..\..\..\pika\aoh\inc;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_PIKA_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + + + pikahmpapi.lib;%(AdditionalDependencies) + ..\..\..\pika\aoh\lib;%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + + + MaxSpeed + true + ..\..\isdn\include;..\..\include;..\..\..\pika\aoh\inc;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_PIKA_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + + + pikahmpapi.lib;%(AdditionalDependencies) + ..\..\..\pika\aoh\lib;%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX86 + + + + + X64 + + + Disabled + ..\..\isdn\include;..\..\include;..\..\..\pika\aoh\inc;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_PIKA_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + pikahmpapi.lib;%(AdditionalDependencies) + ..\..\..\pika\aoh\lib;%(AdditionalLibraryDirectories) + true + Windows + MachineX64 + + + + + X64 + + + MaxSpeed + true + ..\..\isdn\include;..\..\include;..\..\..\pika\aoh\inc;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_PIKA_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + + + pikahmpapi.lib;%(AdditionalDependencies) + ..\..\..\pika\aoh\lib;%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX64 + + + + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj.filters new file mode 100644 index 0000000000..4d4cec4668 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2012.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c index 821937b2d8..fcd5149814 100644 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c +++ b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj new file mode 100644 index 0000000000..b95d13a02f --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_r2 + {08C3EA27-A51D-47F8-B47D-B189C649CF30} + Win32Proj + + + + DynamicLibrary + v110 + + + DynamicLibrary + v110 + + + DynamicLibrary + v110 + + + DynamicLibrary + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + true + true + true + true + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + Disabled + ..\..\include;c:\Program Files\openr2\include\openr2;C:\Program Files\openr2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + + + freetdm.lib;openr2.lib;%(AdditionalDependencies) + C:\Program Files\openr2\lib;$(OutDir);%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + + + Disabled + ..\..\include;c:\Program Files\openr2\include\openr2;C:\Program Files\openr2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + freetdm.lib;openr2.lib;%(AdditionalDependencies) + C:\Program Files\openr2\lib;$(OutDir);%(AdditionalLibraryDirectories) + true + Windows + + + + + ..\..\include;C:\Program Files\openr2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + true + Windows + true + true + MachineX86 + + + + + ..\..\include;C:\Program Files\openr2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + true + Windows + true + true + + + + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj.filters new file mode 100644 index 0000000000..9c91228e09 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2012.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj new file mode 100644 index 0000000000..102e7efe92 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj @@ -0,0 +1,207 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_sangoma_isdn + {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395} + ftmod_sangoma_isdn + Win32Proj + + + + DynamicLibrary + true + v110 + + + DynamicLibrary + true + v110 + + + DynamicLibrary + v110 + + + DynamicLibrary + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Configuration)\ + true + true + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + C:\Program Files\sangoma\sng_isdn\include;../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + EnableFastChecks + + + Level3 + EditAndContinue + MultiThreadedDebugDLL + + + freetdm.lib;libsng_isdn.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\sangoma\sng_isdn\lib;C:\Program Files\Sangoma\api\lib\x86;%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX86 + + + + + Disabled + C:\Program Files\sangoma\sng_isdn\include;../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + EnableFastChecks + + + Level3 + ProgramDatabase + MultiThreadedDebugDLL + + + freetdm.lib;libsng_isdn.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\libsng_isdn\lib;C:\Program Files\Sangoma\api\lib\x86;%(AdditionalLibraryDirectories) + true + Console + false + + + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDLL + + + Level3 + ProgramDatabase + C:\Program Files\sangoma\sng_isdn\include;../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + Disabled + + + true + Windows + true + true + MachineX86 + freetdm.lib;libsng_isdn.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\sangoma\sng_isdn\lib;C:\Program Files\Sangoma\api\lib\x86;%(AdditionalLibraryDirectories) + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDLL + + + Level3 + ProgramDatabase + C:\Program Files\sangoma\sng_isdn\include;../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + + + true + Windows + true + true + freetdm.lib;libsng_isdn.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj.filters new file mode 100644 index 0000000000..b3f44b428c --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2012.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c b/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c index 31544f8a7e..7d8a9b7393 100644 --- a/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c +++ b/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj new file mode 100644 index 0000000000..c91e4dc92a --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj @@ -0,0 +1,205 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ftmod_wanpipe + {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD} + ftmod_wanpipe + Win32Proj + + + + DynamicLibrary + MultiByte + true + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + true + v110 + + + DynamicLibrary + MultiByte + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + + + libsangoma.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\Sangoma\api\lib\x86;%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX86 + + + + + X64 + + + Disabled + ../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + libsangoma.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\Sangoma\api\lib\x64;%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX64 + + + + + ../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + libsangoma.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\Sangoma\api\lib\x86;%(AdditionalLibraryDirectories) + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + ../../include;C:\Program Files\Sangoma\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + libsangoma.lib;%(AdditionalDependencies) + $(OutDir);C:\Program Files\Sangoma\api\lib\x64;%(AdditionalLibraryDirectories) + true + Console + true + true + false + + + MachineX64 + + + + + + + + {93b8812c-3ec4-4f78-8970-ffbfc99e167d} + false + + + + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj.filters new file mode 100644 index 0000000000..15a8bc3d35 --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2012.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index 83dbd62210..ca60e30352 100755 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1397,7 +1397,6 @@ static FIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms) * on at application startup, until that is fixed we check the link status here too */ ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_LINK_STATUS, &sangoma_status); ftdmchan->alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? FTDM_ALARM_RED : FTDM_ALARM_NONE; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Link status is %d\n", sangoma_status); } } diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index bb7e477092..9c5ea6696f 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -951,6 +951,21 @@ static FIO_GET_ALARMS_FUNCTION(zt_get_alarms) return FTDM_SUCCESS; } +#define ftdm_zt_set_event_pending(fchan) \ + do { \ + ftdm_set_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); \ + fchan->last_event_time = ftdm_current_time_in_ms(); \ + } while (0); + +#define ftdm_zt_store_chan_event(fchan, revent) \ + do { \ + if (fchan->io_data) { \ + ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Dropping event %d, not retrieved on time\n", revent); \ + } \ + fchan->io_data = (void *)zt_event_id; \ + ftdm_zt_set_event_pending(fchan); \ + } while (0); + /** * \brief Waits for an event on a Zaptel/DAHDI channel * \param ftdmchan Channel to open @@ -1015,7 +1030,7 @@ pollagain: *flags |= FTDM_WRITE; } - if (inflags & POLLPRI) { + if ((inflags & POLLPRI) || (ftdmchan->io_data && (*flags & FTDM_EVENTS))) { *flags |= FTDM_EVENTS; } @@ -1044,19 +1059,28 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event) j++; } - r = poll(pfds, j, ms); + r = poll(pfds, j, ms); if (r == 0) { return FTDM_TIMEOUT; - } else if (r < 0 || (pfds[i-1].revents & POLLERR)) { + } else if (r < 0) { snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); return FTDM_FAIL; } for(i = 1; i <= span->chan_count; i++) { - if (pfds[i-1].revents & POLLPRI) { - ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_EVENT); - span->channels[i]->last_event_time = ftdm_current_time_in_ms(); + + ftdm_channel_lock(span->channels[i]); + + if (pfds[i-1].revents & POLLERR) { + ftdm_log_chan(span->channels[i], FTDM_LOG_ERROR, "POLLERR, flags=%d\n", pfds[i-1].events); + + ftdm_channel_unlock(span->channels[i]); + + continue; + } + if ((pfds[i-1].revents & POLLPRI) || (span->channels[i]->io_data)) { + ftdm_zt_set_event_pending(span->channels[i]); k++; } if (pfds[i-1].revents & POLLIN) { @@ -1065,6 +1089,9 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event) if (pfds[i-1].revents & POLLOUT) { ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_WRITE); } + + ftdm_channel_unlock(span->channels[i]); + } if (!k) { @@ -1243,7 +1270,10 @@ FIO_CHANNEL_NEXT_EVENT_FUNCTION(zt_channel_next_event) ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); } - if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { + if (ftdmchan->io_data) { + zt_event_id = (zt_event_t)ftdmchan->io_data; + ftdmchan->io_data = NULL; + } else if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event from channel: %s\n", strerror(errno)); return FTDM_FAIL; @@ -1274,30 +1304,48 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event) uint32_t i, event_id = FTDM_OOB_INVALID; zt_event_t zt_event_id = 0; - for(i = 1; i <= span->chan_count; i++) { + for (i = 1; i <= span->chan_count; i++) { ftdm_channel_t *fchan = span->channels[i]; - if (ftdm_test_io_flag(fchan, FTDM_CHANNEL_IO_EVENT)) { - ftdm_clear_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); - if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } - ftdm_channel_lock(fchan); - if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); - ftdm_channel_unlock(fchan); - return FTDM_FAIL; - } + ftdm_channel_lock(fchan); + + if (!ftdm_test_io_flag(fchan, FTDM_CHANNEL_IO_EVENT)) { + ftdm_channel_unlock(fchan); - fchan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = fchan; - *event = &span->event_header; - return FTDM_SUCCESS; + continue; } + + ftdm_clear_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); + + if (fchan->io_data) { + zt_event_id = (zt_event_t)fchan->io_data; + fchan->io_data = NULL; + } else if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { + ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to retrieve DAHDI event from channel: %s\n", strerror(errno)); + + ftdm_channel_unlock(fchan); + + continue; + } + + if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { + ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); + + ftdm_channel_unlock(fchan); + + return FTDM_FAIL; + } + + fchan->last_event_time = 0; + span->event_header.e_type = FTDM_EVENT_OOB; + span->event_header.enum_id = event_id; + span->event_header.channel = fchan; + *event = &span->event_header; + + ftdm_channel_unlock(fchan); + + return FTDM_SUCCESS; } return FTDM_FAIL; @@ -1348,11 +1396,13 @@ static FIO_READ_FUNCTION(zt_read) } if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */ - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Event %d is not dmtf related. Skipping one media read cycle\n", zt_event_id); + /* Enqueue this event for later */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to read data\n", zt_event_id); + ftdm_zt_store_chan_event(ftdmchan, zt_event_id); + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Skipping one IO read cycle due to DTMF event processing\n"); } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Skipping one IO read cycle due to events pending in the driver queue\n"); - break; + continue; } /* Read error, keep going unless to many errors force us to abort ...*/ @@ -1405,8 +1455,9 @@ tryagain: } if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */ - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dropping event %d to be able to write data\n", zt_event_id); + /* Enqueue this event for later */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to write data\n", zt_event_id); + ftdm_zt_store_chan_event(ftdmchan, zt_event_id); } goto tryagain; diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h index dc89ee3ddf..99c7ef451f 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 1aa337b943..972a398add 100755 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -166,10 +166,21 @@ typedef enum { /*! \brief Hunting direction (when hunting for free channels) */ typedef enum { - FTDM_TOP_DOWN, + FTDM_HUNT_TOP_DOWN, + FTDM_HUNT_BOTTOM_UP, + FTDM_HUNT_RR_DOWN, + FTDM_HUNT_RR_UP, +} ftdm_hunt_direction_t; + +/*! \brief Legacy Hunting direction (Top down and Bottom up were reversed), keep for source backwards compatibility of freetdm user applications + * \deprecated + * \see ftdm_hunt_direction_t + */ +typedef enum { FTDM_BOTTOM_UP, - FTDM_RR_DOWN, + FTDM_TOP_DOWN, FTDM_RR_UP, + FTDM_RR_DOWN, } ftdm_direction_t; /*! \brief I/O channel type */ @@ -404,13 +415,13 @@ typedef enum { /*! \brief Structure used for FTDM_HUNT_SPAN mode */ typedef struct { uint32_t span_id; - ftdm_direction_t direction; + ftdm_hunt_direction_t direction; } ftdm_span_hunt_t; /*! \brief Structure used for FTDM_HUNT_GROUP mode */ typedef struct { uint32_t group_id; - ftdm_direction_t direction; + ftdm_hunt_direction_t direction; } ftdm_group_hunt_t; /*! \brief Structure used for FTDM_HUNT_CHAN mode */ @@ -781,7 +792,7 @@ struct ftdm_memory_handler { /*! \brief FreeTDM I/O layer interface argument macros * You don't need these unless your implementing an I/O interface module (most users don't) */ -#define FIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +#define FIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) #define FIO_CHANNEL_OUTGOING_CALL_ARGS (ftdm_channel_t *ftdmchan) #define FIO_CHANNEL_INDICATE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication) #define FIO_CHANNEL_SET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) @@ -1440,7 +1451,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_ph(uint32_t span_id, uint32_t chan_i * \retval FTDM_SUCCESS success (a suitable channel was found available) * \retval FTDM_FAIL failure (no suitable channel was found available) */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); +FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); /*! * \brief Hunts and opens a channel specifying group id @@ -1458,7 +1469,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc * \retval FTDM_SUCCESS success (a suitable channel was found available) * \retval FTDM_FAIL failure (no suitable channel was found available) */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); +FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); /*! * \brief Close a previously open channel diff --git a/libs/freetdm/src/include/private/ftdm_buffer.h b/libs/freetdm/src/include/private/ftdm_buffer.h index 59447ec82f..fd5628c905 100644 --- a/libs/freetdm/src/include/private/ftdm_buffer.h +++ b/libs/freetdm/src/include/private/ftdm_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/include/private/ftdm_config.h b/libs/freetdm/src/include/private/ftdm_config.h index 8793acef93..f55261fcc9 100644 --- a/libs/freetdm/src/include/private/ftdm_config.h +++ b/libs/freetdm/src/include/private/ftdm_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index 4d956e5028..53183594cc 100755 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/freetdm/src/include/private/libteletone.h b/libs/freetdm/src/include/private/libteletone.h index 270500ee51..060a226032 100644 --- a/libs/freetdm/src/include/private/libteletone.h +++ b/libs/freetdm/src/include/private/libteletone.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/include/private/libteletone_detect.h b/libs/freetdm/src/include/private/libteletone_detect.h index 22e4c4a87c..646b03e1be 100644 --- a/libs/freetdm/src/include/private/libteletone_detect.h +++ b/libs/freetdm/src/include/private/libteletone_detect.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/include/private/libteletone_generate.h b/libs/freetdm/src/include/private/libteletone_generate.h index cb2f5c180e..d5f0bf2e48 100644 --- a/libs/freetdm/src/include/private/libteletone_generate.h +++ b/libs/freetdm/src/include/private/libteletone_generate.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/libteletone_detect.c b/libs/freetdm/src/libteletone_detect.c index 5c5e2bcbe5..b89ea11645 100644 --- a/libs/freetdm/src/libteletone_detect.c +++ b/libs/freetdm/src/libteletone_detect.c @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c index ef7a7e03ec..3638d94989 100644 --- a/libs/freetdm/src/libteletone_generate.c +++ b/libs/freetdm/src/libteletone_generate.c @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/priserver.c b/libs/freetdm/src/priserver.c index 11138dc638..786f592982 100644 --- a/libs/freetdm/src/priserver.c +++ b/libs/freetdm/src/priserver.c @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/freetdm/src/sangoma_pri.c b/libs/freetdm/src/sangoma_pri.c index cc0c782d9c..a6e79c9682 100644 --- a/libs/freetdm/src/sangoma_pri.c +++ b/libs/freetdm/src/sangoma_pri.c @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/freetdm/src/sangoma_pri.h b/libs/freetdm/src/sangoma_pri.h index 2072c8b08a..873aab8a27 100644 --- a/libs/freetdm/src/sangoma_pri.h +++ b/libs/freetdm/src/sangoma_pri.h @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/freetdm/src/testapp.c b/libs/freetdm/src/testapp.c index b5891653a3..1d7a2cb8cb 100644 --- a/libs/freetdm/src/testapp.c +++ b/libs/freetdm/src/testapp.c @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) printf("FreeTDM loaded\n"); top: - //if (ftdm_channel_open_any("wanpipe", 0, FTDM_TOP_DOWN, &chan) == FTDM_SUCCESS) { + //if (ftdm_channel_open_any("wanpipe", 0, FTDM_HUNT_BOTTOM_UP, &chan) == FTDM_SUCCESS) { if (ftdm_channel_open(1, 1, &chan) == FTDM_SUCCESS) { int x = 0; spanid = ftdm_channel_get_span_id(chan); diff --git a/libs/ilbc/src/iLBC_decode.c b/libs/ilbc/src/iLBC_decode.c index 9fc7a24bb4..ddc164bed8 100644 --- a/libs/ilbc/src/iLBC_decode.c +++ b/libs/ilbc/src/iLBC_decode.c @@ -40,6 +40,7 @@ #include "hpOutput.h" #include "syntFilter.h" +#if (defined(WIN32) || defined(_WIN32)) && (_MSC_VER < 1800) #if (defined(WIN32) || defined(_WIN32)) && !defined(_WIN64) __inline long int rint(double dbl) { @@ -63,6 +64,7 @@ #endif } #endif +#endif /*----------------------------------------------------------------* * Initiation of decoder instance. diff --git a/libs/js/configure.ac b/libs/js/configure.ac index d13ed9cc06..98fdbe985b 100644 --- a/libs/js/configure.ac +++ b/libs/js/configure.ac @@ -35,7 +35,7 @@ AC_SUBST(JS_VERSION) CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" +LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS -lm" AC_CANONICAL_BUILD AC_CANONICAL_HOST diff --git a/libs/libdingaling/libdingaling.2012.vcxproj b/libs/libdingaling/libdingaling.2012.vcxproj index 127d933cb6..d9ab864504 100644 --- a/libs/libdingaling/libdingaling.2012.vcxproj +++ b/libs/libdingaling/libdingaling.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -137,7 +137,7 @@ EnableFastChecks MultiThreadedDebugDLL Level4 - 4100;4706;%(DisableSpecificWarnings) + 4701;4702;4703;4100;4706;%(DisableSpecificWarnings) @@ -146,7 +146,7 @@ WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL Level4 - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) @@ -161,7 +161,7 @@ Level4 EditAndContinue - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) @@ -184,7 +184,7 @@ Level4 ProgramDatabase - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) @@ -207,7 +207,7 @@ EnableFastChecks MultiThreadedDebugDLL Level4 - 4100;4706;%(DisableSpecificWarnings) + 4701;4702;4703;4100;4706;%(DisableSpecificWarnings) @@ -219,7 +219,7 @@ WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL Level4 - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) @@ -237,7 +237,7 @@ Level4 ProgramDatabase - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) @@ -264,7 +264,7 @@ Level4 ProgramDatabase - 4100;%(DisableSpecificWarnings) + 4701;4702;4703;4100;%(DisableSpecificWarnings) libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) diff --git a/libs/libdingaling/src/ldl_compat.h b/libs/libdingaling/src/ldl_compat.h index 1f2ed41435..80d21db583 100644 --- a/libs/libdingaling/src/ldl_compat.h +++ b/libs/libdingaling/src/ldl_compat.h @@ -1,6 +1,6 @@ /* * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 634b710c95..7394d1d5c5 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -1,6 +1,6 @@ /* * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libdingaling/src/libdingaling.h b/libs/libdingaling/src/libdingaling.h index 7239c5c80b..7c425e6f45 100644 --- a/libs/libdingaling/src/libdingaling.h +++ b/libs/libdingaling/src/libdingaling.h @@ -1,6 +1,6 @@ /* * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libedit/configure.ac b/libs/libedit/configure.ac index 207bb0f118..7bd2ac6326 100644 --- a/libs/libedit/configure.ac +++ b/libs/libedit/configure.ac @@ -71,7 +71,7 @@ AC_PROG_GCC_TRADITIONAL #AC_FUNC_REALLOC AC_TYPE_SIGNAL AC_FUNC_STAT -AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid]) +AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strlcat strlcpy strcspn strdup strerror strrchr strstr strtol issetugid]) EL_GETPW_R_POSIX EL_GETPW_R_DRAFT diff --git a/libs/libedit/src/unvis.c b/libs/libedit/src/unvis.c index 3d71f6f227..19bacec843 100644 --- a/libs/libedit/src/unvis.c +++ b/libs/libedit/src/unvis.c @@ -45,7 +45,7 @@ __RCSID("$NetBSD: unvis.c,v 1.28 2005/09/13 01:44:09 christos Exp $"); #include #include -#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) +#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) __weak_alias(strunvis,_strunvis) #endif diff --git a/libs/libedit/src/vi.c b/libs/libedit/src/vi.c index f09ba6c1ce..e5fbd3baa9 100644 --- a/libs/libedit/src/vi.c +++ b/libs/libedit/src/vi.c @@ -915,14 +915,14 @@ vi_comment_out(EditLine *el, int c) * NB: posix implies that we should enter insert mode, however * this is against historical precedent... */ -#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) +#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) extern char *get_alias_text(const char *) __weak_reference(get_alias_text); #endif protected el_action_t /*ARGSUSED*/ vi_alias(EditLine *el, int c) { -#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) +#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) char alias_name[3]; char *alias_text; diff --git a/libs/libedit/src/vis.c b/libs/libedit/src/vis.c index 673caa9a15..a771d7a70f 100644 --- a/libs/libedit/src/vis.c +++ b/libs/libedit/src/vis.c @@ -88,7 +88,7 @@ __RCSID("$NetBSD: vis.c,v 1.35 2006/08/28 20:42:12 christos Exp $"); #include #include -#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) +#if defined(__weak_reference) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) __weak_alias(strsvis,_strsvis) __weak_alias(strsvisx,_strsvisx) __weak_alias(strvis,_strvis) diff --git a/libs/libks/src/include/ks.h b/libs/libks/src/include/ks.h index 175f929183..2b14891ac4 100644 --- a/libs/libks/src/include/ks.h +++ b/libs/libks/src/include/ks.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/libks/src/include/ks_config.h b/libs/libks/src/include/ks_config.h index eb1ee26f18..2a5a330418 100644 --- a/libs/libks/src/include/ks_config.h +++ b/libs/libks/src/include/ks_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/libks/src/ks.c b/libs/libks/src/ks.c index b328f36798..ebaaa143a2 100644 --- a/libs/libks/src/ks.c +++ b/libs/libks/src/ks.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/libks/src/ks_config.c b/libs/libks/src/ks_config.c index 1ffa0c88d7..3b25dd1634 100644 --- a/libs/libks/src/ks_config.c +++ b/libs/libks/src/ks_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/libscgi/src/include/scgi_oop.h b/libs/libscgi/src/include/scgi_oop.h index 64f3267779..137b5e522b 100644 --- a/libs/libscgi/src/include/scgi_oop.h +++ b/libs/libscgi/src/include/scgi_oop.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/libsndfile/.update b/libs/libsndfile/.update index 1103eb6bc0..cbf0edf709 100644 --- a/libs/libsndfile/.update +++ b/libs/libsndfile/.update @@ -1 +1 @@ -Wed Aug 28 03:22:32 CDT 2013 +Fri Feb 28 03:45:32 CDT 2014 diff --git a/libs/libsndfile/ChangeLog b/libs/libsndfile/ChangeLog index d36eb00e35..d22be00cd7 100644 --- a/libs/libsndfile/ChangeLog +++ b/libs/libsndfile/ChangeLog @@ -1,3 +1,1796 @@ +2013-04-05 Erik de Castro Lopo + + * Makefile.am + Make sure checkprograms are built as part of 'make test-tarball'. + Closes: https://github.com/erikd/libsndfile/issues/37 + +2013-03-29 Erik de Castro Lopo + + * tests/dft_cmp.c + Fix a buffer overflow detected using GCC 4.8's -fsantiize=address runtime + error checking functionality. This was a buffer overflow in libsndfile's + test suite, not in the actual library code. + +2013-03-09 Erik de Castro Lopo + + * M4/gcc_version.m4 + Fix to work with OpenBSD's sed. + +2013-03-07 Erik de Castro Lopo + + * src/ALAC/alac_encoder.c + Patch from Michael Pruett (author of libaudiofile) to add correct byte + swapping for the mChannelLayoutTag field. + +2013-03-02 Erik de Castro Lopo + + * doc/bugs.html + Bugs should bt reported on the github issue tracker. + +2013-02-22 Erik de Castro Lopo + + * configure.ac + Improve sanitization of FLAC_CFLAGS value. + +2013-02-21 Erik de Castro Lopo + + * src/Makefile.am + Call python interpreter instead of using '#!' in script. Thanks to Jan + Stary for reporting this. + + * doc/index.html doc/FAQ.html + Make internal links relative. Patch from Jan Stary. + +2013-02-13 Erik de Castro Lopo + + * src/test_endswap.def src/test_endswap.tpl + Add tests for psf_put_be32() and psf_put_be64(). + + * src/sfendian.h src/test_endswap.(def|tpl) + Add functions psf_get_be(16|32|64) with tests. + These are needed for platforms where un-aligned accesses cause bus faults. + + * src/ALAC/ag_enc.c src/ALAC/alac_decoder.c + Replace all un-aligned accesses with safe alternatives. + Closes: https://github.com/erikd/libsndfile/issues/19 + +2013-02-12 Erik de Castro Lopo + + * src/sfendian.h + Add big endian versions of H2BE_16 and H2BE_32. + +2013-02-11 Erik de Castro Lopo + + * src/ALAC/ + Replace Apple endswap routines with ones from libsndfile. + + * merge from libsndfile-cart repo + Add ability to set and get a cart chunk with WAV and RF64. + Orignal patch by Chris Roberts required a number of + tweaks. + +2013-02-10 Erik de Castro Lopo + + * src/common.h + Bump SF_HEADER_LEN from 8192 to 12292, the value it was in the 1.0.25 + release. + +2013-02-09 Erik de Castro Lopo + + * src/alac.c + Fix segfault when encoding 8 channel files. + Closes: https://github.com/erikd/libsndfile/issues/30 + +2013-02-07 Erik de Castro Lopo + + * src/ALAC/EndianPortable.c + Fall back to compiler's __BYTE_ORDER__ for endian-ness detection. + +2013-02-06 Erik de Castro Lopo + + * configure.ac src/common.h src/ima_adpcm.c src/ms_adpcm.c src/paf.c + Drop tests for and #ifdef hackery for C99 struct flexible array feature. + libsndfile assumes the compiler supports most of the ISO C99 standard. + + * src/alac.c + Fix valgrind invalid realloc. Reported by nu774. + Closes: https://github.com/erikd/libsndfile/issues/31 + +2013-02-05 Erik de Castro Lopo + + * src/alac.c + The 'pakt' chunk header should now be written correctly. + Closes: https://github.com/erikd/libsndfile/issues/24 + + * configure.ac Makefile.am + Use PKG_INSTALLDIR when it exists. Suggestion from Christoph Thompson. + Closes: https://github.com/erikd/libsndfile/pull/28 + +2013-02-03 Erik de Castro Lopo + + * src/common.h src/caf.c + Read the ALAC 'pakt' header and stash the values. + + * src/sfendian.h + Add functions psf_put_be64() and psf_put_be32(). + + * src/alac.c + Start work on filling on the 'pakt' chunk header. + +2013-02-02 Erik de Castro Lopo + + * doc/FAQ.html + Add missing opening

tag. + + * src/alac.c + Increase ALAC_BYTE_BUFFER_SIZE to 82000. + +2013-01-27 Erik de Castro Lopo + + * doc/FAQ.html + Improve question #8. + +2013-01-02 Erik de Castro Lopo + + * src/ogg_opus.c + Add skeleton implementation so someone else can run with it. + +2012-12-12 Erik de Castro Lopo + + * src/common.h src/dwd.c src/rx2.c src/txw.c + Fix for compiling when configured with --enable-experimental. Thanks to + Eric Wong for reporting this. + +2012-12-01 Erik de Castro Lopo + + * configure.ac programs/sndfile-play.c + OS X 10.8 uses a different audio API to previous versions. + Fix compile failure on by disabling sndfile-play on this version. + Someone needs to supply code for the new API. + +2012-11-30 Erik de Castro Lopo + + * Octave/Makefile.am Octave/octave_test.sh + Fix 'make distcheck'. + +2012-10-13 Erik de Castro Lopo + + * M4/octave.m4 + Relax constraints on Octave version. + +2012-10-11 Erik de Castro Lopo + + * tests/utils.tpl + Improve compare_*_or_die() functions. + + * src/command.c + Fix bug reported by Keiler Florian. When reading short or int data from a + file containing float data, and setting SFC_SET_SCALE_FLOAT_INT_READ to + SF_TRUE would fail 3, 5, 7 and other channels counts. Problem was that + psf_calc_signal_max() was not calculating the signal max correctly. + Calculation of the signal max was failing because it was trying to read + a sample count that was not an integer multiple of the channel count. + + * tests/channel_test.c tests/Makefile.am tests/test_wrapper.sh.in + Add test for the above. + +2012-09-25 Erik de Castro Lopo + + * src/sndfile.hh + Added a constructor to allow the use of SF_VIRTUAL_IO. Patch from + DannyDaemonic : https://github.com/erikd/libsndfile/pull/20 + +2012-08-23 Erik de Castro Lopo + + * doc/octave.html + Fix link to octave.sourceforge.net. Thanks to IOhannes m zmoelnig. + + * src/mat5.c + Allow reading of mat5 files without a specified sample rate (default to + 44.1kHz). Thanks to IOhannes m zmoelnig. + +2012-08-19 Erik de Castro Lopo + + * src/paf.c + Error out if channel count is zero. Bug report from William ELla via + launchpad: + https://bugs.launchpad.net/ubuntu/+source/libsndfile/+bug/1036831 + +2012-08-04 Erik de Castro Lopo + + * configure.ac programs/sndfile-play.c + Patch from Ricci Adams to use OSX's AudioQueues on OSX 10.7 and greater. + +2012-07-09 Erik de Castro Lopo + + * programs/common.c + Accept "ogg" as a file extention for Ogg/Vorbis files. + +2012-06-22 Erik de Castro Lopo + + * src/flac.c + Make sure any previously allocated FLAC stream encoder and stream decoder + objects are deleted before a new one is allocated. + +2012-06-20 Erik de Castro Lopo + + * tests/utils.tpl + Rename gen_lowpass_noise_float() to gen_lowpass_signal_float() and add a + sine wave component so that different FLAC compression levels can be + tested. + + * src/sndfile.h.in doc/command.html + Add SFC_SET_COMPRESSION_LEVEL and document it. + + * src/sndfile.c + Catch SFC_SET_VBR_ENCODING_QUALITY command and implement it as the inverse + of SFC_SET_COMPRESSION_LEVEL. + + * src/ogg_vorbis.c src/flac.c + Implement SFC_SET_COMPRESSION_LEVEL command. + + * tests/test_wrapper.sh.in tests/compression_size_test.c + Use the compression_size_test on FLAC as well. + +2012-06-19 Erik de Castro Lopo + + * tests/ + Rename vorbis_test.c -> compression_size_test.c so it can be extended to + test FLAC as well. + +2012-06-18 Erik de Castro Lopo + + * src/broadcast.c + Fix a bug where a file with a 'bext' chunk with a zero length coding + history field would get corrupted when the file was closed. + Reported by Paul Davis of the Ardour project. + + * src/test_broadcast_var.c + Add a test for the above. + +2012-05-19 Erik de Castro Lopo + + * src/sndfile.c + sf_format_check: For SF_FORMAT_AIFF, reject endian-ness setttings for + non-PCM formats. + +2012-04-12 Erik de Castro Lopo + + * src/aiff.c + Fix regression in handling of odd length SSND chunks. + Thanks Olivier Tristan for the example file. + + * src/aiff.c src/wav.c + Exit parser loop when marker == 0. + +2012-04-04 Erik de Castro Lopo + + * doc/FAQ.html + Fix text. Thanks to Richard Collins. + +2012-03-24 Erik de Castro Lopo + + * src/caf.c + Exit parse loop if the marker is zero. Pass jump offsets as size_t instead + of int. + +2012-03-20 Erik de Castro Lopo + + * src/alac.c + Fix segfault when decoding CAF/ALAC file with more than 4 channels. + Fixes github issue #8 reported by Charles Van Winkle. + +2012-03-20 Erik de Castro Lopo + + * src/common.h + Change 'typedef SF_CHUNK_ITERATOR { ... } SF_CHUNK_ITERATOR' into 'struct + SF_CHUNK_ITERATOR { ... }' to prevent older compilers from complaining of + re-typedef-ing of SF_CHUNK_ITERATOR. + + * configure.ac + Fix if test for empty $prefix. + +2012-03-18 Erik de Castro Lopo + + * src/*.c tests/chunk_test.c + Reworking of custom chunk handling code. + - Memory for the iterator is now attached to the SF_PRIVATE struct and + freed one sf_close(). + - Rename sf_create_chunk_iterator() -> sf_get_chunk_iterator(). + - Each SNDFILE handle never has more than one SF_CHUNK_ITERATOR handle. + + * tests/string_test.c + Fix un-initialised char buffer. + +2012-03-17 Erik de Castro Lopo + + * src/*.c tests/chunk_test.c + Add improved handling of custom chunk getting and settings. Set of patches + from IOhannes m zmoelnig submitted via github pull request #6. + + * src/alac.c + Fix calculated frame count for files with zero block length. + +2012-03-13 Erik de Castro Lopo + + * src/avr.c + Remove double assignment to psf->endian. Thanks Kao Dome. + + * src/gsm610.c + Fix clearing of buffers. Thanks Kao Dome. + + * src/paf.c + Remove duplicate code. Thanks Kao Dome. + + * src/test_strncpy_crlf.c + Fix minor error in test. Thanks Kao Dome. + + * src/common.h src/*.c + Fix a bunch of valgrind errors. + +2012-03-13 Erik de Castro Lopo + + * src/sndfile.c + Fix typo in error string 'Uknown' -> 'Unknown'. + + * tests/fix_this.c + Fix potential int overflow. + +2012-03-10 Erik de Castro Lopo + + * src/alac.c + Fix decoding of last block so that the decode length is not a multiple of + the block length. Fixes github issue #4 reported by Charles Van Winkle. + + * src/sfconfig.h src/sfendian.h + Fix for MinGW cross compiling. Use '#if (defined __*66__)' instead of + '#if __*86__' because the MinGW header use '#ifdef __x86_64__'. + +2012-03-10 Erik de Castro Lopo + + * src/ALAC/ src/alac.c + Unify the interface between libsndfile and Apple ALAC codec. Regardless of + file bit width samples are now passed between the two as int32_t that are + justified towards the most significant bit. Without this modification, 16 + conversion functions would have been needed between the libsndfile (short, + int, float, double) types and the ALAC types (16, 20, 24 and 32 bit). With + this mod, only 4 are needed. + + * tests/floating_point_test.tpl tests/write_read_test.(def|tpl) + Add tests for 20 and 24 bit ALAC/CAF files. + + * src/command.c + Add ALAC/CAF to the SFC_GET_FORMAT_* commands. Fixes github issue #5. + + * configure.ac + Only use automake AM_SLIENT_RULES where supported. Thanks Dave Yeo. + + * tests/pipe_test.tpl + Disable tests on OS/2. Thanks Dave Yeo. + +2012-03-09 Erik de Castro Lopo + + * configure.ac src/sfconfig.h src/sfendian.h + For GCC, use inline assembler for endian swapping. This should work with + older versions of GCC like the one currently used in OS/2. + +2012-03-06 Erik de Castro Lopo + + * src/alac.c + Make sure temp file gets opened in binary mode. + + * src/alac.c src/common.c src/common.h + Fix function alac_write16_d(). + + * tests/floating_point_test.tpl + Add tests for 16 bit ALAC/CAF. + + * src/alac.c src/common.c src/common.h + Add support for 32 bit ALAC/CAF files. + + * tests/floating_point_test.tpl tests/write_read_test.tpl + Add tests for 32 bit ALAC/CAF files. + +2012-03-05 Erik de Castro Lopo + + * src/ + Refactor chunk storage so it work on big as well as little endian CPUs. + + * tests/chunk_test.c + Clean up error messages. + + * src/sfendian.h src/*.c + Rename endian swapping macros and add ENDSWAP_64 and BE2H_64. + + * configure.ac + Detect presence of header file. + + * src/sfendian.h + Use intrinsics (ie for MinGW) when is not + present. + Make ENDSWAP_64() work with i686-w64-mingw32 compiler. + + * src/ALAC/EndianPortable.c + Add support for __powerpc__. + + * src/sfconfig.h + Make sure HAVE_X86INTRIN_H is either 1 or 0. + +2012-03-03 Erik de Castro Lopo + + * src/ALAC/* + Big dump of code for Apple's ALAC file format. The copyyright to this code + is owned by Apple who have released it under an Apache style license. A few + small modifications were made to allow this to be integrated into libsndfile + but unfortunately the history of those changes were lost because they were + developed in a Bzr tree and during that time libsndfile moved to Git. + + * src/alac.c src/caf.c src/common.[ch] src/Makefile.am src/sndfile.h.in + src/sndfile.c + Hook new ALAC codec in. + + * programs/sndfile-convert.c + Add support for alac codec. + + * tests/write_read_test.tpl + Expand tests to cover ALAC. + +2012-03-02 Erik de Castro Lopo + + * src/aiff.c src/wav.c + Fix a couple of regressions from version 1.0.25. + +2012-03-01 Erik de Castro Lopo + + * src/strings.c + Minor refactoring. Make sure that the memory allocation size if always > 0 + to avoid undefined behaviour. + +2012-02-29 Erik de Castro Lopo + + * src/chunk.c + Fix buffer overrun introduced in recently added chunk logging. This chunk + logging has not yet made it to a libsndfile release version. Thanks to + Olivier Tristan for providing an example file. + + * src/wav.c + Fix handling of odd sized chunks which was causing the parser to lose some + chunks. Thanks to Olivier Tristan for providing an example file. + +2012-02-26 Erik de Castro Lopo + + * tests/util.tpl + Used gnu_printf format checking with mingw-w64 compiler. + + * tests/header_test.tpl + Printf format fixes. + +2012-02-25 Erik de Castro Lopo + + * M4/extra_pkg.m4 + Update PKG_CHECK_MOD_VERSION macro to add an AC_TRY_LINK step. This fix + allows the configure process to catch attempts to link incompatible + libraries. For example, linking 32 bit version of eg libFLAC to a 64 bit + version of libsndfile will now fail. Similarly, when cross compiling + libsndfile from Linux to Windows linking the Linux versions of a library + to the Windows version of libsndfile will now also fail. + + * src/sndfile.h.in src/sndfile.c src/common.h src/create_symbols_file.py + Add API function sf_current_byterate(). + + * src/dwvw.c src/flac.c src/ogg_vorbis.c src/sds.c + Add codec specific handlers for current byterate. + + * tests/floating_point_test.tpl + Add initial test for sf_current_byterate(). + +2012-02-24 Erik de Castro Lopo + + * src/common.[ch] + Add function psf_decode_frame_count(). + + * src/dwvw.c + Fix a termnation bug that caused the decoder to go into an infinite loop. + +2012-02-24 Erik de Castro Lopo + + * src/wav.c + Fix a regression in the WAV header parser. Thanks to Olivier Tristan for + bug report and the example file. + +2012-02-21 Erik de Castro Lopo + + * src/sndfile.c + Return error when SF_BROADCAST_INFO struct has bad coding_history_size. + Thanks to Alex Weiss for the report. + +2012-02-20 Erik de Castro Lopo + + * src/au.c src/flac.c src/g72x.c src/ogg_vorbis.c src/wav_w64.c + Don't fake psf->bytewidth values. + +2012-02-19 Erik de Castro Lopo + + * tests/string_test.c + Fix valgrind warnings. + + * src/common.h src/sndfile.c src/strings.c + Make string storage dynamically allocated. + + * src/sndfile.c + Add extra validation for custom chunk handling. + +2012-02-18 Erik de Castro Lopo + + * src/wav.c + Improve handlling unknown chunk types. Thanks to Olivier Tristan for sending + example files. + + * src/utils.tpl + Add GCC specific testing for format string parameters for exit_if_true(). + + * tests/*.c tests/*.tpl + Fix all printf format warnings. + + * programs/sndfile-play.c + Remove un-needed OSX include . Thanks jamesfmilne for github + issue #3. + + * tests/chunk_test.c + Extend custom chunk test. + +2012-02-12 Erik de Castro Lopo + + * src/wav.c + Jump over some more chunk types while parsing. + +2012-02-04 Erik de Castro Lopo + + * src/common.h src/strings.c + Change way strings are stored in SF_PRIVATE in preparation for dynamically + allocating the storage. + +2012-02-02 Erik de Castro Lopo + + * src/common.h src*.c + Improve encapsulation of string data in SF_PRIVATE. + +2012-02-01 Erik de Castro Lopo + + * src/common.h src*.c + Remove the buffer union from SF_PRIVATE. Most uses of this have been + replaced with a BUF_UNION that is allocated on the stack. + +2012-01-31 Erik de Castro Lopo + + * src/common.h src*.c + Rename logbuffer field of SF_PRIVATE to parselog and reduce its size. + Put the parselog buffer and the index inside a struct within SF_PRIVATE. + +2012-01-26 Erik de Castro Lopo + + * configure.ac + Fix typo, FLAC_CLFAGS -> FLAC_CFLAGS. Thanks to Jeremy Friesner. + +2012-01-21 Erik de Castro Lopo + + * src/sndfile.c src/ogg.c + Fix misleading error message when trying to create an SF_FORMAT_OGG file + with anything other than SF_FORMAT_FILE. Thanks to Charles Van Winkle for + the bug report. Github issue #1. + +2012-01-20 Erik de Castro Lopo + + * src/sndfile.c src/wav.c + Allow files opened in RDWR mode with string data in the tailer to be + extended. Thanks to Bodo for the patch. + + * tests/string_test.c + Add tests for the above changes (patch from Bodo). + +2012-01-09 Erik de Castro Lopo + + * src/aiff.c + Refactor reading of chunk size and use of psf_store_read_chunk(). + + * src/(caf|wav).c + Correct storing of chunk offset. + +2012-01-05 Erik de Castro Lopo + + * src/aiff.c src/wav.c src/common.h + Refactor common code into src/common.h. + + * src/caf.c + Make custom chunks work for CAF files. + + * tests/chunk_test.c tests/test_wrapper.sh.in + Test CAF files with custom chunks. + + * src/sndfile.c + Prevent psf->codec_close() being called more than once. + +2012-01-04 Erik de Castro Lopo + + * programs/sndfile-cmp.c + Catch the case where the second file has more frames than the first. + +2012-01-02 Erik de Castro Lopo + + * src/create_symbols_file.py + Add sf_set_chunk/sf_get_chunk_size/sf_get_chunk_data. + +2011-12-31 Erik de Castro Lopo + + * tests/chunk_test.c tests/Makefile.am + New test for custom chunks. + + * src/aiff.c src/chunk.c src/common.h src/sndfile.c + Make custom chunks work on AIFF files. + + * src/wav.c + Make custom chunks work on WAV files (includes refactoring). + +2011-11-12 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c + Start working on setting/getting chunks. + +2011-11-24 Erik de Castro Lopo + + * src/binheader_writef_check.py src/create_symbols_file.py + Make it work for Python 2 and 3. Thanks Michael. + +2011-11-19 Erik de Castro Lopo + + * libsndfile.spec.in + Change field name 'URL' to 'Url'. + + * src/sndfile.h.in + Add SF_SEEK_SET/CUR/END. + +2011-11-05 Erik de Castro Lopo + + * src/id3.c + Fix a stack overflow that can occur when parsing a file with multiple + ID3 headers which would cause libsndfile to go into an infinite recursion + until it blew the stack. Thanks to Anders Svensson for supplying an example + file. + +2011-10-30 Erik de Castro Lopo + + * src/double64.c src/float32.c src/common.h + Make (float32|double_64)_(be|le)_read() functions const correct. + +2011-10-28 Erik de Castro Lopo + + * src/sfendian.h + Minor tweaking of types. Cast to ptr to correct final type rather void*. + + * programs/sndfile-play.c tests/utils.tpl + Fix compiler warnings with latest MinGW cross compiler. + +2011-10-13 Erik de Castro Lopo + + * src/file_io.c + Use the non-deprecated resource fork name on OSX. Thanks to Olivier Tristan. + +2011-10-12 Erik de Castro Lopo + + * src/wav.c + Jump over the 'olym' chunks when parsing. + +2011-10-06 Erik de Castro Lopo + + * tests/write_read_test.tpl + Remove windows only truncate() implementation. + +2011-09-04 Erik de Castro Lopo + + * src/sd2.c src/sndfile.c + Make sure 23 bit PCM SD2 files are readable/writeable. + + * tests/write_read_test.tpl + Add tests for 32 bit PCM SD2 files. + +2011-08-23 Erik de Castro Lopo + + * configure.ac + Use AC_SYS_LARGEFILE instead of AC_SYS_EXTRA_LARGEFILE as suggested by + Jan Willies. + +2011-08-07 Erik de Castro Lopo + + * configure.ac Makefile.am + Move ACLOCAL_AMFLAGS setup to Makefile.am. + +2011-07-15 Erik de Castro Lopo + + * doc/command.html + Merge two separate blocks of SFC_SET_VBR_ENCODING_QUALITY documentation. + + * src/paf.c + Replace ppaf24->samplesperblock with a compile time constant. + +2011-07-13 Erik de Castro Lopo + + * src/ogg_vorbis.c + Fix return value of SFC_SET_VBR_ENCODING_QUALITY command. + + * doc/command.html + Document SFC_SET_VBR_ENCODING_QUALITY, SFC_GET/SET_LOOP_INFO and + SFC_GET_INSTRUMENT. + + * NEWS README configure.ac doc/*.html + Updates for 1.0.25. + +2011-07-07 Erik de Castro Lopo + + * src/sfconfig.h + Add handling for HAVE_SYS_WAIT_H. + + * Makefile.am src/Makefile.am tests/Makefile.am + Add 'checkprograms' target. + +2011-07-05 Erik de Castro Lopo + + * src/common.h src/sndfile.c + Purge SF_ASSERT macro. Use standard C assert instead. + + * src/paf.c src/common.h src/sndfile.c + Fix for Secunia Advisory SA45125, heap overflow (heap gets overwritten with + byte value of 0) due to integer overflow if PAF file handler. + + * src/ima_adpcm.c src/ms_adpcm.c src/paf.c + Use calloc instead of malloc followed by memset. + + * tests/utils.tpl + Clean up use of memset. + +2011-07-05 Erik de Castro Lopo + + * src/ogg.c + Fix log message. + + * tests/format_check_test.c + Fix compiler warnings. + +2011-07-04 Erik de Castro Lopo + + * src/sndfile.c + Fix error message for erro code SFE_ZERO_MINOR_FORMAT. + + * tests/format_check_test.c + Add a test to for SF_FINFO format field validation. + + * src/ogg.c src/ogg_vorbis.c src/ogg.h src/ogg_pcm.c src/ogg_speex.c + src/common.h src/Makefile.am + Move vorbis specific code to ogg_vorbis.c, add new files for handling PCM + and Speex codecs in an Ogg container. The later two are only enabled with + ENABLE_EXPERIMENTAL_CODE config variable. + +2011-06-28 Erik de Castro Lopo + + * src/strings.c + Clean up and refactor storage of SF_STR_SOFTWARE. + +2011-06-23 Erik de Castro Lopo + + * src/sndfile.h.in doc/api.html + Fix definition of SF_STR_LAST and update SF_STR_* related docs. Thanks to + Tim van der Molen for the patch. + +2011-06-21 Erik de Castro Lopo + + * programs/sndfile-interleave.c + Fix handling of argc. Thanks to Marius Hennecke. + + * src/wav_w64.c + Accept broken WAV files with blockalign == 0. Thanks to Olivier Tristan for + providing example files. + + * src/wav.c + Jump over 'FLLR' chunks. + +2011-06-14 Erik de Castro Lopo + + * src/sndfile.h.in + Fix -Wundef warning due to ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + + * configure.ac + Add -Wundef to CFLAGS. + + * src/ogg.c + Fix -Wunder warning. + +2011-05-18 Erik de Castro Lopo + + * configure.ac + Use int64_t instead of off_t when they are the same size. + + * src/Makefile.am tests/Makefile.am + Use check_PROGRAMS instead of noinst_PROGRAMS where appropriate. + +2011-05-08 Erik de Castro Lopo + + * src/wav.c + Don't allow unknown and/or un-editable chunks to prevent the file from being + opened in SFM_RDWR mode. + +2011-04-25 Erik de Castro Lopo + + * tests/format_check_test.c + Fix segfault in test program. + +2011-04-25 Erik de Castro Lopo + + * tests/format_check_test.c + New test program to check to make sure that sf_open() and sf_check_format() + agree as to what is a valid program. + + * tests/Makefile.am tests/test_wrapper.sh.in + Hook into build and test runner. + + * src/sndfile.c + Fix some sf_format_check() problems. Thanks to Charles Van Winkle for the + notification. + +2011-04-06 Erik de Castro Lopo + + * src/caf.c + Add validation to size of 'data' chunk and fix size of written 'data' + chunk. Thanks to Michael Pruett for reporting this. + +2011-03-28 Erik de Castro Lopo + + * src/* tests/* programs/* + Fix a bunch of compiler warnings with gcc-4.6. + +2011-03-25 Erik de Castro Lopo + + * tests/util.tpl + Add NOT macro to util.h. + + * src/strings.c + Fix handling of SF_STR_SOFTWARE that resulted in a segfault due to calling + strlen() on an unterminated string. Thanks to Francois Thibaud for reporting + this problem. + + * tests/string_test.c + Add test for SF_STR_SOFTWARE segfault bug. + + * configure.ac + Sanitize FLAC_CFLAGS value supplied by pkg-config which returns a value of + '-I${includedir}/FLAC'. However FLAC also provides an include file + which clashes with the Standard C header of the same name. The + solution is strip the 'FLAC' part off the end and include all FLAC headers + as . + + * configure.ac src/Makefile.am + Use non-recursive make in src/ directory. + +2011-03-23 Erik de Castro Lopo + + * NEWS README docs/*.html + Updates for 1.0.24 release. + +2011-03-22 Erik de Castro Lopo + + * configure.ac + Fix up usage of sed (should not assume GNU sed). + + * M4/add_(c|cxx)flags.m4 + Test flags in isolation. + + * tests/cpp_test.cc + Fix a broken test (test segfaults). Report by Dave Flogeras. + +2011-03-21 Erik de Castro Lopo + + * programs/common.[ch] + Add function program_name() which returns the program name minus the path + from argv [0]. + + * programs/*.c programs/Makefile.am + Use program_name() where appropriate. Fix build. + +2011-03-20 Erik de Castro Lopo + + * src/wav.c + For u-law and A-law files, write an 18 byte 'fmt ' chunk instead of a 16 + byte one. Win98 accepts files with a 16 but not 18 byte 'fmt' chunk. Later + version accept 18 byte but not 16 byte. + +2011-03-15 Erik de Castro Lopo + + * doc/FAQ.html + Add examples for question 12. + + * doc/libsndfile.css.in + Add tweaks for h4 element. + + * doc/api.html + Add documentation for virtual I/O functionality. Thanks to Uli Franke. + + * tests/util.tpl + Add static inline functions sf_info_clear() and sf_info_setup(). + + * tests/(alaw|dwvw|ulaw)_test.c + Use functions sf_info_clear() and sf_info_setup(). + +2011-03-08 Erik de Castro Lopo + + * configure.ac + Fail more gracefully if pkg-config is missing. Suggestion from Brian + Willoughby. + +2011-02-27 Erik de Castro Lopo + + * src/common.c + Use size_t instead of int for size params with varargs. + +2011-02-09 Erik de Castro Lopo + + * doc/index.html + Update supported platforms with more Debian platforms and Android. + +2011-01-27 Erik de Castro Lopo + + * src/sndfile.hh + Add an LPCWSTR version of the SndfileHandle constructor to the SndfileHandle + class definition. Thanks to Eric Eizenman for pointing out this was missing. + + * tests/cpp_test.cc + Add test for LPCWSTR version of the SndfileHandle constructor. + +2011-01-19 Erik de Castro Lopo + + * programs/sndfile-play.c + Remove cruft. + +2010-12-01 Erik de Castro Lopo + + * src/sndfile.hh + Add methods rawHandle() and takeOwnership(). Thanks to Tim Blechmann for + the patch. + + * tests/cpp_test.cc + Add tests for above two methods. Also supplied by Tim Blechmann. + +2010-11-11 Erik de Castro Lopo + + * doc/api.html + Add mention of use of sf_strerror() when sf_open() fails. + +2010-11-01 Erik de Castro Lopo + + * configure.ac + Make TYPEOF_SF_COUNT_T int64_t where possible. This may fix problems where + people are compiling on a 64 bit system with the GCC -m32 flag. + + * src/sndfile.h.in + Fix comments on sf_count_t. + +2010-10-26 Erik de Castro Lopo + + * src/aiff.c + Handle non-zero offset field in SSND chunk. Thanks to Michael Chinen. + +2010-10-20 Erik de Castro Lopo + + * configure.ac + Sed fix for FreeBSD. Thanks Tony Theodore. + +2010-10-14 Erik de Castro Lopo + + * shave.in M4/shave.m4 + Fix shave invocation of windres compiler. Thanks Damien Lespiau (upstream + shave author). + + * configure.ac M4/shave.m4 shave-libtool.in shave.in + Switch from shave to automake-1.11's AM_SILENT_RULES. + +2010-10-13 Erik de Castro Lopo + + * shave-libtool.in shave.in + Sync to upstream version. + + * src/rf64.c + More work to make the parser more robust and accepting of mal-formed files. + +2010-10-12 Erik de Castro Lopo + + * src/common.h + Add functions psf_strlcpy() and psf_strlcat(). + + * src/broadcast.c src/sndfile.c src/strings.c src/test_main.c + src/test_main.h src/test_strncpy_crlf.c + Use functions psf_strlcpy() and psf_strlcat() as appropriate. + + * tests/string_test.c + Add tests for SF_STR_GENRE and SF_STR_TRACKNUMBER. + + * src/rf64.c + Fix size of 'ds64' chunk when writing RF64. + +2010-10-10 Erik de Castro Lopo + + * programs/*.c + Add the libsndfile version to the usage message of all programs. + +2010-10-10 Erik de Castro Lopo + + * configure.ac src/version-metadata.rc.in src/Makefile.am + Add version string resources to the windows DLL. + + * doc/api.html + Update to add missing SF_FORMAT_* values. Closed Debian bug #545257. + + * NEWS README configure.ac doc/*.html + Updates for 1.0.23 release. + +2010-10-09 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + Handle unusual values of CC environment variable. + + * src/rf64.c + Minor tweaks and additional sanity checking. + + * src/Makefile.am src/binheader_writef_check.py + Use python 2.6. + +2010-10-08 Erik de Castro Lopo + + * src/sndfile.hh + Add a missing 'inline' before a constructor defintion. + +2010-10-06 Erik de Castro Lopo + + * src/common.h + Add macro NOT. + + * src/rf64.c + Minor tweaks. + + * Makefile.am */Makefile.am + Add *~ to CLEANFILES. + +2010-10-05 Erik de Castro Lopo + + * src/sndfile.c + Fix a typo in the error string for SFE_OPEN_PIPE_RDWR. Thanks to Charles + Van Winkle for the report. + +2010-10-04 Erik de Castro Lopo + + * src/flac.c src/ogg.c src/sndfile.h.in src/strings.c src/wav.c + Add ability to read/write tracknumber and genre to flac/ogg/wav files. + Thanks to Matti Nykyri for the patch. + + * src/common.h src/broadcast.c src/strings.c + Add function psf_safe_strncpy() and use where appropriate. + +2010-10-04 Erik de Castro Lopo + + * NEWS README configure.ac doc/*.html + Updates for 1.0.22 release. + +2010-10-03 Erik de Castro Lopo + + * src/common.h src/broadcast.c src/rf64.c src/sndfile.c src/wav.c + Rewrite of SF_BROADCAST_INFO handling. + + * src/test_broadcast_var.c tests/command_test.c + Tweak SF_BROADCAST_INFO tests. + + * src/test_broadcast_var.c + Fix OSX stack check error. + +2010-09-30 Erik de Castro Lopo + + * src/sds.c + Set sustain_loop_end to 0 as suggested by Brian Lewis. + +2010-09-29 Erik de Castro Lopo + + * src/sds.c + Make sure the correct frame count gets written into the header. + + * tests/write_read_test.tpl + Don't allow SDS files to have a long frame count. + +2010-09-17 Erik de Castro Lopo + + * src/sds.c + Apply a pair of patches from Brian Lewis to fix the packet number location + and the checksum. + +2010-09-10 Erik de Castro Lopo + + * src/aiff.c src/file_io.c src/ogg.c src/rf64.c src/sndfile.c + src/strings.c src/test_audio_detect.c src/test_strncpy_crlf.c + src/wav.c tests/pcm_test.tpl + Fix a bunch of minor issues found using static analysis. + +2010-08-23 Erik de Castro Lopo + + * src/test_broadcast_var.c + New file containing tests for broadcast_set_var(). + + * src/Makefile.am src/test_main.[ch] + Hook test_broadcast_var.c into tests. + +2010-08-22 Erik de Castro Lopo + + * src/broadcast.c src/common.(c|h) + Move function strncpy_crlf() to src/common.c so the function can be tested + in isolation. + + * src/test_strncpy_crlf.c + New file. + + * src/Makefile.am src/test_main.[ch] + Hook test_strncpy_crlf.c into tests. + +2010-08-18 Erik de Castro Lopo + + * src/common.h + Move code around to make comments make sense. + + * src/broadcast.c + Add debugging code that is disabled by default. + +2010-08-02 Erik de Castro Lopo + + * src/flac.c + When the file meta data says the file has zero frames set psf->sf.frames + to SF_COUNT_MAX. Fixes Debian bug #590752. + + * programs/sndfile-info.c + Print 'unknown' if frame count == SF_COUNT_MAX. + +2010-06-27 Erik de Castro Lopo + + * src/sndfile.c + Only support writing mono SVX files. Multichannel SVX files are not + interleaved and there is no support infrastructure to cache and write + multiple channels to create a non-interleaved file. + + * src/file_io.c + Don't call close() on a file descriptor of -1. Thanks to Jeremy Friesner + for the bug report. + +2010-06-09 Erik de Castro Lopo + + * src/common.h + Add macro SF_ASSERT. + + * src/sndfile.c + Use SF_ASSERT to ensure sizeof (sf_count_t) == 8. + + * src/svx.c + Add support for reading and writing stereo SVX files. + +2010-05-07 Erik de Castro Lopo + + * configure.ac + When compiling with x86_64-w64-mingw32-gcc link with -static-libgcc flags. + + * programs/common.c programs/sndfile-metadata-set.c + Update metadata after the audio data is copied. Other minor fixes. Patch + from Marius Hennecke. + +2010-05-04 Erik de Castro Lopo + + * src/nist.c + Fix a regression reported by Hugh Secker-Walker. + + * src/api.html + Add comment about sf_open_fd() not working on Windows if the application + and the libsndfile DLL are linked to different versions of the Microsoft + C runtime DLL. + +2010-04-23 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + Fix 'make distcheck'. + +2010-04-21 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + New file to test whether sndfile.h can be compiled with gcc's -pedantic + flag. + + * configure.ac tests/test_wrapper.sh.in + Hook pedantic-header-test into test suite. + + * src/sndfile.h.in + Fix -pedantic warning. + +2010-04-19 Erik de Castro Lopo + + * programs/sndfile-salvage.c programs/Makefile.am + New program to salvage the audio data from WAV/WAVEX/AIFF files which are + greater than 4Gig in size. + +2010-04-09 Erik de Castro Lopo + + * programs/sndfile-convert.c + Fix valgrind warning. + +2010-04-06 Erik de Castro Lopo + + * programs/sndfile-cmp.c + When files differ in the PCM data, also print the difference offset. + Minor cleanup. + +2010-03-19 Erik de Castro Lopo + + * src/aiff.c + Don't use the 'twos' marker for 24 and 32 bit PCM, use 'in24' and 'in32' + instead. Thanks to Paul Davis (Ardour) for this suggestion. + +2010-02-28 Erik de Castro Lopo + + * configure.ac + Clean up configure report. + + * tests/utils.tpl + Add functions test_read_raw_or_die and test_write_raw_or_die. + + * tests/rdwr_test.(def|tpl) tests/Makefile.am + Add new test program and hook into build. + + * src/sndfile.c + Fix minor issues with sf_read/write_raw(). Bug reported by Milan Křápek. + + * tests/test_wrapper.sh.in + Add rdwr_test to the test wrapper script. + +2010-02-22 Erik de Castro Lopo + + * configure.ac + Remove -fpascal-strings from OSX's OS_SPECIFIC_CFLAGS. + + * programs/common.[ch] programs/sndfile-metadata-set.c + Apply a patch from Robin Gareus allowing the setting of the time reference + field of the BEXT chunk. + +2010-02-06 Erik de Castro Lopo + + * src/ima_adpcm.c + Add a fix from Jonatan Liljedahl to handle predictor overflow when decoding + IMA4. + +2010-01-26 Erik de Castro Lopo + + * src/sndfile.hh + Add a constructor which takes an existing file descriptor and then calls + sf_open_fd(). Patch from Sakari Bergen. + +2010-01-10 Erik de Castro Lopo + + * programs/sndfile-deinterleave.c programs/sndfile-interleave.c + Improve usage messages. + +2010-01-09 Erik de Castro Lopo + + * src/id3.c src/Makefile.am + Add new file src/id3.c and hook into build. + + * src/sndfile.c src/common.h + Detect and skip and ID3 header at the start of the file. + +2010-01-07 Erik de Castro Lopo + + * programs/common.c + Fix update_strings() copyright, comment, album and license are correctly + written. Thanks to Todd Allen for reporting this. + + * man/Makefile.am + Change GNU makeism to something more widely supported. Thanks to Christian + Weisgerber for reporting this. + + * configure.ac programs/Makefile.am programs/sndfile-play.c + Apply patch from Christian Weisgerber and Jacob Meuserto add support for + OpenBSD's sndio. + +2010-01-05 Erik de Castro Lopo + + * doc/api.html + Discourage the use of sf_read/write_raw(). + +2009-12-28 Erik de Castro Lopo + + * configure.ac + Test for Unix pipe() and waitpid() functions. + + * src/sfconfig.h tests/pipe_test.tpl + Disable pipe_test if pipe() and waitpid() aren't available. + +2009-12-16 Erik de Castro Lopo + + * configure.ac src/Makefile.am src/create_symbols_file.py + src/make-static-lib-hidden-privates.sh + Change name of generated file src/Symbols.linux to Symbols.gnu-binutils and + and use the same symbols file for other systems which use GNU binutils like + Debian's kfreebsd. + + * M4/shave.m4 shave.in + Update shave files from upstream. + +2009-12-15 Erik de Castro Lopo + + * man/sndfile-metadata-get.1 + Fix typo. + + * man/sndfile-interleave.1 man/Makefile.am + New man page. + +2009-12-13 Erik de Castro Lopo + + * src/ogg.c + When decoding to short or int, clip the decoded signal to [-1.0, 1.0] if + its too hot. Thanks to Dmitry Baikov for suggesting this. + + * NEWS README doc/*.html + Updates for 1.0.21. + +2009-12-09 Erik de Castro Lopo + + * programs/sndfile-jackplay.c man/sndfile-jackplay.1 + Remove these which will now be in found in the sndfile-tools package. + + * programs/Makefile.am man/Makefile.am + Remove build rules for sndfile-jackplay. + + * configure.ac + Remove detection of JACK Audio Connect Kit. + + * programs/sndfile-concat.c man/sndfile-concat.1 + Add new program with man page. + + * man/Makefile.am programs/Makefile.am + Hook sndfile-concat into build system. + +2009-12-08 Erik de Castro Lopo + + * tests/error_test.c + Don't terminate when sf_close() returns zero in error_close_test(). + It seems that Windows 7 behaves differently from earlier versions of + Windows. + +2009-12-03 Erik de Castro Lopo + + * configure.ac M4/*.m4 + Rename all custom macros from AC_* to MN_*. + + * programs/sndfile-interleave.c + Make it actually work. + +2009-12-02 Erik de Castro Lopo + + * doc/*.html configure.ac + Corrections and clarifications courtesy of Robin Forder. + + * programs/sndfile-convert.c programs/common.[ch] + Move some code from convert to common for reuse. + + * programs/sndfile-interleave.c programs/sndfile-interleave.c + Add new programs sndfile-interleave and sndfile-deinterleave. + + * programs/Makefile.am + Hook new programs into build. + +2009-12-01 Erik de Castro Lopo + + * src/create_symbols_file.py tests/stdio_test.c tests/win32_test.c + Minor OS/2 tweaks as suggested by David Yeo. + + * tests/multi_file_test.c + Fix file creation flags on windows. Thanks to Bruce Sharpe. + + * src/sf_unistd.h + Set all group and other file create permssions to zero. + + * tests/win32_test.c + Add a new test. + +2009-11-30 Erik de Castro Lopo + + * doc/print.css doc/*.html + Add a print stylesheet and update all HTML documents to reference it. + Thanks to Aditya Bhargava for suggesting this. + + * doc/index.html + Minor corrections. + +2009-11-29 Erik de Castro Lopo + + * sndfile.pc.in + Add a Libs.private entry to assist with static linking. + +2009-11-28 Erik de Castro Lopo + + * src/make-static-lib-hidden-privates.sh src/Makefile.am + Add a script to hide all non-public symbols in the libsndfile.a static + library. + +2009-11-22 Erik de Castro Lopo + + * tests/locale_test.c + Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + +2009-11-20 Erik de Castro Lopo + + * src/windows.c + Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + +2009-11-16 Erik de Castro Lopo + + * programs/sndfile-convert.c + Allow the program to read from stdin by specifying '-' on the command line + as the input file. + + * src/sndfile.h.in + Hash define ENABLE_SNDFILE_WINDOWS_PROTOTYPES to 1 for greater safety. + + * tests/virtual_io_test.c + Add a PAF/PCM_24 test and verify the file length is not negative + immediately after openning the file for write. + +2009-10-18 Erik de Castro Lopo + + * src/wav.c + When writing loop lengths, adjust the end position by one to make up for + Microsoft's screwed up spec. Thanks to Olivier Tristan for the patch. + +2009-10-14 Erik de Castro Lopo + + * src/flac.c + Apply patch from Uli Franke allowing FLAC files to be encoded at any sample + rate. + +2009-10-09 Erik de Castro Lopo + + * src/nist.c + Fix parsing of odd ulaw encoded file provided by Jan Silovsky. + + * configure.ac + Insist on libvorbis >= 1.2.3. Earlier verions have bugs that cause the + libsndfile test suite to fail on MIPS, PowerPC and others. + See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899 + +2009-10-06 Erik de Castro Lopo + + * man/sndfile-convert.1 + Fix warning from Debian's lintian checks. + + * man/sndfile-cmp.1 man/sndfile-jackplay.1 man/sndfile-metadata-get.1 + man/Makefile.am + Add three new minimal manpages and hook into build. + +2009-10-05 Erik de Castro Lopo + + * tests/test_wrapper.sh.in + Don't run cpp_test on x86_64-w64-mingw32. + +2009-09-28 Erik de Castro Lopo + + * tests/utils.tpl + On windows, make sure the open() function doesn't get called with a third + parameter of 0 which fails for no good reason. Also make sure this third + parameter doesn't get called with S_IRGRP when compiling for windows because + Wine complains. + + * src/sndfile.hh + Add a SndfileHandle constructor for windows that takes a 'const wchar_t *' + string. + + * doc/FAQ.html + Add Q/A : I'm cross compiling libsndfile for another platform. How can I + run the test suite? + + * src/create_symbols_file.py src/Makefile.am + Add Symbols.static target, a list of symbols, one per line. + +2009-09-27 Erik de Castro Lopo + + * tests/test_wrapper.sh.in + Update to allow all tests to be gathered up into a testsuite tarball and + then be run using this script. + + * build-test-tarball.mk.in + Add a Make script to build a tarball of all the test binaries and the test + wrapper script. This is useful for cross compiling; you can build the + binaries, build test test tarball and transfer the test tarball to the + target machine for testing. + +2009-09-26 Erik de Castro Lopo + + * src/common.h src/*.c + Modify SF_FILE struct to allow it to carry either 8-bit or 16-bit strings + for the file path, directory and name. Fixes for this change throughout. + + * src/windows.c src/Makefile.am + New file defining new windows only public function sf_wchar_open() which + takes a 'const wchar_t *' string (LPCWSTR) for the file name parameter. + + * src/sndfile.h.in + Add SF_CHANNEL_MAP_ABISONIC_* entries. + Add windows only defintion for sf_wchar_open(). + + * src/create_symbols_file.py + Add sf_wchar_open() to the list of public symbols (windows only). + + * tests/locale_test.c + Add a wchar_test() to test sf_wchar_open(). + +2009-09-25 Erik de Castro Lopo + + * src/common.h src/*.c + Split file stuff into PSF_FILE struct within the SF_PRIVATE struct. + +2009-09-23 Erik de Castro Lopo + + * src/aiff.c src/voc.c + When a byte is needed, use unsigned char. + + * src/ima_oki_adpcm.c src/broadcast.c src/test_ima_oki_adpcm.c + Include sfconfig.h to prevent compile errors with MinGW compilers. + + * configure.ac + Remove AM_CONFIG_HEADER due to warnings from autoconf 2.64. + + * tests/locale_test.c + Update to work with xx_XX.UTF-8 style locales. Refactoring. + +2009-09-22 Erik de Castro Lopo + + * configure.ac + Set __USE_MINGW_ANSI_STDIO to 1 when compiling using MinGW compilers. + Remove unneeded AC_SUBST. + Report Host CPU/OS/vendor. + +2009-09-19 Erik de Castro Lopo + + * src/sndfile.c + Fix error message string. + + * src/flac.c + Add 88200 to the list of supported sample rates. + + * src/ogg.c + Fix compiler warning when using gcc-4.5.0. + + * programs/sndfile-info.c tests/utils.tpl + Remove WIN32 snprintf #define. + + * src/ima_adpcm.c + Fix minor bug in aiff_ima_encode_block. Thanks to Denis Fileev for finding + this. + +2009-09-16 Erik de Castro Lopo + + * src/caf.c + Use the correct C99 format specifier for int64_t. + + * M4/endian.m4 + Fix detection of CPU endian-ness when cross compiling. Thanks to Pierre + Ossman for the bug report. + + * src/caf.c src/sndfile.c + Fix reading and writing of PEAK chunks in CAF files. + + * tests/peak_chunk_test.c tests/test_wrapper.sh.in + Run peak_chunk_test on CAF files. + +2009-09-15 Erik de Castro Lopo + + * src/aiff.c src/wav.c + Use the correct C99 format specifier for int64_t. + +2009-08-30 Erik de Castro Lopo + + * src/rf64.c src/sndfile.c src/wav.c src/wav_w64.h + Apply a patch (massaged slightly) from Uli Franke adding handling of the + BEXT chunk in RF64 files. + + * tests/command_test.c + Update channel_map_test() function so WAV test passes. + + * src/rf64.c + Add channel mapping and ambisonic support. + + * src/sndfile.h + Add comments showing correspondance between libsndfile channel map + defintiions and those used by Apple and MS. + + Add handling of reading/writing channel map info. + + * tests/command_test.c tests/test_wrapper.sh.in + Update channel map tests. + +2009-07-29 Erik de Castro Lopo + + * src/common.h + Add function psf_isprint() a replacement for the standard C isprint() + function which ignores any locale settings and treats all input as ASCII. + + * src/(aiff|common|rf64|sd2|strings|svx|wav).c + Use psf_isprint() instead of isprint(). + +2009-07-13 Erik de Castro Lopo + + * src/command.c + Add string descriptions for SF_FORMAT_RF64 and SF_FORMAT_MPC2K. + +2009-06-30 Erik de Castro Lopo + + * programs/sndfile-play.c + Allow use of Open Sound System audio output under FreeBSD. + +2009-06-24 Erik de Castro Lopo + + * configure.ac + Add patch from Conrad Parker to add --disable-jack. + +2009-05-28 Erik de Castro Lopo + + * src/alaw.c src/float32.c src/htk.c src/pcm.c src/sds.c src/ulaw.c + Fix bugs where invalid files can cause a divide by zero error (SIGFPE). + Thanks to Sami Liedes for reporting this a Debian bug #530831. + +2009-05-26 Erik de Castro Lopo + + * src/chanmap.[ch] + New files for channel map decoding/encoding. + +2009-05-25 Erik de Castro Lopo + + * configure.ac src/sndfile.h.in + Fix MSVC definition of sf_count_t. + +2009-05-24 Erik de Castro Lopo + + * src/wav_w64.[ch] + Add wavex_channelmask to WAV_PRIVATE struct and add a function to convert + an array of SF_CHANNEL_MASK_* values into a bit mask for use in WAV files. + + * src/wav.c + Add ability to write the channel mask. + +2009-05-23 Erik de Castro Lopo + + * programs/sndfile-info.c + Add -c command line option to dump the channel map information. + + * src/wav_w64.c + Don't bail from parser if channel map bitmask is faulty. + + * src/common.h src/sndfile.c + Remove error code SFE_W64_BAD_CHANNEL_MAP which is not needed any more. + + * src/sndfile.c + On SFC_SET_CHANNEL_MAP_INFO pass the channel map command down to container's + command handler. + +2009-05-22 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c src/wav_w64.c + Apply a patch from Lennart Poettering (PulseAudio) to allow reading of + channel data in WAV and W64 files. + Add a test for the above. + +2009-05-20 Erik de Castro Lopo + + * src/FAQ.html + Update the section about pre-compiled binaries for Win64. + +2009-05-14 Erik de Castro Lopo + + * src/common.h src/test_conversions.c + Be more careful when including so compiling on pre-C99 platforms + (hello Slowlaris) might actually work. + + * NEWS README doc/*.html + Updates for 1.0.20. + +2009-04-21 Erik de Castro Lopo + + * src/voc.c + Fix a bug whereby opening a specially crafted VOC file could result in a + heap overflow. Thanks to Tobias Klein (http://www.trapkit.de) for reporting + this issue. + + * src/aiff.c + Fix potential (heap) buffer overflow when parsing 'MARK' chunk. + +2009-04-12 Erik de Castro Lopo + + * tests/stdin_test.c + Check psf->error after opening file. + + * src/file_io.c + Fix obscure seeking bug reported by Hugh Secker-Walker. + + * tests/utils.tpl + Add check of sf_error to test_open_file_or_die(). + + * src/sndfile.c + Clear error if opening resource fork fails. + +2009-04-11 Erik de Castro Lopo + + * tests/alaw_test.c tests/locale_test.c tests/ulaw_test.c + Cleanup output. + +2009-03-25 Erik de Castro Lopo + + * src/float32.c + Fix f2s_clip_array. + +2009-03-24 Erik de Castro Lopo + + * src/float32.c + In host_read_f2s call convert instead of f2s_array. + + * src/ima_adpcm.c + Remove dead code. + + * src/test_ima_oki_adpcm.c examples/generate.c tests/dither_test.c + tests/dwvw_test.c tests/fix_this.c tests/generate.c + tests/multi_file_test.c + Minor fixes. + +2009-03-23 Erik de Castro Lopo + + * M4/shave.m4 shave.in + Pulled update from upstream. + +2009-03-19 Erik de Castro Lopo + + * doc/api.html + Add pointers to example programs in source code tarball. + +2009-03-17 Erik de Castro Lopo + + * src/common.h + Define SF_PLATFORM_S64 for non-gcc compilers with 'long long' type. + + * configure.ac + Add documentation for --disable-external-libs and improve error handling + for that option. + + * src/sndfile.c src/sndfile.h.in src/create_symbols_file.py + Add public function sf_version_string. + + * tests/sfversion.c + Test function sf_version_string. + + * M4/shave.m4 shave-libtool.in shave.in + Add new files from 'git clone git://git.lespiau.name/shave'. + + * configure.ac + Enable shave. + + * src/Makefile.am src/binheader_writef_check.py Octave/* + Shave related tweaks. + +2009-03-15 Erik de Castro Lopo + + * src/common.h src/caf.c src/sndfile.c + Add SF_MAX_CHANNELS (set to 256) and use it. + + * src/sndfile.h.in + Check for either _MSCVER or _MSC_VER being defined. + +2009-03-04 Erik de Castro Lopo + + * tests/vorbis_test.c + Relax test slighly to allow test to pass on more CPUs etc. + 2009-03-03 Erik de Castro Lopo * configure.ac @@ -122,7 +1915,7 @@ * src/wav.c Handle four zero bytes as a marker within a LIST or INFO chunk. - Thanks to Rogrio Brito for supplying an example file. + Thanks to Rogério Brito for supplying an example file. 2009-02-14 Erik de Castro Lopo @@ -683,7 +2476,7 @@ 2008-06-14 Erik de Castro Lopo * src/aiff.c - Apply a fix from Axel Roebel where if the second loop in the instrument + Apply a fix from Axel Röbel where if the second loop in the instrument chunk is none, the loop mode is written into the first loop. 2008-05-31 Erik de Castro Lopo @@ -797,7 +2590,7 @@ 2008-04-09 Erik de Castro Lopo * src/aiff.c - Fix up handling of 'APPL' chunk. Thanks to Axel Roebel for bringing up + Fix up handling of 'APPL' chunk. Thanks to Axel Röbel for bringing up this issue. 2008-04-06 Erik de Castro Lopo @@ -948,10 +2741,10 @@ Allow use of either LGPL v2.1 or LGPL v3. * tests/header_test.tpl - Add header_shrink_test from Axel Roebel. + Add header_shrink_test from Axel Röbel. * src/wav.c - Add fix from Axel Roebel for writing files with float data but no peak + Add fix from Axel Röbel for writing files with float data but no peak chunk (ie peak chunk gets removed after the file is opened). * src/aiff.c tests/header_test.tpl @@ -1408,7 +3201,7 @@ 2007-04-14 Erik de Castro Lopo * src/GSM610/long_term.c src/macbinary3.c tests/cpp_test.cc - Add patch from Andr Pang to clean up compiles on OSX. + Add patch from André Pang to clean up compiles on OSX. * src/wve.c src/common.h src/sndfile.c src/sndfile.h.in examples/sndfile-convert.c @@ -1421,7 +3214,7 @@ * src/sndfile.hh Add a static SndfileHandle::formatCheck method as suggested by Jorge - Jimnez. + Jiménez. 2007-04-09 Erik de Castro Lopo @@ -1926,7 +3719,7 @@ * configure.ac Fix handling of --enable and --disable configure args. Thanks to Diego - 'Flameeyes' Petten who sent the patch. + 'Flameeyes' Pettenò who sent the patch. 2006-03-22 Erik de Castro Lopo @@ -2097,11 +3890,11 @@ 2006-01-10 Erik de Castro Lopo * examples/sndfile-play.c - Fix calculation of samples remaining in win32 code. Thanks Axel Roebel. + Fix calculation of samples remaining in win32 code. Thanks Axel Röbel. * src/common.h Make sure length of header buffer can hold header plus strings. Thanks Axel - Roebel. + Röbel. 2006-01-09 Erik de Castro Lopo @@ -2315,7 +4108,7 @@ * tests/locale_test.c Modify the way the unicode strings were encoded so that older compilers - do not complain. Thanks Axel Roebel. + do not complain. Thanks Axel Röbel. * configure.ac Bump the version to 1.0.12 for release. @@ -2544,7 +4337,7 @@ style strings (no terminating character). * src/aiff.c - Move to new (correct) AIFF string style. Thanks to Axel Roebel for being + Move to new (correct) AIFF string style. Thanks to Axel Röbel for being so persistent on this issue. 2005-07-11 Erik de Castro Lopo @@ -2703,7 +4496,7 @@ 2005-05-10 Erik de Castro Lopo * src/ircam.c - Fix writing of IRCAM files on big endian systems (thanks to Axel Roebel). + Fix writing of IRCAM files on big endian systems (thanks to Axel Röbel). * src/wav.c Add workaround for files created by the Peak audio editor on Mac which can @@ -3302,7 +5095,7 @@ 2004-04-03 Erik de Castro Lopo * configure.ac - Improve printout configuration summary (as suggested by Axel Rbel). + Improve printout configuration summary (as suggested by Axel Röbel). * doc/index.html Add link to pre-release location. @@ -3576,7 +5369,7 @@ 2003-12-07 Erik de Castro Lopo * src/file_io.c - Axel Roebel pointed out that on Mac OSX a pipe is not considered a fifo + Axel Röbel pointed out that on Mac OSX a pipe is not considered a fifo (S_ISFIFO (st.st_mode) is false) but a socket (S_ISSOCK (st.st_mode) is true). The test has therefore been changed to is S_ISREG and anything which which does not return true for S_ISREG is considered a pipe. @@ -3780,11 +5573,11 @@ * src/aiff.c Fixed a bug where opening a file with a non-trival header in SFM_RDWR mode - would over-write part of the header. Thanks to Axel Roebel for pointing + would over-write part of the header. Thanks to Axel Röbel for pointing this out. Axel also provided a patch to fix this but I came up with a neater and more general solution. Return error when openning an AIFF file with data after the SSND chunk - (Thanks Axel Roebel). + (Thanks Axel Röbel). * tests/aiff_rw_test.c Improvements to test program which will later allow it to be generalised to @@ -4068,28 +5861,28 @@ * src/common.c src/common.h src/file_io.h Added is_pipe field to SF_PRIVATE and declaration of psf_is_pipe() - function. (Axel Roebel) + function. (Axel Röbel) * src/sndfile.c - Fixed determination of whether the file is a pipe. (Axel Roebel) + Fixed determination of whether the file is a pipe. (Axel Röbel) * src/paf.c - Force paf24 to start with undefined mode. (Axel Roebel) + Force paf24 to start with undefined mode. (Axel Röbel) * tests/pipe_test.c Mods to make this test work and actually do the test on RAW files. (Axel - Roebel). + Röbel). 2003-05-05 Erik de Castro Lopo * src/sndfile.c Fixed a potential bug where psf->sf.seekable was being set to FALSE when operating on stdin or stdout but then the default initialiser was reseting - it to TRUE. Thanks to Axel Roebel. + it to TRUE. Thanks to Axel Röbel. * src/aiff.c Fixed a bug in the header parser where it was not handling an odd length - COMM chunk correctly. Thanks to Axel Roebel. + COMM chunk correctly. Thanks to Axel Röbel. * src/test_file_io.c Add more tests. @@ -7013,7 +8806,7 @@ This is the boundary between version 1 of the library above and version 0 below. * src/paf.c src/wav_gsm610.c Removed two printf()s which had escaped notice for some time (thanks - Sigbjrn Skjret). + Sigbjørn Skjæret). 2001-07-19 Erik de Castro Lopo @@ -7333,7 +9126,7 @@ This is the boundary between version 1 of the library above and version 0 below. * src/sndfile.h Removed prototype of unimplemented function sf_get_info(). Added prototype - for sf_error_number() Thanks to Sigbjrn Skjret for spotting these. + for sf_error_number() Thanks to Sigbjørn Skjæret for spotting these. 2000-08-18 Erik de Castro Lopo @@ -7343,8 +9136,8 @@ This is the boundary between version 1 of the library above and version 0 below. 2000-08-15 Erik de Castro Lopo * src/sndfile.c - Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbjrn - Skjret for spotting this one. + Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbjørn + Skjæret for spotting this one. 2000-08-13 Erik de Castro Lopo @@ -7438,7 +9231,7 @@ This is the boundary between version 1 of the library above and version 0 below. * src/wav.c Fixed bug in GSM 6.10 handling for big-endian machines. Thanks - to Sigbjrn Skjret for reporting this. + to Sigbjørn Skjæret for reporting this. 2000-04-25 Erik de Castro Lopo @@ -7620,7 +9413,7 @@ This is the boundary between version 1 of the library above and version 0 below. * src/aiff.c Fixed calculation of datalength when reading SSND chunk. Thanks to - Sigbjrn Skjret for pointing out this error. + Sigbjørn Skjæret for pointing out this error. 1999-07-29 Erik de Castro Lopo @@ -7969,4 +9762,3 @@ This is the boundary between version 1 of the library above and version 0 below. * src/aiff.c: Changed reading of 'COMM' chunk to avoid reading an int which overlaps an int (4 byte) boundary. - diff --git a/libs/libsndfile/M4/Makefile.am b/libs/libsndfile/M4/Makefile.am index 1ec5172e57..e2d984a43a 100644 --- a/libs/libsndfile/M4/Makefile.am +++ b/libs/libsndfile/M4/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 extra_largefile.m4 \ +EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 \ flexible_array.m4 llrint.m4 lrint.m4 lrintf.m4 octave.m4 extra_pkg.m4 diff --git a/libs/libsndfile/M4/add_cflags.m4 b/libs/libsndfile/M4/add_cflags.m4 index 7b6b555c7f..55a326c580 100644 --- a/libs/libsndfile/M4/add_cflags.m4 +++ b/libs/libsndfile/M4/add_cflags.m4 @@ -1,17 +1,18 @@ -dnl @synopsis AC_ADD_CFLAGS +dnl @synopsis MN_ADD_CFLAGS dnl dnl Add the given option to CFLAGS, if it doesn't break the compiler -AC_DEFUN([AC_ADD_CFLAGS], +AC_DEFUN([MN_ADD_CFLAGS], [AC_MSG_CHECKING([if $CC accepts $1]) ac_add_cflags__old_cflags="$CFLAGS" - CFLAGS="$CFLAGS $1" + CFLAGS="$1" AC_TRY_LINK([ #include ], [puts("Hello, World!"); return 0;], - AC_MSG_RESULT([yes]), + AC_MSG_RESULT([yes]) + CFLAGS="$ac_add_cflags__old_cflags $1", AC_MSG_RESULT([no]) - CFLAGS="$ac_add_cflags__old_cflags" + CFLAGS="$ac_add_cflags__old_cflags" ) -])# AC_ADD_CFLAGS +])# MN_ADD_CFLAGS diff --git a/libs/libsndfile/M4/add_cxxflags.m4 b/libs/libsndfile/M4/add_cxxflags.m4 index 5e6489faf2..1c0a4deb96 100644 --- a/libs/libsndfile/M4/add_cxxflags.m4 +++ b/libs/libsndfile/M4/add_cxxflags.m4 @@ -1,17 +1,19 @@ -dnl @synopsis AC_ADD_CXXFLAGS +dnl @synopsis MN_ADD_CXXFLAGS dnl dnl Add the given option to CXXFLAGS, if it doesn't break the compiler -AC_DEFUN([AC_ADD_CXXFLAGS], +AC_DEFUN([MN_ADD_CXXFLAGS], [AC_MSG_CHECKING([if $CXX accepts $1]) + AC_LANG_ASSERT([C++]) ac_add_cxxflags__old_cxxflags="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $1" + CXXFLAGS="$1" AC_TRY_LINK([ #include ], [puts("Hello, World!"); return 0;], - AC_MSG_RESULT([yes]), + AC_MSG_RESULT([yes]) + CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1", AC_MSG_RESULT([no]) - CXXFLAGS="$ac_add_cxxflags__old_cxxflags" + CXXFLAGS="$ac_add_cxxflags__old_cxxflags" ) -])# AC_ADD_CXXFLAGS +])# MN_ADD_CXXFLAGS diff --git a/libs/libsndfile/M4/clang.m4 b/libs/libsndfile/M4/clang.m4 new file mode 100644 index 0000000000..4cf3077d64 --- /dev/null +++ b/libs/libsndfile/M4/clang.m4 @@ -0,0 +1,31 @@ +dnl @synopsis MN_C_COMPILER_IS_CLANG +dnl +dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang). +dnl @version 1.0 Oct 31 2013 +dnl @author Erik de Castro Lopo +dnl +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright +dnl and this permission notice appear in all copies. No representations are +dnl made about the suitability of this software for any purpose. It is +dnl provided "as is" without express or implied warranty. +dnl + + +AC_DEFUN([MN_C_COMPILER_IS_CLANG], +[AC_CACHE_CHECK(whether we are using the CLANG C compiler, + mn_cv_c_compiler_clang, + [ AC_LANG_ASSERT(C) + AC_TRY_LINK([ + #include + ], + [ + #ifndef __clang__ + This is not clang! + #endif + ], + mn_cv_c_compiler_clang=yes, + mn_cv_c_compiler_clang=no + ]) + ) +]) diff --git a/libs/libsndfile/M4/clip_mode.m4 b/libs/libsndfile/M4/clip_mode.m4 index 57c94a9626..4556b937a0 100644 --- a/libs/libsndfile/M4/clip_mode.m4 +++ b/libs/libsndfile/M4/clip_mode.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C_CLIP_MODE +dnl @synopsis MN_C_CLIP_MODE dnl dnl Determine the clipping mode when converting float to int. dnl @version 1.0 May 17 2003 @@ -20,7 +20,7 @@ dnl Find the clipping mode in the following way: dnl 1) If we are not cross compiling test it. dnl 2) IF we are cross compiling, assume that clipping isn't done correctly. -AC_DEFUN([AC_C_CLIP_MODE], +AC_DEFUN([MN_C_CLIP_MODE], [AC_CACHE_CHECK(processor clipping capabilities, ac_cv_c_clip_type, @@ -119,6 +119,6 @@ case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in ) ] -)# AC_C_CLIP_MODE +)# MN_C_CLIP_MODE diff --git a/libs/libsndfile/M4/endian.m4 b/libs/libsndfile/M4/endian.m4 index b3a4589764..5d766ff39e 100644 --- a/libs/libsndfile/M4/endian.m4 +++ b/libs/libsndfile/M4/endian.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C_FIND_ENDIAN +dnl @synopsis MN_C_FIND_ENDIAN dnl dnl Determine endian-ness of target processor. dnl @version 1.1 Mar 03 2002 @@ -20,7 +20,7 @@ dnl 2) If 1) fails, look in and . dnl 3) If 1) and 2) fails and not cross compiling run a test program. dnl 4) If 1) and 2) fails and cross compiling then guess based on target. -AC_DEFUN([AC_C_FIND_ENDIAN], +AC_DEFUN([MN_C_FIND_ENDIAN], [AC_CACHE_CHECK(processor byte ordering, ac_cv_c_byte_order, @@ -92,13 +92,11 @@ if test $ac_cv_c_byte_order = unknown ; then [ case "$target_cpu" in alpha* | i?86* | mipsel* | ia64*) - ac_cv_c_big_endian=0 - ac_cv_c_little_endian=1 + ac_cv_c_byte_order=little ;; m68* | mips* | powerpc* | hppa* | sparc*) - ac_cv_c_big_endian=1 - ac_cv_c_little_endian=0 + ac_cv_c_byte_order=big ;; esac @@ -116,7 +114,6 @@ if test $ac_cv_c_byte_order = unknown ; then return (u.c [sizeof (long) - 1] == 1); } ]], , ac_cv_c_byte_order=big, - ac_cv_c_byte_order=unknown ) AC_TRY_RUN( @@ -129,7 +126,6 @@ if test $ac_cv_c_byte_order = unknown ; then u.l = 1 ; return (u.c [0] == 1); }]], , ac_cv_c_byte_order=little, - ac_cv_c_byte_order=unknown ) fi fi @@ -154,6 +150,6 @@ else fi ] -)# AC_C_FIND_ENDIAN +)# MN_C_FIND_ENDIAN diff --git a/libs/libsndfile/M4/extra_largefile.m4 b/libs/libsndfile/M4/extra_largefile.m4 index 47401f85a4..3e614c3f70 100644 --- a/libs/libsndfile/M4/extra_largefile.m4 +++ b/libs/libsndfile/M4/extra_largefile.m4 @@ -6,8 +6,8 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html dnl Written by Paul Eggert . dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE. -dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME) -AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS], +dnl MN_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME) +AC_DEFUN([MN_SYS_EXTRA_LARGEFILE_FLAGS], [AC_CACHE_CHECK([for $1 value to request large file support], ac_cv_sys_largefile_$1, [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || { @@ -67,9 +67,9 @@ AC_DEFUN([AC_SYS_EXTRA_LARGEFILE], [ --disable-largefile omit support for large files]) if test "$enable_largefile" != no; then AC_CHECK_TOOL(GETCONF, getconf) - AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS) - AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS) - AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS) + MN_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS) + MN_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS) + MN_SYS_EXTRA_LARGEFILE_FLAGS(LIBS) for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do case "$ac_flag" in diff --git a/libs/libsndfile/M4/extra_pkg.m4 b/libs/libsndfile/M4/extra_pkg.m4 index a92d090d69..afe474e224 100644 --- a/libs/libsndfile/M4/extra_pkg.m4 +++ b/libs/libsndfile/M4/extra_pkg.m4 @@ -1,5 +1,6 @@ # extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# +# +# Copyright (c) 2008-2012 Erik de Castro Lopo # Copyright (c) 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify @@ -40,6 +41,25 @@ AC_MSG_CHECKING([for $2 ]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) +pkg_link_saved_CFLAGS=$CFLAGS +pkg_link_saved_LIBS=$LIBS + +eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}" +eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}" + +CFLAGS="$CFLAGS $pkg_CFLAGS" +LIBS="$LIBS $pkg_LIBS" + +AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no) + +CFLAGS=$pkg_link_saved_CFLAGS +LIBS=$pkg_link_saved_LIBS + +if test $pkg_link = no ; then + $as_echo_n "link failed ... " + pkg_failed=yes + fi + m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) @@ -48,7 +68,7 @@ if test $pkg_failed = yes; then _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` - else + else $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` fi # Put the nasty error message in config.log where it belongs diff --git a/libs/libsndfile/M4/flexible_array.m4 b/libs/libsndfile/M4/flexible_array.m4 index 7f558d3ebd..661da17b23 100644 --- a/libs/libsndfile/M4/flexible_array.m4 +++ b/libs/libsndfile/M4/flexible_array.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C99_FLEXIBLE_ARRAY +dnl @synopsis MN_C99_FLEXIBLE_ARRAY dnl dnl Dose the compiler support the 1999 ISO C Standard "stuct hack". dnl @version 1.1 Mar 15 2004 @@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. -AC_DEFUN([AC_C99_FLEXIBLE_ARRAY], +AC_DEFUN([MN_C99_FLEXIBLE_ARRAY], [AC_CACHE_CHECK(C99 struct flexible array support, ac_cv_c99_flexible_array, @@ -28,5 +28,5 @@ AC_TRY_LINK([[ ac_cv_c99_flexible_array=yes, ac_cv_c99_flexible_array=no ))] -) # AC_C99_FLEXIBLE_ARRAY +) # MN_C99_FLEXIBLE_ARRAY diff --git a/libs/libsndfile/M4/gcc_version.m4 b/libs/libsndfile/M4/gcc_version.m4 index 84a5ba8d74..f8c5cbebe4 100644 --- a/libs/libsndfile/M4/gcc_version.m4 +++ b/libs/libsndfile/M4/gcc_version.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_GCC_VERSION +dnl @synopsis MN_GCC_VERSION dnl dnl Find the version of gcc. dnl @version 1.0 Nov 05 2007 @@ -11,7 +11,7 @@ dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl -AC_DEFUN([AC_GCC_VERSION], +AC_DEFUN([MN_GCC_VERSION], [ if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then @@ -20,8 +20,8 @@ if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then AC_MSG_RESULT($GCC_VERSION) changequote(,)dnl - GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/^[0-9]\+\.//" | sed "s/\..*//"` GCC_MAJOR_VERSION=`echo $GCC_VERSION | sed "s/\..*//"` + GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/$GCC_MAJOR_VERSION\.//" | sed "s/\..*//"` changequote([,])dnl fi @@ -29,5 +29,5 @@ AC_SUBST(GCC_VERSION) AC_SUBST(GCC_MAJOR_VERSION) AC_SUBST(GCC_MINOR_VERSION) -])# AC_GCC_VERSION +])# MN_GCC_VERSION diff --git a/libs/libsndfile/M4/llrint.m4 b/libs/libsndfile/M4/llrint.m4 index 0f5ce698c4..66be206187 100644 --- a/libs/libsndfile/M4/llrint.m4 +++ b/libs/libsndfile/M4/llrint.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C99_FUNC_LLRINT +dnl @synopsis MN_C99_FUNC_LLRINT dnl dnl Check whether C99's llrint function is available. dnl @version 1.1 Sep 30 2002 @@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl -AC_DEFUN([AC_C99_FUNC_LLRINT], +AC_DEFUN([MN_C99_FUNC_LLRINT], [AC_CACHE_CHECK(for llrint, ac_cv_c99_llrint, [ @@ -34,5 +34,5 @@ if test "$ac_cv_c99_llrint" = yes; then AC_DEFINE(HAVE_LLRINT, 1, [Define if you have C99's llrint function.]) fi -])# AC_C99_FUNC_LLRINT +])# MN_C99_FUNC_LLRINT diff --git a/libs/libsndfile/M4/lrint.m4 b/libs/libsndfile/M4/lrint.m4 index 3e3319e15b..c2c21d60f4 100644 --- a/libs/libsndfile/M4/lrint.m4 +++ b/libs/libsndfile/M4/lrint.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C99_FUNC_LRINT +dnl @synopsis MN_C99_FUNC_LRINT dnl dnl Check whether C99's lrint function is available. dnl @version 1.3 Feb 12 2002 @@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl -AC_DEFUN([AC_C99_FUNC_LRINT], +AC_DEFUN([MN_C99_FUNC_LRINT], [AC_CACHE_CHECK(for lrint, ac_cv_c99_lrint, [ @@ -33,5 +33,5 @@ if test "$ac_cv_c99_lrint" = yes; then AC_DEFINE(HAVE_LRINT, 1, [Define if you have C99's lrint function.]) fi -])# AC_C99_FUNC_LRINT +])# MN_C99_FUNC_LRINT diff --git a/libs/libsndfile/M4/lrintf.m4 b/libs/libsndfile/M4/lrintf.m4 index f921e9ed29..04f4d6603c 100644 --- a/libs/libsndfile/M4/lrintf.m4 +++ b/libs/libsndfile/M4/lrintf.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_C99_FUNC_LRINTF +dnl @synopsis MN_C99_FUNC_LRINTF dnl dnl Check whether C99's lrintf function is available. dnl @version 1.3 Feb 12 2002 @@ -10,7 +10,7 @@ dnl and this permission notice appear in all copies. No representations are dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl -AC_DEFUN([AC_C99_FUNC_LRINTF], +AC_DEFUN([MN_C99_FUNC_LRINTF], [AC_CACHE_CHECK(for lrintf, ac_cv_c99_lrintf, [ @@ -33,5 +33,5 @@ if test "$ac_cv_c99_lrintf" = yes; then AC_DEFINE(HAVE_LRINTF, 1, [Define if you have C99's lrintf function.]) fi -])# AC_C99_FUNC_LRINTF +])# MN_C99_FUNC_LRINTF diff --git a/libs/libsndfile/M4/mkoctfile_version.m4 b/libs/libsndfile/M4/mkoctfile_version.m4 index 3704398298..c17333ea25 100644 --- a/libs/libsndfile/M4/mkoctfile_version.m4 +++ b/libs/libsndfile/M4/mkoctfile_version.m4 @@ -1,4 +1,4 @@ -dnl @synopsis AC_MKOCTFILE_VERSION +dnl @synopsis OCTAVE_MKOCTFILE_VERSION dnl dnl Find the version of mkoctfile. dnl @version 1.0 Aug 23 2007 @@ -11,7 +11,7 @@ dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl -AC_DEFUN([AC_MKOCTFILE_VERSION], +AC_DEFUN([OCTAVE_MKOCTFILE_VERSION], [ @@ -34,5 +34,5 @@ if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then AC_SUBST(MKOCTFILE) AC_SUBST(MKOCTFILE_VERSION) -])# AC_MKOCTFILE_VERSION +])# OCTAVE_MKOCTFILE_VERSION diff --git a/libs/libsndfile/M4/octave.m4 b/libs/libsndfile/M4/octave.m4 index 164653456d..88d5a5b9b0 100644 --- a/libs/libsndfile/M4/octave.m4 +++ b/libs/libsndfile/M4/octave.m4 @@ -18,10 +18,10 @@ dnl Find the version of Octave. dnl @version 1.0 Aug 23 2007 dnl @author Erik de Castro Lopo dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is +dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl @@ -52,10 +52,10 @@ dnl Find the version of Octave. dnl @version 1.0 Aug 23 2007 dnl @author Erik de Castro Lopo dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is +dnl made about the suitability of this software for any purpose. It is dnl provided "as is" without express or implied warranty. dnl @@ -102,7 +102,7 @@ dnl Default to no. OCTAVE_BUILD=no AC_OCTAVE_VERSION -AC_MKOCTFILE_VERSION +OCTAVE_MKOCTFILE_VERSION AC_OCTAVE_CONFIG_VERSION prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE" @@ -119,7 +119,7 @@ if test "x$prog_concat" = "xyesyesyes" ; then 2.*) AC_MSG_WARN([Octave version 2.X is not supported.]) ;; - 3.0.*) + 3.*) OCTAVE_DEST_ODIR=`$OCTAVE_CONFIG --oct-site-dir | sed 's%^/usr%${prefix}%'` OCTAVE_DEST_MDIR=`$OCTAVE_CONFIG --m-site-dir | sed 's%^/usr%${prefix}%'` diff --git a/libs/libsndfile/M4/really_gcc.m4 b/libs/libsndfile/M4/really_gcc.m4 new file mode 100644 index 0000000000..67aed7802f --- /dev/null +++ b/libs/libsndfile/M4/really_gcc.m4 @@ -0,0 +1,33 @@ +dnl @synopsis MN_GCC_REALLY_IS_GCC +dnl +dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang). +dnl @version 1.0 Oct 31 2013 +dnl @author Erik de Castro Lopo +dnl +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright +dnl and this permission notice appear in all copies. No representations are +dnl made about the suitability of this software for any purpose. It is +dnl provided "as is" without express or implied warranty. +dnl + +# If the configure script has already detected GNU GCC, then make sure it +# isn't CLANG masquerading as GCC. + +AC_DEFUN([MN_GCC_REALLY_IS_GCC], +[ AC_LANG_ASSERT(C) + if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then + AC_TRY_LINK([ + #include + ], + [ + #ifdef __clang__ + This is clang! + #endif + ], + ac_cv_c_compiler_gnu=yes, + ac_cv_c_compiler_gnu=no + ) + fi + +]) diff --git a/libs/libsndfile/M4/stack_protect.m4 b/libs/libsndfile/M4/stack_protect.m4 new file mode 100644 index 0000000000..bf27e6e74f --- /dev/null +++ b/libs/libsndfile/M4/stack_protect.m4 @@ -0,0 +1,73 @@ +dnl Copyright (C) 2013 Xiph.org Foundation +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that the following conditions +dnl are met: +dnl +dnl - Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl +dnl - Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in the +dnl documentation and/or other materials provided with the distribution. +dnl +dnl - Neither the name of the Xiph.org Foundation nor the names of its +dnl contributors may be used to endorse or promote products derived from +dnl this software without specific prior written permission. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +dnl Want to know of GCC stack protector works, botfor the C and for the C++ +dnl compiler. +dnl +dnl Just checking if the compiler accepts the required CFLAGSs is not enough +dnl because we have seen at least one instance where this check was +dnl in-sufficient. +dnl +dnl Instead, try to compile and link a test program with the stack protector +dnl flags. If that works, we use it. + +AC_DEFUN([XIPH_GCC_STACK_PROTECTOR], +[AC_LANG_ASSERT(C) + AC_MSG_CHECKING([if $CC supports stack smash protection]) + xiph_stack_check_old_cflags="$CFLAGS" + SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4" + CFLAGS=$SSP_FLAGS + AC_TRY_LINK([ + #include + ], + [puts("Hello, World!"); return 0;], + AC_MSG_RESULT([yes]) + CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS", + AC_MSG_RESULT([no]) + CFLAGS="$xiph_stack_check_old_cflags" + ) +])# XIPH_GCC_STACK_PROTECTOR + +AC_DEFUN([XIPH_GXX_STACK_PROTECTOR], +[AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([if $CXX supports stack smash protection]) + xiph_stack_check_old_cflags="$CFLAGS" + SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4" + CFLAGS=$SSP_FLAGS + AC_TRY_LINK([ + #include + ], + [puts("Hello, World!"); return 0;], + AC_MSG_RESULT([yes]) + CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS", + AC_MSG_RESULT([no]) + CFLAGS="$xiph_stack_check_old_cflags" + ) + AC_LANG_POP([C++]) +])# XIPH_GXX_STACK_PROTECTOR diff --git a/libs/libsndfile/Makefile.am b/libs/libsndfile/Makefile.am index 4fe98eaad4..a429c5b3fa 100644 --- a/libs/libsndfile/Makefile.am +++ b/libs/libsndfile/Makefile.am @@ -1,29 +1,46 @@ -## Process this file with automake to produce Makefile.in - -DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror - -if BUILD_OCTAVE_MOD -octave_dir = Octave -endif - -SUBDIRS = M4 Win32 src $(octave_dir) -#man doc examples regtest tests programs - -DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs - -EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Mingw-make-dist.sh - - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = sndfile.pc - -m4datadir = $(datadir)/aclocal - -test: check-recursive - -# Target to make autogenerated files. -genfiles : - (cd src ; make genfiles) - (cd tests ; make genfiles) - - +## Process this file with automake to produce Makefile.in + +ACLOCAL_AMFLAGS = -I M4 + +DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror + +if BUILD_OCTAVE_MOD +octave_dir = Octave +endif + +SUBDIRS = M4 Win32 src $(octave_dir) +#man doc examples regtest tests programs + +DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs + +EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \ + Scripts/linux-to-win-cross-configure.sh Scripts/build-test-tarball.mk.in + +CLEANFILES = *~ + +#pkgconfig_DATA = sndfile.pc + +m4datadir = $(datadir)/aclocal + +#=============================================================================== + +test: check-recursive + +# Target to make autogenerated files. +genfiles : + (cd src ; make genfiles) +# (cd tests ; make genfiles) + +checkprograms : + (cd src ; make libsndfile.la checkprograms) +# (cd tests ; make checkprograms) + +testprogs : + (cd src ; make testprogs) +# (cd tests ; make testprogs) + + +test-tarball : Scripts/build-test-tarball.mk + (cd src ; make all libsndfile.la checkprograms) +# (cd tests ; make all checkprograms) +# make -f Scripts/build-test-tarball.mk diff --git a/libs/libsndfile/NEWS b/libs/libsndfile/NEWS index 37bf671e4c..9626d45166 100644 --- a/libs/libsndfile/NEWS +++ b/libs/libsndfile/NEWS @@ -1,3 +1,37 @@ +Version 1.0.25 (2011-07-13) + * Fix for Secunia Advisory SA45125, heap overflow in PAF file handler. + * Accept broken WAV files with blockalign == 0. + * Minor bug fixes and improvements. + +Version 1.0.24 (2011-03-23) + * WAV files now have an 18 byte u-law and A-law fmt chunk. + * Document virtual I/O functionality. + * Two new methods rawHandle() and takeOwnership() in sndfile.hh. + * AIFF fix for non-zero offset value in SSND chunk. + * Minor bug fixes and improvements. + +Version 1.0.23 (2010-10-10) + * Add version metadata to Windows DLL. + * Add a missing 'inline' to sndfile.hh. + * Update docs. + * Minor bug fixes and improvements. + +Version 1.0.22 (2010-10-04) + * Couple of fixes for SDS file writer. + * Fixes arising from static analysis. + * Handle FLAC files with ID3 meta data at start of file. + * Handle FLAC files which report zero length. + * Other minor bug fixes and improvements. + +Version 1.0.21 (2009-12-13) + * Add a couple of new binary programs to programs/ dir. + * Remove sndfile-jackplay (now in sndfile-tools package). + * Add windows only function sf_wchar_open(). + * Bunch of minor bug fixes. + +Version 1.0.20 (2009-05-14) + * Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/). + Version 1.0.19 (2009-03-02) * Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research). * Huge number of minor bug fixes as a result of static analysis. diff --git a/libs/libsndfile/Octave/Makefile.am b/libs/libsndfile/Octave/Makefile.am index d905cf6d81..3f0078e18f 100644 --- a/libs/libsndfile/Octave/Makefile.am +++ b/libs/libsndfile/Octave/Makefile.am @@ -21,7 +21,7 @@ OCT_LIB_DIR = @OCT_LIB_DIR@ OCT_LIBS = @OCT_LIBS@ SNDFILEDIR = $(top_builddir)/src -INCLUDES = -I$(SNDFILEDIR) +AM_CPPFLAGS = -I$(SNDFILEDIR) oct_module_srcs = sndfile.cc oct_module_files = sndfile.oct PKG_ADD @@ -30,13 +30,19 @@ oct_module_files = sndfile.oct PKG_ADD noinst_DATA = $(oct_module_files) +# Used by shave which cleans up automake generated Makefile output. +V = @ +Q = $(V:1=) +QUIET_GEN = $(Q:@=@echo ' GEN '$@;) + + # Use Octave's mkoctfile to do all the heavy lifting. Unfortunately, its # a little dumb so we need to guide it carefully. sndfile.oct : sndfile.o - $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ + $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ > /dev/null sndfile.o : sndfile.cc - $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ + $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ > /dev/null # Allow for the test being run in the build dir, but the test script # being located in the source dir. @@ -70,3 +76,4 @@ uninstall-local : clean-local : rm -f sndfile.o sndfile.oct + @if test $(abs_builddir) != $(abs_srcdir) ; then rm -f PKG_ADD ; fi diff --git a/libs/libsndfile/Octave/Readme.txt b/libs/libsndfile/Octave/Readme.txt new file mode 100644 index 0000000000..c38605bffc --- /dev/null +++ b/libs/libsndfile/Octave/Readme.txt @@ -0,0 +1,23 @@ +The libsndfile Modules for GNU Octave +===================================== + +These modules are currently known to work with version 3.0 of GNU Octave on +Linux. They have not been tested elsewhere. + + +Build Requirements +------------------ + +In order to build these libsndfile related modules for GNU Octave on a Debian +GNU/Linux (or Debian derived) system, you will need (on top of what is normally +required to build libsndfile) the package: + + octaveX.Y-headers + +where X.Y matches the version number of your installation of GNU Octave. + +The configure script in the top level libsndfile directory will detect the +presence and correct versions of the Octave build tools. The building of these +modules will only go ahead if everything is correct. + + diff --git a/libs/libsndfile/Octave/format.h b/libs/libsndfile/Octave/format.h new file mode 100644 index 0000000000..ce769b2c69 --- /dev/null +++ b/libs/libsndfile/Octave/format.h @@ -0,0 +1,21 @@ +/* +** Copyright (C) 2007-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +int format_of_str (const std::string & fmt) ; + +void string_of_format (std::string & fmt, int format) ; diff --git a/libs/libsndfile/Octave/octave_test.m b/libs/libsndfile/Octave/octave_test.m index 30b60139b4..25a922e897 100644 --- a/libs/libsndfile/Octave/octave_test.m +++ b/libs/libsndfile/Octave/octave_test.m @@ -1,4 +1,4 @@ -# Copyright (C) 2007 Erik de Castro Lopo +# Copyright (C) 2007-2011 Erik de Castro Lopo # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -16,9 +16,7 @@ # These tests are nowhere near comprehensive. -printf ("\n\n\n\n\n\n\n") ; - -printf (" Running Octave tests : ") ; +printf (" Running Octave tests : ") ; fflush (stdout) ; filename = "whatever" ; @@ -51,6 +49,4 @@ if (err > 1e-7) printf ("ok") ; -printf ("\n\n\n\n\n\n\n") ; - unlink (filename) ; diff --git a/libs/libsndfile/Octave/octave_test.sh b/libs/libsndfile/Octave/octave_test.sh index 6c8bd10d02..3c6f36e236 100755 --- a/libs/libsndfile/Octave/octave_test.sh +++ b/libs/libsndfile/Octave/octave_test.sh @@ -2,28 +2,34 @@ # Check where we're being run from. -if [ -d Octave ]; then +if test -d Octave ; then cd Octave + octave_src_dir=$(pwd) +elif test -z "$octave_src_dir" ; then + echo + echo "Error : \$octave_src_dir is undefined." + echo + exit 1 +else + octave_src_dir=$(cd $octave_src_dir && pwd) fi # Find libsndfile shared object. libsndfile_lib_location="" -if [ -f "../src/.libs/libsndfile.so" ]; then +if test -f "../src/.libs/libsndfile.so" ; then libsndfile_lib_location="../src/.libs/" -elif [ -f "../src/libsndfile.so" ]; then +elif test -f "../src/libsndfile.so" ; then libsndfile_lib_location="../src/" -elif [ -f "../src/.libs/libsndfile.dylib" ]; then +elif test -f "../src/.libs/libsndfile.dylib" ; then libsndfile_lib_location="../src/.libs/" -elif [ -f "../src/libsndfile.dylib" ]; then +elif test -f "../src/libsndfile.dylib" ; then libsndfile_lib_location="../src/" else - echo echo echo "Not able to find the libsndfile shared lib we've just built." echo "This may cause the following test to fail." echo - echo fi libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)` @@ -32,9 +38,9 @@ libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)` # Find sndfile.oct sndfile_oct_location="" -if [ -f .libs/sndfile.oct ]; then +if test -f .libs/sndfile.oct ; then sndfile_oct_location=".libs" -elif [ -f sndfile.oct ]; then +elif test -f sndfile.oct ; then sndfile_oct_location="." else echo "Not able to find the sndfile.oct binaries we've just built." @@ -49,7 +55,7 @@ case `file -b $sndfile_oct_location/sndfile.oct` in exit 0 ;; *) - echo "Not able to find the sndfile.oct binaries we've just built." + echo "Not able to find the sndfile.oct binary we just built." exit 1 ;; esac @@ -57,16 +63,19 @@ case `file -b $sndfile_oct_location/sndfile.oct` in # Make sure the TERM environment variable doesn't contain anything wrong. unset TERM - +# echo "octave_src_dir : $octave_src_dir" # echo "libsndfile_lib_location : $libsndfile_lib_location" # echo "sndfile_oct_location : $sndfile_oct_location" -export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH" +if test ! -f PKG_ADD ; then + cp $octave_src_dir/PKG_ADD . + fi -octave_src_dir=`(cd $octave_src_dir && pwd)` +export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH" octave_script="$octave_src_dir/octave_test.m" (cd $sndfile_oct_location && octave -qH $octave_script) - - +res=$? +echo +exit $res diff --git a/libs/libsndfile/Octave/sndfile.cc b/libs/libsndfile/Octave/sndfile.cc index e75e3279bd..6e9cd44cc9 100644 --- a/libs/libsndfile/Octave/sndfile.cc +++ b/libs/libsndfile/Octave/sndfile.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007 Erik de Castro Lopo +** Copyright (C) 2007-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -367,7 +367,7 @@ string_of_minor_format (int format) case SF_FORMAT_G723_40 : return "g723_40" ; default : break ; } ; - + return "unknown" ; } /* string_of_minor_format */ diff --git a/libs/libsndfile/Octave/sndfile_load.m b/libs/libsndfile/Octave/sndfile_load.m index d13c21a276..c66198fa35 100644 --- a/libs/libsndfile/Octave/sndfile_load.m +++ b/libs/libsndfile/Octave/sndfile_load.m @@ -1,4 +1,4 @@ -## Copyright (C) 2002 Erik de Castro Lopo +## Copyright (C) 2002-2011 Erik de Castro Lopo ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ samplingrate = -1 ; wavedata = -1 ; -eval (sprintf ('load -f %s', filename)) ; +eval (sprintf ('load -f %s', filename)) ; if (samplerate > 0), fs = samplerate ; @@ -42,7 +42,7 @@ elseif (samplingrate > 0), else error ("Not able to find sample rate.") ; endif - + if (max (size (wavedata)) > 1), data = wavedata ; else diff --git a/libs/libsndfile/Octave/sndfile_play.m b/libs/libsndfile/Octave/sndfile_play.m index c0631d94c1..e8a34a74cb 100644 --- a/libs/libsndfile/Octave/sndfile_play.m +++ b/libs/libsndfile/Octave/sndfile_play.m @@ -1,4 +1,4 @@ -## Copyright (C) 2002 Erik de Castro Lopo +## Copyright (C) 2002-2011 Erik de Castro Lopo ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/Octave/sndfile_save.m b/libs/libsndfile/Octave/sndfile_save.m index cddbc648b2..5b7e7c7d0f 100644 --- a/libs/libsndfile/Octave/sndfile_save.m +++ b/libs/libsndfile/Octave/sndfile_save.m @@ -1,4 +1,4 @@ -## Copyright (C) 2002 Erik de Castro Lopo +## Copyright (C) 2002-2011 Erik de Castro Lopo ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/README b/libs/libsndfile/README index aeb597d410..8df79c7d9f 100644 --- a/libs/libsndfile/README +++ b/libs/libsndfile/README @@ -1,4 +1,4 @@ -This is libsndfile, 1.0.19 +This is libsndfile, 1.0.25 libsndfile is a library of C routines for reading and writing files containing sampled audio data. @@ -20,6 +20,9 @@ Bormann. Their original code can be found at : The src/G72x directory contains code written and released by Sun Microsystems under a suitably free license. +The src/ALAC directory contains code written and released by Apple Inc and +released under the Apache license. + LINUX ----- diff --git a/libs/libsndfile/README.md b/libs/libsndfile/README.md new file mode 100644 index 0000000000..a7fdaea71f --- /dev/null +++ b/libs/libsndfile/README.md @@ -0,0 +1,79 @@ +# libsndfile + +libsndfile is a C library for reading and writing files containing sampled audio +data. + +## Hacking + +The canonical source code repository for libsndfile is at +[https://github.com/erikd/libsndfile/][github]. + +You can grab the source code using: + + $ git clone git://github.com/erikd/libsndfile.git + +Building on Linux, OSX and Windows (Using GNU GCC) will require a number of GNU +and other Free and Open Source Software tools including: + +* [Autoconf][autoconf] +* [Autogen][autogen] +* [Automake][automake] +* [Libtool][libtool] +* [Pkgconfig][pkgconfig] +* [Python][python] + +If you are on Linux, its probably best to install these via your Linux +distribution's package manager. + +If you want to compile libsndfile with support for formats like FLAC and +Ogg/Vorbis you will also need to install the following optional libraries: + +* [FLAC][flac] +* [libogg][libogg] +* [libvorbis][libvorbis] + +Support for these extra libraries is an all or nothing affair. Unless all of +them are installed none of them will be supported. + + $ ./autogen.sh + +Running `autogen.sh` also installs a git pre-commit hook. The pre-commit hook +is run each time a user tries to commit and checks code about to be committed +against coding guidelines. + +Nest step is to run configure, with the following configure options being +recommended for anyone contemplating sending libsndfile patches: + + $ ./configure --enable-gcc-werror + +Finally libsndfile can be built and tested: + + $ make + $ make check + +## Submitting Patches. + +* Patches should pass all pre-commit hook tests. +* Patches should always be submitted via a either Github "pull request" or a + via emailed patches created using "git format-patch". +* Patches for new features should include tests and documentation. +* Patches to fix bugs should either pass all tests, or modify the tests in some + sane way. +* When a new feature is added for a particular file format and that feature + makes sense for other formats, then it should also be implemented for one + or two of the other formats. + + + + + +[autoconf]: http://www.gnu.org/s/autoconf/ +[autogen]: http://www.gnu.org/s/autogen/ +[automake]: http://www.gnu.org/software/automake/ +[flac]: http://flac.sourceforge.net/ +[github]: https://github.com/erikd/libsndfile/ +[libogg]: http://xiph.org/ogg/ +[libtool]: http://www.gnu.org/software/libtool/ +[libvorbis]: http://www.vorbis.com/ +[pkgconfig]: http://www.freedesktop.org/wiki/Software/pkg-config +[python]: http://www.python.org/ diff --git a/libs/libsndfile/Scripts/android-configure.sh b/libs/libsndfile/Scripts/android-configure.sh new file mode 100644 index 0000000000..c981d4927a --- /dev/null +++ b/libs/libsndfile/Scripts/android-configure.sh @@ -0,0 +1,92 @@ +#!/bin/bash -e + +# Copyright (C) 2013 Erik de Castro Lopo +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Neither the author nor the names of any contributors may be used +# to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Android NDK version number; eg r8e, r9 etc +ANDROID_NDK_VER=r9 + +# Android NDK gcc version; eg 4.7, 4.9 etc. +ANDROID_GCC_VER=4.8 + +# Android API version; eg 9 (Android 2.3), 14 (Android 4.0) etc. +ANDROID_API_VER=9 + +#------------------------------------------------------------------------------- +# No more user config beyond here. + +BUILD_MACHINE=$(uname -s | tr 'A-Z' 'a-z')-$(uname -m) + +function die_with { + echo $1 + exit 1 +} + +export CROSS_COMPILE=arm-linux-androideabi + +# I put all my dev stuff in here +export DEV_PREFIX=$HOME/Android +test -d ${DEV_PREFIX} || die_with "Error : DEV_PREFIX '$DEV_PREFIX' does not exist." + +# Don't forget to adjust this to your NDK path +export ANDROID_NDK=${DEV_PREFIX}/android-ndk-${ANDROID_NDK_VER} +test -d ${ANDROID_NDK} || die_with "Error : ANDROID_NDK '$ANDROID_NDK' does not exist." + +export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VER}/prebuilt/${BUILD_MACHINE} +test -d ${ANDROID_PREFIX} || die_with "Error : ANDROID_PREFIX '$ANDROID_PREFIX' does not exist." + +export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API_VER}/arch-arm +test -d ${SYSROOT} || die_with "Error : SYSROOT '$SYSROOT' does not exist." + +export CROSS_PREFIX=${ANDROID_PREFIX}/bin/${CROSS_COMPILE} +test -f ${CROSS_PREFIX}-gcc || die_with "Error : CROSS_PREFIX compiler '${CROSS_PREFIX}-gcc' does not exist." + + +# Non-exhaustive lists of compiler + binutils +# Depending on what you compile, you might need more binutils than that +export CPP=${CROSS_PREFIX}-cpp +export AR=${CROSS_PREFIX}-ar +export AS=${CROSS_PREFIX}-as +export NM=${CROSS_PREFIX}-nm +export CC=${CROSS_PREFIX}-gcc +export CXX=${CROSS_PREFIX}-g++ +export LD=${CROSS_PREFIX}-ld +export RANLIB=${CROSS_PREFIX}-ranlib + +# Don't mix up .pc files from your host and build target +export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig + +# Set up the needed FLAGS. +export CFLAGS="${CFLAGS} -gstabs --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include" +export CXXFLAGS="${CXXFLAGS} -gstabs -fno-exceptions --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/include/ -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/libs/armeabi/include" + +export CPPFLAGS="${CFLAGS}" +export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib" + +# Create a symlink to the gdbclient. +test -h gdbclient || ln -s ${ANDROID_PREFIX}/bin/arm-linux-androideabi-gdb gdbclient + +./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} "$@" diff --git a/libs/libsndfile/Scripts/build-test-tarball.mk.in b/libs/libsndfile/Scripts/build-test-tarball.mk.in new file mode 100644 index 0000000000..931edb6464 --- /dev/null +++ b/libs/libsndfile/Scripts/build-test-tarball.mk.in @@ -0,0 +1,61 @@ +#!/usr/bin/make -f + +# This is probably only going to work with GNU Make. +# This in a separate file instead of in Makefile.am because Automake complains +# about the GNU Make-isms. + +EXEEXT = @EXEEXT@ + +PACKAGE_VERSION = @PACKAGE_VERSION@ + +HOST_TRIPLET = @HOST_TRIPLET@ + +SRC_BINDIR = @SRC_BINDIR@ +TEST_BINDIR = @TEST_BINDIR@ + +LIBRARY := $(SRC_BINDIR)libsndfile.so.$(LIB_VERSION) + +LIB_VERSION := $(shell echo $(PACKAGE_VERSION) | sed -e 's/[a-z].*//') + +TESTNAME = libsndfile-testsuite-$(HOST_TRIPLET)-$(PACKAGE_VERSION) + +TARBALL = $(TESTNAME).tar.gz + +# Find the test programs by grepping the script for the programs it executes. +testprogs := $(shell grep '^\./' tests/test_wrapper.sh | sed -e "s|./||" -e "s/ .*//" | sort | uniq) +# Also add the programs not found by the above. +testprogs += sfversion@EXEEXT@ stdin_test@EXEEXT@ stdout_test@EXEEXT@ cpp_test@EXEEXT@ win32_test@EXEEXT@ + +# Find the single test program in src/ . +srcprogs := $(shell if test -x src/.libs/test_main$(EXEEXT) ; then echo "src/.libs/test_main$(EXEEXT)" ; else echo "src/test_main$(EXEEXT)" ; fi) + +libfiles := $(shell if test ! -z $(EXEEXT) ; then echo "src/libsndfile-1.def src/.libs/libsndfile-1.dll" ; elif test -f $(LIBRARY) ; then echo $(LIBRARY) ; fi ; fi) + +testbins := $(addprefix $(TEST_BINDIR),$(subst @EXEEXT@,$(EXEEXT),$(testprogs))) $(libfiles) $(srcprogs) + + +all : $(TARBALL) + +clean : + rm -rf $(TARBALL) $(TESTNAME)/ + +check : $(TESTNAME)/test_wrapper.sh + (cd ./$(TESTNAME)/ && ./test_wrapper.sh) + +$(TARBALL) : $(TESTNAME)/test_wrapper.sh + tar zcf $@ $(TESTNAME) + rm -rf $(TESTNAME) + @echo + @echo "Created : $(TARBALL)" + @echo + +$(TESTNAME)/test_wrapper.sh : $(testbins) tests/test_wrapper.sh tests/pedantic-header-test.sh + rm -rf $(TESTNAME) + mkdir -p $(TESTNAME)/tests/ + cp $(testbins) $(TESTNAME)/tests/ + cp tests/test_wrapper.sh $(TESTNAME)/ + cp tests/pedantic-header-test.sh $(TESTNAME)/tests/ + chmod u+x $@ + +tests/test_wrapper.sh : tests/test_wrapper.sh.in + (cd tests/ ; make $@) diff --git a/libs/libsndfile/Scripts/clang-sanitize.sh b/libs/libsndfile/Scripts/clang-sanitize.sh new file mode 100644 index 0000000000..2898883c21 --- /dev/null +++ b/libs/libsndfile/Scripts/clang-sanitize.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This is known to work with clang-3.4 from Debian testing/unstable. +# 2013/07/14 + +export CC=clang +export CXX=clang++ +export CFLAGS="-O3 -fsanitize=address,integer,undefined" +export CXXFLAGS="-O3 -fsanitize=address,integer,undefined" + +./configure --enable-gcc-werror + +make clean all check diff --git a/libs/libsndfile/Scripts/cstyle.py b/libs/libsndfile/Scripts/cstyle.py new file mode 100644 index 0000000000..94a969c6e2 --- /dev/null +++ b/libs/libsndfile/Scripts/cstyle.py @@ -0,0 +1,246 @@ +#!/usr/bin/python -tt +# +# Copyright (C) 2005-2012 Erik de Castro Lopo +# +# Released under the 2 clause BSD license. + +""" +This program checks C code for compliance to coding standards used in +libsndfile and other projects I run. +""" + +import re +import sys + + +class Preprocessor: + """ + Preprocess lines of C code to make it easier for the CStyleChecker class to + test for correctness. Preprocessing works on a single line at a time but + maintains state between consecutive lines so it can preprocessess multi-line + comments. + Preprocessing involves: + - Strip C++ style comments from a line. + - Strip C comments from a series of lines. When a C comment starts and + ends on the same line it will be replaced with 'comment'. + - Replace arbitrary C strings with the zero length string. + - Replace '#define f(x)' with '#define f (c)' (The C #define requires that + there be no space between defined macro name and the open paren of the + argument list). + Used by the CStyleChecker class. + """ + def __init__ (self): + self.comment_nest = 0 + self.leading_space_re = re.compile ('^(\t+| )') + self.trailing_space_re = re.compile ('(\t+| )$') + self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(") + + def comment_nesting (self): + """ + Return the currect comment nesting. At the start and end of the file, + this value should be zero. Inside C comments it should be 1 or + (possibly) more. + """ + return self.comment_nest + + def __call__ (self, line): + """ + Strip the provided line of C and C++ comments. Stripping of multi-line + C comments works as expected. + """ + + line = self.define_hack_re.sub (r'\1 (', line) + + line = self.process_strings (line) + + # Strip C++ style comments. + if self.comment_nest == 0: + line = re.sub ("( |\t*)//.*", '', line) + + # Strip C style comments. + open_comment = line.find ('/*') + close_comment = line.find ('*/') + + if self.comment_nest > 0 and close_comment < 0: + # Inside a comment block that does not close on this line. + return "" + + if open_comment >= 0 and close_comment < 0: + # A comment begins on this line but doesn't close on this line. + self.comment_nest += 1 + return self.trailing_space_re.sub ('', line [:open_comment]) + + if open_comment < 0 and close_comment >= 0: + # Currently open comment ends on this line. + self.comment_nest -= 1 + return self.trailing_space_re.sub ('', line [close_comment + 2:]) + + if open_comment >= 0 and close_comment > 0 and self.comment_nest == 0: + # Comment begins and ends on this line. Replace it with 'comment' + # so we don't need to check whitespace before and after the comment + # we're removing. + newline = line [:open_comment] + "comment" + line [close_comment + 2:] + return self.__call__ (newline) + + return line + + def process_strings (self, line): + """ + Given a line of C code, return a string where all literal C strings have + been replaced with the empty string literal "". + """ + for k in range (0, len (line)): + if line [k] == '"': + start = k + for k in range (start + 1, len (line)): + if line [k] == '"' and line [k - 1] != '\\': + return line [:start + 1] + '"' + self.process_strings (line [k + 1:]) + return line + + +class CStyleChecker: + """ + A class for checking the whitespace and layout of a C code. + """ + def __init__ (self, debug): + self.debug = debug + self.filename = None + self.error_count = 0 + self.line_num = 1 + self.orig_line = '' + self.trailing_newline_re = re.compile ('[\r\n]+$') + self.indent_re = re.compile ("^\s*") + self.last_line_indent = "" + self.last_line_indent_curly = False + self.re_checks = \ + [ ( re.compile (" "), "multiple space instead of tab" ) + , ( re.compile ("\t "), "space after tab" ) + , ( re.compile ("[^ ];"), "missing space before semi-colon" ) + , ( re.compile ("{[^\s}]"), "missing space after open brace" ) + , ( re.compile ("[^{\s]}"), "missing space before close brace" ) + , ( re.compile ("[ \t]+$"), "contains trailing whitespace" ) + + , ( re.compile (",[^\s\n]"), "missing space after comma" ) + , ( re.compile (";[a-zA-Z0-9]"), "missing space after semi-colon" ) + , ( re.compile ("=[^\s\"'=]"), "missing space after assignment" ) + + # Open and close parenthesis. + , ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" ) + , ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" ) + , ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" ) + , ( re.compile ("\( [^;]"), "space after open parenthesis" ) + , ( re.compile ("[^;] \)"), "space before close parenthesis" ) + + # Open and close square brace. + , ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" ) + , ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" ) + , ( re.compile ("\[ "), "space after open square brace" ) + , ( re.compile (" \]"), "space before close square brace" ) + + # Space around operators. + , ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" ) + , ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" ) + + # Parens around single argument to return. + , ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" ) + ] + + def get_error_count (self): + """ + Return the current error count for this CStyleChecker object. + """ + return self.error_count + + def check_files (self, files): + """ + Run the style checker on all the specified files. + """ + for filename in files: + self.check_file (filename) + + def check_file (self, filename): + """ + Run the style checker on the specified file. + """ + self.filename = filename + cfile = open (filename, "r") + + self.line_num = 1 + + preprocess = Preprocessor () + while 1: + line = cfile.readline () + if not line: + break + + line = self.trailing_newline_re.sub ('', line) + self.orig_line = line + + self.line_checks (preprocess (line)) + + self.line_num += 1 + + cfile.close () + self.filename = None + + # Check for errors finding comments. + if preprocess.comment_nesting () != 0: + print ("Weird, comments nested incorrectly.") + sys.exit (1) + + return + + def line_checks (self, line): + """ + Run the style checker on provided line of text, but within the context + of how the line fits within the file. + """ + + indent = len (self.indent_re.search (line).group ()) + if re.search ("^\s+}", line): + if not self.last_line_indent_curly and indent != self.last_line_indent: + None # self.error ("bad indent on close curly brace") + self.last_line_indent_curly = True + else: + self.last_line_indent_curly = False + + # Now all the regex checks. + for (check_re, msg) in self.re_checks: + if check_re.search (line): + self.error (msg) + + if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line): + if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line): + self.error ("missing space around operator") + + self.last_line_indent = indent + return + + def error (self, msg): + """ + Print an error message and increment the error count. + """ + print ("%s (%d) : %s" % (self.filename, self.line_num, msg)) + if self.debug: + print ("'" + self.orig_line + "'") + self.error_count += 1 + +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +if len (sys.argv) < 1: + print ("Usage : yada yada") + sys.exit (1) + +# Create a new CStyleChecker object +if sys.argv [1] == '-d' or sys.argv [1] == '--debug': + cstyle = CStyleChecker (True) + cstyle.check_files (sys.argv [2:]) +else: + cstyle = CStyleChecker (False) + cstyle.check_files (sys.argv [1:]) + + +if cstyle.get_error_count (): + sys.exit (1) + +sys.exit (0) diff --git a/libs/libsndfile/Scripts/git-pre-commit-hook b/libs/libsndfile/Scripts/git-pre-commit-hook new file mode 100644 index 0000000000..6df1308ac3 --- /dev/null +++ b/libs/libsndfile/Scripts/git-pre-commit-hook @@ -0,0 +1,79 @@ +#!/bin/sh +# + +if git rev-parse --verify HEAD >/dev/null 2>&1 ; then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 + fi + +files=$(git diff-index --name-status --cached HEAD | grep -v ^D | sed -r "s/^[A-Z]+[A-Z0-9]*[ \t]+/ /") + +# Redirect output to stderr. +exec 1>&2 + +#------------------------------------------------------------------------------- +# Check the copyright notice of all files to be commited. + +user=`git config --global user.email` +year=`date +"%Y"` + +missing_copyright_year="" +if test $user = "erikd@mega-nerd.com" ; then + for f in $files ; do + if test `head -5 $f | grep -c -i copyright` -gt 0 ; then + user_copyright=`grep -i copyright $f | grep $user | grep -c $year` + if test $user_copyright -lt 1 ; then + missing_copyright_year="$missing_copyright_year $f" + fi + fi + done + fi + +if test -n "$missing_copyright_year" ; then + echo "Missing current year in the copyright notice of the following files:" + for f in $missing_copyright_year ; do + echo " $f" + done + echo "Commit aborted." + exit 1 + fi + +#------------------------------------------------------------------------------- +# Check the formatting of all C files. + +cfiles="" +for f in $files ; do + if test `dirname $f` = "src/ALAC" ; then + echo "Skipping cstyle checking on $f" + elif test `echo $f | grep -c "\.[ch]$"` -gt 0 ; then + cfiles="$cfiles $f" + fi + done + +if test -n "$cfiles" ; then + Scripts/cstyle.py $cfiles + if test $? -ne 0 ; then + echo + echo "Commit aborted. Fix the above error before trying again." + exit 1 + fi + fi + +#------------------------------------------------------------------------------- +# Prevent files with non-ascii filenames from being committed. + +if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then + echo "Error: Attempt to add a non-ascii file name." + echo + echo "This can cause problems if you want to work" + echo "with people on other platforms." + echo + echo "To be portable it is advisable to rename the file ..." + echo + echo "Commit aborted." + exit 1 + fi + +exit 0 diff --git a/libs/libsndfile/Scripts/linux-to-win-cross-configure.sh b/libs/libsndfile/Scripts/linux-to-win-cross-configure.sh new file mode 100644 index 0000000000..c1fdc072b3 --- /dev/null +++ b/libs/libsndfile/Scripts/linux-to-win-cross-configure.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +case "$1" in + w32) + compiler_name=i686-w64-mingw32 + ;; + w64) + compiler_name=x86_64-w64-mingw32 + ;; + *) + echo "$0 (w32|w64) " + exit 0 + ;; + esac + +shift + +build_cpu=$(dpkg-architecture -qDEB_BUILD_GNU_CPU) +build_host=$build_cpu-linux + +./configure --host=$compiler_name --target=$compiler_name --build=$build_host \ + --program-prefix='' --disable-sqlite --disable-static $@ diff --git a/libs/libsndfile/acinclude.m4 b/libs/libsndfile/acinclude.m4 index 2f27dbd9ef..c411cebbda 100644 --- a/libs/libsndfile/acinclude.m4 +++ b/libs/libsndfile/acinclude.m4 @@ -5,11 +5,21 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html dnl Written by Paul Eggert . - m4_include([M4/gcc_version.m4]) m4_include([M4/octave.m4]) m4_include([M4/mkoctfile_version.m4]) - +m4_include([M4/extra_pkg.m4]) +m4_include([M4/lrint.m4]) +m4_include([M4/lrintf.m4]) +m4_include([M4/clang.m4]) +m4_include([M4/really_gcc.m4]) +m4_include([M4/stack_protect.m4]) +m4_include([M4/clip_mode.m4]) +m4_include([M4/add_cflags.m4]) +m4_include([M4/add_cxxflags.m4]) +m4_include([M4/flexible_array.m4]) +m4_include([M4/endian.m4]) +m4_include([M4/extra_largefile.m4]) dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE. dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME) diff --git a/libs/libsndfile/autogen.sh b/libs/libsndfile/autogen.sh new file mode 100644 index 0000000000..5047159fe4 --- /dev/null +++ b/libs/libsndfile/autogen.sh @@ -0,0 +1,179 @@ +#!/bin/sh +# Run this to set up the build system: configure, makefiles, etc. +# (based on the version in enlightenment's cvs) + +package="libsndfile" + +ACLOCAL_FLAGS="-I M4" + +olddir=`pwd` +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +cd "$srcdir" +DIE=0 + +printf "checking for autogen ... " +result="yes" +(autogen --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have GNU autogen installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + result="no" + DIE=1 +} +echo $result + +printf "checking for autoconf ... " +result="yes" +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + result="no" + DIE=1 +} +echo $result + +VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/" +VERSIONMKMAJ="sed -e s/\([0-9][0-9]*\)[^0-9].*/\\1/" +VERSIONMKMIN="sed -e s/.*[0-9][0-9]*\.//" + +# do we need automake? +if test -r Makefile.am; then + AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am` + AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP` + if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then + AM_NEEDED="" + fi + if test -z $AM_NEEDED; then + printf "checking for automake ... " + AUTOMAKE=automake + ACLOCAL=aclocal + if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then + echo "yes" + else + echo "no" + AUTOMAKE= + fi + else + printf "checking for automake $AM_NEEDED or later ... " + majneeded=`echo $AM_NEEDED | $VERSIONMKMAJ` + minneeded=`echo $AM_NEEDED | $VERSIONMKMIN` + for am in automake-$AM_NEEDED automake$AM_NEEDED \ + automake automake-1.7 automake-1.8 automake-1.9 automake-1.10; do + ($am --version < /dev/null > /dev/null 2>&1) || continue + ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP` + maj=`echo $ver | $VERSIONMKMAJ` + min=`echo $ver | $VERSIONMKMIN` + if test $maj -eq $majneeded -a $min -ge $minneeded; then + AUTOMAKE=$am + echo $AUTOMAKE + break + fi + done + test -z $AUTOMAKE && echo "no" + printf "checking for aclocal $AM_NEEDED or later ... " + for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED \ + aclocal aclocal-1.7 aclocal-1.8 aclocal-1.9 aclocal-1.10; do + ($ac --version < /dev/null > /dev/null 2>&1) || continue + ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP` + maj=`echo $ver | $VERSIONMKMAJ` + min=`echo $ver | $VERSIONMKMIN` + if test $maj -eq $majneeded -a $min -ge $minneeded; then + ACLOCAL=$ac + echo $ACLOCAL + break + fi + done + test -z $ACLOCAL && echo "no" + fi + test -z $AUTOMAKE || test -z $ACLOCAL && { + echo + echo "You must have automake installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + exit 1 + } +fi + +printf "checking for libtool ... " +for LIBTOOLIZE in libtoolize glibtoolize nope; do + ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break +done +if test x$LIBTOOLIZE = xnope; then + echo "nope." + LIBTOOLIZE=libtoolize +else + echo $LIBTOOLIZE +fi +($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have libtool installed to compile $package." + echo "Download the appropriate package for your system," + echo "or get the source from one of the GNU ftp sites" + echo "listed in http://www.gnu.org/order/ftp.html" + DIE=1 +} + +printf "checking for pkg-config ... " +result="yes" +(pkg-config --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have pkg-config installed to compile $package." + echo "Download the appropriate package for your distribution." + result="no" + DIE=1 +} +echo $result + + +printf "checking for python ... " +result="yes" +(python --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have Python installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at http://python.org/" + result="no" + DIE=1 +} +echo $result + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test ! -d Cfg ; then + echo "Creating 'Cfg' directory." + mkdir Cfg +fi + +echo "Generating configuration files for $package, please wait ... " + +echo " $ACLOCAL $ACLOCAL_FLAGS" +$ACLOCAL $ACLOCAL_FLAGS || exit 1 +echo " $LIBTOOLIZE --automake --force" +$LIBTOOLIZE --automake --force || exit 1 +echo " autoheader" +autoheader || exit 1 +echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS" +$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1 +echo " autoconf" +autoconf || exit 1 + +cd $olddir + +fprecommit=.git/hooks/pre-commit +if test ! -f $fprecommit ; then + echo + echo "Installing git pre-commit hook for this project." + cat > $fprecommit << 'foobar' +#!/bin/sh +exec Scripts/git-pre-commit-hook +foobar + chmod u+x $fprecommit + echo + fi diff --git a/libs/libsndfile/binheader_readf_check.py b/libs/libsndfile/binheader_readf_check.py new file mode 100644 index 0000000000..774abcd988 --- /dev/null +++ b/libs/libsndfile/binheader_readf_check.py @@ -0,0 +1,62 @@ +g#!/usr/bin/python + +import re, string, sys + +def trim_function_and_params (section): + k = string.find (section, "(") + 1 + brackets = 1 + section_len = len (section) + while k < section_len: + if section [k] == '(': + brackets += 1 + elif section [k] == ')': + brackets -= 1 + if brackets < 1: + return section [:k+1] + k += 1 + print "Whoops!!!!" + sys.exit (1) + +def get_function_calls (filedata): + filedata = string.split (filedata, "psf_binheader_readf") + filedata = filedata [1:] + + func_calls = [] + for section in filedata: + section = "psf_binheader_readf" + section + func_calls.append (trim_function_and_params (section)) + + return func_calls + +def search_for_problems (filename): + filedata = open (filename, "r").read () + + if len (filedata) < 1: + print "Error : file '%s' contains no data." % filename + sys.exit (1) + + count = 0 + + calls = get_function_calls (filedata) + for call in calls: + if string.find (call, "sizeof") > 0: + print "Found : ", call + count += 1 + + if count == 0: + print "%-20s : No problems found." % filename + else: + print "\n%-20s : Found %d errors." % (filename, count) + sys.exit (1) + return + + +#------------------------------------------------------------------------------- + +if len (sys.argv) < 2: + print "Usage : %s " % sys.argv [0] + sys.exit (1) + +for file in sys.argv [1:]: + search_for_problems (file) + diff --git a/libs/libsndfile/configure.ac b/libs/libsndfile/configure.ac index 4bdbfd0969..4d0e143fb4 100644 --- a/libs/libsndfile/configure.ac +++ b/libs/libsndfile/configure.ac @@ -1,30 +1,49 @@ -# Copyright (C) 1999-2008 Erik de Castro Lopo (erikd AT mega-nerd DOT com). +# Copyright (C) 1999-2013 Erik de Castro Lopo . dnl Require autoconf version AC_PREREQ(2.57) -AC_INIT([libsndfile],[1.0.19],[erikd@mega-nerd.com]) +AC_INIT([libsndfile],[1.0.26pre5],[sndfile@mega-nerd.com], + [libsndfile],[http://www.mega-nerd.com/libsndfile/]) # Put config stuff in Cfg. AC_CONFIG_AUX_DIR(Cfg) -CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" -CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" - AC_CONFIG_SRCDIR([src/sndfile.c]) AC_CANONICAL_TARGET([]) -AM_INIT_AUTOMAKE AC_CONFIG_MACRO_DIR([M4]) - AC_CONFIG_HEADERS([src/config.h]) -dnl Add parameters for aclocal +AM_INIT_AUTOMAKE AC_SUBST(ACLOCAL_AMFLAGS, "-I M4") +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_LANG([C]) +AC_PROG_CC_STDC +AC_USE_SYSTEM_EXTENSIONS +AM_PROG_CC_C_O +AC_PROG_CXX + +MN_C_COMPILER_IS_CLANG +MN_GCC_REALLY_IS_GCC + +AC_PROG_SED + +# Do not check for F77. +define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl + +AM_PROG_LIBTOOL +LT_PROG_RC + +AC_PROG_INSTALL +AC_PROG_LN_S + +AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no) +AC_CHECK_PROG(HAVE_WINE, wine, yes, no) +AC_CHECK_PROG(HAVE_XCODE_SELECT, xcode-select, yes, no) + #------------------------------------------------------------------------------------ # Rules for library version information: # @@ -41,22 +60,12 @@ AC_LANG([C]) # 6. If any interfaces have been removed since the last public release, then set age # to 0. -SHARED_VERSION_INFO="1:19:0" +CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"` +VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"` -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_CXX +SHARED_VERSION_INFO="1:$VERSION_MINOR:0" -# Do not check for F77. -define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl - -AM_PROG_LIBTOOL - -AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no) -AC_CHECK_PROG(HAVE_WINE, wine, yes, no) - -AC_PROG_INSTALL -AC_PROG_LN_S +#------------------------------------------------------------------------------------ AC_HEADER_STDC @@ -77,19 +86,6 @@ else AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST], [test "$build_os:$target_os:$host_os:$HAVE_WINE" = "linux-gnu:mingw32msvc:mingw32msvc:yes"]) -#==================================================================================== -# Check for support of the struct hack. - -AC_C99_FLEXIBLE_ARRAY - -if test x$ac_cv_c99_flexible_array = xyes ; then - AC_DEFINE([HAVE_FLEXIBLE_ARRAY],1, [Set to 1 if the compile supports the struct hack.]) -else - AC_MSG_WARN([[*** This compiler does not support the 1999 ISO C Standard ***]]) - AC_MSG_WARN([[*** feature known as the flexible array struct member. ***]]) - AC_DEFINE([HAVE_FLEXIBLE_ARRAY],0) - fi - #==================================================================================== # Couple of initializations here. Fill in real values later. @@ -107,8 +103,11 @@ if test x$enable_experimental = xyes ; then fi AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE],${EXPERIMENTAL_CODE}, [Set to 1 to enable experimental code.]) -AC_ARG_ENABLE(gcc-werror, - AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles])) +AC_ARG_ENABLE(werror, + AC_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])) + +AC_ARG_ENABLE(stack-smash-protection, + AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection])) AC_ARG_ENABLE(gcc-pipe, AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option])) @@ -129,7 +128,7 @@ AC_ARG_ENABLE(alsa, AC_HELP_STRING([--disable-alsa], [disable use of ALSA])) AC_ARG_ENABLE(external-libs, - AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis])) + AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])) AC_ARG_ENABLE(octave, AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module])) @@ -141,6 +140,7 @@ AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes]) #==================================================================================== # Check types and their sizes. +AC_CHECK_SIZEOF(wchar_t,4) AC_CHECK_SIZEOF(short,2) AC_CHECK_SIZEOF(int,4) AC_CHECK_SIZEOF(long,4) @@ -157,43 +157,48 @@ AC_CHECK_SIZEOF(long long,8) # Unfortunately there is more than one way of ensuring this so need to do some # pretty rigourous testing here. -unset ac_cv_sizeof_off_t +# Check for common 64 bit file offset types. +AC_CHECK_SIZEOF(off_t,1) +AC_CHECK_SIZEOF(loff_t,1) +AC_CHECK_SIZEOF(off64_t,1) + +if test "$enable_largefile:$ac_cv_sizeof_off_t" = "no:8" ; then + echo + echo "Error : Cannot disable large file support because sizeof (off_t) == 8." + echo + exit 1 + fi -AC_CHECK_SIZEOF(off_t,1) # Fake default value. case "$host_os" in - mingw*) + mingw32msvc | mingw32) TYPEOF_SF_COUNT_T="__int64" SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" SIZEOF_SF_COUNT_T=8 + AC_DEFINE([__USE_MINGW_ANSI_STDIO],1,[Set to 1 to use C99 printf/snprintf in MinGW.]) ;; *) + SIZEOF_SF_COUNT_T=0 if test "x$ac_cv_sizeof_off_t" = "x8" ; then # If sizeof (off_t) is 8, no further checking is needed. - TYPEOF_SF_COUNT_T="off_t" + TYPEOF_SF_COUNT_T="int64_t" + SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" + SIZEOF_SF_COUNT_T=8 + elif test "x$ac_cv_sizeof_loff_t" = "x8" ; then + TYPEOF_SF_COUNT_T="int64_t" + SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" + SIZEOF_SF_COUNT_T=8 + elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then + TYPEOF_SF_COUNT_T="int64_t" SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" SIZEOF_SF_COUNT_T=8 else - # Check for common 64 bit file offset types. - AC_CHECK_SIZEOF(loff_t,1) # Fake default value. - AC_CHECK_SIZEOF(off64_t,1) # Fake default value. - - TYPEOF_SF_COUNT_T="unknown" - if test "x$ac_cv_sizeof_loff_t" = "x8" ; then - TYPEOF_SF_COUNT_T="loff_t" - SIZEOF_SF_COUNT_T=8 - elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then - TYPEOF_SF_COUNT_T="off64_t" - SIZEOF_SF_COUNT_T=8 - fi - # Save the old sizeof (off_t) value and then unset it to see if it # changes when Large File Support is enabled. - pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t unset ac_cv_sizeof_off_t - AC_SYS_EXTRA_LARGEFILE + AC_SYS_LARGEFILE if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then ac_cv_sys_largefile_CFLAGS="" @@ -205,14 +210,11 @@ case "$host_os" in ac_cv_sys_largefile_LIBS="" fi - AC_CHECK_SIZEOF(off_t,1) # Fake default value. + AC_CHECK_SIZEOF(off_t,1) if test "x$ac_cv_sizeof_off_t" = "x8" ; then + TYPEOF_SF_COUNT_T="int64_t" SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" - elif test "x$ac_cv_sizeof_off_t" = "x$pre_largefile_sizeof_off_t" ; then - AC_MSG_WARN([[This machine does not seem to support 64 bit file offsets.]]) - TYPEOF_SF_COUNT_T="off_t" - SIZEOF_SF_COUNT_T=$ac_cv_sizeof_off_t elif test "x$TYPEOF_SF_COUNT_T" = "xunknown" ; then echo echo "*** The configure process has determined that this system is capable" @@ -245,7 +247,7 @@ AC_CHECK_SIZEOF(ssize_t,4) #==================================================================================== # Determine endian-ness of target processor. -AC_C_FIND_ENDIAN +MN_C_FIND_ENDIAN AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian}, [Target processor is big endian.]) @@ -258,18 +260,19 @@ AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian}, # Check for functions. AC_CHECK_FUNCS(malloc calloc realloc free) -AC_CHECK_FUNCS(open read write lseek pread pwrite) -AC_CHECK_FUNCS(fstat ftruncate fsync) +AC_CHECK_FUNCS(open read write lseek lseek64) +AC_CHECK_FUNCS(fstat fstat64 ftruncate fsync) AC_CHECK_FUNCS(snprintf vsnprintf) AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r gettimeofday) AC_CHECK_FUNCS(mmap getpagesize) AC_CHECK_FUNCS(setlocale) +AC_CHECK_FUNCS(pipe waitpid) AC_CHECK_LIB([m],floor) -AC_CHECK_FUNCS(floor ceil fmod) +AC_CHECK_FUNCS(floor ceil fmod lround) -AC_C99_FUNC_LRINT -AC_C99_FUNC_LRINTF +MN_C99_FUNC_LRINT +MN_C99_FUNC_LRINTF #==================================================================================== # Check for requirements for building plugins for other languages/enviroments. @@ -293,46 +296,62 @@ EXTERNAL_CFLAGS="" EXTERNAL_LIBS="" # Check for pkg-config outside the if statement. -PKG_PROG_PKG_CONFIG +#PKG_PROG_PKG_CONFIG +#m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig)) -#if test x$enable_external_libs = xno ; then - AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]]) -#else -# PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.2.1, ac_cv_flac=yes, ac_cv_flac=no) -# PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.1.3, ac_cv_ogg=yes, ac_cv_ogg=no) +#if test -n "$PKG_CONFIG" ; then +# if test x$enable_external_libs = xno ; then +# AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]]) +# else +# PKG_CHECK_MOD_VERSION([FLAC], [flac >= 1.2.1], [ac_cv_flac=yes], [ac_cv_flac=no]) - # Vorbis versions earlier than 1.2.1 are not const correct at the API level. - # Vorbis 1.2.2 adds vorbis_version_string. -# PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.0, ac_cv_vorbis=yes, ac_cv_vorbis=no) -# PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.0, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no) + # Make sure the FLAC_CFLAGS value is sane. +# FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s|include/FLAC|include|"` + +# PKG_CHECK_MOD_VERSION([OGG], [ogg >= 1.1.3], [ac_cv_ogg=yes], [ac_cv_ogg=no]) + +# if test x$enable_experimental = xyes ; then +# PKG_CHECK_MOD_VERSION([SPEEX], [speex >= 1.2], [ac_cv_speex=yes], [ac_cv_speex=no]) +# else +# SPEEX_CFLAGS="" +# SPEEX_LIBS="" +# fi + + # Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile + # test suite to fail on MIPS, PowerPC and others. + # See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899 +# PKG_CHECK_MOD_VERSION([VORBIS], [vorbis >= 1.2.3], [ac_cv_vorbis=yes], [ac_cv_vorbis=no]) +# PKG_CHECK_MOD_VERSION([VORBISENC], [vorbisenc >= 1.2.3], [ac_cv_vorbisenc=yes], [ac_cv_vorbisenc=no]) +# enable_external_libs=yes +# fi + +# if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then +# HAVE_EXTERNAL_LIBS=1 +# enable_external_libs=yes + +# EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS" +# EXTERNAL_LIBS="$FLAC_LIBS $OGG_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS " +# else +# echo +# AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg and]]) +# AC_MSG_WARN([[*** libvorbis) is either missing (possibly only the development]]) +# AC_MSG_WARN([[*** headers) or is of an unsupported version.]]) +# AC_MSG_WARN([[***]]) +# AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]]) +# AC_MSG_WARN([[*** are an all or nothing affair.]]) +# echo +# enable_external_libs=no +# fi # fi -HAVE_VORBIS_VERSION_STRING=0 -if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then - - save_LIBS="$LIBS" - LIBS="$VORBIS_LIBS $LIBS" - AC_CHECK_LIB(vorbis, vorbis_version_string, HAVE_VORBIS_VERSION_STRING=1) - LIBS="$save_LIBS" - - HAVE_EXTERNAL_LIBS=1 - enable_external_libs=yes - - EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBISENC_CFLAGS" - EXTERNAL_LIBS="$FLAC_LIBS $VORBISENC_LIBS" -else - enable_external_libs=no - fi - AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_LIBS], $HAVE_EXTERNAL_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.]) -AC_DEFINE_UNQUOTED([HAVE_VORBIS_VERSION_STRING], $HAVE_VORBIS_VERSION_STRING, [Set to 1 if we have vorbis_version_string.]) #==================================================================================== # Check for libsqlite3 (only used in regtest). ac_cv_sqlite3=no #if test x$enable_sqlite != xno ; then -# PKG_CHECK_MOD_VERSION(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no) +# PKG_CHECK_MOD_VERSION([SQLITE3], [sqlite3 >= 3.2], [ac_cv_sqlite3=yes], [ac_cv_sqlite3=no]) # fi if test x$ac_cv_sqlite3 = "xyes" ; then @@ -343,24 +362,11 @@ else AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.]) -#==================================================================================== -# Check for JACK (only used for examples/sndfile-jackplay). - -#PKG_CHECK_MOD_VERSION(JACK, jack >= 0.100, ac_cv_jack=yes, ac_cv_jack=no) - -if test x$ac_cv_jack = "xyes" ; then - HAVE_JACK=1 -else - HAVE_JACK=0 - fi - -AC_DEFINE_UNQUOTED([HAVE_JACK],$HAVE_JACK,[Set to 1 if you have JACK.]) - #==================================================================================== # Determine if the processor can do clipping on float to int conversions. if test x$enable_cpu_clip != "xno" ; then - AC_C_CLIP_MODE + MN_C_CLIP_MODE else echo "checking processor clipping capabilities... disabled" ac_cv_c_clip_positive=0 @@ -378,14 +384,19 @@ AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative}, OS_SPECIFIC_CFLAGS="" OS_SPECIFIC_LINKS="" os_is_win32=0 -os_is_macosx=0 use_windows_api=0 +osx_darwin_version=0 case "$host_os" in darwin* | rhapsody*) - os_is_macosx=1 - OS_SPECIFIC_CFLAGS="-fpascal-strings -I/Developer/Headers/FlatCarbon" - OS_SPECIFIC_LINKS="-framework CoreAudio" + osx_darwin_version=$(echo "$host_os" | sed 's/\..*//;s/darwin//g') + if test x$HAVE_XCODE_SELECT = xyes ; then + developer_path=`xcode-select --print-path` + else + developer_path="/Developer" + fi + OS_SPECIFIC_CFLAGS="-I${developer_path}/Headers/FlatCarbon" + OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation" ;; mingw*) os_is_win32=1 @@ -395,8 +406,9 @@ case "$host_os" in esac AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32]) -AC_DEFINE_UNQUOTED(OS_IS_MACOSX, ${os_is_macosx}, [Set to 1 if compiling for MacOSX]) AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API]) +AC_DEFINE_UNQUOTED(OSX_DARWIN_VERSION, ${osx_darwin_version}, [The darwin version, no-zero is valid]) +AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1) #==================================================================================== # Check for ALSA. @@ -412,16 +424,17 @@ if test x$enable_alsa != xno ; then fi #==================================================================================== -# Test for sanity when cross-compiling. +# Check for OpenBSD's sndio. -if test x$cross_compiling = xyes ; then - AC_MSG_WARN([[******************************************************************]]) - AC_MSG_WARN([[*** We are cross-compiling, so have to assume sizeof (short) == 2 ]]) - AC_MSG_WARN([[*** and sizeof (int) == 4. If this is not the case there is no ]]) - AC_MSG_WARN([[*** chance of this working. Please contact the mantainer. ]]) - AC_MSG_WARN([[******************************************************************]]) +SNDIO_LIBS="" +AC_CHECK_HEADERS(sndio.h) +if test x$ac_cv_header_sndio_h = xyes ; then + SNDIO_LIBS="-lsndio" fi +#==================================================================================== +# Test for sanity when cross-compiling. + if test $ac_cv_sizeof_short != 2 ; then AC_MSG_WARN([[******************************************************************]]) AC_MSG_WARN([[*** sizeof (short) != 2. ]]) @@ -454,14 +467,6 @@ if test x"$ac_cv_prog_HAVE_AUTOGEN" = "xno" ; then #==================================================================================== # Settings for the HTML documentation. -htmldocdir=$prefix/share/doc/libsndfile1-dev/html - -if test $prefix = "NONE" ; then - htmldocdir=/usr/local/share/doc/libsndfile1-dev/html -else - htmldocdir=$prefix/share/doc/libsndfile1-dev/html - fi - if test x$enable_bow_docs = "xyes" ; then HTML_BGCOLOUR="white" HTML_FGCOLOUR="black" @@ -477,49 +482,51 @@ win32_target_dll=0 COMPILER_IS_GCC=0 if test x$ac_cv_c_compiler_gnu = xyes ; then - AC_ADD_CFLAGS(-std=gnu99) + MN_ADD_CFLAGS(-std=gnu99) - AC_GCC_VERSION + MN_GCC_VERSION if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then -# AC_MSG_WARN([****************************************************************]) -# AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **]) -# AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **]) -# AC_MSG_WARN([** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 **]) -# AC_MSG_WARN([** Using -fgnu-inline to avoid this stupidity. **]) -# AC_MSG_WARN([****************************************************************]) - AC_ADD_CFLAGS([-fgnu89-inline]) + AC_MSG_WARN([****************************************************************]) + AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **]) + AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **]) + AC_MSG_WARN([** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 **]) + AC_MSG_WARN([** Using -fgnu-inline to avoid this stupidity. **]) + AC_MSG_WARN([****************************************************************]) + MN_ADD_CFLAGS([-fgnu89-inline]) fi CFLAGS="$CFLAGS -Wall" CXXFLAGS="$CXXFLAGS -Wall" -# AC_ADD_CFLAGS([-Wextra]) + MN_ADD_CFLAGS([-Wextra]) AC_LANG_PUSH([C++]) -# AC_ADD_CXXFLAGS([-Wextra]) + MN_ADD_CXXFLAGS([-Wextra]) AC_LANG_POP([C++]) - AC_ADD_CFLAGS([-Wdeclaration-after-statement]) - AC_ADD_CFLAGS([-Wpointer-arith]) - AC_ADD_CFLAGS([-funsigned-char]) + MN_ADD_CFLAGS([-Wdeclaration-after-statement]) + MN_ADD_CFLAGS([-Wpointer-arith]) + MN_ADD_CFLAGS([-funsigned-char]) - if test x$enable_gcc_werror = "xyes" ; then - CFLAGS="-Werror $CFLAGS" - CXXFLAGS="-Werror $CXXFLAGS" + MN_ADD_CFLAGS([-D_FORTIFY_SOURCE=2]) + + if test x$enable_stack_smash_protection = "xyes" ; then + XIPH_GCC_STACK_PROTECTOR + XIPH_GXX_STACK_PROTECTOR fi if test x$enable_test_coverage = "xyes" ; then - # AC_ADD_CFLAGS([-ftest-coverage]) - AC_ADD_CFLAGS([-coverage]) + # MN_ADD_CFLAGS([-ftest-coverage]) + MN_ADD_CFLAGS([-coverage]) fi - CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings " - # -Wundef -Wmissing-declarations -Winline -Wconversion" - CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo " + CFLAGS="$CFLAGS -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return" + # -Winline -Wconversion -Wunreachable-code" + CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo -Wundef -Wuninitialized -Winit-self" if test "x$enable_gcc_opt" = "xno" ; then - temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"` + temp_CFLAGS=`echo $CFLAGS | $SED "s/O2/O0/"` CFLAGS=$temp_CFLAGS AC_MSG_WARN([[*** Compiler optimisations switched off. ***]]) fi @@ -529,24 +536,24 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then darwin* | rhapsody*) # Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody. # System headers on these systems are broken. - temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//" | sed "s/-Wshadow//" | sed "s/-Waggregate-return//"` + temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"` CFLAGS=$temp_CFLAGS - SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(srcdir)/Symbols.darwin" + SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(builddir)/Symbols.darwin" ;; - linux*) - SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux" + linux*|kfreebsd*-gnu*|gnu*) + SHLIB_VERSION_ARG="-Wl,--version-script=\$(builddir)/Symbols.gnu-binutils" ;; mingw*) # Linker flag '-Wl,--out-implib' does not work with mingw cross compiler # so we don't use it here. - SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile-1.def" + SHLIB_VERSION_ARG="-Wl,\$(builddir)/libsndfile-1.def" win32_target_dll=1 if test x"$enable_shared" = xno ; then win32_target_dll=0 fi ;; os2*) - SHLIB_VERSION_ARG="-Wl,-export-symbols \$(srcdir)/Symbols.os2" + SHLIB_VERSION_ARG="-Wl,-export-symbols \$(builddir)/Symbols.os2" ;; *) ;; @@ -558,36 +565,17 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then COMPILER_IS_GCC=1 fi +if test x$enable_werror = "xyes" ; then + MN_ADD_CFLAGS([-Werror]) + + AC_LANG_PUSH([C++]) + MN_ADD_CXXFLAGS([-Werror]) + AC_LANG_POP([C++]) + fi + + AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], ${win32_target_dll}, [Set to 1 if windows DLL is being built.]) AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], ${COMPILER_IS_GCC}, [Set to 1 if the compile is GNU GCC.]) -AC_DEFUN([AX_COMPILER_VENDOR], -[ -AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown - # note: don't check for gcc first since some other compilers define __GNUC__ - for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do - vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ -#if !($vencpp) - thisisanerror; -#endif -])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) - done - ]) -]) - -AX_COMPILER_VENDOR - -# Enable 64 bit build -AC_ARG_ENABLE(64, -[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"]) - -if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - if test "${enable_64}" = "yes"; then - CFLAGS="$CFLAGS -m64" - fi -fi - CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS" @@ -596,43 +584,64 @@ if test x"$CFLAGS" = x ; then exit fi +HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}" + +AC_DEFINE_UNQUOTED([HOST_TRIPLET], "${HOST_TRIPLET}", [The host triplet of the compiled binary.]) + +if test "$HOST_TRIPLET" = "x86_64-w64-mingw32" ; then + OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS" + fi + +WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/p.*//" -e "s/\./,/g"` + + +if test "$enable_static" = no ; then + SRC_BINDIR=src/.libs/ + TEST_BINDIR=tests/.libs/ +else + SRC_BINDIR=src/ + TEST_BINDIR=tests/ + fi + #------------------------------------------------------------------------------- -AC_SUBST(htmldocdir) +AC_SUBST(HOST_TRIPLET) + AC_SUBST(HTML_BGCOLOUR) AC_SUBST(HTML_FGCOLOUR) AC_SUBST(SHLIB_VERSION_ARG) AC_SUBST(SHARED_VERSION_INFO) +AC_SUBST(CLEAN_VERSION) +AC_SUBST(WIN_RC_VERSION) + AC_SUBST(OS_SPECIFIC_CFLAGS) AC_SUBST(OS_SPECIFIC_LINKS) AC_SUBST(ALSA_LIBS) -AC_SUBST(ENABLE_EXPERIMENTAL_CODE) +AC_SUBST(SNDIO_LIBS) AC_SUBST(EXTERNAL_CFLAGS) AC_SUBST(EXTERNAL_LIBS) - -AC_SUBST(COMPILER_IS_GCC) -AC_SUBST(GCC_MAJOR_VERSION) - -AC_SUBST(HAVE_JACK) +AC_SUBST(SRC_BINDIR) +AC_SUBST(TEST_BINDIR) dnl The following line causes the libtool distributed with the source dnl to be replaced if the build system has a more recent version. AC_SUBST(LIBTOOL_DEPS) AC_CONFIG_FILES([ \ - src/sndfile.h src/Makefile src/GSM610/Makefile src/G72x/Makefile \ - man/Makefile examples/Makefile tests/Makefile regtest/Makefile \ - M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile \ - programs/Makefile doc/libsndfile.css \ - Makefile libsndfile.spec sndfile.pc \ - tests/test_wrapper.sh \ + src/Makefile man/Makefile examples/Makefile tests/Makefile regtest/Makefile \ + M4/Makefile Win32/Makefile Octave/Makefile programs/Makefile \ + Makefile \ + src/version-metadata.rc tests/test_wrapper.sh tests/pedantic-header-test.sh \ + doc/libsndfile.css Scripts/build-test-tarball.mk libsndfile.spec sndfile.pc \ + src/sndfile.h \ + echo-install-dirs ]) AC_OUTPUT -# Make it executable. -chmod u+x tests/test_wrapper.sh +# Make sure these are executable. +chmod u+x tests/test_wrapper.sh build-test-tarball.mk echo-install-dirs #==================================================================================== @@ -641,46 +650,44 @@ AC_MSG_RESULT([ Configuration summary : - Version : ............................. ${VERSION} + libsndfile version : .................. ${VERSION} + + Host CPU : ............................ ${host_cpu} + Host Vendor : ......................... ${host_vendor} + Host OS : ............................. ${host_os} + Experimental code : ................... ${enable_experimental:-no} Using ALSA in example programs : ...... ${enable_alsa:-no} External FLAC/Ogg/Vorbis : ............ ${enable_external_libs:-no} - ]) +if test -z "$PKG_CONFIG" ; then + echo " *****************************************************************" + echo " *** The pkg-config program is missing. ***" + echo " *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***" + echo " *** http://pkg-config.freedesktop.org/wiki/ ***" + echo " *****************************************************************" + echo + fi + +echo " Tools :" +echo +echo " Compiler is Clang : ................... ${mn_cv_c_compiler_clang}" +echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}" + if test x$ac_cv_c_compiler_gnu = xyes ; then - echo -e " Tools :\n" - echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}" echo " GCC version : ......................... ${GCC_VERSION}" if test $GCC_MAJOR_VERSION -lt 3 ; then - echo -e "\n ** This compiler version allows applications to write" + echo "\n" + echo " ** This compiler version allows applications to write" echo " ** to static strings within the library." echo " ** Compile with GCC version 3.X or above to avoid this problem." fi fi -if test $libdir = "\${exec_prefix}/lib" ; then - libdir="$prefix/lib" - fi +./echo-install-dirs -if test $bindir = "\${exec_prefix}/bin" ; then - bindir="$prefix/bin" - fi - -AC_MSG_RESULT([[ - Installation directories : - - Library directory : ................... $libdir - Program directory : ................... $bindir - Pkgconfig directory : ................. $libdir/pkgconfig - HTML docs directory : ................. $htmldocdir -]]) - -if test x$prefix != "x/usr" ; then - echo "Compiling some other packages against libsndfile may require" - echo -e "the addition of \"$libdir/pkgconfig\" to the" - echo -e "PKG_CONFIG_PATH environment variable.\n" - fi +# Remove symlink created by Scripts/android-configure.sh. +test -h gdbclient && rm -f gdbclient (cd src && make genfiles) -(cd tests && make genfiles) diff --git a/libs/libsndfile/doc/FAQ.html b/libs/libsndfile/doc/FAQ.html index f46c4c321f..4465b77bd5 100644 --- a/libs/libsndfile/doc/FAQ.html +++ b/libs/libsndfile/doc/FAQ.html @@ -8,65 +8,70 @@ - + +

libsndfile : Frequently Asked Questions.

-Q1 : Do you plan to support XYZ codec in libsndfile?
+Q1 : Do you plan to support XYZ codec in libsndfile?
Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field - but version 1 does not. Why?
-Q3 : Compiling is really slow on MacOSX. Why?
+ but version 1 does not. Why?
+Q3 : Compiling is really slow on MacOS X. Why?
Q4 : When trying to compile libsndfile on Solaris I get a "bad - substitution" error during linking. What can I do to fix this?
-Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
-Q6 : What's the best format for storing temporary files?
-Q7 : On Linux/Unix/MacOSX, what's the best way of detecting the - presence of libsndfile?
-Q8 : But I just want a simple Makefile! What do I do?
+ substitution" error during linking. What can I do to fix this?
+Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
+Q6 : What's the best format for storing temporary files?
+Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the + presence of libsndfile?
+Q8 : I have libsndfile installed and now I want to use it. I + just want a simple Makefile! What do I do?
Q9 : How about adding the ability to write/read sound files to/from - memory buffers?
+ memory buffers?
Q10 : Reading a 16 bit PCM file as normalised floats and then - writing them back changes some sample values. Why?
+ writing them back changes some sample values. Why?
Q11 : I'm having problems with u-law encoded WAV files generated by - libsndfile in Winamp. Why?
-Q12 : I'm looking at sf_read*. What are items? What are frames?
+ libsndfile in Winamp. Why?
+Q12 : I'm looking at sf_read*. What are items? What are frames?
Q13 : Why can't libsndfile open this Sound Designer II (SD2) - file?
+ file?
Q14 : I'd like to statically link libsndfile to my closed source - application. Can I buy a license so that this is possible?
+ application. Can I buy a license so that this is possible?
Q15 : My program is crashing during a call to a function in libsndfile. - Is this a bug in libsndfile?
+ Is this a bug in libsndfile?
Q16 : Will you accept a fix for compiling libsndfile with compiler X? -
+
Q17 : Can libsndfile read/write files from/to UNIX pipes? -
-Q18 : Is it possible to build a Universal Binary on Mac OSX? -
+
+Q18 : Is it possible to build a Universal Binary on Mac OS X? +
Q19 : I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile? -
+
Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source projects support it! -
+
Q21 : How do I use libsndfile in a closed source or commercial program and comply with the license? -
+
Q22 : What versions of windows does libsndfile work on? -
+
+Q23 : I'm cross compiling libsndfile for another platform. How can I + run the test suite? +


-


Q1 : Do you plan to support XYZ codec in libsnfile?

+


Q1 : Do you plan to support XYZ codec in libsndfile?

If source code for XYZ codec is available under a suitable license (LGPL, BSD, MIT etc) then yes, I'd like to add it.

-If suitable documentation is available on how to decode and enocde the format +If suitable documentation is available on how to decode and encode the format then maybe, depending on how much work is involved.

@@ -80,7 +85,7 @@ If you can't find either then the answer is no.

-


Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field +


Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field but version 1 does not. Why?

This was dropped for a number of reasons: @@ -91,50 +96,50 @@ If you can't find either then the answer is no.

As documented - here -there is now a well defined behavior which ensures that no matter what the + here +there is now a well defined behaviour which ensures that no matter what the bit width of the source file, the scaling always does something sensible. This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short() -and always have the optimal behavior. +and always have the optimal behaviour.

-


Q3 : Compiling is really slow on MacOSX. Why?

+


Q3 : Compiling is really slow on MacOS X. Why?

When you configure and compile libsndfile, it uses the /bin/sh shell for a number of tasks (ie configure script and libtool). -Older versions of OSX (10.2?) shipped a a really crappy Bourne shell as /bin/sh +Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh which resulted in really slow compiles. -New version of OSX ship GNU BASh as /bin/sh and this answer doesn't apply in that +Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that case.

To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to -/bin/sh.old and make a softlink from /bin/sh to the bash shell. +/bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed to behave as a Bourne shell when is is called as /bin/sh.

-When I did this on my iBook running MacOSX, compile times dropped from 13 minutes +When I did this on my iBook running MacOS X, compile times dropped from 13 minutes to 3 minutes.

-


Q4 : When trying to compile libsndfile on Solaris I get a "bad +


Q4 : When trying to compile libsndfile on Solaris I get a "bad substitution" error on linking. Why?

It seems that the Solaris Bourne shell disagrees with GNU libtool.

To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to -/bin/sh.old and make a softlink from /bin/sh to the bash shell. +/bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed to behave as a Bourne shell when is is called as /bin/sh.

-


Q5 : Why doesn't libsndfile do interleaving/de-interleaving?

+


Q5 : Why doesn't libsndfile do interleaving/de-interleaving?

This problem is bigger than it may seem at first.

@@ -143,7 +148,7 @@ For a stereo file, it is a pretty safe bet that a simple interleaving/de-interle could satisfy most users. However, for files with more than 2 channels this is unlikely to be the case. If the user has a 4 channel file and want to play that file on a stereo output -sound card they either want the first two channels or they want some mixed combination +sound card they either want the first 2 channels or they want some mixed combination of the 4 channels.

@@ -156,7 +161,7 @@ This means that this feature will not be added any time soon. -


Q6 : What's the best format for storing temporary files?

+


Q6 : What's the best format for storing temporary files?

When you want to store temporary data there are a number of requirements; @@ -184,7 +189,7 @@ regardless of the host CPU. -


Q7 : On Linux/Unix/MaxOSX, what's the best way of detecting the presence +


Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence of libsndfile using autoconf?

@@ -242,7 +247,8 @@ libsndfile configure process. For instance on my system I get this: -


Q8 : But I just want a simple Makefile! What do I do?

+


Q8 : I have libsndfile installed and now I want to use it. I just want + a simple Makefile! What do I do?

The pkg-config program makes finding the correct compiler flag values and @@ -277,7 +283,7 @@ the command would be: -


Q9 : How about adding the ability to write/read sound files to/from +


Q9 : How about adding the ability to write/read sound files to/from memory buffers?

@@ -287,7 +293,7 @@ This has been added for version 1.0.13. -


Q10 : Reading a 16 bit PCM file as normalised floats and then +


Q10 : Reading a 16 bit PCM file as normalised floats and then writing them back changes some sample values. Why?

@@ -335,7 +341,7 @@ other than normalized floats in the application. Alternatives to normalized floats are the short and int data types (ie using sf_read_short or sf_read_int) or using un-normalized floats (see - + SFC_SET_NORM_FLOAT).

@@ -352,7 +358,7 @@ storage format (and which is also supported by most common file types). -


Q11 : I'm having problems with u-law encoded WAV files generated by +


Q11 : I'm having problems with u-law encoded WAV files generated by libsndfile in Winamp. Why?

@@ -381,21 +387,48 @@ is the risk of breaking something that currently works. -


Q12 : I'm looking at sf_read*. What are items? What are frames? +


Q12 : I'm looking at sf_read*. What are items? What are frames?

-For a sound file with only one channel, a frame is the same as a item. +An item is a single sample of the data type you are reading; ie a +single short value for sf_read_short or a single float +for sf_read_float.

+

-For multi channel sound files, a single frame contains a single item for -each channel. +For a sound file with only one channel, a frame is the same as a item (ie a +single sample) while for multi channel sound files, a single frame contains a +single item for each channel.

+

+Here are two simple, correct examples, both of which are assumed to be working +on a stereo file, first using items: +

+ +
+        #define CHANNELS 2
+        short data [CHANNELS * 100] ;
+        sf_count items_read = sf_read_short (file, data, 200) ;
+        assert (items_read == 200) ;
+
+ +

+and now readng the exact same amount of data using frames: +

+ +
+        #define CHANNELS 2
+        short data [CHANNELS * 100] ;
+        sf_count frames_read = sf_readf_short (file, data, 100) ;
+        assert (frames_read == 100) ;
+
+ -


Q13 : Why can't libsndfile open this Sound Designer II (SD2) file? +


Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?

@@ -407,7 +440,7 @@ First some background. SD2 files are native to the Apple Macintosh platform and use features of the Mac filesystem (file resource forks) to store the file's sample rate, number of channels, sample width and more. -When you look at a file and its resource fork on Mac OSX it looks like +When you look at a file and its resource fork on Mac OS X it looks like this:

@@ -419,7 +452,7 @@ this:

Notice how the file itself looks like a directory containing a single file named rsrc. -When libsndfile is compiled for MacOSX, it should open (for write and read) +When libsndfile is compiled for MacOS X, it should open (for write and read) SD2 file with resource forks like this without any problems. It will also handle files with the resource fork in a separate file as described below. @@ -436,8 +469,8 @@ libsndfile to open the file.

However, it is possible to safely move an SD2 file to a Linux or Windows machine. -For instance, when an SD2 file is copied from inside MacOSX to a windows -shared directory or a Samba share (ie Linux), MacOSX is clever enough to +For instance, when an SD2 file is copied from inside MacOS X to a windows +shared directory or a Samba share (ie Linux), MacOS X is clever enough to store the resource fork of the file in a separate hidden file in the same directory like this:

@@ -475,7 +508,7 @@ files are. -


Q14 : I'd like to statically link libsndfile to my closed source +


Q14 : I'd like to statically link libsndfile to my closed source application. Can I buy a license so that this is possible?

@@ -494,7 +527,7 @@ library is if your application is released under the GNU GPL or LGPL. -


Q15 : My program is crashing during a call to a function in libsndfile. +


Q15 : My program is crashing during a call to a function in libsndfile. Is this a bug in libsndfile?

@@ -527,7 +560,7 @@ following: -


Q16 : Will you accept a fix for compiling libsndfile with compiler X? +


Q16 : Will you accept a fix for compiling libsndfile with compiler X?

@@ -548,7 +581,7 @@ This can make compiling libsndfile with some older compilers difficult. -


Q17 : Can libsndfile read/write files from/to UNIX pipes? +


Q17 : Can libsndfile read/write files from/to UNIX pipes?

@@ -583,7 +616,7 @@ See also FAQ Q6. -


Q18 : Is it possible to build a Universal Binary on Mac OSX? +


Q18 : Is it possible to build a Universal Binary on Mac OS X?

@@ -644,7 +677,7 @@ libsndfile is currently working on. -


Q19 : I have project files for Visual Studio / XCode / Whatever. Why +


Q19 : I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile?

@@ -674,7 +707,7 @@ fixing or even testing it.

I currently release sources that I personally test on Win32, Linux and -MacOSX (PowerPC) using the compiler I trust (GNU GCC). +MacOS X (PowerPC) using the compiler I trust (GNU GCC). Supporting one compiler on three (actually much more because GCC is available almost everywhere) platforms is doable without too much pain. I also release binaries for Win32 with instructions on how to use those @@ -696,7 +729,7 @@ Hence, I'm not willing to enter into an arrangement like that again. -


Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source +


Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source projects support it!

@@ -721,8 +754,7 @@ Some of those authors may be students and hence wouldn't be worth pursuing. However, libsndfile is released under the name of a company, Mega Nerd Pty Ltd; a company which has income from from libsamplerate licensing, libsndfile based consulting income and other unrelated consulting income. -Adding MP3 support to libsndfile could place that income would be under legal -threat. +Adding MP3 support to libsndfile could place that income under legal threat.

@@ -734,7 +766,7 @@ John ffitch of the Csound project) in version 1.0.18. -


Q21 : How do I use libsndfile in a closed source or commercial program +


Q21 : How do I use libsndfile in a closed source or commercial program and comply with the license?

@@ -746,7 +778,7 @@ released under, the GNU Lesser General Public License (LGPL):
  • Make sure you are linking to libsndfile as a shared library (Linux and Unix - systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OSX). + systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X). If you are using some other operating system that doesn't allow dynamically linked libraries, you will not be able to use libsndfile unless you release the source code to your program. @@ -762,28 +794,57 @@ released under, the GNU Lesser General Public License (LGPL): -


    Q22 : What versions of windows does libsndfile work on? +


    Q22 : What versions of Windows does libsndfile work on?

    -Currently the precompiled windows binaries are tested in Windows XP. +Currently the precompiled windows binaries are thoroughly tested on Windows XP. As such, they should also work on Win2k and Windows Vista. -They may also work on earlier versions of windows. +They may also work on earlier versions of Windows.

    -libsndfile does not yet work on 64 bit versions of windows. -Support for 64 bit versions of WinXP and Vista is likely to be working some -time late in 2008. +Since version 0.1.18 I have also been releasing precompiled binaries for Win64, +the 64 bit version of Windows. +These binaries have received much less testing than the 32 bit versions, but +should work as expected. +I'd be very interested in receiving feedback on these binaries.

    + + + +


    Q23 : I'm cross compiling libsndfile for another platform. How can I + run the test suite? +

    + +

    +

    + +

    +Since version 1.0.21 the top level Makefile has an extra make target, +'test-tarball'. +Building this target creates a tarball called called: +

    + +
    +libsndfile-testsuite-${host_triplet}-${version}.tar.gz +
    + +

    +in the top level directory. +This tarball can then be copied to the target platform. +Once untarred and test script test_wrapper.sh can be run from +the top level of the extracted tarball. +

    +

    The libsndfile home page is here : http://www.mega-nerd.com/libsndfile/. -
    -Version : 1.0.19 +
    +Version : 1.0.25

    diff --git a/libs/libsndfile/doc/Makefile.am b/libs/libsndfile/doc/Makefile.am index 40a04d970a..b89f1454aa 100644 --- a/libs/libsndfile/doc/Makefile.am +++ b/libs/libsndfile/doc/Makefile.am @@ -1,8 +1,7 @@ ## Process this file with automake to produce Makefile.in -htmldir = $(htmldocdir) html_DATA = index.html libsndfile.jpg libsndfile.css api.html command.html \ - bugs.html sndfile_info.html new_file_type.HOWTO pkgconfig.html \ + bugs.html sndfile_info.html new_file_type.HOWTO \ win32.html FAQ.html lists.html embedded_files.html octave.html \ dither.html tutorial.html diff --git a/libs/libsndfile/doc/api.html b/libs/libsndfile/doc/api.html index 25c52d2dc0..33d53dd02f 100644 --- a/libs/libsndfile/doc/api.html +++ b/libs/libsndfile/doc/api.html @@ -3,12 +3,13 @@ - The libsndfile API. + The libsndfile API - + + @@ -34,9 +35,15 @@ unambiguous. However, since maintaining the documentation is the least fun part of working on libsndfile, these docs can and do fall behind the behaviour of library. - If any errors omissions or ambiguities are found, please notify - - Erik de Castro Lopo. + If any errors, omissions or ambiguities are found, please notify me (erikd) + at mega-nerd dot com. +

    + +

    + To supplement this reference documentation, there are simple example programs + included in the source code tarball. + The test suite which is also part of the source code tarball is also a good + place to look for the correct usage of the library functions.

    @@ -46,7 +53,7 @@

    -

    SYNOPSIS

    +

    Synopsis

    The functions of libsndfile are defined as follows:

    @@ -57,7 +64,7 @@ The functions of libsndfile are defined as follows: SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; - + SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; int sf_format_check (const SF_INFO *info) ; sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; @@ -186,6 +193,10 @@ Not all combinations of endian-ness and major and minor file types are valid. SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ + SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ + SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ + SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */ + SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */ /* Subtypes from here on. */ @@ -219,6 +230,8 @@ Not all combinations of endian-ness and major and minor file types are valid. SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ + SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ + /* Endian-ness options. */ SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ @@ -238,10 +251,12 @@ memory allocated during the call to sf_open().

    -On success, the sf_open function returns a non NULL pointer which should be +On success, the sf_open function returns a non-NULL pointer which should be passed as the first parameter to all subsequent libsndfile calls dealing with that audio file. On fail, the sf_open function returns a NULL pointer. +An explanation of the error can obtained by passing NULL to + sf_strerror.

    @@ -251,6 +266,11 @@ On fail, the sf_open function returns a NULL pointer. SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; +

    +Note: On Microsoft Windows, this function does not work if the +application and the libsndfile DLL are linked to different versions of the +Microsoft C runtime DLL. +

    The second open function takes a file descriptor of a file that has already been opened. @@ -280,12 +300,92 @@ parameter was TRUE when the sf_open_fd() function was called.

    -On success, the sf_open_fd function returns a non NULL pointer which should be +On success, the sf_open_fd function returns a non-NULL pointer which should be passed as the first parameter to all subsequent libsndfile calls dealing with that audio file. On fail, the sf_open_fd function returns a NULL pointer.

    + +

    Virtual File Open Function

    +
    +      SNDFILE* 	sf_open_virtual	(SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
    +
    +

    + Opens a soundfile from a virtual file I/O context which is provided + by the caller. This is usually used to interface libsndfile to a stream or buffer + based system. Apart from the sfvirtual and the user_data parameters this function behaves + like sf_open. +

    + +
    +      typedef struct
    +      {    sf_vio_get_filelen  get_filelen ;
    +           sf_vio_seek         seek ;
    +           sf_vio_read         read ;
    +           sf_vio_write        write ;
    +           sf_vio_tell         tell ;
    +      } SF_VIRTUAL_IO ;
    +
    +

    +Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when opening, reading +and writing to the virtual file context. The user_data pointer is a user defined context which +will be available in the callbacks. +

    +
    +      typedef sf_count_t  (*sf_vio_get_filelen) (void *user_data) ;
    +      typedef sf_count_t  (*sf_vio_seek)        (sf_count_t offset, int whence, void *user_data) ;
    +      typedef sf_count_t  (*sf_vio_read)        (void *ptr, sf_count_t count, void *user_data) ;
    +      typedef sf_count_t  (*sf_vio_write)       (const void *ptr, sf_count_t count, void *user_data) ;
    +      typedef sf_count_t  (*sf_vio_tell)        (void *user_data) ;
    +
    +

    sf_vio_get_filelen

    +
    +      typedef sf_count_t  (*sf_vio_get_filelen) (void *user_data) ;
    +
    +

    +The virtual file contex must return the length of the virtual file in bytes.
    +

    +

    sf_vio_seek

    +
    +      typedef sf_count_t  (*sf_vio_seek)        (sf_count_t offset, int whence, void *user_data) ;
    +
    +

    +The virtual file context must seek to offset using the seek mode provided by whence which is one of
    +

    +
    +      SEEK_CUR
    +      SEEK_SET
    +      SEEK_END
    +
    +

    +The return value must contain the new offset in the file. +

    +

    sf_vio_read

    +
    +      typedef sf_count_t  (*sf_vio_read)        (void *ptr, sf_count_t count, void *user_data) ;
    +
    +

    +The virtual file context must copy ("read") "count" bytes into the +buffer provided by ptr and return the count of actually copied bytes. +

    +

    sf_vio_write

    +
    +      typedef sf_count_t  (*sf_vio_write)       (const void *ptr, sf_count_t count, void *user_data) ;
    +
    +

    +The virtual file context must process "count" bytes stored in the +buffer passed with ptr and return the count of actually processed bytes.
    +

    +

    sf_vio_tell

    +
    +      typedef sf_count_t  (*sf_vio_tell)        (void *user_data) ;
    +
    +

    +Return the current position of the virtual file context.
    +

    + +

    Format Check Function

    @@ -541,6 +641,12 @@ same as the frames parameter). sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; +

    +Note: Unless you are writing an external decoder/encode that uses +libsndfile to handle the file headers, you should not be using these +functions. +

    +

    The raw read and write functions read raw audio data from the audio file (not to be confused with reading RAW header-less PCM files). The number of bytes read or written @@ -586,12 +692,16 @@ The str_type parameter can be any one of the following string types: SF_STR_SOFTWARE, SF_STR_ARTIST, SF_STR_COMMENT, - SF_STR_DATE + SF_STR_DATE, + SF_STR_ALBUM, + SF_STR_LICENSE, + SF_STR_TRACKNUMBER, + SF_STR_GENRE } ;

    -The sf_get_string() function returns the specificed string if it exists and a +The sf_get_string() function returns the specified string if it exists and a NULL pointer otherwise. In addition to the string ids above, SF_STR_FIRST (== SF_STR_TITLE) and SF_STR_LAST (always the same as the highest numbers string id) are also @@ -648,7 +758,7 @@ would mean that all sample values read from the file will be zero. In order to read these files correctly using integer read methods, it is recommended that you use the sf_command -interface a command of +interface, a command of SFC_SET_SCALE_FLOAT_INT_READ and a parameter of SF_TRUE to force correct scaling.

    @@ -660,7 +770,7 @@ and a parameter of SF_TRUE to force correct scaling. here.

    -Version : 1.0.19 +Version : 1.0.25

    diff --git a/libs/libsndfile/doc/bugs.html b/libs/libsndfile/doc/bugs.html index 94caffecba..3a441fef11 100644 --- a/libs/libsndfile/doc/bugs.html +++ b/libs/libsndfile/doc/bugs.html @@ -6,7 +6,8 @@ Bug Reporting - + + @@ -45,7 +46,7 @@
  • Whether you are using a package provided by your distribution or you compiled it youself.
  • If you compiled it yourself, the compiler you are using. (Also make - sure to run "make check".) + sure to run 'make check'.)
  • A description of the problem.
  • Information generated by the sndfile-info program (see next paragraph).
  • If you are having problems with sndfile-play and ALSA on Linux, I will @@ -67,9 +68,8 @@ problems.

    - Once you have the above information you should email it to one of the - mailing lists - (posting to these lists is limited to the list subscribers). + Once you have the above information you should submit a ticket on the libsnfile + github issue tracker.

    diff --git a/libs/libsndfile/doc/command.html b/libs/libsndfile/doc/command.html index 239e8d2087..f2ed083760 100644 --- a/libs/libsndfile/doc/command.html +++ b/libs/libsndfile/doc/command.html @@ -9,7 +9,8 @@ - + + @@ -27,7 +28,7 @@ Most of these operations are performed on a per-file basis.

    - The cmd parameter is a integer identifier which is defined in <sndfile.h>. + The cmd parameter is an integer identifier which is defined in <sndfile.h>. All of the valid command identifiers have names beginning with "SFC_". Data is passed to and returned from the library by use of a void pointer. The library will not read or write more than datasize bytes from the void pointer. @@ -167,12 +168,12 @@ SFC_GET_CLIPPING - Retreive current clipping setting. + Retrieve current clipping setting. SFC_GET_EMBED_FILE_INFO - Retreive information about audio files embedded inside other files. + Retrieve information about audio files embedded inside other files. @@ -187,7 +188,12 @@ SFC_SET_VBR_ENCODING_QUALITY - Set the the Variable Bit Rate encoding quality + Set the Variable Bit Rate encoding quality + + + + SFC_SET_COMPRESSION_LEVEL + Set the compression level. @@ -205,6 +211,33 @@ Set the Broadcast Chunk info + + SFC_SET_CART_INFO + Set the Cart Chunk info + + + + SFC_GET_CART_INFO + Retrieve the Cart Chunk info + + + + SFC_GET_LOOP_INFO + Get loop info + + + + SFC_GET_INSTRUMENT + Get instrument info + + + + SFC_SET_INSTRUMENT + Set instrument info + + + + + +


    SFC_SET_COMPRESSION_LEVEL

    +

    +Set the compression level. +The compression level should be between 0.0 (minimum compression level) and 1.0 +(highest compression level). +Currenly this command is only implemented for FLAC and Ogg/Vorbis files. +

    +

    +Parameters: +

    +        sndfile  : A valid SNDFILE* pointer
    +        cmd      : SFC_SET_COMPRESSION_LEVEL
    +        data     : A pointer to a double value
    +        datasize : sizeof (double)
    +
    +

    +The command must be sent before any audio data is written to the file. +

    +

    +

    +
    +
    Return value:
    +
    SF_TRUE if compression level was set. + SF_FALSE otherwise.
    @@ -1334,7 +1397,7 @@ Parameters:


    SFC_GET_BROADCAST_INFO

    -Retrieve the Broadcast Extention Chunk from WAV (and related) files. +Retrieve the Broadcast Extension Chunk from WAV (and related) files.

    Parameters: @@ -1367,7 +1430,7 @@ The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:

    Return value:
    -
    SF_TRUE if the file contained a Broadcast Extention chunk or SF_FALSE +
    SF_TRUE if the file contained a Broadcast Extension chunk or SF_FALSE otherwise.
    @@ -1375,7 +1438,7 @@ The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:


    SFC_SET_BROADCAST_INFO

    -Set the Broadcast Extention Chunk for WAV (and related) files. +Set the Broadcast Extension Chunk for WAV (and related) files.

    Parameters: @@ -1389,9 +1452,225 @@ Parameters:

    Return value:
    -
    SF_TRUE if setting the Broadcast Extention chunk was successful and SF_FALSE +
    SF_TRUE if setting the Broadcast Extension chunk was successful and SF_FALSE + otherwise. + +
    + + + +


    SFC_GET_CART_INFO

    +

    Retrieve the Cart Chunk from WAV (and related) files. Based on AES46 standard for CartChunk (see CartChunk.org for more information. +

    +

    +Parameters: +

    +
    +        sndfile  : A valid SNDFILE* pointer
    +        cmd      : SFC_GET_CART_INFO
    +        data     : a pointer to an SF_CART_INFO struct
    +        datasize : sizeof (SF_CART_INFO)
    +
    +

    +The SF_CART_INFO struct is defined in <sndfile.h> as: +

    +
    +#define SF_CART_INFO_VAR(p_tag_text_size) \
    +                        struct
    +                        {       char            version [4] ;
    +                                char            title [64] ;
    +                                char            artist [64] ;
    +                                char            cut_id [64] ;
    +                                char            client_id [64] ;
    +                                char            category [64] ;
    +                                char            classification [64] ;
    +                                char            out_cue [64] ;
    +                                char            start_date [10] ;
    +                                char            start_time [8] ;
    +                                char            end_date [10] ;
    +                                char            end_time [8] ;
    +                                char            producer_app_id [64] ;
    +                                char            producer_app_version [64] ;
    +                                char            user_def [64] ;
    +                                long    level_reference ;
    +                                SF_CART_TIMER   post_timers [8] ;
    +                                char            reserved [276] ;
    +                                char            url [1024] ;
    +                                unsigned int    tag_text_size ;
    +                                char            tag_text[p_tag_text_size] ;
    +                        }
    +
    + +
    +
    Return value:
    +
    SF_TRUE if the file contained a Cart chunk or SF_FALSE otherwise.
    + + + +


    SFC_SET_CART_INFO

    +

    +Set the Cart Chunk for WAV (and related) files. +

    +

    +Parameters: +

    +
    +        sndfile  : A valid SNDFILE* pointer
    +        cmd      : SFC_SET_CART_INFO
    +        data     : a pointer to an SF_CART_INFO struct
    +        datasize : sizeof (SF_CART_INFO)
    +
    + +
    +
    Return value:
    +
    SF_TRUE if setting the Cart chunk was successful and SF_FALSE + otherwise. +
    + + + +


    SFC_GET_LOOP_INFO

    +

    +Retrieve loop information for file including time signature, length in +beats and original MIDI base note +

    +

    +Parameters: +

    +
    +         sndfile  : A valid SNDFILE* pointer
    +         cmd      : SFC_GET_LOOP_INFO
    +         data     : a pointer to an SF_LOOP_INFO struct
    +         datasize : sizeof (SF_LOOP_INFO)
    +
    +

    +The SF_BROADCAST_INFO struct is defined in <sndfile.h> as: +

    +
    +        typedef struct
    +        {   short    time_sig_num ;   /* any positive integer    > 0  */
    +            short    time_sig_den ;   /* any positive power of 2 > 0  */
    +            int        loop_mode ;    /* see SF_LOOP enum             */
    +
    +            int        num_beats ;    /* this is NOT the amount of quarter notes !!!*/
    +                                      /* a full bar of 4/4 is 4 beats */
    +                                      /* a full bar of 7/8 is 7 beats */
    +
    +            float    bpm ;            /* suggestion, as it can be calculated using other fields:*/
    +                                      /* file's lenght, file's sampleRate and our time_sig_den*/
    +                                      /* -> bpms are always the amount of _quarter notes_ per minute */
    +
    +            int    root_key ;         /* MIDI note, or -1 for None */
    +            int future [6] ;
    +        } SF_LOOP_INFO ;
    +
    +

    +Example: +

    +
    +         SF_LOOP_INFO loop;
    +         sf_command (sndfile, SFC_GET_LOOP_INFO, &loop, sizeof (loop)) ;
    +
    +
    +
    Return value:
    +
    SF_TRUE if the file header contains loop information for the file. + SF_FALSE otherwise. +
    + + + + + +


    SFC_GET_INSTRUMENT

    +

    +Retrieve instrument information from file including MIDI base note, +keyboard mapping and looping informations(start/stop and mode). +

    +

    +Parameters: +

    +
    +         sndfile  : A valid SNDFILE* pointer
    +         cmd      : SFC_GET_INSTRUMENT
    +         data     : a pointer to an SF_INSTRUMENT struct
    +         datasize : sizeof (SF_INSTRUMENT)
    +
    + +

    +The SF_INSTRUMENT struct is defined in <sndfile.h> as: +

    +
    +        enum
    +        {    /*
    +            **    The loop mode field in SF_INSTRUMENT will be one of the following.
    +            */
    +            SF_LOOP_NONE = 800,
    +            SF_LOOP_FORWARD,
    +            SF_LOOP_BACKWARD,
    +            SF_LOOP_ALTERNATING
    +        } ;
    +
    +        typedef struct
    +        {   int gain ;
    +            char basenote, detune ;
    +            char velocity_lo, velocity_hi ;
    +            char key_lo, key_hi ;
    +            int loop_count ;
    +
    +            struct
    +            {   int mode ;
    +                unsigned int start ;
    +                unsigned int end ;
    +                unsigned int count ;
    +            } loops [16] ; /* make variable in a sensible way */
    +        } SF_INSTRUMENT ;
    +
    + +

    +Example: +

    +
    +         SF_INSTRUMENT inst ;
    +         sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
    +
    +
    +
    Return value:
    +
    SF_TRUE if the file header contains instrument information for the + file. SF_FALSE otherwise. +
    + + + + + +


    SFC_SET_INSTRUMENT

    +

    +Set the instrument information for the file. +

    +

    +Parameters: +

    +
    +         sndfile  : A valid SNDFILE* pointer
    +         cmd      : SFC_GET_INSTRUMENT
    +         data     : a pointer to an SF_INSTRUMENT struct
    +         datasize : sizeof (SF_INSTRUMENT)
    +
    +

    +Example: +

    +
    +         SF_INSTRUMENT inst ;
    +         sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
    +
    +
    +
    Return value:
    +
    SF_TRUE if the file header contains instrument information for the + file. SF_FALSE otherwise. +
    + @@ -1401,7 +1680,7 @@ Parameters: http://www.mega-nerd.com/libsndfile/.
    -Version : 1.0.19 +Version : 1.0.25

    diff --git a/libs/libsndfile/doc/development.html b/libs/libsndfile/doc/development.html new file mode 100644 index 0000000000..4236cdbb87 --- /dev/null +++ b/libs/libsndfile/doc/development.html @@ -0,0 +1,43 @@ + + + + + + libsndfile Development + + + + + + + + +


    libsndfile Development

    + +

    +libsndfile is being developed by a small but growing community of users +and hackers led by Erik de Castro Lopo. +People interested in helping should join the libsndfile-devel + mailing list +where most of the discussion about new features takes place. +

    + +

    +The main repository can be found on Github: +

    + +
    + + https://github.com/erikd/libsndfile/ +
    + +

    +and includes + + instuctions +on how to build libsndfilefrom the Git repo. +

    + + + + diff --git a/libs/libsndfile/doc/dither.html b/libs/libsndfile/doc/dither.html index c1edd17d1b..01a416f8b3 100644 --- a/libs/libsndfile/doc/dither.html +++ b/libs/libsndfile/doc/dither.html @@ -9,7 +9,8 @@ - + + @@ -1009,7 +1010,7 @@ Example: http://www.mega-nerd.com/libsndfile/.
    -Version : 1.0.19 +Version : 1.0.25

    diff --git a/libs/libsndfile/doc/donate.html b/libs/libsndfile/doc/donate.html new file mode 100644 index 0000000000..c611f47ffd --- /dev/null +++ b/libs/libsndfile/doc/donate.html @@ -0,0 +1,112 @@ + + + + + + libsndfile : donate. + + + + + + + + + + + +
    + +
    + libsndfile.jpg +
    + +
    + +

    +Dear libsndfile user, +

    + +

    +This library was developed on Linux for Linux. I am not a Windows user and +maintaining this library for Windows costs me significant amounts of time above +and beyond the time taken to make it work on Linux and Unix-like systems. +

    + +

    +I therefore ask Windows users of libsndfile to donate to ensure that libsndfile's +support for Windows continues. As long as donations continue to flow in at a decent +rate, I will continue to release precompiled Windows binaries in sync with the +Linux/Unix version. If donations are poor, support for windows will fall behind. +

    + + +

    +You are free to donate any amount you chose. +As a guideline: +

    + +
      +
    • If you are simply a user of libsndfile that would like to ensure that + the development of libsndfile continues, a donation of $10US would be more + than adequate. +
    • +
    • If you are shareware author that distributes libsndfile with your app and + makes more than $1000 a year from your shareware, a one off donation of $50 + would be appropriate. +
    • +
    • If your company is a commercial software house that distributes one or more + products that ship with libsndfile, a donation of $100 every second or third + year would be appropriate. +
    • +
    + + +

    +Donations can be made in Bitcoin to the Bitcoin address + 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ + +which can be verified by checking the following GPG signature. +

    + +
    +-----BEGIN PGP SIGNED MESSAGE-----
    +Hash: SHA256
    +
    +libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ
    +-----BEGIN PGP SIGNATURE-----
    +Version: GnuPG v1.4.12 (GNU/Linux)
    +
    +iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS
    +/Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq
    +eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp
    +DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR
    +waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8
    +WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf
    +p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq
    +N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi
    +nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8
    +Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z
    +Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH
    +bJPKMDcz1ZvfYtX5mSW1
    +=WXGB
    +-----END PGP SIGNATURE-----
    +
    + +

    +Thanks and regards, +
    +Erik de Castro Lopo +
    +Main libsndfile author and maintainer +

    + + + + + + + + diff --git a/libs/libsndfile/doc/embedded_files.html b/libs/libsndfile/doc/embedded_files.html index 455614d2eb..c73e86a3b5 100644 --- a/libs/libsndfile/doc/embedded_files.html +++ b/libs/libsndfile/doc/embedded_files.html @@ -8,7 +8,8 @@ - + + diff --git a/libs/libsndfile/doc/index.html b/libs/libsndfile/doc/index.html index 362e9529cb..bdd25aad10 100644 --- a/libs/libsndfile/doc/index.html +++ b/libs/libsndfile/doc/index.html @@ -6,11 +6,12 @@ libsndfile - + - + + @@ -47,11 +48,8 @@

    The library was written to compile and run on a Linux system but should compile - and run on just about any Unix (including MacOSX). - It can also be compiled and run on Win32 systems using the Microsoft compiler and - MacOS (OS9 and earlier) using the Metrowerks compiler. - There are directions for compiling libsndfile on these platforms in the Win32 and - MacOS directories of the source code distribution. + and run on just about any Unix (including MacOS X). + There are also pre-compiled binaries available for 32 and 64 bit windows.

    It was designed to handle both little-endian (such as WAV) and big-endian @@ -67,18 +65,19 @@

      -
    • i586-pc-linux-gnu (Linux on PC hardware) -
    • powerpc-unknown-linux-gnu (Linux on Apple Mac hardware) -
    • powerpc-apple-darwin7.0 (Mac OS X 10.3) -
    • sparc-sun-solaris2.8 (using gcc) -
    • mips-sgi-irix5.3 (using gcc) -
    • QNX 6.0 -
    • i386-unknown-openbsd2.9 +
    • Every platform supported by Debian GNU/Linux including x86_64-linux-gnu, + i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu, + mips-linux-gnu and armel-linux-gnu.
    • +
    • powerpc-apple-darwin7.0 (Mac OS X 10.3)
    • +
    • sparc-sun-solaris2.8 (using gcc)
    • +
    • mips-sgi-irix5.3 (using gcc)
    • +
    • QNX 6.0
    • +
    • i386-unknown-openbsd2.9

    - At the moment, each new release is being tested on i386 Linux, PowerPC Linux, - MacOSX on PowerPC and Win32. + At the moment, each new release is being tested on i386 Linux, x86_64 Linux, + PowerPC Linux, Win32 and Win64.

    @@ -293,7 +292,7 @@ and I have decided that I will not be adding support for MPEG Layer 3 (commonly known as MP3) due to the patent issues surrounding this file format. See - + the FAQ for more.

    @@ -343,7 +342,7 @@ and
  • Version 1.0.5 (May 03 2003) One new file format and new functionality.
  • Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new functionality and Win32 improvements. -
  • Version 1.0.7 (Feb 24 2004) Fix build problems on MacOSX and fix ia64/MIPS etc +
  • Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS etc clip mode detction.
  • Version 1.0.8 (Mar 14 2004) Minor bug fixes.
  • Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV files. @@ -360,8 +359,15 @@ and
  • Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
  • Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive libraries, many new features and bug fixes. Generate Win32 and Win64 pre-compiled binaries. -
  • Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a +
  • Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a result of static analysis. +
  • Version 1.0.20 (May 14 2009) Fix for potential heap overflow. +
  • Version 1.0.21 (December 13 2009) Bunch of minor bug fixes. +
  • Version 1.0.22 (October 04 2010) Bunch of minor bug fixes. +
  • Version 1.0.23 (October 10 2010) Minor bug fixes. +
  • Version 1.0.24 (March 23 2011) Minor bug fixes. +
  • Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug fixes and + improvements.
@@ -389,7 +395,7 @@ and version 2.1 and version 3. - To mamximise the compatibility of libsndfile, the user may choose to use libsndfile + To maximise the compatibility of libsndfile, the user may choose to use libsndfile under either of the above two licenses. You can also read a simple explanation of the ideas behind the GPL and the LGPL here. @@ -410,24 +416,12 @@ and Free Software or Open Source. - However, if you put in a great deal of effort building a huge application + However, if you put in a great deal of effort building a significant application which simply uses libsndfile for file I/O, then I have no problem with you releasing that as closed source and charging as much money as you want for it as long as you abide by the license.

-

- What I don't like to see is things like Steve Dekorte's SoundConverter - (no I won't link to his page) for Mac OSX. - Mr Dekorte has grabbed a number of Free Software packages and wrapped them in a - rather amateurish, buggy GUI and released the result as shareware. - He charges US$10 for the full version when his contribution to the whole is, by - his own - - admission, - less than 10%. -

-

Download

@@ -435,23 +429,22 @@ and

The Win32 installer was compiled for Windows XP but should also work on Windows -2000 and Vista. -It may even work on earlier versions of Windows. -The Win64 is pretty much untested. +2000, Vista and Windows 7.

diff --git a/libs/libsndfile/doc/libsndfile.css b/libs/libsndfile/doc/libsndfile.css deleted file mode 100644 index 940c136fe8..0000000000 --- a/libs/libsndfile/doc/libsndfile.css +++ /dev/null @@ -1,82 +0,0 @@ -body { - background : black ; - color : white ; - font-family : arial, helvetica, sans-serif ; - line-height: 1.5 ; -} -td { - font-family : arial, helvetica, sans-serif ; - background : black ; - color : white ; -} -center { - font-family : arial, helvetica, sans-serif ; -} -p { - font-family : arial, helvetica, sans-serif ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -.indent_block { - font-family : arial, helvetica, sans-serif ; - text-align : left ; - margin-left : 10% ; - margin-right : 10% ; -} -br { - font-family : arial, helvetica, sans-serif ; -} -form { - font-family : arial, helvetica, sans-serif ; -} -ul { - font-family : arial, helvetica, sans-serif ; - text-align : left ; - margin-left : 3% ; - margin-right : 6% ; -} -ol { - font-family : arial, helvetica, sans-serif ; - text-align : left ; - margin-left : 3% ; - margin-right : 6% ; -} -dl { - font-family : arial, helvetica, sans-serif ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -h1 { - font-size : xx-large ; - background : black ; - color : #5050FF ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -h2 { - font-size : x-large ; - background : black ; - color : #5050FF ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -h3 { - font-size : large ; - background : black ; - color : #5050FF ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -pre { - font-family : courier, monospace ; - font-size : medium ; -} -a:link { color : #9090FF ; } -a:visited { color : #5050FF ; } -a:active { color : #FF00FF ; } -a:hover { background-color : #202080 ; } diff --git a/libs/libsndfile/doc/libsndfile.css.in b/libs/libsndfile/doc/libsndfile.css.in index 3e308b2cc3..40fca0f145 100644 --- a/libs/libsndfile/doc/libsndfile.css.in +++ b/libs/libsndfile/doc/libsndfile.css.in @@ -48,24 +48,32 @@ dl { margin-left : 3% ; margin-right : 3% ; } -h1 { - font-size : xx-large ; - background : @HTML_BGCOLOUR@ ; - color : #5050FF ; - text-align : left ; - margin-left : 3% ; - margin-right : 3% ; -} -h2 { - font-size : x-large ; +h1 { + font-size : xx-large ; background : @HTML_BGCOLOUR@ ; color : #5050FF ; text-align : left ; margin-left : 3% ; margin-right : 3% ; } -h3 { - font-size : large ; +h2 { + font-size : x-large ; + background : @HTML_BGCOLOUR@ ; + color : #5050FF ; + text-align : left ; + margin-left : 3% ; + margin-right : 3% ; +} +h3 { + font-size : large ; + background : @HTML_BGCOLOUR@ ; + color : #5050FF ; + text-align : left ; + margin-left : 3% ; + margin-right : 3% ; +} +h4 { + font-size : medium ; background : @HTML_BGCOLOUR@ ; color : #5050FF ; text-align : left ; @@ -75,6 +83,8 @@ h3 { pre { font-family : courier, monospace ; font-size : medium ; + margin-left : 6% ; + margin-right : 6% ; } a:link { color : #9090FF ; } a:visited { color : #5050FF ; } diff --git a/libs/libsndfile/doc/linux_games_programming.txt b/libs/libsndfile/doc/linux_games_programming.txt new file mode 100644 index 0000000000..747f59db26 --- /dev/null +++ b/libs/libsndfile/doc/linux_games_programming.txt @@ -0,0 +1,434 @@ +# Here are some some emails I exchanged with a guy trying to use +# libsndfile version 1 with code from the book "Linux Games Programming" +# by John Hall. The email addresses have been changed to foil the spam +# bots. + +Date: Tue, 20 Jul 2004 22:49:21 +0100 +From: Paul +To: erikd@fake-domain-name.com +Subject: Can you help with a problem? +Date: Tue, 20 Jul 2004 22:49:21 +0100 + +Hi, + +I'm trying to get the source examples in the "Programming Linux Games" +(NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile. + +While I can guess some of the newer versions of function calls and +enumerations, there are some which I cannot guess. + +Would you be able to translate them to the current version of +enumeration and function calls so that I can update the source? + +These are the three currently failing me: + + sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo)) + SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) + SF_INFO.pcmbitwidth (guess: no idea!) + +There are probably more. I'm happy to send you the source files for +sound calls, scan the pages or anything else. Failing that, is there +somewhere with the changes listed so I can try and fix the code for myself? + +Thanks + +TTFN + +Paul + +================================================================================ + +Date: Wed, 21 Jul 2004 17:38:08 +1000 +From: Erik de Castro Lopo +To: Paul +Subject: Re: Can you help with a problem? + +On Tue, 20 Jul 2004 22:49:21 +0100 +Paul wrote: + +> Hi, +> +> I'm trying to get the source examples in the "Programming Linux Games" +> (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile. +> +> While I can guess some of the newer versions of function calls and +> enumerations, there are some which I cannot guess. +> +> Would you be able to translate them to the current version of +> enumeration and function calls so that I can update the source? +> +> These are the three currently failing me: +> +> sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, +> SFM_READ, &sfinfo)) + +yes. + +> SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) + +Actually this list: + + SF_FORMAT_PCM_U8 + SF_FORMAT_PCM_S8 + SF_FORMAT_PCM_16 + SF_FORMAT_PCM_24 + SF_FORMAT_PCM_32 + +> SF_INFO.pcmbitwidth (guess: no idea!) + +WIth the above change, pcmbitwidth becomes redundant. + +> There are probably more. I'm happy to send you the source files for +> sound calls, scan the pages or anything else. Failing that, is there +> somewhere with the changes listed so I can try and fix the code for +> myself? + +Version 1.0.0 came out some time ago, but I think this: + + http://www.mega-nerd.com/libsndfile/version-1.html + +lists most of the changes. You should also look at the API docs: + + http://www.mega-nerd.com/libsndfile/api.html + +HTH, +Erik +-- ++-----------------------------------------------------------+ + Erik de Castro Lopo nospam@fake-domain-name.com ++-----------------------------------------------------------+ +"There is no reason why anyone would want a computer in their home" +Ken Olson, DEC, 1977 + +================================================================================ + +From: PFJ +To: Erik de Castro Lopo +Subject: Re: Can you help with a problem? +Date: Wed, 21 Jul 2004 09:07:39 +0100 + + +Hi Erik, + +Thanks for getting back to me. + +> > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo)) +> +> yes. + +Yay! + +> > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) +> +> Actually this list: +> +> SF_FORMAT_PCM_U8 +> SF_FORMAT_PCM_S8 +> SF_FORMAT_PCM_16 +> SF_FORMAT_PCM_24 +> SF_FORMAT_PCM_32 + +I know, but the source code explicitly has SF_FORMAT_PCM which given the +code afterwards would equate to one of the above, but given that PCM +files can have a varied bitwidth the author probably wanted to cover all +bases. + +> Version 1.0.0 came out some time ago, but I think this: +> +> http://www.mega-nerd.com/libsndfile/version-1.html +> +> lists most of the changes. You should also look at the API docs: +> +> http://www.mega-nerd.com/libsndfile/api.html + +I'll download them and see what I can gleen. + +Thanks again for getting back to me + +TTFN + +Paul + +================================================================================ + +Date: Wed, 21 Jul 2004 18:20:29 +1000 +From: Erik de Castro Lopo +To: PFJ +Subject: Re: Can you help with a problem? + +On Wed, 21 Jul 2004 09:07:39 +0100 +PFJ wrote: + +> I know, but the source code explicitly has SF_FORMAT_PCM which given the +> code afterwards would equate to one of the above, but given that PCM +> files can have a varied bitwidth the author probably wanted to cover all +> bases. + +But surely the existing code does something like: + + sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; + sfinfo.pcmbitwidth = 16; + +which can be directly translated to: + + sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; + +and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8 +you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF +files use SF_FORMAT_PCM_S8. Thats all there is to it. + +Erik +-- ++-----------------------------------------------------------+ + Erik de Castro Lopo nospam@fake-domain-name.com ++-----------------------------------------------------------+ +"Python addresses true pseudocode's two major failings: that it +isn't standardized, and it isn't executable." +- Grant R. Griffin in comp.dsp + +================================================================================ + +Subject: Re: Can you help with a problem? +From: PFJ +To: Erik de Castro Lopo +Date: Wed, 21 Jul 2004 09:50:55 +0100 + +Hi Erik, + +> > I know, but the source code explicitly has SF_FORMAT_PCM which given the +> > code afterwards would equate to one of the above, but given that PCM +> > files can have a varied bitwidth the author probably wanted to cover all +> > bases. +> +> But surely the existing code does something like: +> +> sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; +> sfinfo.pcmbitwidth = 16; + +If only! + +The actual code is this + +int LoadSoundFile(char *filename, sound_p sound) +{ + SNDFILE *file; + SF_INFO file_info; + short *buffer_short = NULL; + u_int8_t *buffer_8 = NULL; + int16_t *buffer_16 = NULL; + unsigned int i; + + /* Open the file and retrieve sample information. */ + file = sf_open_read(filename, &file_info); + // I've sorted this one already - PFJ + + /* Make sure the format is acceptable. */ + if ((file_info.format & 0x0F) != SF_FORMAT_PCM) { + printf("'%s' is not a PCM-based audio file.\n", filename); + sf_close(file); + return -1; + } + + if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) { + sound->format = AL_FORMAT_MONO8; + } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) { + sound->format = AL_FORMAT_STEREO8; + } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) { + sound->format = AL_FORMAT_MONO16; + } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) { + sound->format = AL_FORMAT_STEREO16; + } else { + printf("Unknown sample format in %s.\n", filename); + sf_close(file); + return -1; + } + + /* Allocate buffers. */ + buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short)); + + buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8); + + buffer_16 = (int16_t *)buffer_8; + + if (buffer_short == NULL || buffer_8 == NULL) { + printf("Unable to allocate enough memory for '%s'.\n", filename); + goto error_cleanup; + } + + /* Read the entire sound file. */ + if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) { + printf("Error while reading samples from '%s'.\n", filename); + goto error_cleanup; + } + + + + /* Fill in the sound data structure. */ + sound->freq = file_info.samplerate; + sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8; + + /* Give our sound data to OpenAL. */ + alGenBuffers(1, &sound->name); + if (alGetError() != AL_NO_ERROR) { + printf("Error creating an AL buffer name for %s.\n", filename); + goto error_cleanup; + } + + alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq); + if (alGetError() != AL_NO_ERROR) { + printf("Error sending buffer data to OpenAL for %s.\n", filename); + goto error_cleanup; + } + + /* Close the file and return success. */ + sf_close(file); + free(buffer_short); + free(buffer_8); + + return 0; + + error_cleanup: + if (file != NULL) fclose(file); + free(buffer_short); + free(buffer_8); + return -1; +} + +As you can see, the PCM material in the listing will not currently +compile and for the other sndfile material, it probably won't either. + +Any help would be appreciated. + +TTFN + +Paul + +================================================================================ + +From: Erik de Castro Lopo +To: PFJ +Subject: Re: Can you help with a problem? +Date: Wed, 21 Jul 2004 19:36:46 +1000 + +On Wed, 21 Jul 2004 09:50:55 +0100 +PFJ wrote: + +> Hi Erik, +> +> > > I know, but the source code explicitly has SF_FORMAT_PCM which given the +> > > code afterwards would equate to one of the above, but given that PCM +> > > files can have a varied bitwidth the author probably wanted to cover all +> > > bases. +> > +> > But surely the existing code does something like: +> > +> > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; +> > sfinfo.pcmbitwidth = 16; +> +> If only! + +No, really. + +Drop this completely: + +> /* Make sure the format is acceptable. */ +> if ((file_info.format & 0x0F) != SF_FORMAT_PCM) { +> printf("'%s' is not a PCM-based audio file.\n", filename); +> sf_close(file); +> return -1; +> } + +Replace this block: + +> if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) { +> sound->format = AL_FORMAT_MONO8; +> } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) { +> sound->format = AL_FORMAT_STEREO8; +> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) { +> sound->format = AL_FORMAT_MONO16; +> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) { +> sound->format = AL_FORMAT_STEREO16; +> } else { +> printf("Unknown sample format in %s.\n", filename); +> sf_close(file); +> return -1; +> } + +with: + + int pcmbitwidth = 0; + + if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16) + { printf("'%s' is not a PCM-based audio file.\n", filename); + sf_close(file); + return -1; + } + + if (file_info.channels < 1 || file_info.channels > 2) + { printf("'%s' bad channel count.\n", filename); + sf_close(file); + return -1; + } + + switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16) + { case (SF_FORMAT_PCM_U8 + 1 << 16): + sound->format = AL_FORMAT_MONO8; + pcmbitwidth = 8; + break; + case (SF_FORMAT_PCM_U8 + 2 << 16): + sound->format = AL_FORMAT_STEREO8; + pcmbitwidth = 8; + break; + case (SF_FORMAT_PCM_16 + 1 << 16): + sound->format = AL_FORMAT_MONO16; + pcmbitwidth = 16; + break; + case (SF_FORMAT_PCM_16 + 2 << 16): + sound->format = AL_FORMAT_STEREO16; + pcmbitwidth = 16; + break; + default: + printf("Unknown sample format in %s.\n", filename); + sf_close(file); + return -1; + } + +> /* Allocate buffers. */ +> buffer_short = (short *)malloc(file_info.samples * +> file_info.channels * +> sizeof (short)); +> +> buffer_8 = (u_int8_t *)malloc(file_info.samples * +> file_info.channels * +> file_info.pcmbitwidth / 8); + +Use pcmbitwidth as calculated above. + +> buffer_16 = (int16_t *)buffer_8; +> +> if (buffer_short == NULL || buffer_8 == NULL) { +> printf("Unable to allocate enough memory for '%s'.\n", filename); +> goto error_cleanup; +> } +> +> /* Read the entire sound file. */ +> if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) { + +Replace "(size_t) - 1" with " < 0". + +> As you can see, the PCM material in the listing will not currently +> compile and for the other sndfile material, it probably won't either. + +None of the changes above should have been very difficult to figure +out. + +Erik +-- ++-----------------------------------------------------------+ + Erik de Castro Lopo nospam@fake-domain-name.com ++-----------------------------------------------------------+ +Microsoft is finally bringing all of its Windows operating system families +under one roof. It will combine all of the features of CE, stability and +support of ME and the speed of NT. +It will be called Windows CEMENT... + diff --git a/libs/libsndfile/doc/lists.html b/libs/libsndfile/doc/lists.html index 349e494cff..7d95170271 100644 --- a/libs/libsndfile/doc/lists.html +++ b/libs/libsndfile/doc/lists.html @@ -6,7 +6,8 @@ libsndfile Mailing Lists - + + diff --git a/libs/libsndfile/doc/octave.html b/libs/libsndfile/doc/octave.html index 33ef1b6c53..b696e6b81a 100644 --- a/libs/libsndfile/doc/octave.html +++ b/libs/libsndfile/doc/octave.html @@ -6,7 +6,8 @@ libsndfile and GNU Octave - + + @@ -14,21 +15,21 @@

libsndfile and GNU Octave

- GNU Octave is a high-level interactive - language for numerical computations. + GNU Octave is a high-level interactive + language for numerical computations. There are currently two development streams, a stable 2.0.X series and a development 2.1.X series. Octave reads and writes data in binary formats that were originally developed - for + for MATLAB. Version 2.0.X of Octave uses binary data files compatible with MATLAB version 4.2 while Octave 2.1.X uses binary data files compatible - with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2 + with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2 format.

- From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading - and writing a small subset of the binary data files used by both versions + From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading + and writing a small subset of the binary data files used by both versions of GNU Octave. This gives people using GNU Octave for audio based work an easy method of moving audio data between GNU Octave and other programs which use libsndfile. @@ -36,22 +37,22 @@

For instance it is now possible to do the following:

- +
    -
  • Load a WAV file into a sound file editor such as +
  • Load a WAV file into a sound file editor such as Sweep.
  • Save it as a MAT4 file.
  • Load the data into Octave for manipulation. -
  • Save the modified data. +
  • Save the modified data.
  • Reload it in Sweep.

Another example would be using the MAT4 or MAT5 file formats as a format which - can be easily loaded into Octave for viewing/analyzing as well as a format + can be easily loaded into Octave for viewing/analyzing as well as a format which can be played with command line players such as the one included with libsndfile.

- +

Details

Octave, like most programming languages, uses variables to store data, and @@ -69,7 +70,7 @@

         octave:1 > samplerate = 44100 ;
         octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
-        octave:3 > save sine.mat samplerate wavedata 
+        octave:3 > save sine.mat samplerate wavedata
 

@@ -83,9 +84,9 @@

In addition, libsndfile contains a command line program which which is able to play the correct types of Octave files. - Using this command line player sndfile-play and a third Octave script + Using this command line player sndfile-play and a third Octave script file allows Octave data to be played from within Octave on any of the platforms - which sndfile-play supports (at the moment: Linux, MacOSX, Solaris and + which sndfile-play supports (at the moment: Linux, MacOS X, Solaris and Win32).

@@ -99,8 +100,8 @@
 

- There are some other Octave scripts for audio to be found - here. + There are some other Octave scripts for audio to be found + here.


@@ -108,7 +109,7 @@

- The libsndfile home page is here : + The libsndfile home page is here : http://www.mega-nerd.com/libsndfile/.

diff --git a/libs/libsndfile/doc/pkgconfig.html b/libs/libsndfile/doc/pkgconfig.html index 1711de9f70..c89193d1ed 100644 --- a/libs/libsndfile/doc/pkgconfig.html +++ b/libs/libsndfile/doc/pkgconfig.html @@ -6,7 +6,8 @@ libsndfile : pkg-config - + + @@ -18,7 +19,7 @@ From version 1.0.0 libsndfile has had the ability to read and write files of greater than 2 Gig in size on most OSes even if sizeof (long) == 4. OSes which support this feature include Linux (2.4 kernel, glibc6) on x86, PPC and - probably others, Win32, MacOSX, *BSD, Solaris and probably others. + probably others, Win32, MacOS X, *BSD, Solaris and probably others. OSes on 64 bit processors where the default compile environment is LP64 (longs and pointers are 64 bit ie Linux on DEC/Compaq/HP Alpha processors) automatically support large file access. @@ -30,7 +31,7 @@ programs which link to the library.

- Note : People using Win32, MacOS (both OSX and pre-OSX) or *BSD can disregard the + Note : People using Win32, MacOS (both OS X and pre-OS X) or *BSD can disregard the rest of this document as it does not apply to either of these OSes.

diff --git a/libs/libsndfile/doc/print.css b/libs/libsndfile/doc/print.css new file mode 100644 index 0000000000..deb5b13da0 --- /dev/null +++ b/libs/libsndfile/doc/print.css @@ -0,0 +1,14 @@ +body { + background:white; + color:black; +} + +h1{ + background:white; + color:black; +} + +h2 { + background:white; + color:#666; +} diff --git a/libs/libsndfile/doc/sndfile_info.html b/libs/libsndfile/doc/sndfile_info.html index 51e2dd35ad..a84f24150f 100644 --- a/libs/libsndfile/doc/sndfile_info.html +++ b/libs/libsndfile/doc/sndfile_info.html @@ -6,7 +6,8 @@ sndfile-info - + + diff --git a/libs/libsndfile/doc/tutorial.html b/libs/libsndfile/doc/tutorial.html index 77c4f0457e..e3112393ad 100644 --- a/libs/libsndfile/doc/tutorial.html +++ b/libs/libsndfile/doc/tutorial.html @@ -6,7 +6,8 @@ libsndfile Tutorial - + + diff --git a/libs/libsndfile/doc/win32.html b/libs/libsndfile/doc/win32.html index 5da8f18d0e..6ee3153c7d 100644 --- a/libs/libsndfile/doc/win32.html +++ b/libs/libsndfile/doc/win32.html @@ -6,7 +6,8 @@ Building libsndfile on Win32 - + + diff --git a/libs/libsndfile/echo-install-dirs.in b/libs/libsndfile/echo-install-dirs.in new file mode 100644 index 0000000000..48d54b4e2d --- /dev/null +++ b/libs/libsndfile/echo-install-dirs.in @@ -0,0 +1,25 @@ +#!/bin/sh +# @configure_input@ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +pkgconfigdir=@pkgconfigdir@ +datadir=@datadir@ +datarootdir=@datarootdir@ +docdir=@docdir@ +htmldir=@htmldir@ + +echo " + Installation directories : + + Library directory : ................... $libdir + Program directory : ................... $bindir + Pkgconfig directory : ................. $pkgconfigdir + HTML docs directory : ................. $htmldir +" +echo "Compiling some other packages against libsndfile may require" +echo "the addition of '$pkgconfigdir' to the" +echo "PKG_CONFIG_PATH environment variable." +echo diff --git a/libs/libsndfile/examples/Makefile.am b/libs/libsndfile/examples/Makefile.am index 9797a72cdb..da841fa218 100644 --- a/libs/libsndfile/examples/Makefile.am +++ b/libs/libsndfile/examples/Makefile.am @@ -2,7 +2,7 @@ noinst_PROGRAMS = make_sine sfprocess list_formats generate sndfilehandle sndfile-to-text -INCLUDES = -I$(top_srcdir)/src +AM_CPPFLAGS = -I$(top_srcdir)/src sndfile_to_text_SOURCES = sndfile-to-text.c sndfile_to_text_LDADD = $(top_builddir)/src/libsndfile.la @@ -22,3 +22,4 @@ generate_LDADD = $(top_builddir)/src/libsndfile.la sndfilehandle_SOURCES = sndfilehandle.cc sndfilehandle_LDADD = $(top_builddir)/src/libsndfile.la +CLEANFILES = *~ *.exe diff --git a/libs/libsndfile/examples/generate.c b/libs/libsndfile/examples/generate.c index 8228c12c4b..884e8d79d3 100644 --- a/libs/libsndfile/examples/generate.c +++ b/libs/libsndfile/examples/generate.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** All rights reserved. ** @@ -98,6 +98,8 @@ encode_file (const char *infilename, const char *outfilename, int filetype) k = 16 - strlen (outfilename) ; PUT_DOTS (k) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; + if (! (infile = sf_open (infilename, SFM_READ, &sfinfo))) { printf ("Error : could not open file : %s\n", infilename) ; puts (sf_strerror (NULL)) ; @@ -119,7 +121,7 @@ encode_file (const char *infilename, const char *outfilename, int filetype) } ; while ((readcount = sf_read_float (infile, buffer, BUFFER_LEN)) > 0) - sf_write_float (outfile, buffer, BUFFER_LEN) ; + sf_write_float (outfile, buffer, readcount) ; sf_close (infile) ; sf_close (outfile) ; diff --git a/libs/libsndfile/examples/generate.cs b/libs/libsndfile/examples/generate.cs new file mode 100644 index 0000000000..1817856fa7 --- /dev/null +++ b/libs/libsndfile/examples/generate.cs @@ -0,0 +1,250 @@ +/* (c) 2004 James Robson, http://www.arbingersys.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** **************************** +** +** How to use: +** - libsndfile.dll must have already been compiled and be in this +** application's search path +** +** - You must edit this file to point to the file you want to convert. Set +** the following line of code (found in the Main() function further below) +** to the name of a .WAV file that exists on your system. +** 186: string sfn = "input.wav"; +** +** - From a command prompt type +** csc generate.cs +** +** - Run the resulting executable 'generate.exe' +** +** +** Note: You will obviously need the csc compiler and the .NET runtime. I think +** these are freely available for download from Microsoft's website +** (part of the .NET SDK?). +*/ + + +using System; +using System.Runtime.InteropServices; +using sf_count_t = System.Int64; //alias; see SF_INFO struct + +#if PLATFORM_64 +using size_t = System.UInt64; +#else +using size_t = System.UInt32; +#endif + + +class lsndf_example { + + +//sound file formats + public enum lsndf_frmts { + SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */ + SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ + SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ + SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ + SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ + SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ + SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ + SF_FORMAT_VOC = 0x080000, /* VOC files. */ + SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ + SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ + SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ + SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ + SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ + SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ + SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ + SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ + + /* Subtypes from here on. */ + + SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ + SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ + SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ + SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ + + SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ + + SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ + SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ + + SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ + SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ + SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ + SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ + + SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ + SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ + + SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ + SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ + SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ + + SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ + + SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ + SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ + + + /* Endian-ness options. */ + + SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ + SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ + SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ + SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ + + SF_FORMAT_SUBMASK = 0x0000FFFF, + SF_FORMAT_TYPEMASK = 0x0FFF0000, + SF_FORMAT_ENDMASK = 0x30000000 + } + + +//modes and other + public enum lsndf_tf + { /* True and false */ + SF_FALSE = 0, + SF_TRUE = 1, + + /* Modes for opening files. */ + SFM_READ = 0x10, + SFM_WRITE = 0x20, + SFM_RDWR = 0x30 + } + + +//important SF_INFO structure + [StructLayout(LayoutKind.Sequential)] + public struct SF_INFO + { + public sf_count_t frames ; // Used to be called samples. Changed to avoid confusion. + public int samplerate ; + public int channels ; + public int format ; + public int sections ; + public int seekable ; + }; + + +//function declarations +//Note: Not all functions have been prototyped here. Only the ones necessary to +// make this application work. The below code should give some clues as to +// how to add the rest since they have a lot of parameter and return type +// similarities. + [DllImport("libsndfile.dll")] + public static extern IntPtr sf_open ([MarshalAs(UnmanagedType.LPStr)] string path, int mode, ref SF_INFO sfinfo); + + [DllImport("libsndfile.dll")] + static extern int sf_error (IntPtr sndfile); + + [DllImport("libsndfile.dll")] + static extern IntPtr sf_strerror (IntPtr sndfile); + + [DllImport("libsndfile.dll")] + static extern int sf_format_check (ref SF_INFO info); + + [DllImport("libsndfile.dll")] + static extern sf_count_t sf_read_float (IntPtr sndfile, float[] ptr, sf_count_t items); + + [DllImport("libsndfile.dll")] + static extern sf_count_t sf_write_float (IntPtr sndfile, float[] ptr, sf_count_t items); + + [DllImport("libsndfile.dll")] + static extern int sf_close (IntPtr sndfile); + + + public const sf_count_t BUFFER_LEN = 4096; + + +//program entry + static void Main( ) { + + +//declarations + SF_INFO sfinfo = new SF_INFO(); + float[] buffer = new float[BUFFER_LEN]; + sf_count_t rcnt; + +//set the input file + string sfn = "input.wav"; //set to a file on YOUR system + //string sfn = "noexist.wav"; //test with non-existent file + +//set the output file + string ofn = "output.wav"; + +//read in sound file to convert + IntPtr infile = sf_open (sfn, (int)lsndf_tf.SFM_READ, ref sfinfo); + +//exit if error was thrown + if ( (int)infile == 0 ) { + Console.WriteLine("Error opening " + sfn); + Console.WriteLine("Error #" + sf_error(infile)); + return; + } + +//set the file type for the output file +//uncomment one and only one of the statements below to change the output +//file encoding. + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_U8); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_16); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_MS_ADPCM); + sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_IMA_ADPCM); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_GSM610); + /* Soundforge W64. */ + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_U8); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_16); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_MS_ADPCM); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_IMA_ADPCM); + //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_GSM610); + + +//check that SF_INFO is valid + if ( sf_format_check(ref sfinfo) == 0 ) { + Console.WriteLine("sf_format_check failed. Invalid encoding"); + return; + } + +//open output file + IntPtr outfile = sf_open (ofn, (int)lsndf_tf.SFM_WRITE, ref sfinfo); + +//exit if error was thrown + if ( (int)outfile == 0 ) { + Console.WriteLine("Error opening " + ofn); + Console.WriteLine("Error #" + sf_error(outfile)); + return; + } + +//infile -> outfile + Console.Write(sfn + " -> " + ofn); + while ( (rcnt = sf_read_float (infile, buffer, BUFFER_LEN)) > 0) { + Console.Write("."); + sf_write_float (outfile, buffer, BUFFER_LEN); + } + Console.WriteLine("done."); + +//close up shop + sf_close(infile); + sf_close(outfile); + + + } //main() + + +} //class lsndf_example {} + diff --git a/libs/libsndfile/examples/list_formats.c b/libs/libsndfile/examples/list_formats.c index c529247da7..6d462f0790 100644 --- a/libs/libsndfile/examples/list_formats.c +++ b/libs/libsndfile/examples/list_formats.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** All rights reserved. ** diff --git a/libs/libsndfile/examples/make_sine.c b/libs/libsndfile/examples/make_sine.c index 3e760333b7..1db0e00d26 100644 --- a/libs/libsndfile/examples/make_sine.c +++ b/libs/libsndfile/examples/make_sine.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** All rights reserved. ** @@ -91,6 +91,6 @@ main (void) puts (sf_strerror (file)) ; sf_close (file) ; - return 0 ; + return 0 ; } /* main */ diff --git a/libs/libsndfile/examples/sfprocess.c b/libs/libsndfile/examples/sfprocess.c index 42c98bdeb3..1c141a4981 100644 --- a/libs/libsndfile/examples/sfprocess.c +++ b/libs/libsndfile/examples/sfprocess.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2013 Erik de Castro Lopo ** ** All rights reserved. ** @@ -7,15 +7,15 @@ ** modification, are permitted provided that the following conditions are ** met: ** -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the author nor the names of any contributors may be used -** to endorse or promote products derived from this software without -** specific prior written permission. +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the author nor the names of any contributors may be used +** to endorse or promote products derived from this software without +** specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -31,12 +31,13 @@ */ #include +#include /* Include this header file to use functions from libsndfile. */ #include -/* This will be the length of the buffer used to hold.frames while -** we process them. +/* This will be the length of the buffer used to hold.frames while +** we process them. */ #define BUFFER_LEN 1024 @@ -49,31 +50,35 @@ static void process_data (double *data, int count, int channels) ; int main (void) -{ /* This is a buffer of double precision floating point values - ** which will hold our data while we process it. - */ - static double data [BUFFER_LEN] ; +{ /* This is a buffer of double precision floating point values + ** which will hold our data while we process it. + */ + static double data [BUFFER_LEN] ; - /* A SNDFILE is very much like a FILE in the Standard C library. The - ** sf_open function return an SNDFILE* pointer when they sucessfully + /* A SNDFILE is very much like a FILE in the Standard C library. The + ** sf_open function return an SNDFILE* pointer when they sucessfully ** open the specified file. - */ - SNDFILE *infile, *outfile ; + */ + SNDFILE *infile, *outfile ; - /* A pointer to an SF_INFO stutct is passed to sf_open. - ** On read, the library fills this struct with information about the file. - ** On write, the struct must be filled in before calling sf_open. - */ - SF_INFO sfinfo ; - int readcount ; - const char *infilename = "input.wav" ; - const char *outfilename = "output.wav" ; + /* A pointer to an SF_INFO struct is passed to sf_open. + ** On read, the library fills this struct with information about the file. + ** On write, the struct must be filled in before calling sf_open. + */ + SF_INFO sfinfo ; + int readcount ; + const char *infilename = "input.wav" ; + const char *outfilename = "output.wav" ; - /* Here's where we open the input file. We pass sf_open the file name and - ** a pointer to an SF_INFO struct. - ** On successful open, sf_open returns a SNDFILE* pointer which is used - ** for all subsequent operations on that file. - ** If an error occurs during sf_open, the function returns a NULL pointer. + /* The SF_INFO struct must be initialized before using it. + */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + + /* Here's where we open the input file. We pass sf_open the file name and + ** a pointer to an SF_INFO struct. + ** On successful open, sf_open returns a SNDFILE* pointer which is used + ** for all subsequent operations on that file. + ** If an error occurs during sf_open, the function returns a NULL pointer. ** ** If you are trying to open a raw headerless file you will need to set the ** format and channels fields of sfinfo before calling sf_open(). For @@ -82,56 +87,56 @@ main (void) ** ** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ; ** sfinfo.channels = 2 ; - */ - if (! (infile = sf_open (infilename, SFM_READ, &sfinfo))) - { /* Open failed so print an error message. */ - printf ("Not able to open input file %s.\n", infilename) ; - /* Print the error message from libsndfile. */ - puts (sf_strerror (NULL)) ; - return 1 ; - } ; + */ + if (! (infile = sf_open (infilename, SFM_READ, &sfinfo))) + { /* Open failed so print an error message. */ + printf ("Not able to open input file %s.\n", infilename) ; + /* Print the error message from libsndfile. */ + puts (sf_strerror (NULL)) ; + return 1 ; + } ; - if (sfinfo.channels > MAX_CHANNELS) - { printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ; - return 1 ; - } ; - /* Open the output file. */ - if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo))) - { printf ("Not able to open output file %s.\n", outfilename) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; + if (sfinfo.channels > MAX_CHANNELS) + { printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ; + return 1 ; + } ; + /* Open the output file. */ + if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo))) + { printf ("Not able to open output file %s.\n", outfilename) ; + puts (sf_strerror (NULL)) ; + return 1 ; + } ; - /* While there are.frames in the input file, read them, process - ** them and write them to the output file. - */ - while ((readcount = sf_read_double (infile, data, BUFFER_LEN))) - { process_data (data, readcount, sfinfo.channels) ; - sf_write_double (outfile, data, readcount) ; - } ; + /* While there are.frames in the input file, read them, process + ** them and write them to the output file. + */ + while ((readcount = sf_read_double (infile, data, BUFFER_LEN))) + { process_data (data, readcount, sfinfo.channels) ; + sf_write_double (outfile, data, readcount) ; + } ; - /* Close input and output files. */ - sf_close (infile) ; - sf_close (outfile) ; + /* Close input and output files. */ + sf_close (infile) ; + sf_close (outfile) ; - return 0 ; + return 0 ; } /* main */ static void process_data (double *data, int count, int channels) { double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ; - int k, chan ; + int k, chan ; - /* Process the data here. - ** If the soundfile contains more then 1 channel you need to take care of - ** the data interleaving youself. - ** Current we just apply a channel dependant gain. - */ + /* Process the data here. + ** If the soundfile contains more then 1 channel you need to take care of + ** the data interleaving youself. + ** Current we just apply a channel dependant gain. + */ - for (chan = 0 ; chan < channels ; chan ++) - for (k = chan ; k < count ; k+= channels) - data [k] *= channel_gain [chan] ; + for (chan = 0 ; chan < channels ; chan ++) + for (k = chan ; k < count ; k+= channels) + data [k] *= channel_gain [chan] ; - return ; + return ; } /* process_data */ diff --git a/libs/libsndfile/examples/sndfile-to-text.c b/libs/libsndfile/examples/sndfile-to-text.c index d7d6492d3b..466bb860b5 100644 --- a/libs/libsndfile/examples/sndfile-to-text.c +++ b/libs/libsndfile/examples/sndfile-to-text.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2012 Erik de Castro Lopo ** ** All rights reserved. ** @@ -68,9 +68,9 @@ convert_to_text (SNDFILE * infile, FILE * outfile, int channels) int main (int argc, char * argv []) { char *progname, *infilename, *outfilename ; - SNDFILE *infile = NULL ; + SNDFILE *infile = NULL ; FILE *outfile = NULL ; - SF_INFO sfinfo ; + SF_INFO sfinfo ; progname = strrchr (argv [0], '/') ; progname = progname ? progname + 1 : argv [0] ; @@ -101,6 +101,8 @@ main (int argc, char * argv []) return 1 ; } ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; + if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL) { printf ("Not able to open input file %s.\n", infilename) ; puts (sf_strerror (NULL)) ; diff --git a/libs/libsndfile/examples/sndfilehandle.cc b/libs/libsndfile/examples/sndfilehandle.cc index 693a4422ed..c9a1931aea 100644 --- a/libs/libsndfile/examples/sndfilehandle.cc +++ b/libs/libsndfile/examples/sndfilehandle.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007 Erik de Castro Lopo +** Copyright (C) 2007-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/libsndfile.spec.in b/libs/libsndfile/libsndfile.spec.in index ad47a5f3f8..d4427289a2 100644 --- a/libs/libsndfile/libsndfile.spec.in +++ b/libs/libsndfile/libsndfile.spec.in @@ -10,7 +10,7 @@ Release: %{release} Copyright: LGPL Group: Libraries/Sound Source: http://www.mega-nerd.com/libsndfile/libsndfile-%{version}.tar.gz -URL: http://www.mega-nerd.com/libsndfile/ +Url: http://www.mega-nerd.com/libsndfile/ BuildRoot: /var/tmp/%{name}-%{version} %description diff --git a/libs/libsndfile/make_lite.py b/libs/libsndfile/make_lite.py new file mode 100644 index 0000000000..eee69fc82d --- /dev/null +++ b/libs/libsndfile/make_lite.py @@ -0,0 +1,491 @@ +#!/usr/bin/python + +import commands, os, re, string, sys, time + +def count_enclosed_functions (source): + func_count = 0 + open_brace = 0 + close_brace = 0 + for ch in source: + if ch == '{': + open_brace += 1 + elif ch == '}': + close_brace += 1 + if open_brace == close_brace: + func_count += 1 + if open_brace < close_brace: + print "count_enclosed_functions : open_brace < close_brace" + return -1 + return func_count + +def find_function_prototype (source, proto_name): + proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name) + proto_result = re.search (proto_re, source, re.MULTILINE | re.DOTALL) + if not proto_result: + return None + proto_text = proto_result.groups ()[0] + return proto_text + +def find_function_definition (source, func_name): + func_re = "(\n[a-zA-Z_ \t]+\n%s[^a-zA-Z0-9_].* /\* %s \*/\n)" % (func_name, func_name) + func_result = re.search (func_re, source, re.MULTILINE | re.DOTALL) + if not func_result: + sys.exit (1) + return None + func_text = func_result.groups ()[0] + + # Now to check that we only have one enclosing function. + func_count = count_enclosed_functions (func_text) + if func_count != 1: + return None + return func_text + +def find_include (source, inc_name): + inc_re = "(^#include\s+[\<\"]%s[\"\>]\s*)" % inc_name + inc_result = re.search (inc_re, source, re.MULTILINE | re.DOTALL) + if not inc_result: + return None + inc_text = inc_result.groups ()[0] + return inc_text + +def find_assign_statement (source, var_name): + var_re = "(^\s+%s\s*=[^;]+;)" % var_name + var_result = re.search (var_re, source, re.MULTILINE | re.DOTALL) + if not var_result: + return None + assign_text = var_result.groups ()[0] + return assign_text + +#-------------------------------------------------------------------------------- + +def remove_include (source, inc_name): + inc_text = find_include (source, inc_name) + if not inc_text: + print "remove_include : include '%s' not found. Exiting." % inc_name + sys.exit (1) + + source = string.replace (source, inc_text, "") + return source + +def remove_assign (source, assign_name): + assign_text = find_assign (source, inc_name) + if not inc_text: + print "remove_include : include '%s' not found. Exiting." % inc_name + sys.exit (1) + + source = string.replace (source, inc_text, "") + return source + +def remove_prototype (source, proto_name): + proto_text = find_function_prototype (source, proto_name) + if not proto_text: + print "remove_prototype : prototype '%s' not found. Exiting." % proto_name + sys.exit (1) + + source = string.replace (source, proto_text, "") + return source + +def remove_function (source, func_name): + func_text = find_function_definition (source, func_name) + if not func_text: + print "remove_function : function '%s' not found. Exiting." % func_name + sys.exit (1) + + source = string.replace (source, func_text, "/* Function %s() removed here. */\n" % func_name) + return source + +def remove_all_assignments (source, var): + count = 0 + while 1: + assign_text = find_assign_statement (source, var) + if not assign_text: + if count != 0: + break + print "remove_all_assignments : variable '%s' not found. Exiting." % var + sys.exit (1) + + source = string.replace (source, assign_text, "") + count += 1 + return source + + + +#---------------------------------------------------------------- + +def remove_funcs_and_protos_from_file (filename, func_list): + source_code = open (filename, 'r').read () + + for func in func_list: + source_code = remove_prototype (source_code, func) ; + source_code = remove_function (source_code, func) ; + open (filename, 'w').write (source_code) + +def remove_funcs_from_file (filename, func_list): + source_code = open (filename, 'r').read () + + for func in func_list: + source_code = remove_function (source_code, func) ; + open (filename, 'w').write (source_code) + +def remove_protos_from_file (filename, func_list): + source_code = open (filename, 'r').read () + + for func in func_list: + source_code = remove_prototype (source_code, func) ; + open (filename, 'w').write (source_code) + +def remove_includes_from_file (filename, inc_list): + source_code = open (filename, 'r').read () + + for inc in inc_list: + source_code = remove_include (source_code, inc) ; + open (filename, 'w').write (source_code) + +def remove_all_assignments_from_file (filename, var_list): + source_code = open (filename, 'r').read () + + for var in var_list: + source_code = remove_all_assignments (source_code, var) ; + open (filename, 'w').write (source_code) + +def remove_comment_start_end (filename, start_comment, end_comment): + source_code = open (filename, 'r').read () + + while 1: + start_index = string.find (source_code, start_comment) + end_index = string.find (source_code, end_comment) + if start_index < 0 or end_index < start_index: + break + end_index += len (end_comment) + source_code = source_code [:start_index-1] + source_code [end_index:] ; + + open (filename, 'w').write (source_code) + +def remove_strings_from_file (filename, str_list): + file_text = open (filename, 'r').read () + for current_str in str_list: + file_text = string.replace (file_text, current_str, '') + open (filename, 'w').write (file_text) + +def string_replace_in_file (filename, from_str, to_str): + file_text = open (filename, 'r').read () + file_text = string.replace (file_text, from_str, to_str) + open (filename, 'w').write (file_text) + +def remove_regex_from_file (filename, regex_list): + file_text = open (filename, 'r').read () + for regex in regex_list: + file_text = re.sub (regex, '', file_text, re.MULTILINE | re.DOTALL) + open (filename, 'w').write (file_text) + +#========================================================================== + +def find_configure_version (filename): + # AM_INIT_AUTOMAKE(libsndfile,0.0.21pre6) + file = open (filename) + while 1: + line = file.readline () + if re.search ("AC_INIT", line): + x = re.sub ("[^\(]+\(", "", line) + x = re.sub ("\).*\n", "", x) + x = string.split (x, ",") + package = x [0] + version = x [1] + break + file.close () + # version = re.escape (version) + return package, version + +def fix_configure_ac_file (filename): + data = open (filename, 'r').read () + data = string.replace (data, "AM_INIT_AUTOMAKE(libsndfile,", "AM_INIT_AUTOMAKE(libsndfile_lite,", 1) + + file = open (filename, 'w') + file.write (data) + file.close () + + +def make_dist_file (package, version): + print "Making dist file." + tar_gz_file = "%s-%s.tar.gz" % (package, version) + if os.path.exists (tar_gz_file): + return + if os.system ("make dist"): + sys.exit (1) + return + +def delete_files (file_list): + for file_name in file_list: + os.remove (file_name) + +#======================================================================= + +source_dir = os.getcwd () + +conf_package, conf_version = find_configure_version ('configure.ac') + +package_version = "%s-%s" % (conf_package, conf_version) +lite_version = "%s_lite-%s" % (conf_package, conf_version) + +os.system ("rm -rf %s%s.tar.gz" % (source_dir, package_version)) + +os.system ("make dist") + +make_dist_file (conf_package, conf_version) + +os.chdir ("/tmp") + +print "Uncompressing .tar.gz file." +os.system ("rm -rf %s" % package_version) +if os.system ("tar zxf %s/%s.tar.gz" % (source_dir, package_version)): + sys.exit (1) + + +print "Renaming to libsndfile_lite." +os.system ("rm -rf %s" % lite_version) +os.rename (package_version, lite_version) + +print "Changing into libsndfile_lite directory." +os.chdir (lite_version) + +print "Removing un-neeed directories." +delete_dirs = [ 'src/G72x' ] + +for dir_name in delete_dirs: + os.system ("rm -rf %s" % dir_name) + +print "Removing un-needed files." +delete_files ([ 'src/ircam.c', 'src/nist.c', + 'src/ima_adpcm.c', 'src/ms_adpcm.c', 'src/au_g72x.c', + 'src/mat4.c', 'src/mat5.c', 'src/dwvw.c', 'src/paf.c', + 'src/ogg.c', 'src/pvf.c', 'src/xi.c', 'src/htk.c', + 'src/sd2.c', 'src/rx2.c', 'src/txw.c', 'src/wve.c', + 'src/dwd.c', 'src/svx.c', 'src/voc.c', 'src/vox_adpcm.c', + 'src/sds.c' + ]) + + +print "Hacking 'configure.ac' and 'src/Makefile.am'." +remove_strings_from_file ('configure.ac', [ 'src/G72x/Makefile' ]) +remove_strings_from_file ('src/Makefile.am', [ 'G72x/libg72x.la', 'G72x', + 'ircam.c', 'nist.c', 'ima_adpcm.c', 'ms_adpcm.c', 'au_g72x.c', 'mat4.c', + 'mat5.c', 'dwvw.c', 'paf.c', 'ogg.c', 'pvf.c', 'xi.c', 'htk.c', + 'sd2.c', 'rx2.c', 'txw.c', 'wve.c', 'dwd.c', 'svx.c', 'voc.c', + 'vox_adpcm.c', 'sds.c' + ]) + +#---------------------------------------------------------------------------- + +print "Hacking header files." + +remove_protos_from_file ('src/common.h', [ 'xi_open', 'sd2_open', 'ogg_open', + 'dwvw_init', 'paf_open', 'svx_open', 'nist_open', 'rx2_open', 'mat4_open', + 'voc_open', 'txw_open', 'dwd_open', 'htk_open', 'wve_open', 'mat5_open', + 'pvf_open', 'ircam_open', 'sds_open', + 'float32_init', 'double64_init', 'aiff_ima_init', 'vox_adpcm_init', + 'wav_w64_ima_init', 'wav_w64_msadpcm_init' + ]) + +remove_protos_from_file ('src/au.h', + [ 'au_g72x_reader_init', 'au_g72x_writer_init' ]) + +remove_protos_from_file ('src/wav_w64.h', [ 'msadpcm_write_adapt_coeffs' ]) + +#---------------------------------------------------------------------------- + +print "Hacking case statements." + +remove_comment_start_end ('src/sndfile.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/aiff.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/au.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/raw.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/w64.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/wav.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/double64.c', '/* Lite remove start */' , '/* Lite remove end */') +remove_comment_start_end ('src/float32.c', '/* Lite remove start */' , '/* Lite remove end */') + + +#---------------------------------------------------------------------------- + +print "Hacking src/pcm.c." +remove_funcs_from_file ('src/pcm.c', [ + 'f2sc_array', 'f2sc_clip_array', 'f2uc_array', 'f2uc_clip_array', + 'f2bes_array', 'f2bes_clip_array', 'f2les_array', 'f2les_clip_array', + 'f2let_array', 'f2let_clip_array', 'f2bet_array', 'f2bet_clip_array', + 'f2bei_array', 'f2bei_clip_array', 'f2lei_array', 'f2lei_clip_array', + 'd2sc_array', 'd2sc_clip_array', 'd2uc_array', 'd2uc_clip_array', + 'd2bes_array', 'd2bes_clip_array', 'd2les_array', 'd2les_clip_array', + 'd2let_array', 'd2let_clip_array', 'd2bet_array', 'd2bet_clip_array', + 'd2bei_array', 'd2bei_clip_array', 'd2lei_array', 'd2lei_clip_array', + ]) + +remove_funcs_and_protos_from_file ('src/pcm.c', [ + 'pcm_read_sc2f', 'pcm_read_uc2f', 'pcm_read_les2f', 'pcm_read_bes2f', + 'pcm_read_let2f', 'pcm_read_bet2f', 'pcm_read_lei2f', 'pcm_read_bei2f', + 'pcm_read_sc2d', 'pcm_read_uc2d', 'pcm_read_les2d', 'pcm_read_bes2d', + 'pcm_read_let2d', 'pcm_read_bet2d', 'pcm_read_lei2d', 'pcm_read_bei2d', + 'pcm_write_f2sc', 'pcm_write_f2uc', 'pcm_write_f2bes', 'pcm_write_f2les', + 'pcm_write_f2bet', 'pcm_write_f2let', 'pcm_write_f2bei', 'pcm_write_f2lei', + 'pcm_write_d2sc', 'pcm_write_d2uc', 'pcm_write_d2bes', 'pcm_write_d2les', + 'pcm_write_d2bet', 'pcm_write_d2let', 'pcm_write_d2bei', 'pcm_write_d2lei', + + 'sc2f_array', 'uc2f_array', 'bes2f_array', 'les2f_array', + 'bet2f_array', 'let2f_array', 'bei2f_array', 'lei2f_array', + 'sc2d_array', 'uc2d_array', 'bes2d_array', 'les2d_array', + 'bet2d_array', 'let2d_array', 'bei2d_array', 'lei2d_array' + ]) + +remove_includes_from_file ('src/pcm.c', [ 'float_cast.h' ]) +remove_all_assignments_from_file ('src/pcm.c', [ + 'psf-\>write_float', 'psf\-\>write_double', + 'psf-\>read_float', 'psf\-\>read_double' ]) + +#---------------------------------------------------------------------------- +print "Hacking src/ulaw.c." +remove_funcs_and_protos_from_file ('src/ulaw.c', [ + 'ulaw_read_ulaw2f', 'ulaw_read_ulaw2d', + 'ulaw_write_f2ulaw', 'ulaw_write_d2ulaw', + 'ulaw2f_array', 'ulaw2d_array', 'f2ulaw_array', 'd2ulaw_array' + ]) + +remove_includes_from_file ('src/ulaw.c', [ 'float_cast.h' ]) +remove_all_assignments_from_file ('src/ulaw.c', [ + 'psf-\>write_float', 'psf\-\>write_double', + 'psf-\>read_float', 'psf\-\>read_double' ]) + +#---------------------------------------------------------------------------- + +print "Hacking src/alaw.c." +remove_funcs_and_protos_from_file ('src/alaw.c', [ + 'alaw_read_alaw2f', 'alaw_read_alaw2d', + 'alaw_write_f2alaw', 'alaw_write_d2alaw', + 'alaw2f_array', 'alaw2d_array', 'f2alaw_array', 'd2alaw_array' + ]) + +remove_includes_from_file ('src/alaw.c', [ 'float_cast.h' ]) +remove_all_assignments_from_file ('src/alaw.c', [ + 'psf-\>write_float', 'psf\-\>write_double', + 'psf-\>read_float', 'psf\-\>read_double' ]) + +#---------------------------------------------------------------------------- + +print "Hacking src/gsm610.c." +remove_funcs_and_protos_from_file ('src/gsm610.c', [ + 'gsm610_read_f', 'gsm610_read_d', 'gsm610_write_f', 'gsm610_write_d' + ]) + +remove_includes_from_file ('src/gsm610.c', [ 'float_cast.h' ]) +remove_all_assignments_from_file ('src/gsm610.c', [ + 'psf-\>write_float', 'psf\-\>write_double', + 'psf-\>read_float', 'psf\-\>read_double' ]) + +#---------------------------------------------------------------------------- + +print "Hacking src/float32.c." + +# string_replace_in_file ('src/float32.c', '"float_cast.h"', '') +remove_funcs_from_file ('src/float32.c', [ 'float32_init' ]) + +remove_funcs_and_protos_from_file ('src/float32.c', [ + 'host_read_f2s', 'host_read_f2i', 'host_read_f', 'host_read_f2d', + 'host_write_s2f', 'host_write_i2f', 'host_write_f', 'host_write_d2f', + 'f2s_array', 'f2i_array', 'f2d_array', 's2f_array', 'i2f_array', 'd2f_array', + 'float32_peak_update', + 'replace_read_f2s', 'replace_read_f2i', 'replace_read_f', 'replace_read_f2d', + 'replace_write_s2f', 'replace_write_i2f', 'replace_write_f', 'replace_write_d2f', + 'bf2f_array', 'f2bf_array', + 'float32_get_capability', + ]) + +#---------------------------------------------------------------------------- + +print "Hacking src/double64.c." +remove_funcs_from_file ('src/double64.c', [ 'double64_init' ]) + +remove_funcs_and_protos_from_file ('src/double64.c', [ + 'host_read_d2s', 'host_read_d2i', 'host_read_d2f', 'host_read_d', + 'host_write_s2d', 'host_write_i2d', 'host_write_f2d', 'host_write_d', + 'd2s_array', 'd2i_array', 'd2f_array', + 's2d_array', 'i2d_array', 'f2d_array', + 'double64_peak_update', 'double64_get_capability', + 'replace_read_d2s', 'replace_read_d2i', 'replace_read_d2f', 'replace_read_d', + 'replace_write_s2d', 'replace_write_i2d', 'replace_write_f2d', 'replace_write_d', + 'd2bd_read', 'bd2d_write' + ]) + +#---------------------------------------------------------------------------- + +print "Hacking test programs." +delete_files ([ 'tests/dwvw_test.c', 'tests/floating_point_test.c', + 'tests/dft_cmp.c', 'tests/peak_chunk_test.c', + 'tests/scale_clip_test.tpl', 'tests/scale_clip_test.def' + ]) + +remove_comment_start_end ('tests/write_read_test.def', '/* Lite remove start */', '/* Lite remove end */') +remove_comment_start_end ('tests/write_read_test.tpl', '/* Lite remove start */', '/* Lite remove end */') + +remove_comment_start_end ('tests/Makefile.am', '# Lite remove start', '# Lite remove end') + +remove_strings_from_file ('tests/Makefile.am', [ + 'scale_clip_test.tpl', 'scale_clip_test.def', + '\n\t./dwvw_test', + '\n\t./floating_point_test', '\n\t./scale_clip_test', + '\n\t./peak_chunk_test aiff', '\n\t./peak_chunk_test wav', + '\n\t./command_test norm', '\n\t./command_test peak', + '\n\t./lossy_comp_test wav_ima', '\n\t./lossy_comp_test wav_msadpcm', + '\n\t./lossy_comp_test au_g721', '\n\t./lossy_comp_test au_g723', + '\n\t./lossy_comp_test vox_adpcm', + '\n\t./lossy_comp_test w64_ima', '\n\t./lossy_comp_test w64_msadpcm', + 'peak_chunk_test', 'dwvw_test', 'floating_point_test', 'scale_clip_test', + + 'paf-tests', 'svx-tests', 'nist-tests', 'ircam-tests', 'voc-tests', + 'mat4-tests', 'mat5-tests', 'pvf-tests', 'xi-tests', 'htk-tests', + 'sds-tests' + ]) + +remove_comment_start_end ('tests/pcm_test.c', '/* Lite remove start */', '/* Lite remove end */') +remove_funcs_and_protos_from_file ('tests/pcm_test.c', [ + 'pcm_test_float', 'pcm_test_double' + ]) + +remove_comment_start_end ('tests/lossy_comp_test.c', '/* Lite remove start */', '/* Lite remove end */') +remove_funcs_and_protos_from_file ('tests/lossy_comp_test.c', [ + 'lcomp_test_float', 'lcomp_test_double', 'sdlcomp_test_float', 'sdlcomp_test_double', + 'smoothed_diff_float', 'smoothed_diff_double' + ]) + +remove_comment_start_end ('tests/multi_file_test.c', '/* Lite remove start */', '/* Lite remove end */') + +remove_strings_from_file ('tests/stdio_test.c', [ + '"paf",', '"svx",', '"nist",', '"ircam",', '"voc",', '"mat4",', '"mat5",', '"pvf",' + ]) + +remove_comment_start_end ('tests/pipe_test.c', '/* Lite remove start */', '/* Lite remove end */') + +#---------------------------------------------------------------------------- + +print "Fixing configure.ac file." +fix_configure_ac_file ('configure.ac') + +print "Building and testing source." + # Try --disable-shared --disable-gcc-opt +if os.system ("./reconfigure.mk && ./configure --disable-shared --disable-gcc-opt && make check"): + os.system ('PS1="FIX > " bash --norc') + sys.exit (1) + +print "Making distcheck" +if os.system ("make distcheck"): + os.system ('PS1="FIX > " bash --norc') + sys.exit (1) + +print "Copying tarball" +if os.system ("cp %s.tar.gz %s" % (lite_version, source_dir)): + print "??? %s.tar.gz ???" % lite_version + os.system ('PS1="FIX > " bash --norc') + sys.exit (1) + +os.chdir (source_dir) + +os.system ("rm -rf /tmp/%s" % lite_version) + +print "Done." diff --git a/libs/libsndfile/man/Makefile.am b/libs/libsndfile/man/Makefile.am index 574f924841..3f5d9efdc4 100644 --- a/libs/libsndfile/man/Makefile.am +++ b/libs/libsndfile/man/Makefile.am @@ -1,6 +1,15 @@ ## Process this file with automake to produce Makefile.in -man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 +man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \ + sndfile-metadata-get.1 sndfile-metadata-set.1 sndfile-concat.1 \ + sndfile-interleave.1 sndfile-deinterleave.1 -EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 +EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \ + sndfile-metadata-get.1 sndfile-concat.1 sndfile-interleave.1 +# Same manpage for both programs. +sndfile-metadata-set.1 : sndfile-metadata-get.1 + $(LN_S) $(srcdir)/sndfile-metadata-get.1 $@ + +sndfile-deinterleave.1 : sndfile-interleave.1 + $(LN_S) $(srcdir)/sndfile-interleave.1 $@ diff --git a/libs/libsndfile/man/sndfile-cmp.1 b/libs/libsndfile/man/sndfile-cmp.1 new file mode 100644 index 0000000000..30870bdfc3 --- /dev/null +++ b/libs/libsndfile/man/sndfile-cmp.1 @@ -0,0 +1,16 @@ +.TH SNDFILE-CMP 1 "October 5, 2009" +.SH NAME +sndfile-cmp \- compares two audio files +.SH SYNOPSIS +.B sndfile-cmp +.RI "file1 file2" +.SH DESCRIPTION +sndfile-cmp compares the audio data of two sound files. In particular most +differences in the audio file header, particularly metadata like string info, +are completely ignored. + +sndfile-cmp does its work using libsndfile +(http://www.mega-nerd.com/libsndfile/). +.SH AUTHOR +This manual page was written by Erik de Castro Lopo . + diff --git a/libs/libsndfile/man/sndfile-concat.1 b/libs/libsndfile/man/sndfile-concat.1 new file mode 100644 index 0000000000..1d95765f6c --- /dev/null +++ b/libs/libsndfile/man/sndfile-concat.1 @@ -0,0 +1,16 @@ +.TH SNDFILE-CONCAT 1 "December 9, 2009" +.SH NAME +sndfile-concat \- concatenates two or more audio files +.SH SYNOPSIS +.B sndfile-concat +.RI "infile1 infile2 .... outfile" +.SH DESCRIPTION +sndfile-concat generates a new output file by concatenating two or more input +files. The format of the output file is the same as the format of the input +file. + +sndfile-concat does its work using libsndfile +(http://www.mega-nerd.com/libsndfile/). +.SH AUTHOR +This manual page was written by Erik de Castro Lopo . + diff --git a/libs/libsndfile/man/sndfile-convert.1 b/libs/libsndfile/man/sndfile-convert.1 index 7847173656..583c9562c9 100644 --- a/libs/libsndfile/man/sndfile-convert.1 +++ b/libs/libsndfile/man/sndfile-convert.1 @@ -16,7 +16,7 @@ The format of the output file is determined by the filename extension of the output file. .LP The optional encoding parameter allows setting of the data encoding for -the output file. Run "sndfile-convert --help" for more information. +the output file. Run "sndfile\-convert \-\-help" for more information. .SH AUTHOR This manual page was written by Erik de Castro Lopo . diff --git a/libs/libsndfile/man/sndfile-interleave.1 b/libs/libsndfile/man/sndfile-interleave.1 new file mode 100644 index 0000000000..26ca345205 --- /dev/null +++ b/libs/libsndfile/man/sndfile-interleave.1 @@ -0,0 +1,23 @@ +.TH SNDFILE-INTERLEAVE 1 "December 14, 2009" +.SH NAME +sndfile-interleave \- convert multiple single channel files into a multi-channel file +.br +sndfile-deinterleave \- split a multi-channel into multiple single channel files +.SH SYNOPSIS +.B sndfile-interleave +.RI " ... -o " +.br +.B sndfile-deinterleave +.RI "filename" + +.SH DESCRIPTION +sndfile-interleave and sndfile-deinterleave use libsndfile +(http://www.mega-nerd.com/libsndfile/) to convert back and forth between multiple +single channel files and a single multi-channel sound file. + +Run "sndfile\-interleave \-\-help" or "sndfile\-deinterleave \-\-help" for +more information + +.SH AUTHOR +This manual page was written by Erik de Castro Lopo . + diff --git a/libs/libsndfile/man/sndfile-metadata-get.1 b/libs/libsndfile/man/sndfile-metadata-get.1 new file mode 100644 index 0000000000..b97560ea39 --- /dev/null +++ b/libs/libsndfile/man/sndfile-metadata-get.1 @@ -0,0 +1,26 @@ +.TH SNDFILE-METADATA-GET 1 "October 6, 2009" +.SH NAME +sndfile-metadata-get \- retrieve metadata from a sound file +.br +sndfile-metadata-set \- set metadata in a sound file +.SH SYNOPSIS +.B sndfile-metadata-get +.RI "[options] file" +.br +.B sndfile-metadata-set +.RI "[options] file" +.br +.B sndfile-metadata-set +.RI "[options] input-file output-file" + +.SH DESCRIPTION +sndfile-metadata-get and sndfile-metadata-set use libsndfile +(http://www.mega-nerd.com/libsndfile/) to retrieve metadata from or set metadata +in a sound file. + +Run "sndfile\-metadata\-get \-\-help" or "sndfile\-metadata\-set \-\-help" for +more information + +.SH AUTHOR +This manual page was written by Erik de Castro Lopo . + diff --git a/libs/libsndfile/programs/Makefile.am b/libs/libsndfile/programs/Makefile.am index 5a3f9ee32b..81495539b3 100644 --- a/libs/libsndfile/programs/Makefile.am +++ b/libs/libsndfile/programs/Makefile.am @@ -1,36 +1,47 @@ ## Process this file with automake to produce Makefile.in -bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-jackplay sndfile-cmp \ - sndfile-metadata-set sndfile-metadata-get +bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-cmp \ + sndfile-metadata-set sndfile-metadata-get sndfile-interleave \ + sndfile-deinterleave sndfile-concat sndfile-salvage OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@ OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@ -INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS) + +CLEANFILES = *~ sndfile-*.exe # This is the BeOS version of sndfile-play. It needs to be compiled with the C++ # compiler. EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py -sndfile_info_SOURCES = sndfile-info.c +sndfile_info_SOURCES = sndfile-info.c common.c common.h sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la -sndfile_play_SOURCES = sndfile-play.c -sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS) - -sndfile_jackplay_SOURCES = sndfile-jackplay.c -sndfile_jackplay_CFLAGS = $(JACK_CFLAGS) -sndfile_jackplay_LDADD = $(top_builddir)/src/libsndfile.la $(JACK_LIBS) +sndfile_play_SOURCES = sndfile-play.c common.c common.h +sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS) $(SNDIO_LIBS) sndfile_convert_SOURCES = sndfile-convert.c common.c common.h sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la -sndfile_cmp_SOURCES = sndfile-cmp.c +sndfile_cmp_SOURCES = sndfile-cmp.c common.c common.h sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la -sndfile_metadata_get_SOURCES = sndfile-metadata-get.c +sndfile_metadata_get_SOURCES = sndfile-metadata-get.c common.c common.h sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la +sndfile_interleave_SOURCES = sndfile-interleave.c common.c common.h +sndfile_interleave_LDADD = $(top_builddir)/src/libsndfile.la + +sndfile_deinterleave_SOURCES = sndfile-deinterleave.c common.c common.h +sndfile_deinterleave_LDADD = $(top_builddir)/src/libsndfile.la + +sndfile_concat_SOURCES = sndfile-concat.c common.c common.h +sndfile_concat_LDADD = $(top_builddir)/src/libsndfile.la + +sndfile_salvage_SOURCES = sndfile-salvage.c common.c common.h +sndfile_salvage_LDADD = $(top_builddir)/src/libsndfile.la + diff --git a/libs/libsndfile/programs/common.c b/libs/libsndfile/programs/common.c index d38d7472ad..2811536f3f 100644 --- a/libs/libsndfile/programs/common.c +++ b/libs/libsndfile/programs/common.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** Copyright (C) 2008 George Blood Audio ** ** All rights reserved. @@ -35,17 +35,18 @@ #include #include #include +#include #include #include "common.h" -#define BUFFER_LEN 4096 +#define BUFFER_LEN 4096 -#define MIN(x,y) ((x) < (y) ? (x) : (y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) void -sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) +sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize) { static double data [BUFFER_LEN], max ; int frames, readcount, k ; @@ -54,7 +55,7 @@ sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ; - if (max < 1.0) + if (!normalize && max < 1.0) { while (readcount > 0) { readcount = sf_readf_double (infile, data, frames) ; sf_writef_double (outfile, data, readcount) ; @@ -146,6 +147,14 @@ merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const MET REPLACE_IF_NEW (origination_time) ; REPLACE_IF_NEW (umid) ; + /* Special case for Time Ref. */ + if (info->time_ref != NULL) + { uint64_t ts = atoll (info->time_ref) ; + + binfo.time_reference_high = (ts >> 32) ; + binfo.time_reference_low = (ts & 0xffffffff) ; + } ; + /* Special case for coding_history because we may want to append. */ if (info->coding_history != NULL) { if (info->coding_hist_append) @@ -180,22 +189,22 @@ update_strings (SNDFILE * outfile, const METADATA_INFO * info) sf_set_string (outfile, SF_STR_TITLE, info->title) ; if (info->copyright != NULL) - sf_set_string (outfile, SF_STR_TITLE, info->copyright) ; + sf_set_string (outfile, SF_STR_COPYRIGHT, info->copyright) ; if (info->artist != NULL) sf_set_string (outfile, SF_STR_ARTIST, info->artist) ; if (info->comment != NULL) - sf_set_string (outfile, SF_STR_TITLE, info->comment) ; + sf_set_string (outfile, SF_STR_COMMENT, info->comment) ; if (info->date != NULL) sf_set_string (outfile, SF_STR_DATE, info->date) ; if (info->album != NULL) - sf_set_string (outfile, SF_STR_TITLE, info->album) ; + sf_set_string (outfile, SF_STR_ALBUM, info->album) ; if (info->license != NULL) - sf_set_string (outfile, SF_STR_TITLE, info->license) ; + sf_set_string (outfile, SF_STR_LICENSE, info->license) ; } /* update_strings */ @@ -238,18 +247,18 @@ sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * in goto cleanup_exit ; } ; - update_strings (outfile, info) ; - if (infile != outfile) { int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ; /* If the input file is not the same as the output file, copy the data. */ if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)) - sfe_copy_data_fp (outfile, infile, sfinfo.channels) ; + sfe_copy_data_fp (outfile, infile, sfinfo.channels, SF_FALSE) ; else sfe_copy_data_int (outfile, infile, sfinfo.channels) ; } ; + update_strings (outfile, info) ; + cleanup_exit : if (outfile != NULL && outfile != infile) @@ -264,3 +273,194 @@ cleanup_exit : return ; } /* sfe_apply_metadata_changes */ +/*============================================================================== +*/ + +typedef struct +{ const char *ext ; + int len ; + int format ; +} OUTPUT_FORMAT_MAP ; + +static OUTPUT_FORMAT_MAP format_map [] = +{ + { "aif", 3, SF_FORMAT_AIFF }, + { "wav", 0, SF_FORMAT_WAV }, + { "au", 0, SF_FORMAT_AU }, + { "caf", 0, SF_FORMAT_CAF }, + { "flac", 0, SF_FORMAT_FLAC }, + { "snd", 0, SF_FORMAT_AU }, + { "svx", 0, SF_FORMAT_SVX }, + { "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF }, + { "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF }, + { "gsm", 0, SF_FORMAT_RAW }, + { "nist", 0, SF_FORMAT_NIST }, + { "htk", 0, SF_FORMAT_HTK }, + { "ircam", 0, SF_FORMAT_IRCAM }, + { "sf", 0, SF_FORMAT_IRCAM }, + { "voc", 0, SF_FORMAT_VOC }, + { "w64", 0, SF_FORMAT_W64 }, + { "raw", 0, SF_FORMAT_RAW }, + { "mat4", 0, SF_FORMAT_MAT4 }, + { "mat5", 0, SF_FORMAT_MAT5 }, + { "mat", 0, SF_FORMAT_MAT4 }, + { "pvf", 0, SF_FORMAT_PVF }, + { "sds", 0, SF_FORMAT_SDS }, + { "sd2", 0, SF_FORMAT_SD2 }, + { "vox", 0, SF_FORMAT_RAW }, + { "xi", 0, SF_FORMAT_XI }, + { "wve", 0, SF_FORMAT_WVE }, + { "oga", 0, SF_FORMAT_OGG }, + { "ogg", 0, SF_FORMAT_OGG }, + { "mpc", 0, SF_FORMAT_MPC2K }, + { "rf64", 0, SF_FORMAT_RF64 }, +} ; /* format_map */ + +int +sfe_file_type_of_ext (const char *str, int format) +{ char buffer [16], *cptr ; + int k ; + + format &= SF_FORMAT_SUBMASK ; + + if ((cptr = strrchr (str, '.')) == NULL) + return 0 ; + + strncpy (buffer, cptr + 1, 15) ; + buffer [15] = 0 ; + + for (k = 0 ; buffer [k] ; k++) + buffer [k] = tolower ((buffer [k])) ; + + if (strcmp (buffer, "gsm") == 0) + return SF_FORMAT_RAW | SF_FORMAT_GSM610 ; + + if (strcmp (buffer, "vox") == 0) + return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ; + + for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++) + { if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0) + return format_map [k].format | format ; + else if (strcmp (buffer, format_map [k].ext) == 0) + return format_map [k].format | format ; + } ; + + /* Default if all the above fails. */ + return (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ; +} /* sfe_file_type_of_ext */ + +void +sfe_dump_format_map (void) +{ SF_FORMAT_INFO info ; + int k ; + + for (k = 0 ; k < ARRAY_LEN (format_map) ; k++) + { info.format = format_map [k].format ; + sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ; + printf (" %-10s : %s\n", format_map [k].ext, info.name == NULL ? "????" : info.name) ; + } ; + +} /* sfe_dump_format_map */ + +const char * +program_name (const char * argv0) +{ const char * tmp ; + + tmp = strrchr (argv0, '/') ; + argv0 = tmp ? tmp + 1 : argv0 ; + + tmp = strrchr (argv0, '/') ; + argv0 = tmp ? tmp + 1 : argv0 ; + + /* Remove leading libtool name mangling. */ + if (strstr (argv0, "lt-") == argv0) + return argv0 + 3 ; + + return argv0 ; +} /* program_name */ + +const char * +sfe_endian_name (int format) +{ + switch (format & SF_FORMAT_ENDMASK) + { case SF_ENDIAN_FILE : return "file" ; + case SF_ENDIAN_LITTLE : return "little" ; + case SF_ENDIAN_BIG : return "big" ; + case SF_ENDIAN_CPU : return "cpu" ; + default : break ; + } ; + + return "unknown" ; +} /* sfe_endian_name */ + +const char * +sfe_container_name (int format) +{ + switch (format & SF_FORMAT_TYPEMASK) + { case SF_FORMAT_WAV : return "WAV" ; + case SF_FORMAT_AIFF : return "AIFF" ; + case SF_FORMAT_AU : return "AU" ; + case SF_FORMAT_RAW : return "RAW" ; + case SF_FORMAT_PAF : return "PAF" ; + case SF_FORMAT_SVX : return "SVX" ; + case SF_FORMAT_NIST : return "NIST" ; + case SF_FORMAT_VOC : return "VOC" ; + case SF_FORMAT_IRCAM : return "IRCAM" ; + case SF_FORMAT_W64 : return "W64" ; + case SF_FORMAT_MAT4 : return "MAT4" ; + case SF_FORMAT_MAT5 : return "MAT5" ; + case SF_FORMAT_PVF : return "PVF" ; + case SF_FORMAT_XI : return "XI" ; + case SF_FORMAT_HTK : return "HTK" ; + case SF_FORMAT_SDS : return "SDS" ; + case SF_FORMAT_AVR : return "AVR" ; + case SF_FORMAT_WAVEX : return "WAVEX" ; + case SF_FORMAT_SD2 : return "SD2" ; + case SF_FORMAT_FLAC : return "FLAC" ; + case SF_FORMAT_CAF : return "CAF" ; + case SF_FORMAT_WVE : return "WVE" ; + case SF_FORMAT_OGG : return "OGG" ; + case SF_FORMAT_MPC2K : return "MPC2K" ; + case SF_FORMAT_RF64 : return "RF64" ; + default : break ; + } ; + + return "unknown" ; +} /* sfe_container_name */ + +const char * +sfe_codec_name (int format) +{ + switch (format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_PCM_S8 : return "signed 8 bit PCM" ; + case SF_FORMAT_PCM_16 : return "16 bit PCM" ; + case SF_FORMAT_PCM_24 : return "24 bit PCM" ; + case SF_FORMAT_PCM_32 : return "32 bit PCM" ; + case SF_FORMAT_PCM_U8 : return "unsigned 8 bit PCM" ; + case SF_FORMAT_FLOAT : return "32 bit float" ; + case SF_FORMAT_DOUBLE : return "64 bit double" ; + case SF_FORMAT_ULAW : return "u-law" ; + case SF_FORMAT_ALAW : return "a-law" ; + case SF_FORMAT_IMA_ADPCM : return "IMA ADPCM" ; + case SF_FORMAT_MS_ADPCM : return "MS ADPCM" ; + case SF_FORMAT_GSM610 : return "gsm610" ; + case SF_FORMAT_VOX_ADPCM : return "Vox ADPCM" ; + case SF_FORMAT_G721_32 : return "g721 32kbps" ; + case SF_FORMAT_G723_24 : return "g723 24kbps" ; + case SF_FORMAT_G723_40 : return "g723 40kbps" ; + case SF_FORMAT_DWVW_12 : return "12 bit DWVW" ; + case SF_FORMAT_DWVW_16 : return "16 bit DWVW" ; + case SF_FORMAT_DWVW_24 : return "14 bit DWVW" ; + case SF_FORMAT_DWVW_N : return "DWVW" ; + case SF_FORMAT_DPCM_8 : return "8 bit DPCM" ; + case SF_FORMAT_DPCM_16 : return "16 bit DPCM" ; + case SF_FORMAT_VORBIS : return "Vorbis" ; + case SF_FORMAT_ALAC_16 : return "16 bit ALAC" ; + case SF_FORMAT_ALAC_20 : return "20 bit ALAC" ; + case SF_FORMAT_ALAC_24 : return "24 bit ALAC" ; + case SF_FORMAT_ALAC_32 : return "32 bit ALAC" ; + default : break ; + } ; + return "unknown" ; +} /* sfe_codec_name */ + diff --git a/libs/libsndfile/programs/common.h b/libs/libsndfile/programs/common.h index dd4d54dd87..eda2d7d743 100644 --- a/libs/libsndfile/programs/common.h +++ b/libs/libsndfile/programs/common.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** All rights reserved. ** @@ -30,7 +30,9 @@ ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include + +#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof (x [0]))) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) typedef struct { const char * title ; @@ -53,12 +55,24 @@ typedef struct const char * origination_time ; const char * umid ; const char * coding_history ; + const char * time_ref ; } METADATA_INFO ; typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ; void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) ; -void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ; +void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize) ; void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ; + +int sfe_file_type_of_ext (const char *filename, int format) ; + +void sfe_dump_format_map (void) ; + +const char * program_name (const char * argv0) ; + +const char * sfe_endian_name (int format) ; +const char * sfe_container_name (int format) ; +const char * sfe_codec_name (int format) ; + diff --git a/libs/libsndfile/programs/sndfile-cmp.c b/libs/libsndfile/programs/sndfile-cmp.c index 59cfbb12b1..121d25a629 100644 --- a/libs/libsndfile/programs/sndfile-cmp.c +++ b/libs/libsndfile/programs/sndfile-cmp.c @@ -1,5 +1,6 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2012 Erik de Castro Lopo +** Copyright (C) 2008 Conrad Parker ** ** All rights reserved. ** @@ -30,27 +31,31 @@ ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* sndfile-cmp.c - * Conrad Parker 2008 - */ - - #include "sfconfig.h" #include +#include #include +#include #include +#include "common.h" + /* Length of comparison data buffers in units of items */ #define BUFLEN 65536 -static char * progname ; -static char * filename1, * filename2 ; +static const char * progname = NULL ; +static char * filename1 = NULL, * filename2 = NULL ; static int -comparison_error (const char * what) -{ printf ("%s: %s of files %s and %s differ\n", progname, what, filename1, filename2) ; +comparison_error (const char * what, sf_count_t frame_offset) +{ char buffer [128] = "" ; + + if (frame_offset >= 0) + snprintf (buffer, sizeof (buffer), " (at frame offset %" PRId64 ")", frame_offset) ; + + printf ("%s: %s of files %s and %s differ%s.\n", progname, what, filename1, filename2, buffer) ; return 1 ; } /* comparison_error */ @@ -60,7 +65,7 @@ compare (void) double buf1 [BUFLEN], buf2 [BUFLEN] ; SF_INFO sfinfo1, sfinfo2 ; SNDFILE * sf1 = NULL, * sf2 = NULL ; - sf_count_t len, i, nread1, nread2 ; + sf_count_t items, i, nread1, nread2, offset = 0 ; int retval = 0 ; memset (&sfinfo1, 0, sizeof (SF_INFO)) ; @@ -80,34 +85,35 @@ compare (void) } ; if (sfinfo1.samplerate != sfinfo2.samplerate) - { retval = comparison_error ("Samplerates") ; + { retval = comparison_error ("Samplerates", -1) ; goto out ; } ; if (sfinfo1.channels != sfinfo2.channels) - { retval = comparison_error ("Number of channels") ; + { retval = comparison_error ("Number of channels", -1) ; goto out ; } ; /* Calculate the framecount that will fit in our data buffers */ - len = BUFLEN / sfinfo1.channels ; + items = BUFLEN / sfinfo1.channels ; - while ( (nread1 = sf_readf_double (sf1, buf1, len)) > 0) + while ((nread1 = sf_readf_double (sf1, buf1, items)) > 0) { nread2 = sf_readf_double (sf2, buf2, nread1) ; if (nread2 != nread1) - { retval = comparison_error ("PCM data lengths") ; + { retval = comparison_error ("PCM data lengths", -1) ; goto out ; } ; - for (i = 0 ; i < nread1 ; i++) + for (i = 0 ; i < nread1 * sfinfo1.channels ; i++) { if (buf1 [i] != buf2 [i]) - { retval = comparison_error ("PCM data") ; + { retval = comparison_error ("PCM data", offset + i / sfinfo1.channels) ; goto out ; } ; } ; + offset += nread1 ; } ; - if ( (nread2 = sf_readf_double (sf2, buf2, nread1)) != 0) - { retval = comparison_error ("PCM data lengths") ; + if ((nread2 = sf_readf_double (sf2, buf2, items)) != 0) + { retval = comparison_error ("PCM data lengths", -1) ; goto out ; } ; @@ -127,22 +133,22 @@ print_version (void) } /* print_version */ static void -print_usage (void) +usage_exit (void) { print_version () ; printf ("Usage : %s \n", progname) ; printf (" Compare the PCM data of two sound files.\n\n") ; -} /* print_usage */ + exit (0) ; +} /* usage_exit */ int main (int argc, char *argv []) { - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; + progname = program_name (argv [0]) ; if (argc != 3) - { print_usage () ; + { usage_exit () ; return 1 ; } ; @@ -151,7 +157,7 @@ main (int argc, char *argv []) if (strcmp (filename1, filename2) == 0) { printf ("Error : Input filenames are the same.\n\n") ; - print_usage () ; + usage_exit () ; return 1 ; } ; diff --git a/libs/libsndfile/programs/sndfile-concat.c b/libs/libsndfile/programs/sndfile-concat.c new file mode 100644 index 0000000000..ef5312b693 --- /dev/null +++ b/libs/libsndfile/programs/sndfile-concat.c @@ -0,0 +1,169 @@ +/* +** Copyright (C) 1999-2012 Erik de Castro Lopo +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the author nor the names of any contributors may be used +** to endorse or promote products derived from this software without +** specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include + +#include + +#include "common.h" + +#define BUFFER_LEN (1 << 16) + + +static void concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) ; +static void concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels) ; + +static void +usage_exit (const char *progname) +{ + printf ("\nUsage : %s ... \n\n", progname) ; + puts ( + " Create a new output file containing the concatenated\n" + " audio data from froms ....\n" + "\n" + " The joined file will be encoded in the same format as the data\n" + " in infile1, with all the data in subsequent files automatically\n" + " converted to the correct encoding.\n" + "\n" + " The only restriction is that the two files must have the same\n" + " number of channels.\n" + ) ; + + exit (0) ; +} /* usage_exit */ + +int +main (int argc, char *argv []) +{ const char *progname, *outfilename ; + SNDFILE *outfile, **infiles ; + SF_INFO sfinfo_out, sfinfo_in ; + void (*func) (SNDFILE*, SNDFILE*, int) ; + int k ; + + progname = program_name (argv [0]) ; + + if (argc < 4) + usage_exit (progname) ; + + argv ++ ; + argc -- ; + + argc -- ; + outfilename = argv [argc] ; + + if ((infiles = calloc (argc, sizeof (SNDFILE*))) == NULL) + { printf ("\nError : Malloc failed.\n\n") ; + exit (1) ; + } ; + + memset (&sfinfo_in, 0, sizeof (sfinfo_in)) ; + + if ((infiles [0] = sf_open (argv [0], SFM_READ, &sfinfo_in)) == NULL) + { printf ("\nError : failed to open file '%s'.\n\n", argv [0]) ; + exit (1) ; + } ; + + sfinfo_out = sfinfo_in ; + + for (k = 1 ; k < argc ; k++) + { if ((infiles [k] = sf_open (argv [k], SFM_READ, &sfinfo_in)) == NULL) + { printf ("\nError : failed to open file '%s'.\n\n", argv [k]) ; + exit (1) ; + } ; + + if (sfinfo_in.channels != sfinfo_out.channels) + { printf ("\nError : File '%s' has %d channels (should have %d).\n\n", argv [k], sfinfo_in.channels, sfinfo_out.channels) ; + exit (1) ; + } ; + } ; + + if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo_out)) == NULL) + { printf ("\nError : Not able to open input file %s.\n", outfilename) ; + puts (sf_strerror (NULL)) ; + exit (1) ; + } ; + + if ((sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DOUBLE || + (sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT) + func = concat_data_fp ; + else + func = concat_data_int ; + + for (k = 0 ; k < argc ; k++) + { func (outfile, infiles [k], sfinfo_out.channels) ; + sf_close (infiles [k]) ; + } ; + + sf_close (outfile) ; + + return 0 ; +} /* main */ + +static void +concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) +{ static double data [BUFFER_LEN] ; + int frames, readcount ; + + frames = BUFFER_LEN / channels ; + readcount = frames ; + + sf_seek (wfile, 0, SEEK_END) ; + + while (readcount > 0) + { readcount = sf_readf_double (rofile, data, frames) ; + sf_writef_double (wfile, data, readcount) ; + } ; + + return ; +} /* concat_data_fp */ + +static void +concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels) +{ static int data [BUFFER_LEN] ; + int frames, readcount ; + + frames = BUFFER_LEN / channels ; + readcount = frames ; + + sf_seek (wfile, 0, SEEK_END) ; + + while (readcount > 0) + { readcount = sf_readf_int (rofile, data, frames) ; + sf_writef_int (wfile, data, readcount) ; + } ; + + return ; +} /* concat_data_int */ + diff --git a/libs/libsndfile/programs/sndfile-convert.c b/libs/libsndfile/programs/sndfile-convert.c index f1aa58ebd0..c22cc9b16a 100644 --- a/libs/libsndfile/programs/sndfile-convert.c +++ b/libs/libsndfile/programs/sndfile-convert.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** All rights reserved. ** @@ -45,93 +45,22 @@ typedef struct SF_INFO infileinfo, outfileinfo ; } OptionData ; -typedef struct -{ const char *ext ; - int len ; - int format ; -} OUTPUT_FORMAT_MAP ; - -static void copy_metadata (SNDFILE *outfile, SNDFILE *infile) ; - -static OUTPUT_FORMAT_MAP format_map [] = -{ - { "aif", 3, SF_FORMAT_AIFF }, - { "wav", 0, SF_FORMAT_WAV }, - { "au", 0, SF_FORMAT_AU }, - { "caf", 0, SF_FORMAT_CAF }, - { "flac", 0, SF_FORMAT_FLAC }, - { "snd", 0, SF_FORMAT_AU }, - { "svx", 0, SF_FORMAT_SVX }, - { "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF }, - { "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF }, - { "gsm", 0, SF_FORMAT_RAW }, - { "nist", 0, SF_FORMAT_NIST }, - { "htk", 0, SF_FORMAT_HTK }, - { "ircam", 0, SF_FORMAT_IRCAM }, - { "sf", 0, SF_FORMAT_IRCAM }, - { "voc", 0, SF_FORMAT_VOC }, - { "w64", 0, SF_FORMAT_W64 }, - { "raw", 0, SF_FORMAT_RAW }, - { "mat4", 0, SF_FORMAT_MAT4 }, - { "mat5", 0, SF_FORMAT_MAT5 }, - { "mat", 0, SF_FORMAT_MAT4 }, - { "pvf", 0, SF_FORMAT_PVF }, - { "sds", 0, SF_FORMAT_SDS }, - { "sd2", 0, SF_FORMAT_SD2 }, - { "vox", 0, SF_FORMAT_RAW }, - { "xi", 0, SF_FORMAT_XI }, - { "wve", 0, SF_FORMAT_WVE }, - { "oga", 0, SF_FORMAT_OGG }, - { "mpc", 0, SF_FORMAT_MPC2K }, - { "rf64", 0, SF_FORMAT_RF64 }, -} ; /* format_map */ - -static int -guess_output_file_type (char *str, int format) -{ char buffer [16], *cptr ; - int k ; - - format &= SF_FORMAT_SUBMASK ; - - if ((cptr = strrchr (str, '.')) == NULL) - return 0 ; - - strncpy (buffer, cptr + 1, 15) ; - buffer [15] = 0 ; - - for (k = 0 ; buffer [k] ; k++) - buffer [k] = tolower ((buffer [k])) ; - - if (strcmp (buffer, "gsm") == 0) - return SF_FORMAT_RAW | SF_FORMAT_GSM610 ; - - if (strcmp (buffer, "vox") == 0) - return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ; - - for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++) - { if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0) - return format_map [k].format | format ; - else if (strcmp (buffer, format_map [k].ext) == 0) - return format_map [k].format | format ; - } ; - - return 0 ; -} /* guess_output_file_type */ - +static void copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) ; static void -print_usage (char *progname) -{ SF_FORMAT_INFO info ; - - int k ; - +usage_exit (const char *progname) +{ printf ("\nUsage : %s [options] [encoding] \n", progname) ; puts ("\n" " where [option] may be:\n\n" - " -override-sample-rate=X : force sample rate of input to X\n\n" + " -override-sample-rate=X : force sample rate of input to X\n" + " -endian=little : force output file to little endian data\n" + " -endian=big : force output file to big endian data\n" + " -endian=cpu : force output file same endian-ness as the CPU\n" + " -normalize : normalize the data in the output file\n" ) ; - puts ("\n" + puts ( " where [encoding] may be one of the following:\n\n" " -pcms8 : force the output to signed 8 bit pcm\n" " -pcmu8 : force the output to unsigned 8 bit pcm\n" @@ -143,6 +72,10 @@ print_usage (char *progname) puts ( " -ulaw : force the output ULAW\n" " -alaw : force the output ALAW\n" + " -alac16 : force the output 16 bit ALAC (CAF only)\n" + " -alac20 : force the output 20 bit ALAC (CAF only)\n" + " -alac24 : force the output 24 bit ALAC (CAF only)\n" + " -alac32 : force the output 32 bit ALAC (CAF only)\n" " -ima-adpcm : force the output to IMA ADPCM (WAV only)\n" " -ms-adpcm : force the output to MS ADPCM (WAV only)\n" " -gsm610 : force the GSM6.10 (WAV only)\n" @@ -152,33 +85,57 @@ print_usage (char *progname) " -vorbis : force the output to Vorbis (OGG only)\n" ) ; + puts ( + " If no encoding is specified, the program will try to use the encoding\n" + " of the input file in the output file. This will not always work as\n" + " most container formats (eg WAV, AIFF etc) only support a small subset\n" + " of codec formats (eg 16 bit PCM, a-law, Vorbis etc).\n" + ) ; + puts ( " The format of the output file is determined by the file extension of the\n" " output file name. The following extensions are currently understood:\n" ) ; - for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++) - { info.format = format_map [k].format ; - sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ; - printf (" %-10s : %s\n", format_map [k].ext, info.name) ; - } ; + sfe_dump_format_map () ; puts ("") ; -} /* print_usage */ + exit (0) ; +} /* usage_exit */ + +static void +report_format_error_exit (const char * argv0, SF_INFO * sfinfo) +{ int old_format = sfinfo->format ; + int endian = sfinfo->format & SF_FORMAT_ENDMASK ; + + sfinfo->format = old_format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; + + if (endian && sf_format_check (sfinfo)) + { printf ("Error : output file format does not support %s endian-ness.\n", sfe_endian_name (endian)) ; + exit (1) ; + } ; + + printf ("\n" + "Error : output file format is invalid.\n" + "The '%s' container does not support '%s' codec data.\n" + "Run '%s --help' for clues.\n\n", + sfe_container_name (sfinfo->format), sfe_codec_name (sfinfo->format), program_name (argv0)) ; + exit (1) ; +} /* report_format_error_exit */ int main (int argc, char * argv []) -{ char *progname, *infilename, *outfilename ; - SNDFILE *infile = NULL, *outfile = NULL ; - SF_INFO sfinfo ; +{ const char *progname, *infilename, *outfilename ; + SNDFILE *infile = NULL, *outfile = NULL ; + SF_INFO sfinfo ; int k, outfilemajor, outfileminor = 0, infileminor ; int override_sample_rate = 0 ; /* assume no sample rate override. */ + int endian = SF_ENDIAN_FILE, normalize = SF_FALSE ; - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; + progname = program_name (argv [0]) ; if (argc < 3 || argc > 5) - { print_usage (progname) ; + { usage_exit (progname) ; return 1 ; } ; @@ -187,19 +144,19 @@ main (int argc, char * argv []) if (strcmp (infilename, outfilename) == 0) { printf ("Error : Input and output filenames are the same.\n\n") ; - print_usage (progname) ; + usage_exit (progname) ; return 1 ; } ; - if (infilename [0] == '-') + if (strlen (infilename) > 1 && infilename [0] == '-') { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ; - print_usage (progname) ; + usage_exit (progname) ; return 1 ; } ; if (outfilename [0] == '-') { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ; - print_usage (progname) ; + usage_exit (progname) ; return 1 ; } ; @@ -236,6 +193,22 @@ main (int argc, char * argv []) { outfileminor = SF_FORMAT_ALAW ; continue ; } ; + if (! strcmp (argv [k], "-alac16")) + { outfileminor = SF_FORMAT_ALAC_16 ; + continue ; + } ; + if (! strcmp (argv [k], "-alac20")) + { outfileminor = SF_FORMAT_ALAC_20 ; + continue ; + } ; + if (! strcmp (argv [k], "-alac24")) + { outfileminor = SF_FORMAT_ALAC_24 ; + continue ; + } ; + if (! strcmp (argv [k], "-alac32")) + { outfileminor = SF_FORMAT_ALAC_32 ; + continue ; + } ; if (! strcmp (argv [k], "-ima-adpcm")) { outfileminor = SF_FORMAT_IMA_ADPCM ; continue ; @@ -273,10 +246,37 @@ main (int argc, char * argv []) continue ; } ; + if (! strcmp (argv [k], "-endian=little")) + { endian = SF_ENDIAN_LITTLE ; + continue ; + } ; + + if (! strcmp (argv [k], "-endian=big")) + { endian = SF_ENDIAN_BIG ; + continue ; + } ; + + if (! strcmp (argv [k], "-endian=cpu")) + { endian = SF_ENDIAN_CPU ; + continue ; + } ; + + if (! strcmp (argv [k], "-endian=file")) + { endian = SF_ENDIAN_FILE ; + continue ; + } ; + + if (! strcmp (argv [k], "-normalize")) + { normalize = SF_TRUE ; + continue ; + } ; + printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ; exit (1) ; } ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; + if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL) { printf ("Not able to open input file %s.\n", infilename) ; puts (sf_strerror (NULL)) ; @@ -289,7 +289,7 @@ main (int argc, char * argv []) infileminor = sfinfo.format & SF_FORMAT_SUBMASK ; - if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0) + if ((sfinfo.format = sfe_file_type_of_ext (outfilename, sfinfo.format)) == 0) { printf ("Error : Not able to determine output file type for %s.\n", outfilename) ; return 1 ; } ; @@ -304,6 +304,8 @@ main (int argc, char * argv []) else sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ; + sfinfo.format |= endian ; + if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI) switch (sfinfo.format & SF_FORMAT_SUBMASK) { case SF_FORMAT_PCM_16 : @@ -317,9 +319,7 @@ main (int argc, char * argv []) } ; if (sf_format_check (&sfinfo) == 0) - { printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ; - return 1 ; - } ; + report_format_error_exit (argv [0], &sfinfo) ; /* Open the output file. */ if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL) @@ -328,12 +328,13 @@ main (int argc, char * argv []) } ; /* Copy the metadata */ - copy_metadata (outfile, infile) ; + copy_metadata (outfile, infile, sfinfo.channels) ; - if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT) + if (normalize + || (outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT) || (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT) || (infileminor == SF_FORMAT_VORBIS) || (outfileminor == SF_FORMAT_VORBIS)) - sfe_copy_data_fp (outfile, infile, sfinfo.channels) ; + sfe_copy_data_fp (outfile, infile, sfinfo.channels, normalize) ; else sfe_copy_data_int (outfile, infile, sfinfo.channels) ; @@ -344,21 +345,28 @@ main (int argc, char * argv []) } /* main */ static void -copy_metadata (SNDFILE *outfile, SNDFILE *infile) +copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) { SF_INSTRUMENT inst ; SF_BROADCAST_INFO_2K binfo ; const char *str ; - int k, err = 0 ; + int k, chanmap [256] ; for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++) { str = sf_get_string (infile, k) ; if (str != NULL) - err = sf_set_string (outfile, k, str) ; + sf_set_string (outfile, k, str) ; } ; memset (&inst, 0, sizeof (inst)) ; memset (&binfo, 0, sizeof (binfo)) ; + if (channels < ARRAY_LEN (chanmap)) + { size_t size = channels * sizeof (chanmap [0]) ; + + if (sf_command (infile, SFC_GET_CHANNEL_MAP_INFO, chanmap, size) == SF_TRUE) + sf_command (outfile, SFC_SET_CHANNEL_MAP_INFO, chanmap, size) ; + } ; + if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE) sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ; diff --git a/libs/libsndfile/programs/sndfile-deinterleave.c b/libs/libsndfile/programs/sndfile-deinterleave.c new file mode 100644 index 0000000000..df80b04222 --- /dev/null +++ b/libs/libsndfile/programs/sndfile-deinterleave.c @@ -0,0 +1,194 @@ +/* +** Copyright (C) 2009-2011 Erik de Castro Lopo +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the author nor the names of any contributors may be used +** to endorse or promote products derived from this software without +** specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include + +#include "common.h" + +#define BUFFER_LEN 4096 +#define MAX_CHANNELS 16 + + +typedef struct +{ SNDFILE * infile ; + SNDFILE * outfile [MAX_CHANNELS] ; + + union + { double d [MAX_CHANNELS * BUFFER_LEN] ; + int i [MAX_CHANNELS * BUFFER_LEN] ; + } din ; + + union + { double d [BUFFER_LEN] ; + int i [BUFFER_LEN] ; + } dout ; + + int channels ; +} STATE ; + +static void usage_exit (void) ; + +static void deinterleave_int (STATE * state) ; +static void deinterleave_double (STATE * state) ; + +int +main (int argc, char **argv) +{ STATE state ; + SF_INFO sfinfo ; + char pathname [512], ext [32], *cptr ; + int ch, double_split ; + + if (argc != 2) + { if (argc != 1) + puts ("\nError : need a single input file.\n") ; + usage_exit () ; + } ; + + memset (&state, 0, sizeof (state)) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; + + if ((state.infile = sf_open (argv [1], SFM_READ, &sfinfo)) == NULL) + { printf ("\nError : Not able to open input file '%s'\n%s\n", argv [1], sf_strerror (NULL)) ; + exit (1) ; + } ; + + if (sfinfo.channels < 2) + { printf ("\nError : Input file '%s' only has one channel.\n", argv [1]) ; + exit (1) ; + } ; + + state.channels = sfinfo.channels ; + sfinfo.channels = 1 ; + + snprintf (pathname, sizeof (pathname), "%s", argv [1]) ; + if ((cptr = strrchr (pathname, '.')) == NULL) + ext [0] = 0 ; + else + { snprintf (ext, sizeof (ext), "%s", cptr) ; + cptr [0] = 0 ; + } ; + + printf ("Input file : %s\n", pathname) ; + puts ("Output files :") ; + + for (ch = 0 ; ch < state.channels ; ch++) + { char filename [520] ; + + snprintf (filename, sizeof (filename), "%s_%02d%s", pathname, ch, ext) ; + + if ((state.outfile [ch] = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) + { printf ("Not able to open output file '%s'\n%s\n", filename, sf_strerror (NULL)) ; + exit (1) ; + } ; + + printf (" %s\n", filename) ; + } ; + + switch (sfinfo.format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_FLOAT : + case SF_FORMAT_DOUBLE : + case SF_FORMAT_VORBIS : + double_split = 1 ; + break ; + + default : + double_split = 0 ; + break ; + } ; + + if (double_split) + deinterleave_double (&state) ; + else + deinterleave_int (&state) ; + + sf_close (state.infile) ; + for (ch = 0 ; ch < MAX_CHANNELS ; ch++) + if (state.outfile [ch] != NULL) + sf_close (state.outfile [ch]) ; + + return 0 ; +} /* main */ + +/*------------------------------------------------------------------------------ +*/ + +static void +usage_exit (void) +{ puts ("\nUsage : sndfile-deinterleave \n") ; + puts ( + "Split a mutli-channel file into a set of mono files.\n" + "\n" + "If the input file is named 'a.wav', the output files will be named\n" + "a_00.wav, a_01.wav and so on.\n" + ) ; + printf ("Using %s.\n\n", sf_version_string ()) ; + exit (0) ; +} /* usage_exit */ + +static void +deinterleave_int (STATE * state) +{ int read_len ; + int ch, k ; + + do + { read_len = sf_readf_int (state->infile, state->din.i, BUFFER_LEN) ; + + for (ch = 0 ; ch < state->channels ; ch ++) + { for (k = 0 ; k < read_len ; k++) + state->dout.i [k] = state->din.i [k * state->channels + ch] ; + sf_write_int (state->outfile [ch], state->dout.i, read_len) ; + } ; + } + while (read_len > 0) ; + +} /* deinterleave_int */ + +static void +deinterleave_double (STATE * state) +{ int read_len ; + int ch, k ; + + do + { read_len = sf_readf_double (state->infile, state->din.d, BUFFER_LEN) ; + + for (ch = 0 ; ch < state->channels ; ch ++) + { for (k = 0 ; k < read_len ; k++) + state->dout.d [k] = state->din.d [k * state->channels + ch] ; + sf_write_double (state->outfile [ch], state->dout.d, read_len) ; + } ; + } + while (read_len > 0) ; + +} /* deinterleave_double */ diff --git a/libs/libsndfile/programs/sndfile-info.c b/libs/libsndfile/programs/sndfile-info.c index 3ac12a8f04..06982fd2c2 100644 --- a/libs/libsndfile/programs/sndfile-info.c +++ b/libs/libsndfile/programs/sndfile-info.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** All rights reserved. ** @@ -45,15 +45,16 @@ #if (defined (WIN32) || defined (_WIN32)) #include -#define snprintf _snprintf #endif static void print_version (void) ; -static void print_usage (const char *progname) ; +static void usage_exit (const char *progname) ; static void info_dump (const char *filename) ; static int instrument_dump (const char *filename) ; static int broadcast_dump (const char *filename) ; +static int chanmap_dump (const char *filename) ; +static int cart_dump (const char *filename) ; static void total_dump (void) ; static double total_seconds = 0.0 ; @@ -65,16 +66,11 @@ main (int argc, char *argv []) print_version () ; if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) - { char *progname ; - - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; - - print_usage (progname) ; + { usage_exit (program_name (argv [0])) ; return 1 ; } ; - if (strcmp (argv [1], "-i") == 0) + if (strcmp (argv [1], "--instrument") == 0) { int error = 0 ; for (k = 2 ; k < argc ; k++) @@ -82,7 +78,7 @@ main (int argc, char *argv []) return error ; } ; - if (strcmp (argv [1], "-b") == 0) + if (strcmp (argv [1], "--broadcast") == 0) { int error = 0 ; for (k = 2 ; k < argc ; k++) @@ -90,6 +86,22 @@ main (int argc, char *argv []) return error ; } ; + if (strcmp (argv [1], "--channel-map") == 0) + { int error = 0 ; + + for (k = 2 ; k < argc ; k++) + error += chanmap_dump (argv [k]) ; + return error ; + } ; + + if (strcmp (argv [1], "--cart") == 0) + { int error = 0 ; + + for (k = 2 ; k < argc ; k++) + error += cart_dump (argv [k]) ; + return error ; + } ; + for (k = 1 ; k < argc ; k++) info_dump (argv [k]) ; @@ -115,13 +127,17 @@ print_version (void) static void -print_usage (const char *progname) +usage_exit (const char *progname) { printf ("Usage :\n %s ...\n", progname) ; printf (" Prints out information about one or more sound files.\n\n") ; - printf (" %s -i \n", progname) ; + printf (" %s --instrument \n", progname) ; printf (" Prints out the instrument data for the given file.\n\n") ; - printf (" %s -b \n", progname) ; + printf (" %s --broadcast \n", progname) ; printf (" Prints out the broadcast WAV info for the given file.\n\n") ; + printf (" %s --channel-map \n", progname) ; + printf (" Prints out the channel map for the given file.\n\n") ; + printf (" %s --cart \n", progname) ; + printf (" Prints out the cart chunk WAV info for the given file.\n\n") ; #if (defined (_WIN32) || defined (WIN32)) printf ("This is a Unix style command line application which\n" "should be run in a MSDOS box or Command Shell window.\n\n") ; @@ -135,7 +151,8 @@ print_usage (const char *progname) */ Sleep (5 * 1000) ; #endif -} /* print_usage */ + exit (0) ; +} /* usage_exit */ /*============================================================================== ** Dumping of sndfile info. @@ -143,15 +160,6 @@ print_usage (const char *progname) static double data [BUFFER_LEN] ; -static double -get_signal_max (SNDFILE *file) -{ double max ; - - sf_command (file, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ; - - return max ; -} /* get_signal_max */ - static double calc_decibels (SF_INFO * sfinfo, double max) { double decibels ; @@ -226,8 +234,8 @@ generate_duration_str (SF_INFO *sfinfo) static void info_dump (const char *filename) { static char strbuffer [BUFFER_LEN] ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; double signal_max, decibels ; memset (&sfinfo, 0, sizeof (sfinfo)) ; @@ -248,7 +256,12 @@ info_dump (const char *filename) printf ("----------------------------------------\n") ; printf ("Sample Rate : %d\n", sfinfo.samplerate) ; - printf ("Frames : %" PRId64 "\n", sfinfo.frames) ; + + if (sfinfo.frames == SF_COUNT_MAX) + printf ("Frames : unknown\n") ; + else + printf ("Frames : %" PRId64 "\n", sfinfo.frames) ; + printf ("Channels : %d\n", sfinfo.channels) ; printf ("Format : 0x%08X\n", sfinfo.format) ; printf ("Sections : %d\n", sfinfo.sections) ; @@ -257,7 +270,7 @@ info_dump (const char *filename) if (sfinfo.frames < 100 * 1024 * 1024) { /* Do not use sf_signal_max because it doesn't work for non-seekable files . */ - signal_max = get_signal_max (file) ; + sf_command (file, SFC_CALC_SIGNAL_MAX, &signal_max, sizeof (signal_max)) ; decibels = calc_decibels (&sfinfo, signal_max) ; printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ; } ; @@ -286,8 +299,8 @@ str_of_type (int mode) static int instrument_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; +{ SNDFILE *file ; + SF_INFO sfinfo ; SF_INSTRUMENT inst ; int got_inst, k ; @@ -325,8 +338,8 @@ instrument_dump (const char *filename) static int broadcast_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; +{ SNDFILE *file ; + SF_INFO sfinfo ; SF_BROADCAST_INFO_2K bext ; double time_ref_sec ; int got_bext ; @@ -379,6 +392,136 @@ broadcast_dump (const char *filename) return 0 ; } /* broadcast_dump */ +static int +chanmap_dump (const char *filename) +{ SNDFILE *file ; + SF_INFO sfinfo ; + int * channel_map ; + int got_chanmap, k ; + + memset (&sfinfo, 0, sizeof (sfinfo)) ; + + if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) + { printf ("Error : Not able to open input file %s.\n", filename) ; + fflush (stdout) ; + memset (data, 0, sizeof (data)) ; + puts (sf_strerror (NULL)) ; + return 1 ; + } ; + + if ((channel_map = calloc (sfinfo.channels, sizeof (int))) == NULL) + { printf ("Error : malloc failed.\n\n") ; + return 1 ; + } ; + + got_chanmap = sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map, sfinfo.channels * sizeof (int)) ; + sf_close (file) ; + + if (got_chanmap == SF_FALSE) + { printf ("Error : File '%s' does not contain channel map information.\n\n", filename) ; + free (channel_map) ; + return 1 ; + } ; + + printf ("File : %s\n\n", filename) ; + + puts (" Chan Position") ; + for (k = 0 ; k < sfinfo.channels ; k ++) + { const char * name ; + +#define CASE_NAME(x) case x : name = #x ; break ; + switch (channel_map [k]) + { CASE_NAME (SF_CHANNEL_MAP_INVALID) ; + CASE_NAME (SF_CHANNEL_MAP_MONO) ; + CASE_NAME (SF_CHANNEL_MAP_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_FRONT_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_REAR_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_REAR_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_REAR_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_LFE) ; + CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_SIDE_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_SIDE_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_LEFT) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_RIGHT) ; + CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_CENTER) ; + CASE_NAME (SF_CHANNEL_MAP_MAX) ; + default : name = "default" ; + break ; + } ; + + printf (" %3d %s\n", k, name) ; + } ; + + putchar ('\n') ; + free (channel_map) ; + + return 0 ; +} /* chanmap_dump */ + +static int +cart_dump (const char *filename) +{ SNDFILE *file ; + SF_INFO sfinfo ; + SF_CART_INFO_VAR (1024) cart ; + int got_cart, k ; + + memset (&sfinfo, 0, sizeof (sfinfo)) ; + memset (&cart, 0, sizeof (cart)) ; + + if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) + { printf ("Error : Not able to open input file %s.\n", filename) ; + fflush (stdout) ; + memset (data, 0, sizeof (data)) ; + puts (sf_strerror (NULL)) ; + return 1 ; + } ; + + got_cart = sf_command (file, SFC_GET_CART_INFO, &cart, sizeof (cart)) ; + sf_close (file) ; + + if (got_cart == SF_FALSE) + { printf ("Error : File '%s' does not contain cart information.\n\n", filename) ; + return 1 ; + } ; + + printf ("Version : %.*s\n", (int) sizeof (cart.version), cart.version) ; + printf ("Title : %.*s\n", (int) sizeof (cart.title), cart.title) ; + printf ("Artist : %.*s\n", (int) sizeof (cart.artist), cart.artist) ; + printf ("Cut id : %.*s\n", (int) sizeof (cart.cut_id), cart.cut_id) ; + printf ("Category : %.*s\n", (int) sizeof (cart.category), cart.category) ; + printf ("Classification : %.*s\n", (int) sizeof (cart.classification), cart.classification) ; + printf ("Out cue : %.*s\n", (int) sizeof (cart.out_cue), cart.out_cue) ; + printf ("Start date : %.*s\n", (int) sizeof (cart.start_date), cart.start_date) ; + printf ("Start time : %.*s\n", (int) sizeof (cart.start_time), cart.start_time) ; + printf ("End date : %.*s\n", (int) sizeof (cart.end_date), cart.end_date) ; + printf ("End time : %.*s\n", (int) sizeof (cart.end_time), cart.end_time) ; + printf ("App id : %.*s\n", (int) sizeof (cart.producer_app_id), cart.producer_app_id) ; + printf ("App version : %.*s\n", (int) sizeof (cart.producer_app_version), cart.producer_app_version) ; + printf ("User defined : %.*s\n", (int) sizeof (cart.user_def), cart.user_def) ; + printf ("Level ref. : %d\n", cart.level_reference) ; + printf ("Post timers :\n") ; + + for (k = 0 ; k < ARRAY_LEN (cart.post_timers) ; k++) + if (cart.post_timers [k].usage [0]) + printf (" %d %.*s %d\n", k, (int) sizeof (cart.post_timers [k].usage), cart.post_timers [k].usage, cart.post_timers [k].value) ; + + printf ("Reserved : %.*s\n", (int) sizeof (cart.reserved), cart.reserved) ; + printf ("Url : %.*s\n", (int) sizeof (cart.url), cart.url) ; + printf ("Tag text : %.*s\n", cart.tag_text_size, cart.tag_text) ; + + return 0 ; +} /* cart_dump */ + static void total_dump (void) { printf ("========================================\n") ; diff --git a/libs/libsndfile/programs/sndfile-interleave.c b/libs/libsndfile/programs/sndfile-interleave.c new file mode 100644 index 0000000000..24d6b9d874 --- /dev/null +++ b/libs/libsndfile/programs/sndfile-interleave.c @@ -0,0 +1,202 @@ +/* +** Copyright (C) 2009-2011 Erik de Castro Lopo +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the author nor the names of any contributors may be used +** to endorse or promote products derived from this software without +** specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include + +#include "common.h" + +#define BUFFER_LEN 4096 +#define MAX_INPUTS 16 + + +typedef struct +{ SNDFILE * infile [MAX_INPUTS] ; + SNDFILE * outfile ; + + union + { double d [BUFFER_LEN] ; + int i [BUFFER_LEN] ; + } din ; + + union + + { double d [MAX_INPUTS * BUFFER_LEN] ; + int i [MAX_INPUTS * BUFFER_LEN] ; + } dout ; + + int channels ; +} STATE ; + + +static void usage_exit (void) ; +static void interleave_int (STATE * state) ; +static void interleave_double (STATE * state) ; + + +int +main (int argc, char **argv) +{ STATE state ; + SF_INFO sfinfo ; + int k, double_merge = 0 ; + + if (argc < 5) + { if (argc > 1) + puts ("\nError : need at least 2 input files.") ; + usage_exit () ; + } ; + + if (strcmp (argv [argc - 2], "-o") != 0) + { puts ("\nError : second last command line parameter should be '-o'.\n") ; + usage_exit () ; + } ; + + if (argc - 3 > MAX_INPUTS) + { printf ("\nError : Cannot handle more than %d input channels.\n\n", MAX_INPUTS) ; + exit (1) ; + } ; + + memset (&state, 0, sizeof (state)) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; + + for (k = 1 ; k < argc - 2 ; k++) + { + if ((state.infile [k - 1] = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL) + { printf ("\nError : Not able to open input file '%s'\n%s\n", argv [k], sf_strerror (NULL)) ; + exit (1) ; + } ; + + if (sfinfo.channels != 1) + { printf ("\bError : Input file '%s' should be mono (has %d channels).\n", argv [k], sfinfo.channels) ; + exit (1) ; + } ; + + switch (sfinfo.format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_FLOAT : + case SF_FORMAT_DOUBLE : + case SF_FORMAT_VORBIS : + double_merge = 1 ; + break ; + + default : + break ; + } ; + + state.channels ++ ; + } ; + + sfinfo.channels = state.channels ; + sfinfo.format = sfe_file_type_of_ext (argv [argc - 1], sfinfo.format) ; + + if ((state.outfile = sf_open (argv [argc - 1], SFM_WRITE, &sfinfo)) == NULL) + { printf ("Not able to open output file '%s'\n%s\n", argv [argc - 1], sf_strerror (NULL)) ; + exit (1) ; + } ; + + if (double_merge) + interleave_double (&state) ; + else + interleave_int (&state) ; + + for (k = 0 ; k < MAX_INPUTS ; k++) + if (state.infile [k] != NULL) + sf_close (state.infile [k]) ; + sf_close (state.outfile) ; + + return 0 ; +} /* main */ + +/*------------------------------------------------------------------------------ +*/ + + +static void +usage_exit (void) +{ puts ("\nUsage : sndfile-interleave ... -o \n") ; + puts ("Merge two or more mono files into a single multi-channel file.\n") ; + printf ("Using %s.\n\n", sf_version_string ()) ; + exit (0) ; +} /* usage_exit */ + + +static void +interleave_int (STATE * state) +{ int max_read_len, read_len ; + int ch, k ; + + do + { max_read_len = 0 ; + + for (ch = 0 ; ch < state->channels ; ch ++) + { read_len = sf_read_int (state->infile [ch], state->din.i, BUFFER_LEN) ; + if (read_len < BUFFER_LEN) + memset (state->din.i + read_len, 0, sizeof (state->din.i [0]) * (BUFFER_LEN - read_len)) ; + + for (k = 0 ; k < read_len ; k++) + state->dout.i [k * state->channels + ch] = state->din.i [k] ; + + max_read_len = MAX (max_read_len, read_len) ; + } ; + + sf_writef_int (state->outfile, state->dout.i, max_read_len) ; + } + while (max_read_len > 0) ; + +} /* interleave_int */ + + +static void +interleave_double (STATE * state) +{ int max_read_len, read_len ; + int ch, k ; + + do + { max_read_len = 0 ; + + for (ch = 0 ; ch < state->channels ; ch ++) + { read_len = sf_read_double (state->infile [ch], state->din.d, BUFFER_LEN) ; + if (read_len < BUFFER_LEN) + memset (state->din.d + read_len, 0, sizeof (state->din.d [0]) * (BUFFER_LEN - read_len)) ; + + for (k = 0 ; k < read_len ; k++) + state->dout.d [k * state->channels + ch] = state->din.d [k] ; + + max_read_len = MAX (max_read_len, read_len) ; + } ; + + sf_writef_double (state->outfile, state->dout.d, max_read_len) ; + } + while (max_read_len > 0) ; + +} /* interleave_double */ diff --git a/libs/libsndfile/programs/sndfile-metadata-get.c b/libs/libsndfile/programs/sndfile-metadata-get.c index 1d370b38e5..b4aa9b60f0 100644 --- a/libs/libsndfile/programs/sndfile-metadata-get.c +++ b/libs/libsndfile/programs/sndfile-metadata-get.c @@ -1,6 +1,6 @@ /* -** Copyright (C) 2008 George Blood Audio -** Written by Erik de Castro Lopo +** Copyright (C) 2008-2012 Erik de Castro Lopo +** Copyright (C) 2008-2010 George Blood Audio ** ** All rights reserved. ** @@ -58,8 +58,7 @@ main (int argc, char *argv []) int start ; /* Store the program name. */ - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; + progname = program_name (argv [0]) ; /* Check if we've been asked for help. */ if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) @@ -123,6 +122,7 @@ usage_exit (const char *progname, int exit_code) " --str-license Print the license metadata.\n" ) ; + printf ("Using %s.\n\n", sf_version_string ()) ; exit (exit_code) ; } /* usage_exit */ @@ -131,14 +131,14 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char { const char * str ; int k, do_all = 0 ; -#define HANDLE_BEXT_ARG(cmd,name,field) \ +#define HANDLE_BEXT_ARG(cmd, name, field) \ if (do_all || strcmp (argv [k], cmd) == 0) \ { printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \ if (! do_all) \ continue ; \ } ; -#define HANDLE_STR_ARG(cmd,name,id) \ +#define HANDLE_STR_ARG(cmd, name, id) \ if (do_all || strcmp (argv [k], cmd) == 0) \ { str = sf_get_string (file, id) ; \ printf ("%-20s : %s\n", name, str ? str : "") ; \ diff --git a/libs/libsndfile/programs/sndfile-metadata-set.c b/libs/libsndfile/programs/sndfile-metadata-set.c index 58e1922fa9..b1d021a888 100644 --- a/libs/libsndfile/programs/sndfile-metadata-set.c +++ b/libs/libsndfile/programs/sndfile-metadata-set.c @@ -1,6 +1,6 @@ /* -** Copyright (C) 2008 George Blood Audio -** Written by Erik de Castro Lopo +** Copyright (C) 2008-2012 Erik de Castro Lopo +** Copyright (C) 2008-2010 George Blood Audio ** ** All rights reserved. ** @@ -60,8 +60,7 @@ main (int argc, char *argv []) int k ; /* Store the program name. */ - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; + progname = program_name (argv [0]) ; /* Check if we've been asked for help. */ if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) @@ -88,7 +87,7 @@ main (int argc, char *argv []) continue ; } ; -#define HANDLE_BEXT_ARG(cmd,field) \ +#define HANDLE_BEXT_ARG(cmd, field) \ if (strcmp (argv [k], cmd) == 0) \ { k ++ ; \ if (k == argc) missing_param (argv [k - 1]) ; \ @@ -103,8 +102,9 @@ main (int argc, char *argv []) HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ; HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ; HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ; + HANDLE_BEXT_ARG ("--bext-time-ref", time_ref) ; -#define HANDLE_STR_ARG(cmd,field) \ +#define HANDLE_STR_ARG(cmd, field) \ if (strcmp (argv [k], cmd) == 0) \ { k ++ ; \ if (k == argc) missing_param (argv [k - 1]) ; \ @@ -112,6 +112,7 @@ main (int argc, char *argv []) continue ; \ } ; + HANDLE_STR_ARG ("--str-comment", comment) ; HANDLE_STR_ARG ("--str-title", title) ; HANDLE_STR_ARG ("--str-copyright", copyright) ; HANDLE_STR_ARG ("--str-artist", artist) ; @@ -206,8 +207,10 @@ usage_exit (const char *progname, int exit_code) " --bext-umid Set the 'bext' UMID.\n" " --bext-orig-date Set the 'bext' origination date.\n" " --bext-orig-time Set the 'bext' origination time.\n" - " --bext-coding-hist Set the 'bext' coding history\n" + " --bext-coding-hist Set the 'bext' coding history.\n" + " --bext-time-raf Set the 'bext' Time ref.\n" "\n" + " --str-comment Set the metadata comment.\n" " --str-title Set the metadata title.\n" " --str-copyright Set the metadata copyright.\n" " --str-artist Set the metadata artist.\n" @@ -231,6 +234,7 @@ usage_exit (const char *progname, int exit_code) "exit with an appropriate error message.\n" ) ; + printf ("Using %s.\n\n", sf_version_string ()) ; exit (exit_code) ; } /* usage_exit */ @@ -250,7 +254,7 @@ has_bext_fields_set (const METADATA_INFO * info) if (info->description || info->originator || info->originator_reference) return 1 ; - if (info->origination_date || info->origination_time || info->umid || info->coding_history) + if (info->origination_date || info->origination_time || info->umid || info->coding_history || info->time_ref) return 1 ; return 0 ; diff --git a/libs/libsndfile/programs/sndfile-play.c b/libs/libsndfile/programs/sndfile-play.c index 56d1a7b06c..f779f11a86 100644 --- a/libs/libsndfile/programs/sndfile-play.c +++ b/libs/libsndfile/programs/sndfile-play.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** All rights reserved. ** @@ -41,6 +41,10 @@ #include #endif +#include + +#include "common.h" + #if HAVE_ALSA_ASOUNDLIB_H #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API @@ -48,14 +52,28 @@ #include #endif -#if defined (__linux__) +#if defined (__ANDROID__) + +#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) #include #include #include #elif (defined (__MACH__) && defined (__APPLE__)) - #include - #include + #include + #include + + #if (OSX_DARWIN_VERSION > 11) + /* Includes go here. */ + #elif (OSX_DARWIN_VERSION == 11) + #include + #elif (OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10) + #include + #include + #endif + +#elif defined (HAVE_SNDIO_H) + #include #elif (defined (sun) && defined (unix)) #include @@ -68,8 +86,6 @@ #endif -#include - #define SIGNED_SIZEOF(x) ((int) sizeof (x)) #define BUFFER_LEN (2048) @@ -348,12 +364,12 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ** Linux/OSS functions for playing a sound. */ -#if defined (__linux__) +#if !defined (__ANDROID__) && (defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)) -static int linux_open_dsp_device (int channels, int srate) ; +static int opensoundsys_open_device (int channels, int srate) ; -static void -linux_play (int argc, char *argv []) +static int +opensoundsys_play (int argc, char *argv []) { static short buffer [BUFFER_LEN] ; SNDFILE *sndfile ; SF_INFO sfinfo ; @@ -373,7 +389,7 @@ linux_play (int argc, char *argv []) continue ; } ; - audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ; + audio_device = opensoundsys_open_device (sfinfo.channels, sfinfo.samplerate) ; subformat = sfinfo.format & SF_FORMAT_SUBMASK ; @@ -410,54 +426,54 @@ linux_play (int argc, char *argv []) sf_close (sndfile) ; } ; - return ; -} /* linux_play */ + return writecount ; +} /* opensoundsys_play */ static int -linux_open_dsp_device (int channels, int srate) +opensoundsys_open_device (int channels, int srate) { int fd, stereo, fmt ; if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 && (fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1) - { perror ("linux_open_dsp_device : open ") ; + { perror ("opensoundsys_open_device : open ") ; exit (1) ; } ; stereo = 0 ; if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1) { /* Fatal error */ - perror ("linux_open_dsp_device : stereo ") ; + perror ("opensoundsys_open_device : stereo ") ; exit (1) ; } ; if (ioctl (fd, SNDCTL_DSP_RESET, 0)) - { perror ("linux_open_dsp_device : reset ") ; + { perror ("opensoundsys_open_device : reset ") ; exit (1) ; } ; fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ; if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0) - { perror ("linux_open_dsp_device : set format ") ; + { perror ("opensoundsys_open_device : set format ") ; exit (1) ; - } ; + } ; if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0) - { perror ("linux_open_dsp_device : channels ") ; + { perror ("opensoundsys_open_device : channels ") ; exit (1) ; } ; if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0) - { perror ("linux_open_dsp_device : sample rate ") ; + { perror ("opensoundsys_open_device : sample rate ") ; exit (1) ; } ; if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0) - { perror ("linux_open_dsp_device : sync ") ; + { perror ("opensoundsys_open_device : sync ") ; exit (1) ; } ; return fd ; -} /* linux_open_dsp_device */ +} /* opensoundsys_open_device */ #endif /* __linux__ */ @@ -465,7 +481,174 @@ linux_open_dsp_device (int channels, int srate) ** Mac OS X functions for playing a sound. */ -#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */ +#if (OSX_DARWIN_VERSION > 11) +/* MacOSX 10.8 use a new Audio API. Someone needs to write some code for it. */ +#endif /* OSX_DARWIN_VERSION > 11 */ + +#if (OSX_DARWIN_VERSION == 11) +/* MacOSX 10.7 use AudioQueue API */ + +#define kBytesPerAudioBuffer (1024 * 8) +#define kNumberOfAudioBuffers 4 + +typedef struct +{ AudioStreamBasicDescription format ; + + AudioQueueRef queue ; + AudioQueueBufferRef queueBuffer [kNumberOfAudioBuffers] ; + + UInt32 buf_size ; + + SNDFILE *sndfile ; + SF_INFO sfinfo ; + + int done_playing ; +} MacOSXAudioData ; + + +static void +macosx_fill_buffer (MacOSXAudioData *audio_data, AudioQueueBufferRef audio_buffer) +{ int size, sample_count, read_count ; + short *buffer ; + + size = audio_buffer->mAudioDataBytesCapacity ; + sample_count = size / sizeof (short) ; + + buffer = (short*) audio_buffer->mAudioData ; + + read_count = sf_read_short (audio_data->sndfile, buffer, sample_count) ; + + if (read_count > 0) + { audio_buffer->mAudioDataByteSize = read_count * sizeof (short) ; + AudioQueueEnqueueBuffer (audio_data->queue, audio_buffer, 0, NULL) ; + } + else + AudioQueueStop (audio_data->queue, false) ; + +} /* macosx_fill_buffer */ + + +static void +macosx_audio_out_callback (void *user_data, AudioQueueRef audio_queue, AudioQueueBufferRef audio_buffer) +{ MacOSXAudioData *audio_data = (MacOSXAudioData *) user_data ; + + if (audio_data->queue == audio_queue) + macosx_fill_buffer (audio_data, audio_buffer) ; + +} /* macosx_audio_out_callback */ + + +static void +macosx_audio_out_property_callback (void *user_data, AudioQueueRef audio_queue, AudioQueuePropertyID prop) +{ MacOSXAudioData *audio_data = (MacOSXAudioData *) user_data ; + + if (prop == kAudioQueueProperty_IsRunning) + { UInt32 is_running = 0 ; + UInt32 is_running_size = sizeof (is_running) ; + + AudioQueueGetProperty (audio_queue, kAudioQueueProperty_IsRunning, &is_running, &is_running_size) ; + + if (!is_running) + { audio_data->done_playing = SF_TRUE ; + CFRunLoopStop (CFRunLoopGetCurrent ()) ; + } ; + } ; +} /* macosx_audio_out_property_callback */ + + + +static void +macosx_play (int argc, char *argv []) +{ MacOSXAudioData audio_data ; + OSStatus err ; + int i ; + int k ; + + memset (&audio_data, 0x55, sizeof (audio_data)) ; + + for (k = 1 ; k < argc ; k++) + { memset (&(audio_data.sfinfo), 0, sizeof (audio_data.sfinfo)) ; + + printf ("Playing %s\n", argv [k]) ; + if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo)))) + { puts (sf_strerror (NULL)) ; + continue ; + } ; + + if (audio_data.sfinfo.channels < 1 || audio_data.sfinfo.channels > 2) + { printf ("Error : channels = %d.\n", audio_data.sfinfo.channels) ; + continue ; + } ; + + /* fill ASBD */ + audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ; + audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ; + audio_data.format.mFormatID = kAudioFormatLinearPCM ; + audio_data.format.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked ; + audio_data.format.mBytesPerPacket = audio_data.format.mChannelsPerFrame * 2 ; + audio_data.format.mFramesPerPacket = 1 ; + audio_data.format.mBytesPerFrame = audio_data.format.mBytesPerPacket ; + audio_data.format.mBitsPerChannel = 16 ; + audio_data.format.mReserved = 0 ; + + /* create the queue */ + if ((err = AudioQueueNewOutput (&(audio_data.format), macosx_audio_out_callback, &audio_data, + CFRunLoopGetCurrent (), kCFRunLoopCommonModes, 0, &(audio_data.queue))) != noErr) + { printf ("AudioQueueNewOutput failed\n") ; + return ; + } ; + + /* add property listener */ + if ((err = AudioQueueAddPropertyListener (audio_data.queue, kAudioQueueProperty_IsRunning, macosx_audio_out_property_callback, &audio_data)) != noErr) + { printf ("AudioQueueAddPropertyListener failed\n") ; + return ; + } ; + + /* create the buffers */ + for (i = 0 ; i < kNumberOfAudioBuffers ; i++) + { if ((err = AudioQueueAllocateBuffer (audio_data.queue, kBytesPerAudioBuffer, &audio_data.queueBuffer [i])) != noErr) + { printf ("AudioQueueAllocateBuffer failed\n") ; + return ; + } ; + + macosx_fill_buffer (&audio_data, audio_data.queueBuffer [i]) ; + } ; + + audio_data.done_playing = SF_FALSE ; + + /* start queue */ + if ((err = AudioQueueStart (audio_data.queue, NULL)) != noErr) + { printf ("AudioQueueStart failed\n") ; + return ; + } ; + + while (audio_data.done_playing == SF_FALSE) + CFRunLoopRun () ; + + /* free the buffers */ + for (i = 0 ; i < kNumberOfAudioBuffers ; i++) + { if ((err = AudioQueueFreeBuffer (audio_data.queue, audio_data.queueBuffer [i])) != noErr) + { printf ("AudioQueueFreeBuffer failed\n") ; + return ; + } ; + } ; + + /* free the queue */ + if ((err = AudioQueueDispose (audio_data.queue, true)) != noErr) + { printf ("AudioQueueDispose failed\n") ; + return ; + } ; + + sf_close (audio_data.sndfile) ; + } ; + + return ; +} /* macosx_play, AudioQueue implementation */ + +#endif /* OSX_DARWIN_VERSION == 11 */ + +#if (OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10) +/* MacOSX 10.6 or earlier, use Carbon and AudioHardware API */ typedef struct { AudioStreamBasicDescription format ; @@ -564,7 +747,9 @@ macosx_play (int argc, char *argv []) /* Base setup completed. Now play files. */ for (k = 1 ; k < argc ; k++) - { printf ("Playing %s\n", argv [k]) ; + { memset (&(audio_data.sfinfo), 0, sizeof (audio_data.sfinfo)) ; + + printf ("Playing %s\n", argv [k]) ; if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo)))) { puts (sf_strerror (NULL)) ; continue ; @@ -625,10 +810,9 @@ macosx_play (int argc, char *argv []) } ; return ; -} /* macosx_play */ - -#endif /* MacOSX */ +} /* macosx_play, AudioHardware implementation */ +#endif /* OSX_DARWIN_VERSION > 0 && OSX_DARWIN_VERSION <= 10 */ /*------------------------------------------------------------------------------ ** Win32 functions for playing a sound. @@ -640,7 +824,7 @@ macosx_play (int argc, char *argv []) #if (OS_IS_WIN32 == 1) -#define WIN32_BUFFER_LEN (1<<15) +#define WIN32_BUFFER_LEN (1 << 15) typedef struct { HWAVEOUT hwave ; @@ -696,8 +880,9 @@ win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD_PTR data, DWORD param1 { Win32_Audio_Data *audio_data ; /* Prevent compiler warnings. */ - hwave = hwave ; - param1 = param2 ; + (void) hwave ; + (void) param1 ; + (void) param2 ; if (data == 0) return ; @@ -819,6 +1004,66 @@ win32_play (int argc, char *argv []) #endif /* Win32 */ +/*------------------------------------------------------------------------------ +** OpenBDS's sndio. +*/ + +#if defined (HAVE_SNDIO_H) + +static void +sndio_play (int argc, char *argv []) +{ struct sio_hdl *hdl ; + struct sio_par par ; + short buffer [BUFFER_LEN] ; + SNDFILE *sndfile ; + SF_INFO sfinfo ; + int k, readcount ; + + for (k = 1 ; k < argc ; k++) + { printf ("Playing %s\n", argv [k]) ; + if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo))) + { puts (sf_strerror (NULL)) ; + continue ; + } ; + + if (sfinfo.channels < 1 || sfinfo.channels > 2) + { printf ("Error : channels = %d.\n", sfinfo.channels) ; + continue ; + } ; + + if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL) + { fprintf (stderr, "open sndio device failed") ; + return ; + } ; + + sio_initpar (&par) ; + par.rate = sfinfo.samplerate ; + par.pchan = sfinfo.channels ; + par.bits = 16 ; + par.sig = 1 ; + par.le = SIO_LE_NATIVE ; + + if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par)) + { fprintf (stderr, "set sndio params failed") ; + return ; + } ; + + if (! sio_start (hdl)) + { fprintf (stderr, "sndio start failed") ; + return ; + } ; + + while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN))) + sio_write (hdl, buffer, readcount * sizeof (short)) ; + + sio_close (hdl) ; + } ; + + return ; +} /* sndio_play */ + +#endif /* sndio */ + /*------------------------------------------------------------------------------ ** Solaris. */ @@ -914,35 +1159,43 @@ main (int argc, char *argv []) { if (argc < 2) { - printf ("\nUsage : %s \n\n", argv [0]) ; + printf ("\nUsage : %s \n\n", program_name (argv [0])) ; + printf (" Using %s.\n\n", sf_version_string ()) ; #if (OS_IS_WIN32 == 1) printf ("This is a Unix style command line application which\n" "should be run in a MSDOS box or Command Shell window.\n\n") ; printf ("Sleeping for 5 seconds before exiting.\n\n") ; - /* This is the officially blessed by microsoft way but I can't get - ** it to link. - ** Sleep (15) ; - ** Instead, use this: - */ Sleep (5 * 1000) ; #endif return 1 ; } ; -#if defined (__linux__) +#if defined (__ANDROID__) + puts ("*** Playing sound not yet supported on Android.") ; + puts ("*** Please feel free to submit a patch.") ; + return 1 ; +#elif defined (__linux__) #if HAVE_ALSA_ASOUNDLIB_H if (access ("/proc/asound/cards", R_OK) == 0) alsa_play (argc, argv) ; else #endif - linux_play (argc, argv) ; -#elif (defined (__MACH__) && defined (__APPLE__)) + opensoundsys_play (argc, argv) ; +#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__) + opensoundsys_play (argc, argv) ; +#elif (defined (__MACH__) && defined (__APPLE__) && OSX_DARWIN_VERSION <= 11) macosx_play (argc, argv) ; +#elif defined HAVE_SNDIO_H + sndio_play (argc, argv) ; #elif (defined (sun) && defined (unix)) solaris_play (argc, argv) ; #elif (OS_IS_WIN32 == 1) win32_play (argc, argv) ; +#elif (defined (__MACH__) && defined (__APPLE__) && OSX_DARWIN_VERSION > 11) + printf ("OS X 10.8 and later have a new Audio API.\n") ; + printf ("Someone needs to write code to use that API.\n") ; + return 1 ; #elif defined (__BEOS__) printf ("This program cannot be compiled on BeOS.\n") ; printf ("Instead, compile the file sfplay_beos.cpp.\n") ; diff --git a/libs/libsndfile/programs/sndfile-salvage.c b/libs/libsndfile/programs/sndfile-salvage.c new file mode 100644 index 0000000000..db55e60edd --- /dev/null +++ b/libs/libsndfile/programs/sndfile-salvage.c @@ -0,0 +1,277 @@ +/* +** Copyright (C) 2010-2012 Erik de Castro Lopo +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the author nor the names of any contributors may be used +** to endorse or promote products derived from this software without +** specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "common.h" + +#define BUFFER_LEN (1 << 16) + +#define NOT(x) (! (x)) + + +static void usage_exit (const char *progname) ; +static void salvage_file (const char * broken_wav, const char * fixed_w64) ; + +int +main (int argc, char *argv []) +{ + if (argc != 3) + usage_exit (program_name (argv [0])) ; + + salvage_file (argv [1], argv [2]) ; + + return 0 ; +} /* main */ + +/*============================================================================== +*/ + +static void lseek_or_die (int fd, off_t offset, int whence) ; +static sf_count_t get_file_length (int fd, const char * name) ; +static sf_count_t find_data_offset (int fd, int format) ; +static void copy_data (int fd, SNDFILE * sndfile, int readsize) ; + + +static void +usage_exit (const char *progname) +{ printf ("Usage :\n\n %s \n\n", progname) ; + puts ("Salvages the audio data from WAV files which are more than 4G in length.\n") ; + printf ("Using %s.\n\n", sf_version_string ()) ; + exit (0) ; +} /* usage_exit */ + +static void +salvage_file (const char * broken_wav, const char * fixed_w64) +{ SNDFILE * sndfile ; + SF_INFO sfinfo ; + sf_count_t broken_len, data_offset ; + int fd, read_size ; + + if (strcmp (broken_wav, fixed_w64) == 0) + { printf ("Error : Input and output files must be different.\n\n") ; + exit (1) ; + } ; + + if ((fd = open (broken_wav, O_RDONLY)) < 0) + { printf ("Error : Not able to open file '%s' : %s\n", broken_wav, strerror (errno)) ; + exit (1) ; + } ; + + broken_len = get_file_length (fd, broken_wav) ; + if (broken_len <= 0xffffffff) + printf ("File is not greater than 4Gig but salvaging anyway.\n") ; + + /* Grab the format info from the broken file. */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + if ((sndfile = sf_open (broken_wav, SFM_READ, &sfinfo)) == NULL) + { printf ("sf_open ('%s') failed : %s\n", broken_wav, sf_strerror (NULL)) ; + exit (1) ; + } ; + sf_close (sndfile) ; + + data_offset = find_data_offset (fd, sfinfo.format & SF_FORMAT_TYPEMASK) ; + + printf ("Offset to audio data : %" PRId64 "\n", data_offset) ; + + switch (sfinfo.format & SF_FORMAT_TYPEMASK) + { case SF_FORMAT_WAV : + case SF_FORMAT_WAVEX : + sfinfo.format = SF_FORMAT_W64 | (sfinfo.format & SF_FORMAT_SUBMASK) ; + break ; + + default : + printf ("Don't currently support this file type.\n") ; + exit (1) ; + } ; + + switch (sfinfo.format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_PCM_U8 : + case SF_FORMAT_PCM_S8 : + read_size = 1 ; + break ; + + case SF_FORMAT_PCM_16 : + read_size = 2 ; + break ; + + case SF_FORMAT_PCM_24 : + read_size = 3 ; + break ; + + case SF_FORMAT_PCM_32 : + case SF_FORMAT_FLOAT : + read_size = 4 ; + break ; + + case SF_FORMAT_DOUBLE : + read_size = 8 ; + break ; + + default : + printf ("Sorry, don't currently support this file encoding type.\n") ; + exit (1) ; + } ; + + read_size *= sfinfo.channels ; + + if ((sndfile = sf_open (fixed_w64, SFM_WRITE, &sfinfo)) == NULL) + { printf ("sf_open ('%s') failed : %s\n", broken_wav, sf_strerror (NULL)) ; + exit (1) ; + } ; + + lseek_or_die (fd, data_offset, SEEK_SET) ; + + copy_data (fd, sndfile, read_size) ; + + sf_close (sndfile) ; + + puts ("Done!") ; +} /* salvage_file */ + +/*------------------------------------------------------------------------------ +*/ + +static void +lseek_or_die (int fd, off_t offset, int whence) +{ + if (lseek (fd, offset, whence) < 0) + { printf ("lseek failed : %s\n", strerror (errno)) ; + exit (1) ; + } ; + + return ; +} /* lseek_or_die */ + + +static sf_count_t +get_file_length (int fd, const char * name) +{ struct stat sbuf ; + + if (sizeof (sbuf.st_size) != 8) + { puts ("Error : sizeof (sbuf.st_size) != 8. Was program compiled with\n" + " 64 bit file offsets?\n") ; + exit (1) ; + } ; + + if (fstat (fd, &sbuf) != 0) + { printf ("Error : fstat ('%s') failed : %s\n", name, strerror (errno)) ; + exit (1) ; + } ; + + return sbuf.st_size ; +} /* get_file_length */ + +static sf_count_t +find_data_offset (int fd, int format) +{ char buffer [8192], *cptr ; + const char * target = "XXXX" ; + sf_count_t offset = -1, extra ; + int rlen, slen ; + + switch (format) + { case SF_FORMAT_WAV : + case SF_FORMAT_WAVEX : + target = "data" ; + extra = 8 ; + break ; + + case SF_FORMAT_AIFF : + target = "SSND" ; + extra = 16 ; + break ; + + default : + puts ("Error : Sorry, don't handle this input file format.\n") ; + exit (1) ; + } ; + + slen = strlen (target) ; + + lseek_or_die (fd, 0, SEEK_SET) ; + + printf ("Searching for '%s' maker.\n", target) ; + + if ((rlen = read (fd, buffer, sizeof (buffer))) < 0) + { printf ("Error : failed read : %s\n", strerror (errno)) ; + exit (1) ; + } ; + + cptr = memchr (buffer, target [0], rlen - slen) ; + if (cptr && memcmp (cptr, target, slen) == 0) + offset = cptr - buffer ; + else + { printf ("Error : Could not find data offset.\n") ; + exit (1) ; + } ; + + return offset + extra ; +} /* find_data_offset */ + +static void +copy_data (int fd, SNDFILE * sndfile, int readsize) +{ static char * buffer ; + sf_count_t readlen, count ; + int bufferlen, done = 0 ; + + bufferlen = readsize * 1024 ; + buffer = malloc (bufferlen) ; + + while (NOT (done) && (readlen = read (fd, buffer, bufferlen)) >= 0) + { if (readlen < bufferlen) + { readlen -= readlen % readsize ; + done = 1 ; + } ; + + if ((count = sf_write_raw (sndfile, buffer, readlen)) != readlen) + { printf ("Error : sf_write_raw returned %" PRId64 " : %s\n", count, sf_strerror (sndfile)) ; + return ; + } ; + } ; + + free (buffer) ; + + return ; +} /* copy_data */ + diff --git a/libs/libsndfile/programs/test-sndfile-metadata-set.py b/libs/libsndfile/programs/test-sndfile-metadata-set.py index 248cb70cd1..a21a36b3d1 100644 --- a/libs/libsndfile/programs/test-sndfile-metadata-set.py +++ b/libs/libsndfile/programs/test-sndfile-metadata-set.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright (C) 2008 Erik de Castro Lopo +# Copyright (C) 2008-2011 Erik de Castro Lopo # # All rights reserved. # @@ -176,7 +176,8 @@ test_post_mod (tests) test_update ([ ("--str-artist", "Fox") ]) -test_coding_history () +# This never worked. +# test_coding_history () test_rewrite () diff --git a/libs/libsndfile/regtest/Makefile.am b/libs/libsndfile/regtest/Makefile.am index 4d1ed4c0ce..a87d0c4f83 100644 --- a/libs/libsndfile/regtest/Makefile.am +++ b/libs/libsndfile/regtest/Makefile.am @@ -4,8 +4,9 @@ bin_PROGRAMS = sndfile-regtest noinst_HEADERS = regtest.h -INCLUDES = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS) sndfile_regtest_SOURCES = sndfile-regtest.c database.c checksum.c sndfile_regtest_LDADD = $(top_builddir)/src/libsndfile.la $(SQLITE3_LIBS) +CLEANFILES = *~ *.exe diff --git a/libs/libsndfile/regtest/Readme.txt b/libs/libsndfile/regtest/Readme.txt new file mode 100644 index 0000000000..bc038d6429 --- /dev/null +++ b/libs/libsndfile/regtest/Readme.txt @@ -0,0 +1,108 @@ +sndfile-regtest +=============== + +The 'sndfile-regtest' program is a regression test-suite for libsndile. + +This program is intended to allow anyone who has an interest in the +reliability and correctness of libsndfile to do their own regression +testing. From the point of view of the libsndfile developers, this +program now allows for distributed regression testing of libsndfile +which will make libsndfile better. + + +How Does it Work +---------------- +Anyone who wishes to take part in the distributed regression testing of +libsndfile can download the regression test program and install it. + +Once installed the user can start collecting files and adding them to +their own personal database. Then, as new versions of libsndfile come +out, the user should test the new library version against their database +of files (instructions below). + +Any files which were successfully added to the database in the past but +now fail the check with the new library version represent a regression. +The user should then contact the libsndfile developers so that a copy +of the test file can be made available to the developers. + + +Requirements +------------ +The regression test program uses sqlite3 as the database engine. On +Debian, the required packages are : + + sqlite3 + libsqlite3-0 + libsqlite3-dev + +but similar packages should be available on any other Linux style +system. + +The regression test currently only compiles under Unix-like systems. +At some time in the future the regression test will distributed along +with the libsndfile source code distribution. + + +Organization of Files +--------------------- +The regession test program keeps its database file in the directory it +is run from. In addition, the database only contains information about +the files, not the files themselves. + +This means that database file should probably be kept in the same +directory (or a directory above) the test files. + + +Setting it Up for the First Time +-------------------------------- +The sndfile-regtest program should be on your PATH. You can then cd into +the directory where you intend to keep you test files and +run the command: + + sndfile-regtest --create-db + +which creates a file named '.sndfile-regtest.db' in the current directory. + +Files can then be added to the database using the command: + + sndfile-regtest --add-file file1.wav + +The --add-file option allows more than one file to be added at a time +using: + + sndfile-regtest --add-file file1.wav file2.aif ..... + + +Checking Files +-------------- +One or more files that have already been added to the database can be +checked using: + + sndfile-regtest --check-file file1.wav file2.aif ..... + +It is also possible to check all files in the database using: + + sndfile-regtest --check-all + + +Running a Regression Test +------------------------- +Once you have a collection of files and a database it is possible to test +new versions of libsndfile before you install them. If for instance you +have just compiled a new version of libsndfile in the directory +/usr/src/libsndfile-X.Y.Z, then you can use an existing sndfile-regtest +binary with the new libsndfile using something like: + + LD_PRELOAD=/usr/src/libsndfile-X.Y.Z/src/.libs/libsndfile.so.X.Y.Z \ + sndfile-regtest --check-all + + +Reporting Regressions +--------------------- +Any user who finds a file which was added to the regression database with +an earlier version of libsndfile and then fails the check with a later +version of the library should contact the author (erikd at mega dash nerd +dot com). If possible place the file on a web server and email the author +a link to it. + + diff --git a/libs/libsndfile/regtest/checksum.c b/libs/libsndfile/regtest/checksum.c index 863fbed708..7f433a41c8 100644 --- a/libs/libsndfile/regtest/checksum.c +++ b/libs/libsndfile/regtest/checksum.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/regtest/database.c b/libs/libsndfile/regtest/database.c index f439f685df..f800a2c873 100644 --- a/libs/libsndfile/regtest/database.c +++ b/libs/libsndfile/regtest/database.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -146,7 +146,7 @@ db_file_exists (REG_DB * db_handle, const char * filename) db->count = 0 ; err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) count_callback, db, &errmsg) ; - if (db->count == 1) + if (err == 0 && db->count == 1) return 1 ; return 0 ; diff --git a/libs/libsndfile/regtest/regtest.h b/libs/libsndfile/regtest/regtest.h index 589f386de8..567d97be28 100644 --- a/libs/libsndfile/regtest/regtest.h +++ b/libs/libsndfile/regtest/regtest.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005 Erik de Castro Lopo +** Copyright (C) 2005-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/regtest/sndfile-regtest.c b/libs/libsndfile/regtest/sndfile-regtest.c index f7db490bd0..a28caa2d84 100644 --- a/libs/libsndfile/regtest/sndfile-regtest.c +++ b/libs/libsndfile/regtest/sndfile-regtest.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/sndfile.pc.in b/libs/libsndfile/sndfile.pc.in index f2a833bddb..28269c19eb 100644 --- a/libs/libsndfile/sndfile.pc.in +++ b/libs/libsndfile/sndfile.pc.in @@ -8,4 +8,5 @@ Description: A library for reading and writing audio files Requires: Version: @VERSION@ Libs: -L${libdir} -lsndfile +Libs.private: @EXTERNAL_LIBS@ Cflags: -I${includedir} diff --git a/libs/libsndfile/src/ALAC/ALACAudioTypes.h b/libs/libsndfile/src/ALAC/ALACAudioTypes.h new file mode 100644 index 0000000000..4d120fa5e4 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ALACAudioTypes.h @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ALACAudioTypes.h +*/ + +#ifndef ALACAUDIOTYPES_H +#define ALACAUDIOTYPES_H + +/* Force these Mac OS specific things to zero. */ +#define PRAGMA_STRUCT_ALIGN 0 +#define PRAGMA_STRUCT_PACKPUSH 0 +#define PRAGMA_STRUCT_PACK 0 +#define PRAGMA_ONCE 0 +#define PRAGMA_MARK 0 + + +#if PRAGMA_ONCE +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "sfendian.h" + +#if CPU_IS_BIG_ENDIAN == 1 +#define TARGET_RT_BIG_ENDIAN 1 +#else +#define TARGET_RT_BIG_ENDIAN 0 +#endif + +#define kChannelAtomSize 12 + +enum +{ + kALAC_UnimplementedError = -4, + kALAC_FileNotFoundError = -43, + kALAC_ParamError = -50, + kALAC_MemFullError = -108, + fALAC_FrameLengthError = -666, +}; + +enum +{ + kALACFormatAppleLossless = MAKE_MARKER ('a', 'l', 'a', 'c'), + kALACFormatLinearPCM = MAKE_MARKER ('l', 'p', 'c', 'm') +}; + +enum +{ + kALACMaxChannels = 8, + kALACMaxEscapeHeaderBytes = 8, + kALACMaxSearches = 16, + kALACMaxCoefs = 16, + kALACDefaultFramesPerPacket = 4096 +}; + +typedef uint32_t ALACChannelLayoutTag; + +enum +{ + kALACFormatFlagIsFloat = (1 << 0), // 0x1 + kALACFormatFlagIsBigEndian = (1 << 1), // 0x2 + kALACFormatFlagIsSignedInteger = (1 << 2), // 0x4 + kALACFormatFlagIsPacked = (1 << 3), // 0x8 + kALACFormatFlagIsAlignedHigh = (1 << 4), // 0x10 +}; + +enum +{ +#if TARGET_RT_BIG_ENDIAN + kALACFormatFlagsNativeEndian = kALACFormatFlagIsBigEndian +#else + kALACFormatFlagsNativeEndian = 0 +#endif +}; + +// this is required to be an IEEE 64bit float +typedef double alac_float64_t; + +// These are the Channel Layout Tags used in the Channel Layout Info portion of the ALAC magic cookie +enum +{ + kALACChannelLayoutTag_Mono = (100<<16) | 1, // C + kALACChannelLayoutTag_Stereo = (101<<16) | 2, // L R + kALACChannelLayoutTag_MPEG_3_0_B = (113<<16) | 3, // C L R + kALACChannelLayoutTag_MPEG_4_0_B = (116<<16) | 4, // C L R Cs + kALACChannelLayoutTag_MPEG_5_0_D = (120<<16) | 5, // C L R Ls Rs + kALACChannelLayoutTag_MPEG_5_1_D = (124<<16) | 6, // C L R Ls Rs LFE + kALACChannelLayoutTag_AAC_6_1 = (142<<16) | 7, // C L R Ls Rs Cs LFE + kALACChannelLayoutTag_MPEG_7_1_B = (127<<16) | 8 // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC) +}; + +// ALAC currently only utilizes these channels layouts. There is a one for one correspondance between a +// given number of channels and one of these layout tags +static const ALACChannelLayoutTag ALACChannelLayoutTags[kALACMaxChannels] = +{ + kALACChannelLayoutTag_Mono, // C + kALACChannelLayoutTag_Stereo, // L R + kALACChannelLayoutTag_MPEG_3_0_B, // C L R + kALACChannelLayoutTag_MPEG_4_0_B, // C L R Cs + kALACChannelLayoutTag_MPEG_5_0_D, // C L R Ls Rs + kALACChannelLayoutTag_MPEG_5_1_D, // C L R Ls Rs LFE + kALACChannelLayoutTag_AAC_6_1, // C L R Ls Rs Cs LFE + kALACChannelLayoutTag_MPEG_7_1_B // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC) +}; + +// AudioChannelLayout from CoreAudioTypes.h. We never need the AudioChannelDescription so we remove it +struct ALACAudioChannelLayout +{ + ALACChannelLayoutTag mChannelLayoutTag; + uint32_t mChannelBitmap; + uint32_t mNumberChannelDescriptions; +}; +typedef struct ALACAudioChannelLayout ALACAudioChannelLayout; + +struct AudioFormatDescription +{ + alac_float64_t mSampleRate; + uint32_t mFormatID; + uint32_t mFormatFlags; + uint32_t mBytesPerPacket; + uint32_t mFramesPerPacket; + uint32_t mBytesPerFrame; + uint32_t mChannelsPerFrame; + uint32_t mBitsPerChannel; + uint32_t mReserved; +}; +typedef struct AudioFormatDescription AudioFormatDescription; + +/* Lossless Definitions */ + +enum +{ + kALACCodecFormat = MAKE_MARKER ('a', 'l', 'a', 'c'), + kALACVersion = 0, + kALACCompatibleVersion = kALACVersion, + kALACDefaultFrameSize = 4096 +}; + +// note: this struct is wrapped in an 'alac' atom in the sample description extension area +// note: in QT movies, it will be further wrapped in a 'wave' atom surrounded by 'frma' and 'term' atoms +typedef struct ALACSpecificConfig +{ + uint32_t frameLength; + uint8_t compatibleVersion; + uint8_t bitDepth; // max 32 + uint8_t pb; // 0 <= pb <= 255 + uint8_t mb; + uint8_t kb; + uint8_t numChannels; + uint16_t maxRun; + uint32_t maxFrameBytes; + uint32_t avgBitRate; + uint32_t sampleRate; + +} ALACSpecificConfig; + + +// The AudioChannelLayout atom type is not exposed yet so define it here +enum +{ + AudioChannelLayoutAID = MAKE_MARKER ('c', 'h', 'a', 'n') +}; + +#if PRAGMA_STRUCT_ALIGN + #pragma options align=reset +#elif PRAGMA_STRUCT_PACKPUSH + #pragma pack(pop) +#elif PRAGMA_STRUCT_PACK + #pragma pack() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ALACAUDIOTYPES_H */ diff --git a/libs/libsndfile/src/ALAC/ALACBitUtilities.c b/libs/libsndfile/src/ALAC/ALACBitUtilities.c new file mode 100644 index 0000000000..f385daff0c --- /dev/null +++ b/libs/libsndfile/src/ALAC/ALACBitUtilities.c @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/*============================================================================= + File: ALACBitUtilities.c + + $NoKeywords: $ +=============================================================================*/ + +#include +#include "ALACBitUtilities.h" + +#define PRAGMA_MARK 0 + +// BitBufferInit +// +void BitBufferInit( BitBuffer * bits, uint8_t * buffer, uint32_t byteSize ) +{ + bits->cur = buffer; + bits->end = bits->cur + byteSize; + bits->bitIndex = 0; + bits->byteSize = byteSize; +} + +// BitBufferRead +// +uint32_t BitBufferRead( BitBuffer * bits, uint8_t numBits ) +{ + uint32_t returnBits; + + //Assert( numBits <= 16 ); + + returnBits = ((uint32_t)bits->cur[0] << 16) | ((uint32_t)bits->cur[1] << 8) | ((uint32_t)bits->cur[2]); + returnBits = returnBits << bits->bitIndex; + returnBits &= 0x00FFFFFF; + + bits->bitIndex += numBits; + + returnBits = returnBits >> (24 - numBits); + + bits->cur += (bits->bitIndex >> 3); + bits->bitIndex &= 7; + + //Assert( bits->cur <= bits->end ); + + return returnBits; +} + +// BitBufferReadSmall +// +// Reads up to 8 bits +uint8_t BitBufferReadSmall( BitBuffer * bits, uint8_t numBits ) +{ + uint16_t returnBits; + + //Assert( numBits <= 8 ); + + returnBits = (bits->cur[0] << 8) | bits->cur[1]; + returnBits = returnBits << bits->bitIndex; + + bits->bitIndex += numBits; + + returnBits = returnBits >> (16 - numBits); + + bits->cur += (bits->bitIndex >> 3); + bits->bitIndex &= 7; + + //Assert( bits->cur <= bits->end ); + + return (uint8_t)returnBits; +} + +// BitBufferReadOne +// +// Reads one byte +uint8_t BitBufferReadOne( BitBuffer * bits ) +{ + uint8_t returnBits; + + returnBits = (bits->cur[0] >> (7 - bits->bitIndex)) & 1; + + bits->bitIndex++; + + bits->cur += (bits->bitIndex >> 3); + bits->bitIndex &= 7; + + //Assert( bits->cur <= bits->end ); + + return returnBits; +} + +// BitBufferPeek +// +uint32_t BitBufferPeek( BitBuffer * bits, uint8_t numBits ) +{ + return ((((((uint32_t) bits->cur[0] << 16) | ((uint32_t) bits->cur[1] << 8) | + ((uint32_t) bits->cur[2])) << bits->bitIndex) & 0x00FFFFFF) >> (24 - numBits)); +} + +// BitBufferPeekOne +// +uint32_t BitBufferPeekOne( BitBuffer * bits ) +{ + return ((bits->cur[0] >> (7 - bits->bitIndex)) & 1); +} + +// BitBufferUnpackBERSize +// +uint32_t BitBufferUnpackBERSize( BitBuffer * bits ) +{ + uint32_t size; + uint8_t tmp; + + for ( size = 0, tmp = 0x80u; tmp &= 0x80u; size = (size << 7u) | (tmp & 0x7fu) ) + tmp = (uint8_t) BitBufferReadSmall( bits, 8 ); + + return size; +} + +// BitBufferGetPosition +// +uint32_t BitBufferGetPosition( BitBuffer * bits ) +{ + uint8_t * begin; + + begin = bits->end - bits->byteSize; + + return ((uint32_t)(bits->cur - begin) * 8) + bits->bitIndex; +} + +// BitBufferByteAlign +// +void BitBufferByteAlign( BitBuffer * bits, int32_t addZeros ) +{ + // align bit buffer to next byte boundary, writing zeros if requested + if ( bits->bitIndex == 0 ) + return; + + if ( addZeros ) + BitBufferWrite( bits, 0, 8 - bits->bitIndex ); + else + BitBufferAdvance( bits, 8 - bits->bitIndex ); +} + +// BitBufferAdvance +// +void BitBufferAdvance( BitBuffer * bits, uint32_t numBits ) +{ + if ( numBits ) + { + bits->bitIndex += numBits; + bits->cur += (bits->bitIndex >> 3); + bits->bitIndex &= 7; + } +} + +// BitBufferRewind +// +void BitBufferRewind( BitBuffer * bits, uint32_t numBits ) +{ + uint32_t numBytes; + + if ( numBits == 0 ) + return; + + if ( bits->bitIndex >= numBits ) + { + bits->bitIndex -= numBits; + return; + } + + numBits -= bits->bitIndex; + bits->bitIndex = 0; + + numBytes = numBits / 8; + numBits = numBits % 8; + + bits->cur -= numBytes; + + if ( numBits > 0 ) + { + bits->bitIndex = 8 - numBits; + bits->cur--; + } + + if ( bits->cur < (bits->end - bits->byteSize) ) + { + //DebugCMsg("BitBufferRewind: Rewound too far."); + + bits->cur = (bits->end - bits->byteSize); + bits->bitIndex = 0; + } +} + +// BitBufferWrite +// +void BitBufferWrite( BitBuffer * bits, uint32_t bitValues, uint32_t numBits ) +{ + uint32_t invBitIndex; + + RequireAction( bits != NULL, return; ); + RequireActionSilent( numBits > 0, return; ); + + invBitIndex = 8 - bits->bitIndex; + + while ( numBits > 0 ) + { + uint32_t tmp; + uint8_t shift; + uint8_t mask; + uint32_t curNum; + + curNum = MIN( invBitIndex, numBits ); + + tmp = bitValues >> (numBits - curNum); + + shift = (uint8_t)(invBitIndex - curNum); + mask = 0xffu >> (8 - curNum); // must be done in two steps to avoid compiler sequencing ambiguity + mask <<= shift; + + bits->cur[0] = (bits->cur[0] & ~mask) | (((uint8_t) tmp << shift) & mask); + numBits -= curNum; + + // increment to next byte if need be + invBitIndex -= curNum; + if ( invBitIndex == 0 ) + { + invBitIndex = 8; + bits->cur++; + } + } + + bits->bitIndex = 8 - invBitIndex; +} + +void BitBufferReset( BitBuffer * bits ) +//void BitBufferInit( BitBuffer * bits, uint8_t * buffer, uint32_t byteSize ) +{ + bits->cur = bits->end - bits->byteSize; + bits->bitIndex = 0; +} + +#if PRAGMA_MARK +#pragma mark - +#endif diff --git a/libs/libsndfile/src/ALAC/ALACBitUtilities.h b/libs/libsndfile/src/ALAC/ALACBitUtilities.h new file mode 100644 index 0000000000..5d3a4c1433 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ALACBitUtilities.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/*============================================================================= + File: ALACBitUtilities.h + + $NoKeywords: $ +=============================================================================*/ + +#ifndef __ALACBITUTILITIES_H +#define __ALACBITUTILITIES_H + +#include + +#ifndef MIN +#define MIN(x, y) ( (x)<(y) ?(x) :(y) ) +#endif //MIN +#ifndef MAX +#define MAX(x, y) ( (x)>(y) ?(x): (y) ) +#endif //MAX + +#define RequireAction(condition, action) if (!(condition)) { action } +#define RequireActionSilent(condition, action) if (!(condition)) { action } +#define RequireNoErr(condition, action) if ((condition)) { action } + +enum +{ + ALAC_noErr = 0 +}; + + +typedef enum +{ + + ID_SCE = 0, /* Single Channel Element */ + ID_CPE = 1, /* Channel Pair Element */ + ID_CCE = 2, /* Coupling Channel Element */ + ID_LFE = 3, /* LFE Channel Element */ + ID_DSE = 4, /* not yet supported */ + ID_PCE = 5, + ID_FIL = 6, + ID_END = 7 +} ELEMENT_TYPE; + +// types +typedef struct BitBuffer +{ + uint8_t * cur; + uint8_t * end; + uint32_t bitIndex; + uint32_t byteSize; + +} BitBuffer; + +/* + BitBuffer routines + - these routines take a fixed size buffer and read/write to it + - bounds checking must be done by the client +*/ +void BitBufferInit( BitBuffer * bits, uint8_t * buffer, uint32_t byteSize ); +uint32_t BitBufferRead( BitBuffer * bits, uint8_t numBits ); // note: cannot read more than 16 bits at a time +uint8_t BitBufferReadSmall( BitBuffer * bits, uint8_t numBits ); +uint8_t BitBufferReadOne( BitBuffer * bits ); +uint32_t BitBufferPeek( BitBuffer * bits, uint8_t numBits ); // note: cannot read more than 16 bits at a time +uint32_t BitBufferPeekOne( BitBuffer * bits ); +uint32_t BitBufferUnpackBERSize( BitBuffer * bits ); +uint32_t BitBufferGetPosition( BitBuffer * bits ); +void BitBufferByteAlign( BitBuffer * bits, int32_t addZeros ); +void BitBufferAdvance( BitBuffer * bits, uint32_t numBits ); +void BitBufferRewind( BitBuffer * bits, uint32_t numBits ); +void BitBufferWrite( BitBuffer * bits, uint32_t value, uint32_t numBits ); +void BitBufferReset( BitBuffer * bits); + +#endif /* __BITUTILITIES_H */ diff --git a/libs/libsndfile/src/ALAC/ALACDecoder.h b/libs/libsndfile/src/ALAC/ALACDecoder.h new file mode 100644 index 0000000000..baebd4fac4 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ALACDecoder.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ALACDecoder.h +*/ + +#ifndef _ALACDECODER_H +#define _ALACDECODER_H + +#include + +#include "ALACAudioTypes.h" + +struct BitBuffer; + +class ALACDecoder +{ + public: + ALACDecoder(); + ~ALACDecoder(); + + int32_t Init( void * inMagicCookie, uint32_t inMagicCookieSize ); + int32_t Decode( struct BitBuffer * bits, uint8_t * sampleBuffer, uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples ); + + public: + // decoding parameters (public for use in the analyzer) + ALACSpecificConfig mConfig; + + protected: + int32_t FillElement( struct BitBuffer * bits ); + int32_t DataStreamElement( struct BitBuffer * bits ); + + uint16_t mActiveElements; + + // decoding buffers + int32_t * mMixBufferU; + int32_t * mMixBufferV; + int32_t * mPredictor; + uint16_t * mShiftBuffer; // note: this points to mPredictor's memory but different + // variable for clarity and type difference +}; + +#endif /* _ALACDECODER_H */ diff --git a/libs/libsndfile/src/ALAC/ALACEncoder.h b/libs/libsndfile/src/ALAC/ALACEncoder.h new file mode 100644 index 0000000000..75a0a43721 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ALACEncoder.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ALACEncoder.h +*/ + +#pragma once + +#include + +#include "ALACAudioTypes.h" + + +struct BitBuffer; + +class ALACEncoder +{ + public: + ALACEncoder(); + virtual ~ALACEncoder(); + + virtual int32_t Encode(AudioFormatDescription theInputFormat, AudioFormatDescription theOutputFormat, + unsigned char * theReadBuffer, unsigned char * theWriteBuffer, int32_t * ioNumBytes); + virtual int32_t Finish( ); + + void SetFastMode( bool fast ) { mFastMode = fast; }; + + // this must be called *before* InitializeEncoder() + void SetFrameSize( uint32_t frameSize ) { mFrameSize = frameSize; }; + + void GetConfig( ALACSpecificConfig & config ); + uint32_t GetMagicCookieSize(uint32_t inNumChannels); + void GetMagicCookie( void * config, uint32_t * ioSize ); + + virtual int32_t InitializeEncoder(AudioFormatDescription theOutputFormat); + + protected: + virtual void GetSourceFormat( const AudioFormatDescription * source, AudioFormatDescription * output ); + + int32_t EncodeStereo( struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); + int32_t EncodeStereoFast( struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); + int32_t EncodeStereoEscape( struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t numSamples ); + int32_t EncodeMono( struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); + + + // ALAC encoder parameters + int16_t mBitDepth; + bool mFastMode; + + // encoding state + int16_t mLastMixRes[kALACMaxChannels]; + + // encoding buffers + int32_t * mMixBufferU; + int32_t * mMixBufferV; + int32_t * mPredictorU; + int32_t * mPredictorV; + uint16_t * mShiftBufferUV; + + uint8_t * mWorkBuffer; + + // per-channel coefficients buffers + int16_t mCoefsU[kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs]; + int16_t mCoefsV[kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs]; + + // encoding statistics + uint32_t mTotalBytesGenerated; + uint32_t mAvgBitRate; + uint32_t mMaxFrameBytes; + uint32_t mFrameSize; + uint32_t mMaxOutputBytes; + uint32_t mNumChannels; + uint32_t mOutputSampleRate; +}; diff --git a/libs/libsndfile/src/ALAC/EndianPortable.h b/libs/libsndfile/src/ALAC/EndianPortable.h new file mode 100644 index 0000000000..d0b132761f --- /dev/null +++ b/libs/libsndfile/src/ALAC/EndianPortable.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. +** Copyright (C) 2013 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +// +// EndianPortable.h +// +// Copyright 2011 Apple Inc. All rights reserved. +// + +#ifndef _EndianPortable_h +#define _EndianPortable_h + +#include + +#define Swap16NtoB(x) H2BE_16(x) +#define Swap16BtoN(x) BE2H_16(x) + +#define Swap32NtoB(x) H2BE_32(x) +#define Swap32BtoN(x) BE2H_32(x) + +#endif diff --git a/libs/libsndfile/src/ALAC/LICENSE b/libs/libsndfile/src/ALAC/LICENSE new file mode 100644 index 0000000000..7d8595490d --- /dev/null +++ b/libs/libsndfile/src/ALAC/LICENSE @@ -0,0 +1,170 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the +copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other +entities that control, are controlled by, or are under common control +with that entity. For the purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (ii) ownership +of fifty percent (50%) or more of the outstanding shares, or (iii) +beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but not +limited to compiled object code, generated documentation, and +conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object +form, made available under the License, as indicated by a copyright +notice that is included in or attached to the work (an example is +provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual +or Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor +or its representatives, including but not limited to communication +on electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated in +writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions +of this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, publicly +display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except +as stated in this section) patent license to make, have made, use, +offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work to which +such Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim in a +lawsuit) alleging that the Work or a Contribution incorporated within +the Work constitutes direct or contributory patent infringement, then +any patent licenses granted to You under this License for that Work +shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You meet the +following conditions: + +You must give any other recipients of the Work or Derivative Works a +copy of this License; and + +You must cause any modified files to carry prominent notices stating +that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You +distribute, all copyright, patent, trademark, and attribution notices +from the Source form of the Work, excluding those notices that do not +pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, +then any Derivative Works that You distribute must include a readable +copy of the attribution notices contained within such NOTICE file, +excluding those notices that do not pertain to any part of the +Derivative Works, in at least one of the following places: within a +NOTICE text file distributed as part of the Derivative Works; within +the Source form or documentation, if provided along with the Derivative +Works; or, within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents of the +NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative +Works that You distribute, alongside or as an addendum to the NOTICE +text from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional +or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as +a whole, provided Your use, reproduction, and distribution of the Work +otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work by +You to the Licensor shall be under the terms and conditions of this +License, without any additional terms or conditions. Notwithstanding +the above, nothing herein shall supersede or modify the terms of any +separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed +to in writing, Licensor provides the Work (and each Contributor +provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied, including, without +limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, +MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your +exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, unless +required by applicable law (such as deliberate and grossly negligent +acts) or agreed to in writing, shall any Contributor be liable to You +for damages, including any direct, indirect, special, incidental, or +consequential damages of any character arising as a result of this +License or out of the use or inability to use the Work (including but +not limited to damages for loss of goodwill, work stoppage, computer +failure or malfunction, or any and all other commercial damages or +losses), even if such Contributor has been advised of the possibility of +such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the +Work or Derivative Works thereof, You may choose to offer, and charge a +fee for, acceptance of support, warranty, indemnity, or other liability +obligations and/or rights consistent with this License. However, in +accepting such obligations, You may act only on Your own behalf and +on Your sole responsibility, not on behalf of any other Contributor, +and only if You agree to indemnify, defend, and hold each Contributor +harmless for any liability incurred by, or claims asserted against, such +Contributor by reason of your accepting any such warranty or additional +liability. diff --git a/libs/libsndfile/src/ALAC/ag_dec.c b/libs/libsndfile/src/ALAC/ag_dec.c new file mode 100644 index 0000000000..81c18dc920 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ag_dec.c @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ag_dec.c + + Contains: Adaptive Golomb decode routines. + + Copyright: (c) 2001-2011 Apple, Inc. +*/ + +#include "aglib.h" +#include "ALACBitUtilities.h" +#include "ALACAudioTypes.h" + +#include +#include +#include +#include + +#define CODE_TO_LONG_MAXBITS 32 +#define N_MAX_MEAN_CLAMP 0xffff +#define N_MEAN_CLAMP_VAL 0xffff +#define REPORT_VAL 40 + +#if __GNUC__ +#define ALWAYS_INLINE __attribute__((always_inline)) +#else +#define ALWAYS_INLINE +#endif + +/* And on the subject of the CodeWarrior x86 compiler and inlining, I reworked a lot of this + to help the compiler out. In many cases this required manual inlining or a macro. Sorry + if it is ugly but the performance gains are well worth it. + - WSK 5/19/04 +*/ + +void set_standard_ag_params(AGParamRecPtr params, uint32_t fullwidth, uint32_t sectorwidth) +{ + /* Use + fullwidth = sectorwidth = numOfSamples, for analog 1-dimensional type-short data, + but use + fullwidth = full image width, sectorwidth = sector (patch) width + for such as image (2-dim.) data. + */ + set_ag_params( params, MB0, PB0, KB0, fullwidth, sectorwidth, MAX_RUN_DEFAULT ); +} + +void set_ag_params(AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uint32_t f, uint32_t s, uint32_t maxrun) +{ + params->mb = params->mb0 = m; + params->pb = p; + params->kb = k; + params->wb = (1u<kb)-1; + params->qb = QB-params->pb; + params->fw = f; + params->sw = s; + params->maxrun = maxrun; +} + +#if PRAGMA_MARK +#pragma mark - +#endif + + +// note: implementing this with some kind of "count leading zeros" assembly is a big performance win +static inline int32_t lead( int32_t m ) +{ + long j; + unsigned long c = (1ul << 31); + + for(j=0; j < 32; j++) + { + if((c & m) != 0) + break; + c >>= 1; + } + return (j); +} + +#define arithmin(a, b) ((a) < (b) ? (a) : (b)) + +static inline int32_t ALWAYS_INLINE lg3a( int32_t x) +{ + int32_t result; + + x += 3; + result = lead(x); + + return 31 - result; +} + +static inline uint32_t ALWAYS_INLINE read32bit( uint8_t * buffer ) +{ + // embedded CPUs typically can't read unaligned 32-bit words so just read the bytes + uint32_t value; + + value = ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | + ((uint32_t)buffer[2] << 8) | (uint32_t)buffer[3]; + return value; + +} + +#if PRAGMA_MARK +#pragma mark - +#endif + +#define get_next_fromlong(inlong, suff) ((inlong) >> (32 - (suff))) + + +static inline uint32_t ALWAYS_INLINE +getstreambits( uint8_t *in, int32_t bitoffset, int32_t numbits ) +{ + uint32_t load1, load2; + uint32_t byteoffset = bitoffset / 8; + uint32_t result; + + //Assert( numbits <= 32 ); + + load1 = read32bit( in + byteoffset ); + + if ( (numbits + (bitoffset & 0x7)) > 32) + { + int32_t load2shift; + + result = load1 << (bitoffset & 0x7); + load2 = (uint32_t) in[byteoffset+4]; + load2shift = (8-(numbits + (bitoffset & 0x7)-32)); + load2 >>= load2shift; + result >>= (32-numbits); + result |= load2; + } + else + { + result = load1 >> (32-numbits-(bitoffset & 7)); + } + + // a shift of >= "the number of bits in the type of the value being shifted" results in undefined + // behavior so don't try to shift by 32 + if ( numbits != (sizeof(result) * 8) ) + result &= ~(0xfffffffful << numbits); + + return result; +} + + +static inline int32_t dyn_get(unsigned char *in, uint32_t *bitPos, uint32_t m, uint32_t k) +{ + uint32_t tempbits = *bitPos; + uint32_t result; + uint32_t pre = 0, v; + uint32_t streamlong; + + streamlong = read32bit( in + (tempbits >> 3) ); + streamlong <<= (tempbits & 7); + + /* find the number of bits in the prefix */ + { + uint32_t notI = ~streamlong; + pre = lead( notI); + } + + if(pre >= MAX_PREFIX_16) + { + pre = MAX_PREFIX_16; + tempbits += pre; + streamlong <<= pre; + result = get_next_fromlong(streamlong,MAX_DATATYPE_BITS_16); + tempbits += MAX_DATATYPE_BITS_16; + + } + else + { + // all of the bits must fit within the long we have loaded + //Assert(pre+1+k <= 32); + + tempbits += pre; + tempbits += 1; + streamlong <<= pre+1; + v = get_next_fromlong(streamlong, k); + tempbits += k; + + result = pre*m + v-1; + + if(v<2) { + result -= (v-1); + tempbits -= 1; + } + } + + *bitPos = tempbits; + return result; +} + + +static inline int32_t dyn_get_32bit( uint8_t * in, uint32_t * bitPos, int32_t m, int32_t k, int32_t maxbits ) +{ + uint32_t tempbits = *bitPos; + uint32_t v; + uint32_t streamlong; + uint32_t result; + + streamlong = read32bit( in + (tempbits >> 3) ); + streamlong <<= (tempbits & 7); + + /* find the number of bits in the prefix */ + { + uint32_t notI = ~streamlong; + result = lead( notI); + } + + if(result >= MAX_PREFIX_32) + { + result = getstreambits(in, tempbits+MAX_PREFIX_32, maxbits); + tempbits += MAX_PREFIX_32 + maxbits; + } + else + { + /* all of the bits must fit within the long we have loaded*/ + //Assert(k<=14); + //Assert(result=2) + { + result += (v-1); + tempbits += 1; + } + } + } + + *bitPos = tempbits; + + return result; +} + +int32_t dyn_decomp( AGParamRecPtr params, BitBuffer * bitstream, int32_t * pc, int32_t numSamples, int32_t maxSize, uint32_t * outNumBits ) +{ + uint8_t *in; + int32_t *outPtr = pc; + uint32_t bitPos, startPos, maxPos; + uint32_t j, m, k, n, c, mz; + int32_t del, zmode; + uint32_t mb; + uint32_t pb_local = params->pb; + uint32_t kb_local = params->kb; + uint32_t wb_local = params->wb; + int32_t status; + + RequireAction( (bitstream != NULL) && (pc != NULL) && (outNumBits != NULL), return kALAC_ParamError; ); + *outNumBits = 0; + + in = bitstream->cur; + startPos = bitstream->bitIndex; + maxPos = bitstream->byteSize * 8; + bitPos = startPos; + + mb = params->mb0; + zmode = 0; + + c = 0; + status = ALAC_noErr; + + while (c < (uint32_t) numSamples) + { + // bail if we've run off the end of the buffer + RequireAction( bitPos < maxPos, status = kALAC_ParamError; goto Exit; ); + + m = (mb)>>QBSHIFT; + k = lg3a(m); + + k = arithmin(k, kb_local); + m = (1<> 1) * (multiplier); + } + + *outPtr++ = del; + + c++; + + mb = pb_local*(n+zmode) + mb - ((pb_local*mb)>>QBSHIFT); + + // update mean tracking + if (n > N_MAX_MEAN_CLAMP) + mb = N_MEAN_CLAMP_VAL; + + zmode = 0; + + if (((mb << MMULSHIFT) < QB) && (c < (uint32_t) numSamples)) + { + zmode = 1; + k = lead(mb) - BITOFF+((mb+MOFF)>>MDENSHIFT); + mz = ((1<= 65535) + zmode = 0; + + mb = 0; + } + } + +Exit: + *outNumBits = (bitPos - startPos); + BitBufferAdvance( bitstream, *outNumBits ); + RequireAction( bitstream->cur <= bitstream->end, status = kALAC_ParamError; ); + + return status; +} diff --git a/libs/libsndfile/src/ALAC/ag_enc.c b/libs/libsndfile/src/ALAC/ag_enc.c new file mode 100644 index 0000000000..0916cc0852 --- /dev/null +++ b/libs/libsndfile/src/ALAC/ag_enc.c @@ -0,0 +1,360 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2013 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ag_enc.c + + Contains: Adaptive Golomb encode routines. + + Copyright: (c) 2001-2011 Apple, Inc. +*/ + +#include "aglib.h" +#include "ALACBitUtilities.h" +#include "EndianPortable.h" +#include "ALACAudioTypes.h" + +#include +#include +#include +#include + +#define CODE_TO_LONG_MAXBITS 32 +#define N_MAX_MEAN_CLAMP 0xffff +#define N_MEAN_CLAMP_VAL 0xffff +#define REPORT_VAL 40 + +#if __GNUC__ +#define ALWAYS_INLINE __attribute__((always_inline)) +#else +#define ALWAYS_INLINE +#endif + + +/* And on the subject of the CodeWarrior x86 compiler and inlining, I reworked a lot of this + to help the compiler out. In many cases this required manual inlining or a macro. Sorry + if it is ugly but the performance gains are well worth it. + - WSK 5/19/04 +*/ + +// note: implementing this with some kind of "count leading zeros" assembly is a big performance win +static inline int32_t lead( int32_t m ) +{ + long j; + unsigned long c = (1ul << 31); + + for(j=0; j < 32; j++) + { + if((c & m) != 0) + break; + c >>= 1; + } + return (j); +} + +#define arithmin(a, b) ((a) < (b) ? (a) : (b)) + +static inline int32_t ALWAYS_INLINE lg3a( int32_t x) +{ + int32_t result; + + x += 3; + result = lead(x); + + return 31 - result; +} + +static inline int32_t ALWAYS_INLINE abs_func( int32_t a ) +{ + // note: the CW PPC intrinsic __abs() turns into these instructions so no need to try and use it + int32_t isneg = a >> 31; + int32_t xorval = a ^ isneg; + int32_t result = xorval-isneg; + + return result; +} + +static inline uint32_t ALWAYS_INLINE read32bit( uint8_t * buffer ) +{ + // embedded CPUs typically can't read unaligned 32-bit words so just read the bytes + uint32_t value; + + value = ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | + ((uint32_t)buffer[2] << 8) | (uint32_t)buffer[3]; + return value; +} + +#if PRAGMA_MARK +#pragma mark - +#endif + +static inline int32_t dyn_code(int32_t m, int32_t k, int32_t n, uint32_t *outNumBits) +{ + uint32_t divx, mod, de; + uint32_t numBits; + uint32_t value; + + //Assert( n >= 0 ); + + divx = n/m; + + if(divx >= MAX_PREFIX_16) + { + numBits = MAX_PREFIX_16 + MAX_DATATYPE_BITS_16; + value = (((1< MAX_PREFIX_16 + MAX_DATATYPE_BITS_16) + { + numBits = MAX_PREFIX_16 + MAX_DATATYPE_BITS_16; + value = (((1< 25) + goto codeasescape; + } + else + { +codeasescape: + numBits = MAX_PREFIX_32; + value = (((1<> 3); + + shift = 32 - (bitPos & 7) - numBits; + + mask = ~0u >> (32 - numBits); // mask must be created in two steps to avoid compiler sequencing ambiguity + mask <<= shift; + + value = (value << shift) & mask; + value |= curr & ~mask; + + psf_put_be32 (out, bitPos >> 3, value) ; +} + + +static inline void ALWAYS_INLINE dyn_jam_noDeref_large(unsigned char *out, uint32_t bitPos, uint32_t numBits, uint32_t value) +{ + uint32_t w; + uint32_t curr; + uint32_t mask; + int32_t shiftvalue = (32 - (bitPos&7) - numBits); + + //Assert(numBits <= 32); + + curr = psf_get_be32 (out, bitPos >> 3); + + if (shiftvalue < 0) + { + uint8_t tailbyte; + uint8_t *tailptr; + + w = value >> -shiftvalue; + mask = ~0u >> -shiftvalue; + w |= (curr & ~mask); + + tailptr = out + (bitPos>>3) + 4; + tailbyte = (value << ((8+shiftvalue))) & 0xff; + *tailptr = (uint8_t)tailbyte; + } + else + { + mask = ~0u >> (32 - numBits); + mask <<= shiftvalue; // mask must be created in two steps to avoid compiler sequencing ambiguity + + w = (value << shiftvalue) & mask; + w |= curr & ~mask; + } + + psf_put_be32 (out, bitPos >> 3, w) ; +} + + +int32_t dyn_comp( AGParamRecPtr params, int32_t * pc, BitBuffer * bitstream, int32_t numSamples, int32_t bitSize, uint32_t * outNumBits ) +{ + unsigned char * out; + uint32_t bitPos, startPos; + uint32_t m, k, n, c, mz, nz; + uint32_t numBits; + uint32_t value; + int32_t del, zmode; + uint32_t overflow, overflowbits; + int32_t status; + + // shadow the variables in params so there's not the dereferencing overhead + uint32_t mb, pb, kb, wb; + int32_t rowPos = 0; + int32_t rowSize = params->sw; + int32_t rowJump = (params->fw) - rowSize; + int32_t * inPtr = pc; + + *outNumBits = 0; + RequireAction( (bitSize >= 1) && (bitSize <= 32), return kALAC_ParamError; ); + + out = bitstream->cur; + startPos = bitstream->bitIndex; + bitPos = startPos; + + mb = params->mb = params->mb0; + pb = params->pb; + kb = params->kb; + wb = params->wb; + zmode = 0; + + c=0; + status = ALAC_noErr; + + while (c < (uint32_t) numSamples) + { + m = mb >> QBSHIFT; + k = lg3a(m); + if ( k > kb) + { + k = kb; + } + m = (1<> 31) & 1) - zmode; + //Assert( 32-lead(n) <= bitSize ); + + if ( dyn_code_32bit(bitSize, m, k, n, &numBits, &value, &overflow, &overflowbits) ) + { + dyn_jam_noDeref(out, bitPos, numBits, value); + bitPos += numBits; + dyn_jam_noDeref_large(out, bitPos, overflowbits, overflow); + bitPos += overflowbits; + } + else + { + dyn_jam_noDeref(out, bitPos, numBits, value); + bitPos += numBits; + } + + c++; + if ( rowPos >= rowSize) + { + rowPos = 0; + inPtr += rowJump; + } + + mb = pb * (n + zmode) + mb - ((pb *mb)>>QBSHIFT); + + // update mean tracking if it's overflowed + if (n > N_MAX_MEAN_CLAMP) + mb = N_MEAN_CLAMP_VAL; + + zmode = 0; + + RequireAction(c <= (uint32_t) numSamples, status = kALAC_ParamError; goto Exit; ); + + if (((mb << MMULSHIFT) < QB) && (c < (uint32_t) numSamples)) + { + zmode = 1; + nz = 0; + + while(c<(uint32_t) numSamples && *inPtr == 0) + { + /* Take care of wrap-around globals. */ + ++inPtr; + ++nz; + ++c; + if ( ++rowPos >= rowSize) + { + rowPos = 0; + inPtr += rowJump; + } + + if(nz >= 65535) + { + zmode = 0; + break; + } + } + + k = lead(mb) - BITOFF+((mb+MOFF)>>MDENSHIFT); + mz = ((1< + +#ifdef __cplusplus +extern "C" { +#endif + +#define QBSHIFT 9 +#define QB (1< + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: alac_codec.h +*/ + +#ifndef ALAC_CODEC_H +#define ALAC_CODEC_H + +#include + +#include "ALACAudioTypes.h" + +#define ALAC_FRAME_LENGTH 4096 + +struct BitBuffer; + +typedef struct alac_decoder_s +{ + // decoding parameters (public for use in the analyzer) + ALACSpecificConfig mConfig; + + uint16_t mActiveElements; + + // decoding buffers + int32_t mMixBufferU [ALAC_FRAME_LENGTH]; + int32_t mMixBufferV [ALAC_FRAME_LENGTH]; + union + { + int32_t mPredictor [ALAC_FRAME_LENGTH]; + uint16_t mShiftBuffer [ALAC_FRAME_LENGTH]; + } ; +} ALAC_DECODER ; + +typedef struct alac_encoder_s +{ + // ALAC encoder parameters + int16_t mBitDepth; + + // encoding state + int16_t mLastMixRes [kALACMaxChannels]; + + int32_t mFastMode; + + // encoding buffers + int32_t mMixBufferU [ALAC_FRAME_LENGTH] ; + int32_t mMixBufferV [ALAC_FRAME_LENGTH] ; + int32_t mPredictorU [ALAC_FRAME_LENGTH] ; + int32_t mPredictorV [ALAC_FRAME_LENGTH] ; + uint16_t mShiftBufferUV [2 * ALAC_FRAME_LENGTH] ; + uint8_t mWorkBuffer [4 * ALAC_FRAME_LENGTH]; + + // per-channel coefficients buffers + int16_t mCoefsU [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs]; + int16_t mCoefsV [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs]; + + // encoding statistics + uint32_t mTotalBytesGenerated; + uint32_t mAvgBitRate; + uint32_t mMaxFrameBytes; + uint32_t mFrameSize; + uint32_t mMaxOutputBytes; + uint32_t mNumChannels; + uint32_t mOutputSampleRate; +} ALAC_ENCODER ; + + +int32_t alac_decoder_init (ALAC_DECODER *p, void * inMagicCookie, uint32_t inMagicCookieSize) ; +int32_t alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint32_t format_flags, uint32_t frameSize) ; + +int32_t alac_decode (ALAC_DECODER *, struct BitBuffer * bits, int32_t * sampleBuffer, + uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples) ; + +int32_t alac_encode (ALAC_ENCODER *p, uint32_t numChannels, uint32_t numSamples, + int32_t * theReadBuffer, unsigned char * theWriteBuffer, + uint32_t * ioNumBytes) ; + +void alac_set_fastmode(ALAC_ENCODER * p, int32_t fast) ; + +uint32_t alac_get_magic_cookie_size(uint32_t inNumChannels) ; +void alac_get_magic_cookie(ALAC_ENCODER *p, void * config, uint32_t * ioSize) ; +void alac_get_source_format(ALAC_ENCODER *p, const AudioFormatDescription * source, AudioFormatDescription * output) ; + +#endif diff --git a/libs/libsndfile/src/ALAC/alac_decoder.c b/libs/libsndfile/src/ALAC/alac_decoder.c new file mode 100644 index 0000000000..2681ef6275 --- /dev/null +++ b/libs/libsndfile/src/ALAC/alac_decoder.c @@ -0,0 +1,646 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012-2013 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ALACDecoder.cpp +*/ + +#include +#include +#include + +#include "alac_codec.h" + +#include "dplib.h" +#include "aglib.h" +#include "matrixlib.h" + +#include "ALACBitUtilities.h" +#include "EndianPortable.h" + +typedef enum +{ false = 0, + true = 1 +} bool ; + +// constants/data +const uint32_t kMaxBitDepth = 32; // max allowed bit depth is 32 + + +// prototypes +static int32_t alac_fill_element (struct BitBuffer * bits) ; +static int32_t alac_data_stream_element (struct BitBuffer * bits) ; + +static void Zero32( int32_t * buffer, uint32_t numItems, uint32_t stride ); + + +/* + Init() + - initialize the decoder with the given configuration +*/ +int32_t +alac_decoder_init (ALAC_DECODER *p, void * inMagicCookie, uint32_t inMagicCookieSize) +{ + int32_t status = ALAC_noErr; + ALACSpecificConfig theConfig; + uint8_t * theActualCookie = (uint8_t *)inMagicCookie; + uint32_t theCookieBytesRemaining = inMagicCookieSize; + + // For historical reasons the decoder needs to be resilient to magic cookies vended by older encoders. + // As specified in the ALACMagicCookieDescription.txt document, there may be additional data encapsulating + // the ALACSpecificConfig. This would consist of format ('frma') and 'alac' atoms which precede the + // ALACSpecificConfig. + // See ALACMagicCookieDescription.txt for additional documentation concerning the 'magic cookie' + + // skip format ('frma') atom if present + if (theActualCookie[4] == 'f' && theActualCookie[5] == 'r' && theActualCookie[6] == 'm' && theActualCookie[7] == 'a') + { + theActualCookie += 12; + theCookieBytesRemaining -= 12; + } + + // skip 'alac' atom header if present + if (theActualCookie[4] == 'a' && theActualCookie[5] == 'l' && theActualCookie[6] == 'a' && theActualCookie[7] == 'c') + { + theActualCookie += 12; + theCookieBytesRemaining -= 12; + } + + // read the ALACSpecificConfig + if (theCookieBytesRemaining >= sizeof(ALACSpecificConfig)) + { + theConfig.frameLength = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, frameLength)) ; + + if (theConfig.frameLength > ALAC_FRAME_LENGTH) + return fALAC_FrameLengthError ; + + theConfig.compatibleVersion = theActualCookie [offsetof (ALACSpecificConfig, compatibleVersion)] ; + theConfig.bitDepth = theActualCookie [offsetof (ALACSpecificConfig, bitDepth)] ; + theConfig.pb = theActualCookie [offsetof (ALACSpecificConfig, pb)] ; + theConfig.mb = theActualCookie [offsetof (ALACSpecificConfig, mb)] ; + theConfig.kb = theActualCookie [offsetof (ALACSpecificConfig, kb)] ; + theConfig.numChannels = theActualCookie [offsetof (ALACSpecificConfig, numChannels)] ; + theConfig.maxRun = psf_get_be16 (theActualCookie, offsetof (ALACSpecificConfig, maxRun)) ; + theConfig.maxFrameBytes = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, maxFrameBytes)) ; + theConfig.avgBitRate = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, avgBitRate)) ; + theConfig.sampleRate = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, sampleRate)) ; + + p->mConfig = theConfig; + + RequireAction( p->mConfig.compatibleVersion <= kALACVersion, return kALAC_ParamError; ); + + RequireAction( (p->mMixBufferU != NULL) && (p->mMixBufferV != NULL) && (p->mPredictor != NULL), + status = kALAC_MemFullError; goto Exit; ); + } + else + { + status = kALAC_ParamError; + } + + // skip to Channel Layout Info + // theActualCookie += sizeof(ALACSpecificConfig); + + // Currently, the Channel Layout Info portion of the magic cookie (as defined in the + // ALACMagicCookieDescription.txt document) is unused by the decoder. + +Exit: + return status; +} + +/* + Decode() + - the decoded samples are interleaved into the output buffer in the order they arrive in + the bitstream +*/ +int32_t +alac_decode (ALAC_DECODER *p, struct BitBuffer * bits, int32_t * sampleBuffer, uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples) +{ + BitBuffer shiftBits; + uint32_t bits1, bits2; + uint8_t tag; + uint8_t elementInstanceTag; + AGParamRec agParams; + uint32_t channelIndex; + int16_t coefsU[32]; // max possible size is 32 although NUMCOEPAIRS is the current limit + int16_t coefsV[32]; + uint8_t numU, numV; + uint8_t mixBits; + int8_t mixRes; + uint16_t unusedHeader; + uint8_t escapeFlag; + uint32_t chanBits; + uint8_t bytesShifted; + uint32_t shift; + uint8_t modeU, modeV; + uint32_t denShiftU, denShiftV; + uint16_t pbFactorU, pbFactorV; + uint16_t pb; + int32_t * out32; + uint8_t headerByte; + uint8_t partialFrame; + uint32_t extraBits; + int32_t val; + uint32_t i, j; + int32_t status; + + RequireAction( (bits != NULL) && (sampleBuffer != NULL) && (outNumSamples != NULL), return kALAC_ParamError; ); + RequireAction( numChannels > 0, return kALAC_ParamError; ); + + p->mActiveElements = 0; + channelIndex = 0; + + status = ALAC_noErr; + *outNumSamples = numSamples; + + while ( status == ALAC_noErr ) + { + // bail if we ran off the end of the buffer + RequireAction( bits->cur < bits->end, status = kALAC_ParamError; goto Exit; ); + + // copy global decode params for this element + pb = p->mConfig.pb; + + // read element tag + tag = BitBufferReadSmall( bits, 3 ); + switch ( tag ) + { + case ID_SCE: + case ID_LFE: + { + // mono/LFE channel + elementInstanceTag = BitBufferReadSmall( bits, 4 ); + p->mActiveElements |= (1u << elementInstanceTag); + + // read the 12 unused header bits + unusedHeader = (uint16_t) BitBufferRead( bits, 12 ); + RequireAction( unusedHeader == 0, status = kALAC_ParamError; goto Exit; ); + + // read the 1-bit "partial frame" flag, 2-bit "shift-off" flag & 1-bit "escape" flag + headerByte = (uint8_t) BitBufferRead( bits, 4 ); + + partialFrame = headerByte >> 3; + + bytesShifted = (headerByte >> 1) & 0x3u; + RequireAction( bytesShifted != 3, status = kALAC_ParamError; goto Exit; ); + + shift = bytesShifted * 8; + + escapeFlag = headerByte & 0x1; + + chanBits = p->mConfig.bitDepth - (bytesShifted * 8); + + // check for partial frame to override requested numSamples + if ( partialFrame != 0 ) + { + numSamples = BitBufferRead( bits, 16 ) << 16; + numSamples |= BitBufferRead( bits, 16 ); + } + + if ( escapeFlag == 0 ) + { + // compressed frame, read rest of parameters + mixBits = (uint8_t) BitBufferRead( bits, 8 ); + mixRes = (int8_t) BitBufferRead( bits, 8 ); + //Assert( (mixBits == 0) && (mixRes == 0) ); // no mixing for mono + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + modeU = headerByte >> 4; + denShiftU = headerByte & 0xfu; + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + pbFactorU = headerByte >> 5; + numU = headerByte & 0x1fu; + + for ( i = 0; i < numU; i++ ) + coefsU[i] = (int16_t) BitBufferRead( bits, 16 ); + + // if shift active, skip the the shift buffer but remember where it starts + if ( bytesShifted != 0 ) + { + shiftBits = *bits; + BitBufferAdvance( bits, (bytesShifted * 8) * numSamples ); + } + + // decompress + set_ag_params( &agParams, p->mConfig.mb, (pb * pbFactorU) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun ); + status = dyn_decomp( &agParams, bits, p->mPredictor, numSamples, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + if ( modeU == 0 ) + { + unpc_block( p->mPredictor, p->mMixBufferU, numSamples, &coefsU[0], numU, chanBits, denShiftU ); + } + else + { + // the special "numActive == 31" mode can be done in-place + unpc_block( p->mPredictor, p->mPredictor, numSamples, NULL, 31, chanBits, 0 ); + unpc_block( p->mPredictor, p->mMixBufferU, numSamples, &coefsU[0], numU, chanBits, denShiftU ); + } + } + else + { + //Assert( bytesShifted == 0 ); + + // uncompressed frame, copy data into the mix buffer to use common output code + shift = 32 - chanBits; + if ( chanBits <= 16 ) + { + for ( i = 0; i < numSamples; i++ ) + { + val = (int32_t) BitBufferRead( bits, (uint8_t) chanBits ); + val = (val << shift) >> shift; + p->mMixBufferU[i] = val; + } + } + else + { + // BitBufferRead() can't read more than 16 bits at a time so break up the reads + extraBits = chanBits - 16; + for ( i = 0; i < numSamples; i++ ) + { + val = (int32_t) BitBufferRead( bits, 16 ); + val = (val << 16) >> shift; + p->mMixBufferU[i] = val | BitBufferRead( bits, (uint8_t) extraBits ); + } + } + + mixBits = mixRes = 0; + bits1 = chanBits * numSamples; + bytesShifted = 0; + } + + // now read the shifted values into the shift buffer + if ( bytesShifted != 0 ) + { + shift = bytesShifted * 8; + //Assert( shift <= 16 ); + + for ( i = 0; i < numSamples; i++ ) + p->mShiftBuffer[i] = (uint16_t) BitBufferRead( &shiftBits, (uint8_t) shift ); + } + + // convert 32-bit integers into output buffer + switch ( p->mConfig.bitDepth ) + { + case 16: + out32 = sampleBuffer + channelIndex; + for ( i = 0, j = 0; i < numSamples; i++, j += numChannels ) + out32[j] = p->mMixBufferU[i] << 16; + break; + case 20: + out32 = sampleBuffer + channelIndex; + copyPredictorTo20( p->mMixBufferU, out32, numChannels, numSamples ); + break; + case 24: + out32 = sampleBuffer + channelIndex; + if ( bytesShifted != 0 ) + copyPredictorTo24Shift( p->mMixBufferU, p->mShiftBuffer, out32, numChannels, numSamples, bytesShifted ); + else + copyPredictorTo24( p->mMixBufferU, out32, numChannels, numSamples ); + break; + case 32: + out32 = sampleBuffer + channelIndex; + if ( bytesShifted != 0 ) + copyPredictorTo32Shift( p->mMixBufferU, p->mShiftBuffer, out32, numChannels, numSamples, bytesShifted ); + else + copyPredictorTo32( p->mMixBufferU, out32, numChannels, numSamples); + break; + } + + channelIndex += 1; + *outNumSamples = numSamples; + break; + } + + case ID_CPE: + { + // if decoding this pair would take us over the max channels limit, bail + if ( (channelIndex + 2) > numChannels ) + goto NoMoreChannels; + + // stereo channel pair + elementInstanceTag = BitBufferReadSmall( bits, 4 ); + p->mActiveElements |= (1u << elementInstanceTag); + + // read the 12 unused header bits + unusedHeader = (uint16_t) BitBufferRead( bits, 12 ); + RequireAction( unusedHeader == 0, status = kALAC_ParamError; goto Exit; ); + + // read the 1-bit "partial frame" flag, 2-bit "shift-off" flag & 1-bit "escape" flag + headerByte = (uint8_t) BitBufferRead( bits, 4 ); + + partialFrame = headerByte >> 3; + + bytesShifted = (headerByte >> 1) & 0x3u; + RequireAction( bytesShifted != 3, status = kALAC_ParamError; goto Exit; ); + + shift = bytesShifted * 8; + + escapeFlag = headerByte & 0x1; + + chanBits = p->mConfig.bitDepth - (bytesShifted * 8) + 1; + + // check for partial frame length to override requested numSamples + if ( partialFrame != 0 ) + { + numSamples = BitBufferRead( bits, 16 ) << 16; + numSamples |= BitBufferRead( bits, 16 ); + } + + if ( escapeFlag == 0 ) + { + // compressed frame, read rest of parameters + mixBits = (uint8_t) BitBufferRead( bits, 8 ); + mixRes = (int8_t) BitBufferRead( bits, 8 ); + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + modeU = headerByte >> 4; + denShiftU = headerByte & 0xfu; + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + pbFactorU = headerByte >> 5; + numU = headerByte & 0x1fu; + for ( i = 0; i < numU; i++ ) + coefsU[i] = (int16_t) BitBufferRead( bits, 16 ); + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + modeV = headerByte >> 4; + denShiftV = headerByte & 0xfu; + + headerByte = (uint8_t) BitBufferRead( bits, 8 ); + pbFactorV = headerByte >> 5; + numV = headerByte & 0x1fu; + for ( i = 0; i < numV; i++ ) + coefsV[i] = (int16_t) BitBufferRead( bits, 16 ); + + // if shift active, skip the interleaved shifted values but remember where they start + if ( bytesShifted != 0 ) + { + shiftBits = *bits; + BitBufferAdvance( bits, (bytesShifted * 8) * 2 * numSamples ); + } + + // decompress and run predictor for "left" channel + set_ag_params( &agParams, p->mConfig.mb, (pb * pbFactorU) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun ); + status = dyn_decomp( &agParams, bits, p->mPredictor, numSamples, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + if ( modeU == 0 ) + { + unpc_block( p->mPredictor, p->mMixBufferU, numSamples, &coefsU[0], numU, chanBits, denShiftU ); + } + else + { + // the special "numActive == 31" mode can be done in-place + unpc_block( p->mPredictor, p->mPredictor, numSamples, NULL, 31, chanBits, 0 ); + unpc_block( p->mPredictor, p->mMixBufferU, numSamples, &coefsU[0], numU, chanBits, denShiftU ); + } + + // decompress and run predictor for "right" channel + set_ag_params( &agParams, p->mConfig.mb, (pb * pbFactorV) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun ); + status = dyn_decomp( &agParams, bits, p->mPredictor, numSamples, chanBits, &bits2 ); + RequireNoErr( status, goto Exit; ); + + if ( modeV == 0 ) + { + unpc_block( p->mPredictor, p->mMixBufferV, numSamples, &coefsV[0], numV, chanBits, denShiftV ); + } + else + { + // the special "numActive == 31" mode can be done in-place + unpc_block( p->mPredictor, p->mPredictor, numSamples, NULL, 31, chanBits, 0 ); + unpc_block( p->mPredictor, p->mMixBufferV, numSamples, &coefsV[0], numV, chanBits, denShiftV ); + } + } + else + { + //Assert( bytesShifted == 0 ); + + // uncompressed frame, copy data into the mix buffers to use common output code + chanBits = p->mConfig.bitDepth; + shift = 32 - chanBits; + if ( chanBits <= 16 ) + { + for ( i = 0; i < numSamples; i++ ) + { + val = (int32_t) BitBufferRead( bits, (uint8_t) chanBits ); + val = (val << shift) >> shift; + p->mMixBufferU[i] = val; + + val = (int32_t) BitBufferRead( bits, (uint8_t) chanBits ); + val = (val << shift) >> shift; + p->mMixBufferV[i] = val; + } + } + else + { + // BitBufferRead() can't read more than 16 bits at a time so break up the reads + extraBits = chanBits - 16; + for ( i = 0; i < numSamples; i++ ) + { + val = (int32_t) BitBufferRead( bits, 16 ); + val = (val << 16) >> shift; + p->mMixBufferU[i] = val | BitBufferRead( bits, (uint8_t)extraBits ); + + val = (int32_t) BitBufferRead( bits, 16 ); + val = (val << 16) >> shift; + p->mMixBufferV[i] = val | BitBufferRead( bits, (uint8_t)extraBits ); + } + } + + bits1 = chanBits * numSamples; + bits2 = chanBits * numSamples; + mixBits = mixRes = 0; + bytesShifted = 0; + } + + // now read the shifted values into the shift buffer + if ( bytesShifted != 0 ) + { + shift = bytesShifted * 8; + //Assert( shift <= 16 ); + + for ( i = 0; i < (numSamples * 2); i += 2 ) + { + p->mShiftBuffer[i + 0] = (uint16_t) BitBufferRead( &shiftBits, (uint8_t) shift ); + p->mShiftBuffer[i + 1] = (uint16_t) BitBufferRead( &shiftBits, (uint8_t) shift ); + } + } + + // un-mix the data and convert to output format + // - note that mixRes = 0 means just interleave so we use that path for uncompressed frames + switch ( p->mConfig.bitDepth ) + { + case 16: + out32 = sampleBuffer + channelIndex; + unmix16( p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, mixBits, mixRes ); + break; + case 20: + out32 = sampleBuffer + channelIndex; + unmix20( p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, mixBits, mixRes ); + break; + case 24: + out32 = sampleBuffer + channelIndex; + unmix24( p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, + mixBits, mixRes, p->mShiftBuffer, bytesShifted ); + break; + case 32: + out32 = sampleBuffer + channelIndex; + unmix32( p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, + mixBits, mixRes, p->mShiftBuffer, bytesShifted ); + break; + } + + channelIndex += 2; + *outNumSamples = numSamples; + break; + } + + case ID_CCE: + case ID_PCE: + { + // unsupported element, bail + //AssertNoErr( tag ); + status = kALAC_ParamError; + break; + } + + case ID_DSE: + { + // data stream element -- parse but ignore + status = alac_data_stream_element (bits) ; + break; + } + + case ID_FIL: + { + // fill element -- parse but ignore + status = alac_fill_element (bits) ; + break; + } + + case ID_END: + { + // frame end, all done so byte align the frame and check for overruns + BitBufferByteAlign( bits, false ); + //Assert( bits->cur == bits->end ); + goto Exit; + } + } + +#if 0 // ! DEBUG + // if we've decoded all of our channels, bail (but not in debug b/c we want to know if we're seeing bad bits) + // - this also protects us if the config does not match the bitstream or crap data bits follow the audio bits + if ( channelIndex >= numChannels ) + break; +#endif + } + +NoMoreChannels: + + // if we get here and haven't decoded all of the requested channels, fill the remaining channels with zeros + for ( ; channelIndex < numChannels; channelIndex++ ) + { + int32_t * fill32 = sampleBuffer + channelIndex; + Zero32( fill32, numSamples, numChannels ); + } + +Exit: + return status; +} + +#if PRAGMA_MARK +#pragma mark - +#endif + +/* + FillElement() + - they're just filler so we don't need 'em +*/ +static int32_t +alac_fill_element (struct BitBuffer * bits) +{ + int16_t count; + + // 4-bit count or (4-bit + 8-bit count) if 4-bit count == 15 + // - plus this weird -1 thing I still don't fully understand + count = BitBufferReadSmall( bits, 4 ); + if ( count == 15 ) + count += (int16_t) BitBufferReadSmall( bits, 8 ) - 1; + + BitBufferAdvance( bits, count * 8 ); + + RequireAction( bits->cur <= bits->end, return kALAC_ParamError; ); + + return ALAC_noErr; +} + +/* + DataStreamElement() + - we don't care about data stream elements so just skip them +*/ +static int32_t +alac_data_stream_element (struct BitBuffer * bits) +{ + int32_t data_byte_align_flag; + uint16_t count; + + // the tag associates this data stream element with a given audio element + + /* element_instance_tag = */ BitBufferReadSmall( bits, 4 ); + + data_byte_align_flag = BitBufferReadOne( bits ); + + // 8-bit count or (8-bit + 8-bit count) if 8-bit count == 255 + count = BitBufferReadSmall( bits, 8 ); + if ( count == 255 ) + count += BitBufferReadSmall( bits, 8 ); + + // the align flag means the bitstream should be byte-aligned before reading the following data bytes + if ( data_byte_align_flag ) + BitBufferByteAlign( bits, false ); + + // skip the data bytes + BitBufferAdvance( bits, count * 8 ); + + RequireAction( bits->cur <= bits->end, return kALAC_ParamError; ); + + return ALAC_noErr; +} + +/* + ZeroN() + - helper routines to clear out output channel buffers when decoding fewer channels than requested +*/ +static void Zero32( int32_t * buffer, uint32_t numItems, uint32_t stride ) +{ + uint32_t indx; + + if ( stride == 1 ) + { + memset( buffer, 0, numItems * sizeof(int32_t) ); + } + else + { + for ( indx = 0; indx < (numItems * stride); indx += stride ) + buffer[indx] = 0; + } +} diff --git a/libs/libsndfile/src/ALAC/alac_decoder.h b/libs/libsndfile/src/ALAC/alac_decoder.h new file mode 100644 index 0000000000..78f3cb29ca --- /dev/null +++ b/libs/libsndfile/src/ALAC/alac_decoder.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: alac_decoder.h +*/ + +#ifndef ALAC_DECODER_H +#define ALAC_DECODER_H + +#include + +#include "ALACAudioTypes.h" + +typedef enum +{ + false = 0, + ALAC_TRUE = 1 +} bool ; + +struct BitBuffer; + +typedef struct alac_decoder +{ + // decoding parameters (public for use in the analyzer) + ALACSpecificConfig mConfig; + + uint16_t mActiveElements; + + // decoding buffers + int32_t * mMixBufferU; + int32_t * mMixBufferV; + int32_t * mPredictor; + uint16_t * mShiftBuffer; // note: this points to mPredictor's memory but different + // variable for clarity and type difference +} alac_decoder ; + +alac_decoder * alac_decoder_new (void) ; +void alac_decoder_delete (alac_decoder *) ; + +int32_t alac_init (alac_decoder *p, void * inMagicCookie, uint32_t inMagicCookieSize) ; +int32_t alac_decode (alac_decoder *, struct BitBuffer * bits, uint8_t * sampleBuffer, uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples) ; + +#endif /* ALAC_DECODER_H */ diff --git a/libs/libsndfile/src/ALAC/alac_encoder.c b/libs/libsndfile/src/ALAC/alac_encoder.c new file mode 100644 index 0000000000..02210ee51b --- /dev/null +++ b/libs/libsndfile/src/ALAC/alac_encoder.c @@ -0,0 +1,1342 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012-2013 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: ALACEncoder.cpp +*/ + +// build stuff +#define VERBOSE_DEBUG 0 +#define DebugMsg printf + +// headers +#include +#include +#include + +#include "sfendian.h" + +#include "alac_codec.h" + +#include "aglib.h" +#include "dplib.h" +#include "matrixlib.h" + +#include "ALACBitUtilities.h" +#include "ALACAudioTypes.h" +#include "EndianPortable.h" + +typedef enum +{ + false = 0, + true = 1 +} bool ; + +static void GetConfig(ALAC_ENCODER *p, ALACSpecificConfig * config ); + +static int32_t EncodeStereo(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); +static int32_t EncodeStereoFast(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); +static int32_t EncodeStereoEscape(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * input, uint32_t stride, uint32_t numSamples ); +static int32_t EncodeMono(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ); + + + +// Note: in C you can't typecast to a 2-dimensional array pointer but that's what we need when +// picking which coefs to use so we declare this typedef b/c we *can* typecast to this type +typedef int16_t (*SearchCoefs)[kALACMaxCoefs]; + +// defines/constants +const uint32_t kALACEncoderMagic = MAKE_MARKER ('d', 'p', 'g', 'e'); +const uint32_t kMaxSampleSize = 32; // max allowed bit width is 32 +const uint32_t kDefaultMixBits = 2; +const uint32_t kDefaultMixRes = 0; +const uint32_t kMaxRes = 4; +const uint32_t kDefaultNumUV = 8; +const uint32_t kMinUV = 4; +const uint32_t kMaxUV = 8; + +// static functions +#if VERBOSE_DEBUG +static void AddFiller( BitBuffer * bits, int32_t numBytes ); +#endif + + +/* + Map Format: 3-bit field per channel which is the same as the "element tag" that should be placed + at the beginning of the frame for that channel. Indicates whether SCE, CPE, or LFE. + Each particular field is accessed via the current channel indx. Note that the channel + indx increments by two for channel pairs. + + For example: + + C L R 3-channel input = (ID_CPE << 3) | (ID_SCE) + indx 0 value = (map & (0x7ul << (0 * 3))) >> (0 * 3) + indx 1 value = (map & (0x7ul << (1 * 3))) >> (1 * 3) + + C L R Ls Rs LFE 5.1-channel input = (ID_LFE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE) + indx 0 value = (map & (0x7ul << (0 * 3))) >> (0 * 3) + indx 1 value = (map & (0x7ul << (1 * 3))) >> (1 * 3) + indx 3 value = (map & (0x7ul << (3 * 3))) >> (3 * 3) + indx 5 value = (map & (0x7ul << (5 * 3))) >> (5 * 3) + indx 7 value = (map & (0x7ul << (7 * 3))) >> (7 * 3) +*/ +static const uint32_t sChannelMaps[kALACMaxChannels] = +{ + ID_SCE, + ID_CPE, + (ID_CPE << 3) | (ID_SCE), + (ID_SCE << 9) | (ID_CPE << 3) | (ID_SCE), + (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), + (ID_SCE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), + (ID_SCE << 18) | (ID_SCE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), + (ID_SCE << 21) | (ID_CPE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE) +}; + +static const uint32_t sSupportediPodSampleRates[] = +{ + 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 +}; + + +#if PRAGMA_MARK +#pragma mark - +#endif + +void +alac_set_fastmode (ALAC_ENCODER * p, int32_t fast ) +{ + p->mFastMode = fast; +} + + +/* + HEADER SPECIFICATION + + For every segment we adopt the following header: + + 1 byte reserved (always 0) + 1 byte flags (see below) + [4 byte frame length] (optional, see below) + ---Next, the per-segment ALAC parameters--- + 1 byte mixBits (middle-side parameter) + 1 byte mixRes (middle-side parameter, interpreted as signed char) + + 1 byte shiftU (4 bits modeU, 4 bits denShiftU) + 1 byte filterU (3 bits pbFactorU, 5 bits numU) + (numU) shorts (signed DP coefficients for V channel) + ---Next, 2nd-channel ALAC parameters in case of stereo mode--- + 1 byte shiftV (4 bits modeV, 4 bits denShiftV) + 1 byte filterV (3 bits pbFactorV, 5 bits numV) + (numV) shorts (signed DP coefficients for V channel) + ---After this come the shift-off bytes for (>= 24)-bit data (n-byte shift) if indicated--- + ---Then comes the AG-compressor bitstream--- + + + FLAGS + ----- + + The presence of certain flag bits changes the header format such that the parameters might + not even be sent. The currently defined flags format is: + + 0000psse + + where 0 = reserved, must be 0 + p = 1-bit field "partial frame" flag indicating 32-bit frame length follows this byte + ss = 2-bit field indicating "number of shift-off bytes ignored by compression" + e = 1-bit field indicating "escape" + + The "partial frame" flag means that the following segment is not equal to the frame length specified + in the out-of-band decoder configuration. This allows the decoder to deal with end-of-file partial + segments without incurring the 32-bit overhead for each segment. + + The "shift-off" field indicates the number of bytes at the bottom of the word that were passed through + uncompressed. The reason for this is that the entropy inherent in the LS bytes of >= 24-bit words + quite often means that the frame would have to be "escaped" b/c the compressed size would be >= the + uncompressed size. However, by shifting the input values down and running the remaining bits through + the normal compression algorithm, a net win can be achieved. If this field is non-zero, it means that + the shifted-off bytes follow after the parameter section of the header and before the compressed + bitstream. Note that doing this also allows us to use matrixing on 32-bit inputs after one or more + bytes are shifted off the bottom which helps the eventual compression ratio. For stereo channels, + the shifted off bytes are interleaved. + + The "escape" flag means that this segment was not compressed b/c the compressed size would be + >= uncompressed size. In that case, the audio data was passed through uncompressed after the header. + The other header parameter bytes will not be sent. + + + PARAMETERS + ---------- + + If the segment is not a partial or escape segment, the total header size (in bytes) is given exactly by: + + 4 + (2 + 2 * numU) (mono mode) + 4 + (2 + 2 * numV) + (2 + 2 * numV) (stereo mode) + + where the ALAC filter-lengths numU, numV are bounded by a + constant (in the current source, numU, numV <= NUMCOEPAIRS), and + this forces an absolute upper bound on header size. + + Each segment-decode process loads up these bytes from the front of the + local stream, in the above order, then follows with the entropy-encoded + bits for the given segment. + + To generalize middle-side, there are various mixing modes including middle-side, each lossless, + as embodied in the mix() and unmix() functions. These functions exploit a generalized middle-side + transformation: + + u := [(rL + (m-r)R)/m]; + v := L - R; + + where [ ] denotes integer floor. The (lossless) inverse is + + L = u + v - [rV/m]; + R = L - v; + + In the segment header, m and r are encoded in mixBits and mixRes. + Classical "middle-side" is obtained with m = 2, r = 1, but now + we have more generalized mixes. + + NOTES + ----- + The relevance of the ALAC coefficients is explained in detail + in patent documents. +*/ + +/* + EncodeStereo() + - encode a channel pair +*/ +static int32_t +EncodeStereo(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ) +{ + BitBuffer workBits; + BitBuffer startBits = *bitstream; // squirrel away copy of current state in case we need to go back and do an escape packet + AGParamRec agParams; + uint32_t bits1, bits2; + uint32_t dilate; + int32_t mixBits, mixRes, maxRes; + uint32_t minBits, minBits1, minBits2; + uint32_t numU, numV; + uint32_t mode; + uint32_t pbFactor; + uint32_t chanBits; + uint8_t bytesShifted; + SearchCoefs coefsU; + SearchCoefs coefsV; + uint32_t indx; + uint8_t partialFrame; + uint32_t escapeBits; + bool doEscape; + int32_t status = ALAC_noErr; + int32_t bestRes; + uint32_t numUV, converge; + + // make sure we handle this bit-depth before we get going + RequireAction( (p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError; ); + + // reload coefs pointers for this channel pair + // - note that, while you might think they should be re-initialized per block, retaining state across blocks + // actually results in better overall compression + // - strangely, re-using the same coefs for the different passes of the "mixRes" search loop instead of using + // different coefs for the different passes of "mixRes" results in even better compression + coefsU = (SearchCoefs) p->mCoefsU[channelIndex]; + coefsV = (SearchCoefs) p->mCoefsV[channelIndex]; + + // matrix encoding adds an extra bit but 32-bit inputs cannot be matrixed b/c 33 is too many + // so enable 16-bit "shift off" and encode in 17-bit mode + // - in addition, 24-bit mode really improves with one byte shifted off + if ( p->mBitDepth == 32 ) + bytesShifted = 2; + else if ( p->mBitDepth >= 24 ) + bytesShifted = 1; + else + bytesShifted = 0; + + chanBits = p->mBitDepth - (bytesShifted * 8) + 1; + + // flag whether or not this is a partial frame + partialFrame = (numSamples == p->mFrameSize) ? 0 : 1; + + // brute-force encode optimization loop + // - run over variations of the encoding params to find the best choice + mixBits = kDefaultMixBits; + maxRes = kMaxRes; + numU = numV = kDefaultNumUV; + mode = 0; + pbFactor = 4; + dilate = 8; + + minBits = minBits1 = minBits2 = 1ul << 31; + + bestRes = p->mLastMixRes[channelIndex]; + + for ( mixRes = 0; mixRes <= maxRes; mixRes++ ) + { + // mix the stereo inputs + switch ( p->mBitDepth ) + { + case 16: + mix16( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples/dilate, mixBits, mixRes ); + break; + case 20: + mix20( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples/dilate, mixBits, mixRes ); + break; + case 24: + // includes extraction of shifted-off bytes + mix24( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples/dilate, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + case 32: + // includes extraction of shifted-off bytes + mix32( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples/dilate, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + } + + BitBufferInit( &workBits, p->mWorkBuffer, p->mMaxOutputBytes ); + + // run the dynamic predictors + pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numU - 1], numU, chanBits, DENSHIFT_DEFAULT ); + pc_block( p->mMixBufferV, p->mPredictorV, numSamples/dilate, coefsV[numV - 1], numV, chanBits, DENSHIFT_DEFAULT ); + + // run the lossless compressor on each channel + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples/dilate, numSamples/dilate, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorU, &workBits, numSamples/dilate, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples/dilate, numSamples/dilate, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorV, &workBits, numSamples/dilate, chanBits, &bits2 ); + RequireNoErr( status, goto Exit; ); + + // look for best match + if ( (bits1 + bits2) < minBits1 ) + { + minBits1 = bits1 + bits2; + bestRes = mixRes; + } + } + + p->mLastMixRes[channelIndex] = (int16_t)bestRes; + + // mix the stereo inputs with the current best mixRes + mixRes = p->mLastMixRes[channelIndex]; + switch ( p->mBitDepth ) + { + case 16: + mix16( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes ); + break; + case 20: + mix20( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes ); + break; + case 24: + // also extracts the shifted off bytes into the shift buffers + mix24( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + case 32: + // also extracts the shifted off bytes into the shift buffers + mix32( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + } + + // now it's time for the predictor coefficient search loop + numU = numV = kMinUV; + minBits1 = minBits2 = 1ul << 31; + + for ( numUV = kMinUV; numUV <= kMaxUV; numUV += 4 ) + { + BitBufferInit( &workBits, p->mWorkBuffer, p->mMaxOutputBytes ); + + dilate = 32; + + // run the predictor over the same data multiple times to help it converge + for ( converge = 0; converge < 8; converge++ ) + { + pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numUV-1], numUV, chanBits, DENSHIFT_DEFAULT ); + pc_block( p->mMixBufferV, p->mPredictorV, numSamples/dilate, coefsV[numUV-1], numUV, chanBits, DENSHIFT_DEFAULT ); + } + + dilate = 8; + + set_ag_params( &agParams, MB0, (pbFactor * PB0)/4, KB0, numSamples/dilate, numSamples/dilate, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorU, &workBits, numSamples/dilate, chanBits, &bits1 ); + + if ( (bits1 * dilate + 16 * numUV) < minBits1 ) + { + minBits1 = bits1 * dilate + 16 * numUV; + numU = numUV; + } + + set_ag_params( &agParams, MB0, (pbFactor * PB0)/4, KB0, numSamples/dilate, numSamples/dilate, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorV, &workBits, numSamples/dilate, chanBits, &bits2 ); + + if ( (bits2 * dilate + 16 * numUV) < minBits2 ) + { + minBits2 = bits2 * dilate + 16 * numUV; + numV = numUV; + } + } + + // test for escape hatch if best calculated compressed size turns out to be more than the input size + minBits = minBits1 + minBits2 + (8 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0); + if ( bytesShifted != 0 ) + minBits += (numSamples * (bytesShifted * 8) * 2); + + escapeBits = (numSamples * p->mBitDepth * 2) + ((partialFrame == true) ? 32 : 0) + (2 * 8); /* 2 common header bytes */ + + doEscape = (minBits >= escapeBits) ? true : false; + + if ( doEscape == false ) + { + // write bitstream header and coefs + BitBufferWrite( bitstream, 0, 12 ); + BitBufferWrite( bitstream, (partialFrame << 3) | (bytesShifted << 1), 4 ); + if ( partialFrame ) + BitBufferWrite( bitstream, numSamples, 32 ); + BitBufferWrite( bitstream, mixBits, 8 ); + BitBufferWrite( bitstream, mixRes, 8 ); + + //Assert( (mode < 16) && (DENSHIFT_DEFAULT < 16) ); + //Assert( (pbFactor < 8) && (numU < 32) ); + //Assert( (pbFactor < 8) && (numV < 32) ); + + BitBufferWrite( bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8 ); + BitBufferWrite( bitstream, (pbFactor << 5) | numU, 8 ); + for ( indx = 0; indx < numU; indx++ ) + BitBufferWrite( bitstream, coefsU[numU - 1][indx], 16 ); + + BitBufferWrite( bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8 ); + BitBufferWrite( bitstream, (pbFactor << 5) | numV, 8 ); + for ( indx = 0; indx < numV; indx++ ) + BitBufferWrite( bitstream, coefsV[numV - 1][indx], 16 ); + + // if shift active, write the interleaved shift buffers + if ( bytesShifted != 0 ) + { + uint32_t bitShift = bytesShifted * 8; + + //Assert( bitShift <= 16 ); + + for ( indx = 0; indx < (numSamples * 2); indx += 2 ) + { + uint32_t shiftedVal; + + shiftedVal = ((uint32_t) p->mShiftBufferUV[indx + 0] << bitShift) | (uint32_t) p->mShiftBufferUV[indx + 1]; + BitBufferWrite( bitstream, shiftedVal, bitShift * 2 ); + } + } + + // run the dynamic predictor and lossless compression for the "left" channel + // - note: to avoid allocating more buffers, we're mixing and matching between the available buffers instead + // of only using "U" buffers for the U-channel and "V" buffers for the V-channel + if ( mode == 0 ) + { + pc_block( p->mMixBufferU, p->mPredictorU, numSamples, coefsU[numU - 1], numU, chanBits, DENSHIFT_DEFAULT ); + } + else + { + pc_block( p->mMixBufferU, p->mPredictorV, numSamples, coefsU[numU - 1], numU, chanBits, DENSHIFT_DEFAULT ); + pc_block( p->mPredictorV, p->mPredictorU, numSamples, NULL, 31, chanBits, 0 ); + } + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + // run the dynamic predictor and lossless compression for the "right" channel + if ( mode == 0 ) + { + pc_block( p->mMixBufferV, p->mPredictorV, numSamples, coefsV[numV - 1], numV, chanBits, DENSHIFT_DEFAULT ); + } + else + { + pc_block( p->mMixBufferV, p->mPredictorU, numSamples, coefsV[numV - 1], numV, chanBits, DENSHIFT_DEFAULT ); + pc_block( p->mPredictorU, p->mPredictorV, numSamples, NULL, 31, chanBits, 0 ); + } + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorV, bitstream, numSamples, chanBits, &bits2 ); + RequireNoErr( status, goto Exit; ); + + /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, + chuck it and do an escape packet + */ + minBits = BitBufferGetPosition( bitstream ) - BitBufferGetPosition( &startBits ); + if ( minBits >= escapeBits ) + { + *bitstream = startBits; // reset bitstream state + doEscape = true; + printf( "compressed frame too big: %u vs. %u \n", minBits, escapeBits ); + } + } + + if ( doEscape == true ) + { + /* escape */ + status = EncodeStereoEscape(p, bitstream, inputBuffer, stride, numSamples ); + +#if VERBOSE_DEBUG + DebugMsg( "escape!: %u vs %u\n", minBits, escapeBits ); +#endif + } + +Exit: + return status; +} + +/* + EncodeStereoFast() + - encode a channel pair without the search loop for maximum possible speed +*/ +static int32_t +EncodeStereoFast(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ) +{ + BitBuffer startBits = *bitstream; // squirrel away current bit position in case we decide to use escape hatch + AGParamRec agParams; + uint32_t bits1, bits2; + int32_t mixBits, mixRes; + uint32_t minBits, minBits1, minBits2; + uint32_t numU, numV; + uint32_t mode; + uint32_t pbFactor; + uint32_t chanBits; + uint8_t bytesShifted; + SearchCoefs coefsU; + SearchCoefs coefsV; + uint32_t indx; + uint8_t partialFrame; + uint32_t escapeBits; + bool doEscape; + int32_t status; + + // make sure we handle this bit-depth before we get going + RequireAction( (p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError; ); + + // reload coefs pointers for this channel pair + // - note that, while you might think they should be re-initialized per block, retaining state across blocks + // actually results in better overall compression + // - strangely, re-using the same coefs for the different passes of the "mixRes" search loop instead of using + // different coefs for the different passes of "mixRes" results in even better compression + coefsU = (SearchCoefs) p->mCoefsU[channelIndex]; + coefsV = (SearchCoefs) p->mCoefsV[channelIndex]; + + // matrix encoding adds an extra bit but 32-bit inputs cannot be matrixed b/c 33 is too many + // so enable 16-bit "shift off" and encode in 17-bit mode + // - in addition, 24-bit mode really improves with one byte shifted off + if ( p->mBitDepth == 32 ) + bytesShifted = 2; + else if ( p->mBitDepth >= 24 ) + bytesShifted = 1; + else + bytesShifted = 0; + + chanBits = p->mBitDepth - (bytesShifted * 8) + 1; + + // flag whether or not this is a partial frame + partialFrame = (numSamples == p->mFrameSize) ? 0 : 1; + + // set up default encoding parameters for "fast" mode + mixBits = kDefaultMixBits; + mixRes = kDefaultMixRes; + numU = numV = kDefaultNumUV; + mode = 0; + pbFactor = 4; + + minBits = minBits1 = minBits2 = 1ul << 31; + + // mix the stereo inputs with default mixBits/mixRes + switch ( p->mBitDepth ) + { + case 16: + mix16( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes ); + break; + case 20: + mix20( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes ); + break; + case 24: + // also extracts the shifted off bytes into the shift buffers + mix24( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + case 32: + // also extracts the shifted off bytes into the shift buffers + mix32( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, + mixBits, mixRes, p->mShiftBufferUV, bytesShifted ); + break; + } + + /* speculatively write the bitstream assuming the compressed version will be smaller */ + + // write bitstream header and coefs + BitBufferWrite( bitstream, 0, 12 ); + BitBufferWrite( bitstream, (partialFrame << 3) | (bytesShifted << 1), 4 ); + if ( partialFrame ) + BitBufferWrite( bitstream, numSamples, 32 ); + BitBufferWrite( bitstream, mixBits, 8 ); + BitBufferWrite( bitstream, mixRes, 8 ); + + //Assert( (mode < 16) && (DENSHIFT_DEFAULT < 16) ); + //Assert( (pbFactor < 8) && (numU < 32) ); + //Assert( (pbFactor < 8) && (numV < 32) ); + + BitBufferWrite( bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8 ); + BitBufferWrite( bitstream, (pbFactor << 5) | numU, 8 ); + for ( indx = 0; indx < numU; indx++ ) + BitBufferWrite( bitstream, coefsU[numU - 1][indx], 16 ); + + BitBufferWrite( bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8 ); + BitBufferWrite( bitstream, (pbFactor << 5) | numV, 8 ); + for ( indx = 0; indx < numV; indx++ ) + BitBufferWrite( bitstream, coefsV[numV - 1][indx], 16 ); + + // if shift active, write the interleaved shift buffers + if ( bytesShifted != 0 ) + { + uint32_t bitShift = bytesShifted * 8; + + //Assert( bitShift <= 16 ); + + for ( indx = 0; indx < (numSamples * 2); indx += 2 ) + { + uint32_t shiftedVal; + + shiftedVal = ((uint32_t) p->mShiftBufferUV[indx + 0] << bitShift) | (uint32_t) p->mShiftBufferUV[indx + 1]; + BitBufferWrite( bitstream, shiftedVal, bitShift * 2 ); + } + } + + // run the dynamic predictor and lossless compression for the "left" channel + // - note: we always use mode 0 in the "fast" path so we don't need the code for mode != 0 + pc_block( p->mMixBufferU, p->mPredictorU, numSamples, coefsU[numU - 1], numU, chanBits, DENSHIFT_DEFAULT ); + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + // run the dynamic predictor and lossless compression for the "right" channel + pc_block( p->mMixBufferV, p->mPredictorV, numSamples, coefsV[numV - 1], numV, chanBits, DENSHIFT_DEFAULT ); + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorV, bitstream, numSamples, chanBits, &bits2 ); + RequireNoErr( status, goto Exit; ); + + // do bit requirement calculations + minBits1 = bits1 + (numU * sizeof(int16_t) * 8); + minBits2 = bits2 + (numV * sizeof(int16_t) * 8); + + // test for escape hatch if best calculated compressed size turns out to be more than the input size + minBits = minBits1 + minBits2 + (8 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0); + if ( bytesShifted != 0 ) + minBits += (numSamples * (bytesShifted * 8) * 2); + + escapeBits = (numSamples * p->mBitDepth * 2) + ((partialFrame == true) ? 32 : 0) + (2 * 8); /* 2 common header bytes */ + + doEscape = (minBits >= escapeBits) ? true : false; + + if ( doEscape == false ) + { + /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, + chuck it and do an escape packet + */ + minBits = BitBufferGetPosition( bitstream ) - BitBufferGetPosition( &startBits ); + if ( minBits >= escapeBits ) + { + doEscape = true; + printf( "compressed frame too big: %u vs. %u\n", minBits, escapeBits ); + } + + } + + if ( doEscape == true ) + { + /* escape */ + + // reset bitstream position since we speculatively wrote the compressed version + *bitstream = startBits; + + // write escape frame + status = EncodeStereoEscape(p, bitstream, inputBuffer, stride, numSamples ); + +#if VERBOSE_DEBUG + DebugMsg( "escape!: %u vs %u\n", minBits, (numSamples * p->mBitDepth * 2) ); +#endif + } + +Exit: + return status; +} + +/* + EncodeStereoEscape() + - encode stereo escape frame +*/ +static int32_t +EncodeStereoEscape(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer, uint32_t stride, uint32_t numSamples ) +{ + uint8_t partialFrame; + uint32_t indx; + + // flag whether or not this is a partial frame + partialFrame = (numSamples == p->mFrameSize) ? 0 : 1; + + // write bitstream header + BitBufferWrite( bitstream, 0, 12 ); + BitBufferWrite( bitstream, (partialFrame << 3) | 1, 4 ); // LSB = 1 means "frame not compressed" + if ( partialFrame ) + BitBufferWrite( bitstream, numSamples, 32 ); + + // just copy the input data to the output buffer + switch ( p->mBitDepth ) + { + case 16: + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + { + BitBufferWrite( bitstream, inputBuffer[indx + 0] >> 16, 16 ); + BitBufferWrite( bitstream, inputBuffer[indx + 1] >> 16, 16 ); + } + break; + case 20: + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + { + BitBufferWrite( bitstream, inputBuffer[indx + 0] >> 12, 16 ); + BitBufferWrite( bitstream, inputBuffer[indx + 1] >> 12, 16 ); + } + break; + case 24: + // mix24() with mixres param = 0 means de-interleave so use it to simplify things + mix24( inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, 0, 0, p->mShiftBufferUV, 0 ); + for ( indx = 0; indx < numSamples; indx++ ) + { + BitBufferWrite( bitstream, p->mMixBufferU[indx] >> 8, 24 ); + BitBufferWrite( bitstream, p->mMixBufferV[indx] >> 8, 24 ); + } + break; + case 32: + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + { + BitBufferWrite( bitstream, inputBuffer[indx + 0], 32 ); + BitBufferWrite( bitstream, inputBuffer[indx + 1], 32 ); + } + break; + } + + return ALAC_noErr; +} + +/* + EncodeMono() + - encode a mono input buffer +*/ +static int32_t +EncodeMono(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples ) +{ + BitBuffer startBits = *bitstream; // squirrel away copy of current state in case we need to go back and do an escape packet + AGParamRec agParams; + uint32_t bits1; + uint32_t numU; + SearchCoefs coefsU; + uint32_t dilate; + uint32_t minBits, bestU; + uint32_t minU, maxU; + uint32_t indx, indx2; + uint8_t bytesShifted; + uint32_t shift; + uint32_t mask; + uint32_t chanBits; + uint8_t pbFactor; + uint8_t partialFrame; + uint32_t escapeBits; + bool doEscape; + int32_t status = ALAC_noErr; + uint32_t converge; + + + // make sure we handle this bit-depth before we get going + RequireAction( (p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError; ); + + // reload coefs array from previous frame + coefsU = (SearchCoefs) p->mCoefsU[channelIndex]; + + // pick bit depth for actual encoding + // - we lop off the lower byte(s) for 24-/32-bit encodings + if ( p->mBitDepth == 32 ) + bytesShifted = 2; + else if ( p->mBitDepth >= 24 ) + bytesShifted = 1; + else + bytesShifted = 0; + + shift = bytesShifted * 8; + mask = (1ul << shift) - 1; + chanBits = p->mBitDepth - (bytesShifted * 8); + + // flag whether or not this is a partial frame + partialFrame = (numSamples == p->mFrameSize) ? 0 : 1; + + // convert N-bit data to 32-bit for predictor + switch ( p->mBitDepth ) + { + case 16: + // convert 16-bit data to 32-bit for predictor + for ( indx = 0, indx2 = 0; indx < numSamples; indx++, indx2 += stride ) + p->mMixBufferU[indx] = inputBuffer[indx2] >> 16; + break; + + case 20: + // convert 20-bit data to 32-bit for predictor + for ( indx = 0, indx2 = 0; indx < numSamples; indx++, indx2 += stride ) + p->mMixBufferU[indx] = inputBuffer[indx2] >> 12; + break; + case 24: + // convert 24-bit data to 32-bit for the predictor and extract the shifted off byte(s) + for ( indx = 0, indx2 = 0; indx < numSamples; indx++, indx2 += stride ) + { + p->mMixBufferU[indx] = inputBuffer[indx2] >> 8; + p->mShiftBufferUV[indx] = (uint16_t)(p->mMixBufferU[indx] & mask); + p->mMixBufferU[indx] >>= shift; + } + + break; + case 32: + // just copy the 32-bit input data for the predictor and extract the shifted off byte(s) + for ( indx = 0, indx2 = 0; indx < numSamples; indx++, indx2 += stride ) + { + p->mShiftBufferUV[indx] = (uint16_t)(inputBuffer[indx2] & mask); + p->mMixBufferU[indx] = inputBuffer[indx2] >> shift; + } + break; + } + + // brute-force encode optimization loop (implied "encode depth" of 0 if comparing to cmd line tool) + // - run over variations of the encoding params to find the best choice + minU = 4; + maxU = 8; + minBits = 1ul << 31; + pbFactor = 4; + + bestU = minU; + + for ( numU = minU; numU <= maxU; numU += 4 ) + { + BitBuffer workBits; + uint32_t numBits; + + BitBufferInit( &workBits, p->mWorkBuffer, p->mMaxOutputBytes ); + + dilate = 32; + for ( converge = 0; converge < 7; converge++ ) + pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numU-1], numU, chanBits, DENSHIFT_DEFAULT ); + + dilate = 8; + pc_block( p->mMixBufferU, p->mPredictorU, numSamples/dilate, coefsU[numU-1], numU, chanBits, DENSHIFT_DEFAULT ); + + set_ag_params( &agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples/dilate, numSamples/dilate, MAX_RUN_DEFAULT ); + status = dyn_comp( &agParams, p->mPredictorU, &workBits, numSamples/dilate, chanBits, &bits1 ); + RequireNoErr( status, goto Exit; ); + + numBits = (dilate * bits1) + (16 * numU); + if ( numBits < minBits ) + { + bestU = numU; + minBits = numBits; + } + } + + // test for escape hatch if best calculated compressed size turns out to be more than the input size + // - first, add bits for the header bytes mixRes/maxRes/shiftU/filterU + minBits += (4 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0); + if ( bytesShifted != 0 ) + minBits += (numSamples * (bytesShifted * 8)); + + escapeBits = (numSamples * p->mBitDepth) + ((partialFrame == true) ? 32 : 0) + (2 * 8); /* 2 common header bytes */ + + doEscape = (minBits >= escapeBits) ? true : false; + + if ( doEscape == false ) + { + // write bitstream header + BitBufferWrite( bitstream, 0, 12 ); + BitBufferWrite( bitstream, (partialFrame << 3) | (bytesShifted << 1), 4 ); + if ( partialFrame ) + BitBufferWrite( bitstream, numSamples, 32 ); + BitBufferWrite( bitstream, 0, 16 ); // mixBits = mixRes = 0 + + // write the params and predictor coefs + numU = bestU; + BitBufferWrite( bitstream, (0 << 4) | DENSHIFT_DEFAULT, 8 ); // modeU = 0 + BitBufferWrite( bitstream, (pbFactor << 5) | numU, 8 ); + for ( indx = 0; indx < numU; indx++ ) + BitBufferWrite( bitstream, coefsU[numU-1][indx], 16 ); + + // if shift active, write the interleaved shift buffers + if ( bytesShifted != 0 ) + { + for ( indx = 0; indx < numSamples; indx++ ) + BitBufferWrite( bitstream, p->mShiftBufferUV[indx], shift ); + } + + // run the dynamic predictor with the best result + pc_block( p->mMixBufferU, p->mPredictorU, numSamples, coefsU[numU-1], numU, chanBits, DENSHIFT_DEFAULT ); + + // do lossless compression + set_standard_ag_params( &agParams, numSamples, numSamples ); + status = dyn_comp( &agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1 ); + //AssertNoErr( status ); + + + /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, + chuck it and do an escape packet + */ + minBits = BitBufferGetPosition( bitstream ) - BitBufferGetPosition( &startBits ); + if ( minBits >= escapeBits ) + { + *bitstream = startBits; // reset bitstream state + doEscape = true; + printf( "compressed frame too big: %u vs. %u\n", minBits, escapeBits ); + } + } + + if ( doEscape == true ) + { + // write bitstream header and coefs + BitBufferWrite( bitstream, 0, 12 ); + BitBufferWrite( bitstream, (partialFrame << 3) | 1, 4 ); // LSB = 1 means "frame not compressed" + if ( partialFrame ) + BitBufferWrite( bitstream, numSamples, 32 ); + + // just copy the input data to the output buffer + switch ( p->mBitDepth ) + { + case 16: + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + BitBufferWrite( bitstream, inputBuffer[indx] >> 16, 16 ); + break; + case 20: + // convert 20-bit data to 32-bit for simplicity + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + BitBufferWrite( bitstream, inputBuffer[indx] >> 12, 20 ); + break; + case 24: + // convert 24-bit data to 32-bit for simplicity + for ( indx = 0, indx2 = 0; indx < numSamples; indx++, indx2 += stride ) + { + p->mMixBufferU[indx] = inputBuffer[indx2] >> 8; + BitBufferWrite( bitstream, p->mMixBufferU[indx], 24 ); + } + break; + case 32: + for ( indx = 0; indx < (numSamples * stride); indx += stride ) + BitBufferWrite( bitstream, inputBuffer[indx], 32 ); + break; + } +#if VERBOSE_DEBUG + DebugMsg( "escape!: %u vs %u\n", minBits, (numSamples * p->mBitDepth) ); +#endif + } + +Exit: + return status; +} + +#if PRAGMA_MARK +#pragma mark - +#endif + +/* + Encode() + - encode the next block of samples +*/ +int32_t +alac_encode(ALAC_ENCODER *p, uint32_t numChannels, uint32_t numSamples, + int32_t * theReadBuffer, unsigned char * theWriteBuffer, uint32_t * ioNumBytes) +{ + uint32_t outputSize; + BitBuffer bitstream; + int32_t status; + + // create a bit buffer structure pointing to our output buffer + BitBufferInit( &bitstream, theWriteBuffer, p->mMaxOutputBytes ); + + if ( numChannels == 2 ) + { + // add 3-bit frame start tag ID_CPE = channel pair & 4-bit element instance tag = 0 + BitBufferWrite( &bitstream, ID_CPE, 3 ); + BitBufferWrite( &bitstream, 0, 4 ); + + // encode stereo input buffer + if ( p->mFastMode == false ) + status = EncodeStereo(p, &bitstream, theReadBuffer, 2, 0, numSamples ); + else + status = EncodeStereoFast(p, &bitstream, theReadBuffer, 2, 0, numSamples ); + RequireNoErr( status, goto Exit; ); + } + else if ( numChannels == 1 ) + { + // add 3-bit frame start tag ID_SCE = mono channel & 4-bit element instance tag = 0 + BitBufferWrite( &bitstream, ID_SCE, 3 ); + BitBufferWrite( &bitstream, 0, 4 ); + + // encode mono input buffer + status = EncodeMono(p, &bitstream, theReadBuffer, 1, 0, numSamples ); + RequireNoErr( status, goto Exit; ); + } + else + { + int32_t * inputBuffer; + uint32_t tag; + uint32_t channelIndex; + uint32_t inputIncrement; + uint8_t stereoElementTag; + uint8_t monoElementTag; + uint8_t lfeElementTag; + + inputBuffer = theReadBuffer; + inputIncrement = ((p->mBitDepth + 7) / 8); + + stereoElementTag = 0; + monoElementTag = 0; + lfeElementTag = 0; + + for ( channelIndex = 0; channelIndex < numChannels; ) + { + tag = (sChannelMaps[numChannels - 1] & (0x7ul << (channelIndex * 3))) >> (channelIndex * 3); + + BitBufferWrite( &bitstream, tag, 3 ); + switch ( tag ) + { + case ID_SCE: + // mono + BitBufferWrite( &bitstream, monoElementTag, 4 ); + + status = EncodeMono(p, &bitstream, inputBuffer, numChannels, channelIndex, numSamples ); + + inputBuffer += inputIncrement; + channelIndex++; + monoElementTag++; + break; + + case ID_CPE: + // stereo + BitBufferWrite( &bitstream, stereoElementTag, 4 ); + + status = EncodeStereo(p,&bitstream, inputBuffer, numChannels, channelIndex, numSamples ); + + inputBuffer += (inputIncrement * 2); + channelIndex += 2; + stereoElementTag++; + break; + + case ID_LFE: + // LFE channel (subwoofer) + BitBufferWrite( &bitstream, lfeElementTag, 4 ); + + status = EncodeMono(p, &bitstream, inputBuffer, numChannels, channelIndex, numSamples ); + + inputBuffer += inputIncrement; + channelIndex++; + lfeElementTag++; + break; + + default: + printf( "That ain't right! (%u)\n", tag ); + status = kALAC_ParamError; + goto Exit; + } + + RequireNoErr( status, goto Exit; ); + } + } + +#if VERBOSE_DEBUG +{ + // if there is room left in the output buffer, add some random fill data to test decoder + int32_t bitsLeft; + int32_t bytesLeft; + + bitsLeft = BitBufferGetPosition( &bitstream ) - 3; // - 3 for ID_END tag + bytesLeft = bitstream.byteSize - ((bitsLeft + 7) / 8); + + if ( (bytesLeft > 20) && ((bytesLeft & 0x4u) != 0) ) + AddFiller( &bitstream, bytesLeft ); +} +#endif + + // add 3-bit frame end tag: ID_END + BitBufferWrite( &bitstream, ID_END, 3 ); + + // byte-align the output data + BitBufferByteAlign( &bitstream, true ); + + outputSize = BitBufferGetPosition( &bitstream ) / 8; + //Assert( outputSize <= mMaxOutputBytes ); + + + // all good, let iTunes know what happened and remember the total number of input sample frames + *ioNumBytes = outputSize; + //mEncodedFrames += encodeMsg->numInputSamples; + + // gather encoding stats + p->mTotalBytesGenerated += outputSize; + p->mMaxFrameBytes = MAX( p->mMaxFrameBytes, outputSize ); + + status = ALAC_noErr; + +Exit: + return status; +} + + +#if PRAGMA_MARK +#pragma mark - +#endif + +/* + GetConfig() +*/ +void +GetConfig(ALAC_ENCODER *p, ALACSpecificConfig * config ) +{ + config->frameLength = Swap32NtoB(p->mFrameSize); + config->compatibleVersion = (uint8_t) kALACCompatibleVersion; + config->bitDepth = (uint8_t) p->mBitDepth; + config->pb = (uint8_t) PB0; + config->kb = (uint8_t) KB0; + config->mb = (uint8_t) MB0; + config->numChannels = (uint8_t) p->mNumChannels; + config->maxRun = Swap16NtoB((uint16_t) MAX_RUN_DEFAULT); + config->maxFrameBytes = Swap32NtoB(p->mMaxFrameBytes); + config->avgBitRate = Swap32NtoB(p->mAvgBitRate); + config->sampleRate = Swap32NtoB(p->mOutputSampleRate); +} + +uint32_t +alac_get_magic_cookie_size(uint32_t inNumChannels) +{ + if (inNumChannels > 2) + { + return sizeof(ALACSpecificConfig) + kChannelAtomSize + sizeof(ALACAudioChannelLayout); + } + else + { + return sizeof(ALACSpecificConfig); + } +} + +void +alac_get_magic_cookie(ALAC_ENCODER *p, void * outCookie, uint32_t * ioSize ) +{ + ALACSpecificConfig theConfig = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + ALACAudioChannelLayout theChannelLayout = {0, 0, 0}; + uint8_t theChannelAtom[kChannelAtomSize] = {0, 0, 0, 0, 'c', 'h', 'a', 'n', 0, 0, 0, 0}; + uint32_t theCookieSize = sizeof(ALACSpecificConfig); + uint8_t * theCookiePointer = (uint8_t *)outCookie; + + GetConfig(p, &theConfig); + if (theConfig.numChannels > 2) + { + theChannelLayout.mChannelLayoutTag = Swap32NtoB(ALACChannelLayoutTags[theConfig.numChannels - 1]); + theCookieSize += (sizeof(ALACAudioChannelLayout) + kChannelAtomSize); + } + if (*ioSize >= theCookieSize) + { + memcpy(theCookiePointer, &theConfig, sizeof(ALACSpecificConfig)); + theChannelAtom[3] = (sizeof(ALACAudioChannelLayout) + kChannelAtomSize); + if (theConfig.numChannels > 2) + { + theCookiePointer += sizeof(ALACSpecificConfig); + memcpy(theCookiePointer, theChannelAtom, kChannelAtomSize); + theCookiePointer += kChannelAtomSize; + memcpy(theCookiePointer, &theChannelLayout, sizeof(ALACAudioChannelLayout)); + } + *ioSize = theCookieSize; + } + else + { + *ioSize = 0; // no incomplete cookies + } +} + +/* + alac_encoder_init() + - initialize the encoder component with the current config +*/ +int32_t +alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint32_t format_flags, uint32_t frameSize) +{ + int32_t status; + uint32_t indx; + int32_t channel, search; + + p->mFrameSize = (frameSize > 0 && frameSize <= ALAC_FRAME_LENGTH) ? frameSize : ALAC_FRAME_LENGTH ; + + p->mOutputSampleRate = samplerate; + p->mNumChannels = channels; + switch (format_flags) + { + case 1: + p->mBitDepth = 16; + break; + case 2: + p->mBitDepth = 20; + break; + case 3: + p->mBitDepth = 24; + break; + case 4: + p->mBitDepth = 32; + break; + default: + break; + } + + // set up default encoding parameters and state + // - note: mFrameSize is set in the constructor or via alac_set_frame_size() which must be called before this routine + for ( indx = 0; indx < kALACMaxChannels; indx++ ) + p->mLastMixRes[indx] = kDefaultMixRes; + + // the maximum output frame size can be no bigger than (samplesPerBlock * numChannels * ((10 + sampleSize)/8) + 1) + // but note that this can be bigger than the input size! + // - since we don't yet know what our input format will be, use our max allowed sample size in the calculation + p->mMaxOutputBytes = p->mFrameSize * p->mNumChannels * ((10 + kMaxSampleSize) / 8) + 1; + + status = ALAC_noErr; + + // initialize coefs arrays once b/c retaining state across blocks actually improves the encode ratio + for ( channel = 0; channel < (int32_t) p->mNumChannels; channel++ ) + { + for ( search = 0; search < kALACMaxSearches; search++ ) + { + init_coefs( p->mCoefsU[channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs ); + init_coefs( p->mCoefsV[channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs ); + } + } + + return status; +} + +/* + alac_get_source_format() + - given the input format, return one of our supported formats +*/ +void +alac_get_source_format(ALAC_ENCODER *p, const AudioFormatDescription * source, AudioFormatDescription * output ) +{ + (void) output ; + // default is 16-bit native endian + // - note: for float input we assume that's coming from one of our decoders (mp3, aac) so it only makes sense + // to encode to 16-bit since the source was lossy in the first place + // - note: if not a supported bit depth, find the closest supported bit depth to the input one + if ( (source->mFormatID != kALACFormatLinearPCM) || ((source->mFormatFlags & kALACFormatFlagIsFloat) != 0) || + ( source->mBitsPerChannel <= 16 ) ) + p->mBitDepth = 16; + else if ( source->mBitsPerChannel <= 20 ) + p->mBitDepth = 20; + else if ( source->mBitsPerChannel <= 24 ) + p->mBitDepth = 24; + else + p->mBitDepth = 32; + + // we support 16/20/24/32-bit integer data at any sample rate and our target number of channels + // and sample rate were specified when we were configured + /* + MakeUncompressedAudioFormat( mNumChannels, (float) mOutputSampleRate, mBitDepth, kAudioFormatFlagsNativeIntegerPacked, output ); + */ +} + + + +#if VERBOSE_DEBUG + +#if PRAGMA_MARK +#pragma mark - +#endif + +/* + AddFiller() + - add fill and data stream elements to the bitstream to test the decoder +*/ +static void AddFiller( BitBuffer * bits, int32_t numBytes ) +{ + uint8_t tag; + int32_t indx; + + // out of lameness, subtract 6 bytes to deal with header + alignment as required for fill/data elements + numBytes -= 6; + if ( numBytes <= 0 ) + return; + + // randomly pick Fill or Data Stream Element based on numBytes requested + tag = (numBytes & 0x8) ? ID_FIL : ID_DSE; + + BitBufferWrite( bits, tag, 3 ); + if ( tag == ID_FIL ) + { + // can't write more than 269 bytes in a fill element + numBytes = (numBytes > 269) ? 269 : numBytes; + + // fill element = 4-bit size unless >= 15 then 4-bit size + 8-bit extension size + if ( numBytes >= 15 ) + { + uint16_t extensionSize; + + BitBufferWrite( bits, 15, 4 ); + + // 8-bit extension count field is "extra + 1" which is weird but I didn't define the syntax + // - otherwise, there's no way to represent 15 + // - for example, to really mean 15 bytes you must encode extensionSize = 1 + // - why it's not like data stream elements I have no idea + extensionSize = (numBytes - 15) + 1; + //Assert( extensionSize <= 255 ); + BitBufferWrite( bits, extensionSize, 8 ); + } + else + BitBufferWrite( bits, numBytes, 4 ); + + BitBufferWrite( bits, 0x10, 8 ); // extension_type = FILL_DATA = b0001 or'ed with fill_nibble = b0000 + for ( indx = 0; indx < (numBytes - 1); indx++ ) + BitBufferWrite( bits, 0xa5, 8 ); // fill_byte = b10100101 = 0xa5 + } + else + { + // can't write more than 510 bytes in a data stream element + numBytes = (numBytes > 510) ? 510 : numBytes; + + BitBufferWrite( bits, 0, 4 ); // element instance tag + BitBufferWrite( bits, 1, 1 ); // byte-align flag = true + + // data stream element = 8-bit size unless >= 255 then 8-bit size + 8-bit size + if ( numBytes >= 255 ) + { + BitBufferWrite( bits, 255, 8 ); + BitBufferWrite( bits, numBytes - 255, 8 ); + } + else + BitBufferWrite( bits, numBytes, 8 ); + + BitBufferByteAlign( bits, true ); // byte-align with zeros + + for ( indx = 0; indx < numBytes; indx++ ) + BitBufferWrite( bits, 0x5a, 8 ); + } +} + +#endif /* VERBOSE_DEBUG */ diff --git a/libs/libsndfile/src/ALAC/dp_dec.c b/libs/libsndfile/src/ALAC/dp_dec.c new file mode 100644 index 0000000000..45aae7a9e1 --- /dev/null +++ b/libs/libsndfile/src/ALAC/dp_dec.c @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: dp_dec.c + + Contains: Dynamic Predictor decode routines + + Copyright: (c) 2001-2011 Apple, Inc. +*/ + + +#include "dplib.h" +#include + +#if __GNUC__ +#define ALWAYS_INLINE __attribute__((always_inline)) +#else +#define ALWAYS_INLINE +#endif + +#define LOOP_ALIGN + +static inline int32_t ALWAYS_INLINE sign_of_int( int32_t i ) +{ + int32_t negishift; + + negishift = ((uint32_t)-i) >> 31; + return negishift | (i >> 31); +} + +void unpc_block( int32_t * pc1, int32_t * out, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift ) +{ + register int16_t a0, a1, a2, a3; + register int32_t b0, b1, b2, b3; + int32_t j, k, lim; + int32_t sum1, sg, sgn, top, dd; + int32_t * pout; + int32_t del, del0; + uint32_t chanshift = 32 - chanbits; + int32_t denhalf = 1<<(denshift-1); + + out[0] = pc1[0]; + if ( numactive == 0 ) + { + // just copy if numactive == 0 (but don't bother if in/out pointers the same) + if ( (num > 1) && (pc1 != out) ) + memcpy( &out[1], &pc1[1], (num - 1) * sizeof(int32_t) ); + return; + } + if ( numactive == 31 ) + { + // short-circuit if numactive == 31 + int32_t prev; + + /* this code is written such that the in/out buffers can be the same + to conserve buffer space on embedded devices like the iPod + + (original code) + for ( j = 1; j < num; j++ ) + del = pc1[j] + out[j-1]; + out[j] = (del << chanshift) >> chanshift; + */ + prev = out[0]; + for ( j = 1; j < num; j++ ) + { + del = pc1[j] + prev; + prev = (del << chanshift) >> chanshift; + out[j] = prev; + } + return; + } + + for ( j = 1; j <= numactive; j++ ) + { + del = pc1[j] + out[j-1]; + out[j] = (del << chanshift) >> chanshift; + } + + lim = numactive + 1; + + if ( numactive == 4 ) + { + // optimization for numactive == 4 + register int16_t ia0, ia1, ia2, ia3; + register int32_t ib0, ib1, ib2, ib3; + + ia0 = coefs[0]; + ia1 = coefs[1]; + ia2 = coefs[2]; + ia3 = coefs[3]; + + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + top = out[j - lim]; + pout = out + j - 1; + + ib0 = top - pout[0]; + ib1 = top - pout[-1]; + ib2 = top - pout[-2]; + ib3 = top - pout[-3]; + + sum1 = (denhalf - ia0 * ib0 - ia1 * ib1 - ia2 * ib2 - ia3 * ib3) >> denshift; + + del = pc1[j]; + del0 = del; + sg = sign_of_int(del); + del += top + sum1; + + out[j] = (del << chanshift) >> chanshift; + + if ( sg > 0 ) + { + sgn = sign_of_int( ib3 ); + ia3 -= sgn; + del0 -= (4 - 3) * ((sgn * ib3) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( ib2 ); + ia2 -= sgn; + del0 -= (4 - 2) * ((sgn * ib2) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( ib1 ); + ia1 -= sgn; + del0 -= (4 - 1) * ((sgn * ib1) >> denshift); + if ( del0 <= 0 ) + continue; + + ia0 -= sign_of_int( ib0 ); + } + else if ( sg < 0 ) + { + // note: to avoid unnecessary negations, we flip the value of "sgn" + sgn = -sign_of_int( ib3 ); + ia3 -= sgn; + del0 -= (4 - 3) * ((sgn * ib3) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( ib2 ); + ia2 -= sgn; + del0 -= (4 - 2) * ((sgn * ib2) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( ib1 ); + ia1 -= sgn; + del0 -= (4 - 1) * ((sgn * ib1) >> denshift); + if ( del0 >= 0 ) + continue; + + ia0 += sign_of_int( ib0 ); + } + } + + coefs[0] = ia0; + coefs[1] = ia1; + coefs[2] = ia2; + coefs[3] = ia3; + } + else if ( numactive == 8 ) + { + register int16_t a4, a5, a6, a7; + register int32_t b4, b5, b6, b7; + + // optimization for numactive == 8 + a0 = coefs[0]; + a1 = coefs[1]; + a2 = coefs[2]; + a3 = coefs[3]; + a4 = coefs[4]; + a5 = coefs[5]; + a6 = coefs[6]; + a7 = coefs[7]; + + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + top = out[j - lim]; + pout = out + j - 1; + + b0 = top - (*pout--); + b1 = top - (*pout--); + b2 = top - (*pout--); + b3 = top - (*pout--); + b4 = top - (*pout--); + b5 = top - (*pout--); + b6 = top - (*pout--); + b7 = top - (*pout); + pout += 8; + + sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3 + - a4 * b4 - a5 * b5 - a6 * b6 - a7 * b7) >> denshift; + + del = pc1[j]; + del0 = del; + sg = sign_of_int(del); + del += top + sum1; + + out[j] = (del << chanshift) >> chanshift; + + if ( sg > 0 ) + { + sgn = sign_of_int( b7 ); + a7 -= sgn; + del0 -= 1 * ((sgn * b7) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b6 ); + a6 -= sgn; + del0 -= 2 * ((sgn * b6) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b5 ); + a5 -= sgn; + del0 -= 3 * ((sgn * b5) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b4 ); + a4 -= sgn; + del0 -= 4 * ((sgn * b4) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b3 ); + a3 -= sgn; + del0 -= 5 * ((sgn * b3) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b2 ); + a2 -= sgn; + del0 -= 6 * ((sgn * b2) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b1 ); + a1 -= sgn; + del0 -= 7 * ((sgn * b1) >> denshift); + if ( del0 <= 0 ) + continue; + + a0 -= sign_of_int( b0 ); + } + else if ( sg < 0 ) + { + // note: to avoid unnecessary negations, we flip the value of "sgn" + sgn = -sign_of_int( b7 ); + a7 -= sgn; + del0 -= 1 * ((sgn * b7) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b6 ); + a6 -= sgn; + del0 -= 2 * ((sgn * b6) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b5 ); + a5 -= sgn; + del0 -= 3 * ((sgn * b5) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b4 ); + a4 -= sgn; + del0 -= 4 * ((sgn * b4) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b3 ); + a3 -= sgn; + del0 -= 5 * ((sgn * b3) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b2 ); + a2 -= sgn; + del0 -= 6 * ((sgn * b2) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b1 ); + a1 -= sgn; + del0 -= 7 * ((sgn * b1) >> denshift); + if ( del0 >= 0 ) + continue; + + a0 += sign_of_int( b0 ); + } + } + + coefs[0] = a0; + coefs[1] = a1; + coefs[2] = a2; + coefs[3] = a3; + coefs[4] = a4; + coefs[5] = a5; + coefs[6] = a6; + coefs[7] = a7; + } + else + { + // general case + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + sum1 = 0; + pout = out + j - 1; + top = out[j-lim]; + + for ( k = 0; k < numactive; k++ ) + sum1 += coefs[k] * (pout[-k] - top); + + del = pc1[j]; + del0 = del; + sg = sign_of_int( del ); + del += top + ((sum1 + denhalf) >> denshift); + out[j] = (del << chanshift) >> chanshift; + + if ( sg > 0 ) + { + for ( k = (numactive - 1); k >= 0; k-- ) + { + dd = top - pout[-k]; + sgn = sign_of_int( dd ); + coefs[k] -= sgn; + del0 -= (numactive - k) * ((sgn * dd) >> denshift); + if ( del0 <= 0 ) + break; + } + } + else if ( sg < 0 ) + { + for ( k = (numactive - 1); k >= 0; k-- ) + { + dd = top - pout[-k]; + sgn = sign_of_int( dd ); + coefs[k] += sgn; + del0 -= (numactive - k) * ((-sgn * dd) >> denshift); + if ( del0 >= 0 ) + break; + } + } + } + } +} diff --git a/libs/libsndfile/src/ALAC/dp_enc.c b/libs/libsndfile/src/ALAC/dp_enc.c new file mode 100644 index 0000000000..f81cdba520 --- /dev/null +++ b/libs/libsndfile/src/ALAC/dp_enc.c @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: dp_enc.c + + Contains: Dynamic Predictor encode routines + + Copyright: (c) 2001-2011 Apple, Inc. +*/ + +#include "dplib.h" +#include + +#if __GNUC__ +#define ALWAYS_INLINE __attribute__((always_inline)) +#else +#define ALWAYS_INLINE +#endif + +#define LOOP_ALIGN + +void init_coefs( int16_t * coefs, uint32_t denshift, int32_t numPairs ) +{ + int32_t k; + int32_t den = 1 << denshift; + + coefs[0] = (AINIT * den) >> 4; + coefs[1] = (BINIT * den) >> 4; + coefs[2] = (CINIT * den) >> 4; + for ( k = 3; k < numPairs; k++ ) + coefs[k] = 0; +} + +void copy_coefs( int16_t * srcCoefs, int16_t * dstCoefs, int32_t numPairs ) +{ + int32_t k; + + for ( k = 0; k < numPairs; k++ ) + dstCoefs[k] = srcCoefs[k]; +} + +static inline int32_t ALWAYS_INLINE sign_of_int( int32_t i ) +{ + int32_t negishift; + + negishift = ((uint32_t)-i) >> 31; + return negishift | (i >> 31); +} + +void pc_block( int32_t * in, int32_t * pc1, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift ) +{ + register int16_t a0, a1, a2, a3; + register int32_t b0, b1, b2, b3; + int32_t j, k, lim; + int32_t * pin; + int32_t sum1, dd; + int32_t sg, sgn; + int32_t top; + int32_t del, del0; + uint32_t chanshift = 32 - chanbits; + int32_t denhalf = 1 << (denshift - 1); + + pc1[0] = in[0]; + if ( numactive == 0 ) + { + // just copy if numactive == 0 (but don't bother if in/out pointers the same) + if ( (num > 1) && (in != pc1) ) + memcpy( &pc1[1], &in[1], (num - 1) * sizeof(int32_t) ); + return; + } + if ( numactive == 31 ) + { + // short-circuit if numactive == 31 + for( j = 1; j < num; j++ ) + { + del = in[j] - in[j-1]; + pc1[j] = (del << chanshift) >> chanshift; + } + return; + } + + for ( j = 1; j <= numactive; j++ ) + { + del = in[j] - in[j-1]; + pc1[j] = (del << chanshift) >> chanshift; + } + + lim = numactive + 1; + + if ( numactive == 4 ) + { + // optimization for numactive == 4 + a0 = coefs[0]; + a1 = coefs[1]; + a2 = coefs[2]; + a3 = coefs[3]; + + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + top = in[j - lim]; + pin = in + j - 1; + + b0 = top - pin[0]; + b1 = top - pin[-1]; + b2 = top - pin[-2]; + b3 = top - pin[-3]; + + sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3) >> denshift; + + del = in[j] - top - sum1; + del = (del << chanshift) >> chanshift; + pc1[j] = del; + del0 = del; + + sg = sign_of_int(del); + if ( sg > 0 ) + { + sgn = sign_of_int( b3 ); + a3 -= sgn; + del0 -= (4 - 3) * ((sgn * b3) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b2 ); + a2 -= sgn; + del0 -= (4 - 2) * ((sgn * b2) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b1 ); + a1 -= sgn; + del0 -= (4 - 1) * ((sgn * b1) >> denshift); + if ( del0 <= 0 ) + continue; + + a0 -= sign_of_int( b0 ); + } + else if ( sg < 0 ) + { + // note: to avoid unnecessary negations, we flip the value of "sgn" + sgn = -sign_of_int( b3 ); + a3 -= sgn; + del0 -= (4 - 3) * ((sgn * b3) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b2 ); + a2 -= sgn; + del0 -= (4 - 2) * ((sgn * b2) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b1 ); + a1 -= sgn; + del0 -= (4 - 1) * ((sgn * b1) >> denshift); + if ( del0 >= 0 ) + continue; + + a0 += sign_of_int( b0 ); + } + } + + coefs[0] = a0; + coefs[1] = a1; + coefs[2] = a2; + coefs[3] = a3; + } + else if ( numactive == 8 ) + { + // optimization for numactive == 8 + register int16_t a4, a5, a6, a7; + register int32_t b4, b5, b6, b7; + + a0 = coefs[0]; + a1 = coefs[1]; + a2 = coefs[2]; + a3 = coefs[3]; + a4 = coefs[4]; + a5 = coefs[5]; + a6 = coefs[6]; + a7 = coefs[7]; + + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + top = in[j - lim]; + pin = in + j - 1; + + b0 = top - (*pin--); + b1 = top - (*pin--); + b2 = top - (*pin--); + b3 = top - (*pin--); + b4 = top - (*pin--); + b5 = top - (*pin--); + b6 = top - (*pin--); + b7 = top - (*pin); + pin += 8; + + sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3 + - a4 * b4 - a5 * b5 - a6 * b6 - a7 * b7) >> denshift; + + del = in[j] - top - sum1; + del = (del << chanshift) >> chanshift; + pc1[j] = del; + del0 = del; + + sg = sign_of_int(del); + if ( sg > 0 ) + { + sgn = sign_of_int( b7 ); + a7 -= sgn; + del0 -= 1 * ((sgn * b7) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b6 ); + a6 -= sgn; + del0 -= 2 * ((sgn * b6) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b5 ); + a5 -= sgn; + del0 -= 3 * ((sgn * b5) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b4 ); + a4 -= sgn; + del0 -= 4 * ((sgn * b4) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b3 ); + a3 -= sgn; + del0 -= 5 * ((sgn * b3) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b2 ); + a2 -= sgn; + del0 -= 6 * ((sgn * b2) >> denshift); + if ( del0 <= 0 ) + continue; + + sgn = sign_of_int( b1 ); + a1 -= sgn; + del0 -= 7 * ((sgn * b1) >> denshift); + if ( del0 <= 0 ) + continue; + + a0 -= sign_of_int( b0 ); + } + else if ( sg < 0 ) + { + // note: to avoid unnecessary negations, we flip the value of "sgn" + sgn = -sign_of_int( b7 ); + a7 -= sgn; + del0 -= 1 * ((sgn * b7) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b6 ); + a6 -= sgn; + del0 -= 2 * ((sgn * b6) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b5 ); + a5 -= sgn; + del0 -= 3 * ((sgn * b5) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b4 ); + a4 -= sgn; + del0 -= 4 * ((sgn * b4) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b3 ); + a3 -= sgn; + del0 -= 5 * ((sgn * b3) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b2 ); + a2 -= sgn; + del0 -= 6 * ((sgn * b2) >> denshift); + if ( del0 >= 0 ) + continue; + + sgn = -sign_of_int( b1 ); + a1 -= sgn; + del0 -= 7 * ((sgn * b1) >> denshift); + if ( del0 >= 0 ) + continue; + + a0 += sign_of_int( b0 ); + } + } + + coefs[0] = a0; + coefs[1] = a1; + coefs[2] = a2; + coefs[3] = a3; + coefs[4] = a4; + coefs[5] = a5; + coefs[6] = a6; + coefs[7] = a7; + } + else + { +//pc_block_general: + // general case + for ( j = lim; j < num; j++ ) + { + LOOP_ALIGN + + top = in[j - lim]; + pin = in + j - 1; + + sum1 = 0; + for ( k = 0; k < numactive; k++ ) + sum1 -= coefs[k] * (top - pin[-k]); + + del = in[j] - top - ((sum1 + denhalf) >> denshift); + del = (del << chanshift) >> chanshift; + pc1[j] = del; + del0 = del; + + sg = sign_of_int( del ); + if ( sg > 0 ) + { + for ( k = (numactive - 1); k >= 0; k-- ) + { + dd = top - pin[-k]; + sgn = sign_of_int( dd ); + coefs[k] -= sgn; + del0 -= (numactive - k) * ((sgn * dd) >> denshift); + if ( del0 <= 0 ) + break; + } + } + else if ( sg < 0 ) + { + for ( k = (numactive - 1); k >= 0; k-- ) + { + dd = top - pin[-k]; + sgn = sign_of_int( dd ); + coefs[k] += sgn; + del0 -= (numactive - k) * ((-sgn * dd) >> denshift); + if ( del0 >= 0 ) + break; + } + } + } + } +} diff --git a/libs/libsndfile/src/ALAC/dplib.h b/libs/libsndfile/src/ALAC/dplib.h new file mode 100644 index 0000000000..37d3353313 --- /dev/null +++ b/libs/libsndfile/src/ALAC/dplib.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: dplib.h + + Contains: Dynamic Predictor routines + + Copyright: Copyright (C) 2001-2011 Apple, Inc. +*/ + +#ifndef __DPLIB_H__ +#define __DPLIB_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// defines + +#define DENSHIFT_MAX 15 +#define DENSHIFT_DEFAULT 9 +#define AINIT 38 +#define BINIT (-29) +#define CINIT (-2) +#define NUMCOEPAIRS 16 + +// prototypes + +void init_coefs( int16_t * coefs, uint32_t denshift, int32_t numPairs ); +void copy_coefs( int16_t * srcCoefs, int16_t * dstCoefs, int32_t numPairs ); + +// NOTE: these routines read at least "numactive" samples so the i/o buffers must be at least that big + +void pc_block( int32_t * in, int32_t * pc, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift ); +void unpc_block( int32_t * pc, int32_t * out, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift ); + +#ifdef __cplusplus +} +#endif + +#endif /* __DPLIB_H__ */ diff --git a/libs/libsndfile/src/ALAC/matrix_dec.c b/libs/libsndfile/src/ALAC/matrix_dec.c new file mode 100644 index 0000000000..cb812d1d4d --- /dev/null +++ b/libs/libsndfile/src/ALAC/matrix_dec.c @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: matrix_dec.c + + Contains: ALAC mixing/matrixing decode routines. + + Copyright: (c) 2004-2011 Apple, Inc. +*/ + +#include "matrixlib.h" +#include "ALACAudioTypes.h" + +// up to 24-bit "offset" macros for the individual bytes of a 20/24-bit word +#if TARGET_RT_BIG_ENDIAN + #define LBYTE 2 + #define MBYTE 1 + #define HBYTE 0 +#else + #define LBYTE 0 + #define MBYTE 1 + #define HBYTE 2 +#endif + +/* + There is no plain middle-side option; instead there are various mixing + modes including middle-side, each lossless, as embodied in the mix() + and unmix() functions. These functions exploit a generalized middle-side + transformation: + + u := [(rL + (m-r)R)/m]; + v := L - R; + + where [ ] denotes integer floor. The (lossless) inverse is + + L = u + v - [rV/m]; + R = L - v; +*/ + +// 16-bit routines + +void unmix16( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres ) +{ + int32_t j; + + if ( mixres != 0 ) + { + /* matrixed stereo */ + for ( j = 0; j < numSamples; j++ ) + { + int32_t l, r; + + l = u[j] + v[j] - ((mixres * v[j]) >> mixbits); + r = l - v[j]; + + out[0] = l << 16; + out[1] = r << 16; + out += stride; + } + } + else + { + /* Conventional separated stereo. */ + for ( j = 0; j < numSamples; j++ ) + { + out[0] = u[j] << 16; + out[1] = v[j] << 16; + out += stride; + } + } +} + +// 20-bit routines +// - the 20 bits of data are left-justified in 3 bytes of storage but right-aligned for input/output predictor buffers + +void unmix20( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres ) +{ + int32_t j; + + if ( mixres != 0 ) + { + /* matrixed stereo */ + for ( j = 0; j < numSamples; j++ ) + { + int32_t l, r; + + l = u[j] + v[j] - ((mixres * v[j]) >> mixbits); + r = l - v[j]; + + out[0] = l << 12; + out[1] = r << 12; + out += stride; + } + } + else + { + /* Conventional separated stereo. */ + for ( j = 0; j < numSamples; j++ ) + { + out[0] = u[j] << 12; + out[1] = v[j] << 12; + out += stride; + } + } +} + +// 24-bit routines +// - the 24 bits of data are right-justified in the input/output predictor buffers + +void unmix24( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ) +{ + int32_t shift = bytesShifted * 8; + int32_t l, r; + int32_t j, k; + + if ( mixres != 0 ) + { + /* matrixed stereo */ + if ( bytesShifted != 0 ) + { + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = u[j] + v[j] - ((mixres * v[j]) >> mixbits); + r = l - v[j]; + + l = (l << shift) | (uint32_t) shiftUV[k + 0]; + r = (r << shift) | (uint32_t) shiftUV[k + 1]; + + out[0] = l << 8; + out[1] = r << 8; + out += stride; + } + } + else + { + for ( j = 0; j < numSamples; j++ ) + { + l = u[j] + v[j] - ((mixres * v[j]) >> mixbits); + r = l - v[j]; + + out[0] = l << 8; + out[1] = r << 8; + out += stride; + } + } + } + else + { + /* Conventional separated stereo. */ + if ( bytesShifted != 0 ) + { + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = u[j]; + r = v[j]; + + l = (l << shift) | (uint32_t) shiftUV[k + 0]; + r = (r << shift) | (uint32_t) shiftUV[k + 1]; + + out[0] = l << 8; + out[1] = r << 8; + out += stride; + } + } + else + { + for ( j = 0; j < numSamples; j++ ) + { + out[0] = u[j] << 8; + out[1] = v[j] << 8; + out += stride; + } + } + } +} + +// 32-bit routines +// - note that these really expect the internal data width to be < 32 but the arrays are 32-bit +// - otherwise, the calculations might overflow into the 33rd bit and be lost +// - therefore, these routines deal with the specified "unused lower" bytes in the "shift" buffers + +void unmix32( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ) +{ + int32_t shift = bytesShifted * 8; + int32_t l, r; + int32_t j, k; + + if ( mixres != 0 ) + { + //Assert( bytesShifted != 0 ); + + /* matrixed stereo with shift */ + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + int32_t lt, rt; + + lt = u[j]; + rt = v[j]; + + l = lt + rt - ((mixres * rt) >> mixbits); + r = l - rt; + + out[0] = (l << shift) | (uint32_t) shiftUV[k + 0]; + out[1] = (r << shift) | (uint32_t) shiftUV[k + 1]; + out += stride; + } + } + else + { + if ( bytesShifted == 0 ) + { + /* interleaving w/o shift */ + for ( j = 0; j < numSamples; j++ ) + { + out[0] = u[j]; + out[1] = v[j]; + out += stride; + } + } + else + { + /* interleaving with shift */ + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + out[0] = (u[j] << shift) | (uint32_t) shiftUV[k + 0]; + out[1] = (v[j] << shift) | (uint32_t) shiftUV[k + 1]; + out += stride; + } + } + } +} + +// 20/24-bit <-> 32-bit helper routines (not really matrixing but convenient to put here) + +void copyPredictorTo24( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ) +{ + int32_t j; + + for ( j = 0; j < numSamples; j++ ) + { + out[0] = in[j] << 8; + out += stride; + } +} + +void copyPredictorTo24Shift( int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted ) +{ + int32_t shiftVal = bytesShifted * 8; + int32_t j; + + //Assert( bytesShifted != 0 ); + + for ( j = 0; j < numSamples; j++ ) + { + int32_t val = in[j]; + + val = (val << shiftVal) | (uint32_t) shift[j]; + out[0] = val << 8; + out += stride; + } +} + +void copyPredictorTo20( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ) +{ + int32_t j; + + // 32-bit predictor values are right-aligned but 20-bit output values should be left-aligned + // in the 24-bit output buffer + for ( j = 0; j < numSamples; j++ ) + { + out[0] = in[j] << 12; + out += stride; + } +} + +void copyPredictorTo32( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ) +{ + int32_t i, j; + + // this is only a subroutine to abstract the "iPod can only output 16-bit data" problem + for ( i = 0, j = 0; i < numSamples; i++, j += stride ) + out[j] = in[i] << 8; +} + +void copyPredictorTo32Shift( int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted ) +{ + int32_t * op = out; + uint32_t shiftVal = bytesShifted * 8; + int32_t j; + + //Assert( bytesShifted != 0 ); + + // this is only a subroutine to abstract the "iPod can only output 16-bit data" problem + for ( j = 0; j < numSamples; j++ ) + { + op[0] = (in[j] << shiftVal) | (uint32_t) shift[j]; + op += stride; + } +} diff --git a/libs/libsndfile/src/ALAC/matrix_enc.c b/libs/libsndfile/src/ALAC/matrix_enc.c new file mode 100644 index 0000000000..5b4d1589eb --- /dev/null +++ b/libs/libsndfile/src/ALAC/matrix_enc.c @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: matrix_enc.c + + Contains: ALAC mixing/matrixing encode routines. + + Copyright: (c) 2004-2011 Apple, Inc. +*/ + +#include "matrixlib.h" +#include "ALACAudioTypes.h" + +/* + There is no plain middle-side option; instead there are various mixing + modes including middle-side, each lossless, as embodied in the mix() + and unmix() functions. These functions exploit a generalized middle-side + transformation: + + u := [(rL + (m-r)R)/m]; + v := L - R; + + where [ ] denotes integer floor. The (lossless) inverse is + + L = u + v - [rV/m]; + R = L - v; +*/ + +// 16-bit routines + +void mix16( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres ) +{ + int32_t j; + + if ( mixres != 0 ) + { + int32_t mod = 1 << mixbits; + int32_t m2; + + /* matrixed stereo */ + m2 = mod - mixres; + for ( j = 0; j < numSamples; j++ ) + { + int32_t l, r; + + l = in[0] >> 16; + r = in[1] >> 16; + in += stride; + u[j] = (mixres * l + m2 * r) >> mixbits; + v[j] = l - r; + } + } + else + { + /* Conventional separated stereo. */ + for ( j = 0; j < numSamples; j++ ) + { + u[j] = in[0] >> 16; + v[j] = in[1] >> 16; + in += stride; + } + } +} + +// 20-bit routines +// - the 20 bits of data are left-justified in 3 bytes of storage but right-aligned for input/output predictor buffers + +void mix20( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres ) +{ + int32_t l, r; + int32_t j; + + if ( mixres != 0 ) + { + /* matrixed stereo */ + int32_t mod = 1 << mixbits; + int32_t m2 = mod - mixres; + + for ( j = 0; j < numSamples; j++ ) + { + l = in[0] >> 12; + r = in[1] >> 12; + in += stride; + + u[j] = (mixres * l + m2 * r) >> mixbits; + v[j] = l - r; + } + } + else + { + /* Conventional separated stereo. */ + for ( j = 0; j < numSamples; j++ ) + { + u[j] = in[0] >> 12; + v[j] = in[1] >> 12; + in += stride; + } + } +} + +// 24-bit routines +// - the 24 bits of data are right-justified in the input/output predictor buffers + +void mix24( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ) +{ + int32_t l, r; + int32_t shift = bytesShifted * 8; + uint32_t mask = (1ul << shift) - 1; + int32_t j, k; + + if ( mixres != 0 ) + { + /* matrixed stereo */ + int32_t mod = 1 << mixbits; + int32_t m2 = mod - mixres; + + if ( bytesShifted != 0 ) + { + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = in[0] >> 8; + r = in[1] >> 8; + in += stride; + + shiftUV[k + 0] = (uint16_t)(l & mask); + shiftUV[k + 1] = (uint16_t)(r & mask); + + l >>= shift; + r >>= shift; + + u[j] = (mixres * l + m2 * r) >> mixbits; + v[j] = l - r; + } + } + else + { + for ( j = 0; j < numSamples; j++ ) + { + l = in[0] >> 8; + r = in[1] >> 8; + in += stride; + + u[j] = (mixres * l + m2 * r) >> mixbits; + v[j] = l - r; + } + } + } + else + { + /* Conventional separated stereo. */ + if ( bytesShifted != 0 ) + { + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = in[0] >> 8; + r = in[1] >> 8; + in += stride; + + shiftUV[k + 0] = (uint16_t)(l & mask); + shiftUV[k + 1] = (uint16_t)(r & mask); + + l >>= shift; + r >>= shift; + + u[j] = l; + v[j] = r; + } + } + else + { + for ( j = 0; j < numSamples; j++ ) + { + l = in[0] >> 8; + r = in[1] >> 8; + in += stride; + } + } + } +} + +// 32-bit routines +// - note that these really expect the internal data width to be < 32 but the arrays are 32-bit +// - otherwise, the calculations might overflow into the 33rd bit and be lost +// - therefore, these routines deal with the specified "unused lower" bytes in the "shift" buffers + +void mix32( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ) +{ + int32_t shift = bytesShifted * 8; + uint32_t mask = (1ul << shift) - 1; + int32_t l, r; + int32_t j, k; + + if ( mixres != 0 ) + { + int32_t mod = 1 << mixbits; + int32_t m2; + + //Assert( bytesShifted != 0 ); + + /* matrixed stereo with shift */ + m2 = mod - mixres; + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = in[0]; + r = in[1]; + in += stride; + + shiftUV[k + 0] = (uint16_t)(l & mask); + shiftUV[k + 1] = (uint16_t)(r & mask); + + l >>= shift; + r >>= shift; + + u[j] = (mixres * l + m2 * r) >> mixbits; + v[j] = l - r; + } + } + else + { + if ( bytesShifted == 0 ) + { + /* de-interleaving w/o shift */ + for ( j = 0; j < numSamples; j++ ) + { + u[j] = in[0]; + v[j] = in[1]; + in += stride; + } + } + else + { + /* de-interleaving with shift */ + for ( j = 0, k = 0; j < numSamples; j++, k += 2 ) + { + l = in[0]; + r = in[1]; + in += stride; + + shiftUV[k + 0] = (uint16_t)(l & mask); + shiftUV[k + 1] = (uint16_t)(r & mask); + + l >>= shift; + r >>= shift; + + u[j] = l; + v[j] = r; + } + } + } +} + diff --git a/libs/libsndfile/src/ALAC/matrixlib.h b/libs/libsndfile/src/ALAC/matrixlib.h new file mode 100644 index 0000000000..d405cbcd20 --- /dev/null +++ b/libs/libsndfile/src/ALAC/matrixlib.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012 Erik de Castro Lopo + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + File: matrixlib.h + + Contains: ALAC mixing/matrixing routines to/from 32-bit predictor buffers. + + Copyright: Copyright (C) 2004 to 2011 Apple, Inc. +*/ + +#ifndef __MATRIXLIB_H +#define __MATRIXLIB_H + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// 16-bit routines +void mix16( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres ); +void unmix16( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres ); + +// 20-bit routines +void mix20( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres ); +void unmix20( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres ); + +// 24-bit routines +// - 24-bit data sometimes compresses better by shifting off the bottom byte so these routines deal with +// the specified "unused lower bytes" in the combined "shift" buffer +void mix24( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ); +void unmix24( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ); + +// 32-bit routines +// - note that these really expect the internal data width to be < 32-bit but the arrays are 32-bit +// - otherwise, the calculations might overflow into the 33rd bit and be lost +// - therefore, these routines deal with the specified "unused lower" bytes in the combined "shift" buffer +void mix32( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ); +void unmix32( int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, + int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted ); + +// 20/24/32-bit <-> 32-bit helper routines (not really matrixing but convenient to put here) +void copy20ToPredictor( int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples ); +void copy24ToPredictor( int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples ); + +void copyPredictorTo24( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ); +void copyPredictorTo24Shift( int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted ); +void copyPredictorTo20( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ); + +void copyPredictorTo32( int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples ); +void copyPredictorTo32Shift( int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted ); + +#ifdef __cplusplus +} +#endif + +#endif /* __MATRIXLIB_H */ diff --git a/libs/libsndfile/src/G72x/g72x.h b/libs/libsndfile/src/G72x/g72x.h index 785a5d090d..d7631e6d8e 100644 --- a/libs/libsndfile/src/G72x/g72x.h +++ b/libs/libsndfile/src/G72x/g72x.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/G72x/g72x_test.c b/libs/libsndfile/src/G72x/g72x_test.c index 3959efe69e..79cabce11b 100644 --- a/libs/libsndfile/src/G72x/g72x_test.c +++ b/libs/libsndfile/src/G72x/g72x_test.c @@ -1,21 +1,21 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo -** +** Copyright (C) 1999-2011 Erik de Castro Lopo +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + #include #include #include @@ -77,20 +77,20 @@ main (int argc, char *argv []) return 0 ; } /* main */ -static void +static void g721_test (void) { return ; } /* g721_test */ -static void +static void g723_test (double margin) { static double orig_buffer [BUFFER_SIZE] ; static short orig [BUFFER_SIZE] ; static short data [BUFFER_SIZE] ; G72x_STATE encoder_state, decoder_state ; - + long k ; int code, position, max_err ; @@ -104,10 +104,10 @@ g723_test (double margin) memset (data, 0, BUFFER_SIZE * sizeof (short)) ; memset (orig, 0, BUFFER_SIZE * sizeof (short)) ; - + printf (" g723_test : ") ; fflush (stdout) ; - + gen_signal_double (orig_buffer, 32000.0, BUFFER_SIZE) ; for (k = 0 ; k < BUFFER_SIZE ; k++) orig [k] = (short) orig_buffer [k] ; @@ -144,13 +144,13 @@ g723_test (double margin) #define SIGNAL_MAXVAL 30000.0 #define DECAY_COUNT 1000 -static void +static void gen_signal_double (double *gendata, double scale, int gendatalen) { int k, ramplen ; double amp = 0.0 ; - + ramplen = DECAY_COUNT ; - + for (k = 0 ; k < gendatalen ; k++) { if (k <= ramplen) amp = scale * k / ((double) ramplen) ; @@ -160,11 +160,11 @@ gen_signal_double (double *gendata, double scale, int gendatalen) gendata [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE)) + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ; } ; - + return ; } /* gen_signal_double */ -static int +static int error_function (double data, double orig, double margin) { double error ; @@ -174,7 +174,7 @@ error_function (double data, double orig, double margin) error = fabs (data - orig) / 3000.0 ; else error = fabs (data - orig) / fabs (orig) ; - + if (error > margin) { printf ("\n\n*******************\nError : %f\n", error) ; return 1 ; @@ -182,21 +182,21 @@ error_function (double data, double orig, double margin) return 0 ; } /* error_function */ -static int +static int oct_save_short (short *a, short *b, int len) { FILE *file ; int k ; if (! (file = fopen ("error.dat", "w"))) return 1 ; - + fprintf (file, "# Not created by Octave\n") ; - + fprintf (file, "# name: a\n") ; fprintf (file, "# type: matrix\n") ; fprintf (file, "# rows: %d\n", len) ; fprintf (file, "# columns: 1\n") ; - + for (k = 0 ; k < len ; k++) fprintf (file, "% d\n", a [k]) ; @@ -204,7 +204,7 @@ oct_save_short (short *a, short *b, int len) fprintf (file, "# type: matrix\n") ; fprintf (file, "# rows: %d\n", len) ; fprintf (file, "# columns: 1\n") ; - + for (k = 0 ; k < len ; k++) fprintf (file, "% d\n", b [k]) ; diff --git a/libs/libsndfile/src/Makefile.am b/libs/libsndfile/src/Makefile.am index 1297b360f7..7c307a8b42 100644 --- a/libs/libsndfile/src/Makefile.am +++ b/libs/libsndfile/src/Makefile.am @@ -1,100 +1,134 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = GSM610 G72x +AUTOMAKE_OPTIONS = subdir-objects -INCLUDES = @EXTERNAL_CFLAGS@ +AM_CPPFLAGS = @EXTERNAL_CFLAGS@ lib_LTLIBRARIES = libsndfile.la include_HEADERS = sndfile.hh nodist_include_HEADERS = sndfile.h -noinst_LTLIBRARIES = libcommon.la +noinst_LTLIBRARIES = GSM610/libgsm.la G72x/libg72x.la ALAC/libalac.la libcommon.la OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@ OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@ -SYMBOL_FILES = Symbols.linux Symbols.darwin libsndfile-1.def Symbols.os2 +SYMBOL_FILES = Symbols.gnu-binutils Symbols.darwin libsndfile-1.def Symbols.os2 Symbols.static EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \ - $(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py + create_symbols_file.py binheader_writef_check.py \ + GSM610/README GSM610/COPYRIGHT GSM610/ChangeLog \ + G72x/README G72x/README.original G72x/ChangeLog \ + make-static-lib-hidden-privates.sh -noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h +noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h ogg.h chanmap.h noinst_PROGRAMS = COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \ double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \ - interleave.c strings.c dither.c broadcast.c audio_detect.c \ - ima_oki_adpcm.c ima_oki_adpcm.h chunk.c + interleave.c strings.c dither.c cart.c broadcast.c audio_detect.c \ + ima_oki_adpcm.c ima_oki_adpcm.h alac.c chunk.c ogg.c chanmap.c \ + windows.c id3.c $(WIN_VERSION_FILE) FILESPECIFIC = sndfile.c aiff.c au.c avr.c caf.c dwd.c flac.c g72x.c htk.c ircam.c \ - macbinary3.c macos.c mat4.c mat5.c nist.c ogg.c paf.c pvf.c raw.c rx2.c sd2.c \ - sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c mpc2k.c rf64.c + macbinary3.c macos.c mat4.c mat5.c nist.c paf.c pvf.c raw.c rx2.c sd2.c \ + sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c mpc2k.c rf64.c \ + ogg_vorbis.c ogg_speex.c ogg_pcm.c ogg_opus.c +CLEANFILES = *~ *.exe G72x/*.exe + +if USE_WIN_VERSION_FILE +WIN_VERSION_FILE = version-metadata.rc +else +WIN_VERSION_FILE = +endif + +#=============================================================================== # MinGW requires -no-undefined if a DLL is to be built. libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@ libsndfile_la_SOURCES = $(FILESPECIFIC) $(noinst_HEADERS) nodist_libsndfile_la_SOURCES = $(nodist_include_HEADERS) -libsndfile_la_LIBADD = libcommon.la GSM610/libgsm.la G72x/libg72x.la \ - @EXTERNAL_LIBS@ -lm +libsndfile_la_LIBADD = GSM610/libgsm.la G72x/libg72x.la ALAC/libalac.la \ + libcommon.la @EXTERNAL_LIBS@ -lm libcommon_la_SOURCES = $(COMMON) +#====================================================================== +# Subdir libraries. + +GSM610_libgsm_la_SOURCES = GSM610/config.h GSM610/gsm.h GSM610/gsm610_priv.h \ + GSM610/add.c GSM610/code.c GSM610/decode.c GSM610/gsm_create.c \ + GSM610/gsm_decode.c GSM610/gsm_destroy.c GSM610/gsm_encode.c \ + GSM610/gsm_option.c GSM610/long_term.c GSM610/lpc.c GSM610/preprocess.c \ + GSM610/rpe.c GSM610/short_term.c GSM610/table.c + +G72x_libg72x_la_SOURCES = G72x/g72x.h G72x/g72x_priv.h \ + G72x/g721.c G72x/g723_16.c G72x/g723_24.c G72x/g723_40.c G72x/g72x.c + +ALAC_libalac_la_SOURCES = ALAC/ALACAudioTypes.h ALAC/ALACBitUtilities.h \ + ALAC/EndianPortable.h ALAC/aglib.h ALAC/dplib.h ALAC/matrixlib.h \ + ALAC/alac_codec.h \ + ALAC/ALACBitUtilities.c ALAC/ag_dec.c \ + ALAC/ag_enc.c ALAC/dp_dec.c ALAC/dp_enc.c ALAC/matrix_dec.c \ + ALAC/matrix_enc.c ALAC/alac_decoder.c ALAC/alac_encoder.c + +#=============================================================================== +# Test programs. + #test_main_SOURCES = test_main.c test_main.h test_conversions.c test_float.c test_endswap.c \ -# test_audio_detect.c test_log_printf.c test_file_io.c test_ima_oki_adpcm.c +# test_audio_detect.c test_log_printf.c test_file_io.c test_ima_oki_adpcm.c \ +# test_strncpy_crlf.c test_broadcast_var.c test_cart_var.c #test_main_LDADD = libcommon.la -# -# + +#G72x_g72x_test_SOURCES = G72x/g72x_test.c +#G72x_g72x_test_LDADD = G72x/libg72x.la + #test_endswap.c: test_endswap.def test_endswap.tpl -# autogen --writable test_endswap.def +# cd $(srcdir) && autogen --writable test_endswap.def && cd $(abs_builddir) -genfiles : $(SYMBOL_FILES) +genfiles : #$(SYMBOL_FILES) -# A single test programs. -# It is not possible to place these in the tests/ directory because they -# need access to the internals of the SF_PRIVATE struct. - -check: $(noinst_PROGRAMS) - @echo - @echo - @echo - @echo "============================================================" - @if [ -x /usr/bin/python2.5 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi +check : + @if [ -x /usr/bin/python ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi +# G72x/g72x_test$(EXEEXT) all ./test_main$(EXEEXT) - @echo "============================================================" - @echo - @echo - @echo + +# Need this target to force building of test programs. +checkprograms : $(check_PROGRAMS) #====================================================================== # Generate an OS specific Symbols files. This is done when the author # builds the distribution tarball. There should be not need for the # end user to create these files. -Symbols.linux: create_symbols_file.py - ./create_symbols_file.py linux $(VERSION) > $@ +Symbols.gnu-binutils: create_symbols_file.py + python $(srcdir)/create_symbols_file.py linux $(VERSION) > $@ Symbols.darwin: create_symbols_file.py - ./create_symbols_file.py darwin $(VERSION) > $@ + python $(srcdir)/create_symbols_file.py darwin $(VERSION) > $@ libsndfile-1.def: create_symbols_file.py - ./create_symbols_file.py win32 $(VERSION) > $@ + python $(srcdir)/create_symbols_file.py win32 $(VERSION) > $@ Symbols.os2: create_symbols_file.py - ./create_symbols_file.py os2 $(VERSION) > $@ + python $(srcdir)/create_symbols_file.py os2 $(VERSION) > $@ + +Symbols.static: create_symbols_file.py + python $(srcdir)/create_symbols_file.py static $(VERSION) > $@ # Fake dependancy to force the creation of these files. -sndfile.o : $(SYMBOL_FILES) +#sndfile.o : $(SYMBOL_FILES) + +#====================================================================== +# Building windows resource files (if needed). + +.rc.lo: + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) $< -o $@ #====================================================================== # Disable autoheader. AUTOHEADER=echo -# Dependancies. -aiff.c au.c g72x.c ircam.c mat4.c mat5.c nist.c paf.c pvf.c : sndfile.h common.h -raw.c svx.c voc.c w64.c wav.c wav_w64.c htk.c sd2.c rx2.c txw.c : sndfile.h common.h -sds.c wve.c dwd.c ogg.c xi.c sndfile.c common.c file_io.c : sndfile.h common.h -command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h -ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c interleave.c strings.c : sndfile.h common.h -dither.c : sndfile.h common.h + diff --git a/libs/libsndfile/src/Symbols.darwin b/libs/libsndfile/src/Symbols.darwin index 271e0b0c87..a671460756 100644 --- a/libs/libsndfile/src/Symbols.darwin +++ b/libs/libsndfile/src/Symbols.darwin @@ -30,6 +30,7 @@ _sf_write_double _sf_strerror _sf_get_string _sf_set_string +_sf_version_string _sf_open_fd _sf_open_virtual _sf_write_sync diff --git a/libs/libsndfile/src/Symbols.os2 b/libs/libsndfile/src/Symbols.os2 index fbef2c42e4..118ceba728 100644 --- a/libs/libsndfile/src/Symbols.os2 +++ b/libs/libsndfile/src/Symbols.os2 @@ -1,6 +1,6 @@ ; Auto-generated by create_symbols_file.py -LIBRARY sndfile1.dll +LIBRARY sndfile1 INITINSTANCE TERMINSTANCE CODE PRELOAD MOVEABLE DISCARDABLE DATA PRELOAD MOVEABLE MULTIPLE NONSHARED @@ -36,6 +36,7 @@ _sf_write_double @40 _sf_strerror @50 _sf_get_string @60 _sf_set_string @61 +_sf_version_string @68 _sf_open_fd @70 _sf_open_virtual @80 _sf_write_sync @90 diff --git a/libs/libsndfile/src/aiff.c b/libs/libsndfile/src/aiff.c index c18324c262..c0175b2f24 100644 --- a/libs/libsndfile/src/aiff.c +++ b/libs/libsndfile/src/aiff.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** Copyright (C) 2005 David Viens ** ** This program is free software; you can redistribute it and/or modify @@ -24,10 +24,14 @@ #include #include #include +#ifdef HAVE_INTTYPES_H +#include +#endif #include "sndfile.h" #include "sfendian.h" #include "common.h" +#include "chanmap.h" /*------------------------------------------------------------------------------ * Macros to handle big/little endian issues. @@ -41,6 +45,7 @@ #define MARK_MARKER (MAKE_MARKER ('M', 'A', 'R', 'K')) #define INST_MARKER (MAKE_MARKER ('I', 'N', 'S', 'T')) #define APPL_MARKER (MAKE_MARKER ('A', 'P', 'P', 'L')) +#define CHAN_MARKER (MAKE_MARKER ('C', 'H', 'A', 'N')) #define c_MARKER (MAKE_MARKER ('(', 'c', ')', ' ')) #define NAME_MARKER (MAKE_MARKER ('N', 'A', 'M', 'E')) @@ -182,11 +187,11 @@ typedef struct } MARK_ID_POS ; typedef struct -{ PRIV_CHUNK4 chunk4 ; - - sf_count_t comm_offset ; +{ sf_count_t comm_offset ; sf_count_t ssnd_offset ; + int chanmap_tag ; + MARK_ID_POS *markstr ; } AIFF_PRIVATE ; @@ -215,8 +220,15 @@ static short get_loop_mode (short mode) ; static int aiff_read_basc_chunk (SF_PRIVATE * psf, int) ; +static int aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword) ; + static unsigned int marker_to_position (const MARK_ID_POS *m, unsigned short n, int marksize) ; +static int aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; +static SF_CHUNK_ITERATOR * aiff_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; +static int aiff_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; +static int aiff_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; + /*------------------------------------------------------------------------------ ** Public function. */ @@ -233,38 +245,44 @@ aiff_open (SF_PRIVATE *psf) if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL) return SFE_MALLOC_FAILED ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = aiff_read_header (psf, &comm_fmt))) return error ; + + psf->next_chunk_iterator = aiff_next_chunk_iterator ; + psf->get_chunk_size = aiff_get_chunk_size ; + psf->get_chunk_data = aiff_get_chunk_data ; + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AIFF) return SFE_BAD_OPEN_FORMAT ; - if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) + if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) return SFE_MALLOC_FAILED ; psf->peak_info->peak_loc = SF_PEAK_START ; } ; - if (psf->mode != SFM_RDWR || psf->filelength < 40) + if (psf->file.mode != SFM_RDWR || psf->filelength < 40) { psf->filelength = 0 ; psf->datalength = 0 ; psf->dataoffset = 0 ; psf->sf.frames = 0 ; } ; - psf->str_flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; + psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; if ((error = aiff_write_header (psf, SF_FALSE))) return error ; - psf->write_header = aiff_write_header ; + psf->write_header = aiff_write_header ; + psf->set_chunk = aiff_set_chunk ; } ; psf->container_close = aiff_close ; @@ -315,7 +333,7 @@ aiff_open (SF_PRIVATE *psf) break ; case SF_FORMAT_DWVW_N : - if (psf->mode != SFM_READ) + if (psf->file.mode != SFM_READ) { error = SFE_DWVW_BAD_BITWIDTH ; break ; } ; @@ -357,19 +375,20 @@ static unsigned int marker_to_position (const MARK_ID_POS *m, unsigned short n, int marksize) { int i ; - for (i = 0 ; i < marksize ; i++) + for (i = 0 ; i < marksize ; i++) if (m [i].markerID == n) return m [i].position ; - return 0 ; + return 0 ; } /* marker_to_position */ static int aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) { SSND_CHUNK ssnd_fmt ; AIFF_PRIVATE *paiff ; - unsigned marker, dword, FORMsize, SSNDsize, bytesread ; + BUF_UNION ubuf ; + unsigned chunk_size = 0, FORMsize, SSNDsize, bytesread ; int k, found_chunk = 0, done = 0, error = 0 ; - char *cptr, byte ; + char *cptr ; int instr_found = 0, mark_found = 0, mark_count = 0 ; if (psf->filelength > SF_PLATFORM_S64 (0xffffffff)) @@ -394,54 +413,61 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) ** one and then check for the mandatory chunks at the end. */ while (! done) - { psf_binheader_readf (psf, "m", &marker) ; + { unsigned marker ; + size_t jump = chunk_size & 1 ; - if (psf->mode == SFM_RDWR && (found_chunk & HAVE_SSND)) + marker = chunk_size = 0 ; + psf_binheader_readf (psf, "Ejm4", jump, &marker, &chunk_size) ; + if (marker == 0) + { psf_log_printf (psf, "Have 0 marker.\n") ; + break ; + } ; + + if (psf->file.mode == SFM_RDWR && (found_chunk & HAVE_SSND)) return SFE_AIFF_RW_SSND_NOT_LAST ; + psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; + switch (marker) { case FORM_MARKER : if (found_chunk) return SFE_AIFF_NO_FORM ; - psf_binheader_readf (psf, "E4", &FORMsize) ; - pchk4_store (&(paiff->chunk4), marker, psf->headindex - 8, FORMsize) ; + FORMsize = chunk_size ; + + found_chunk |= HAVE_FORM ; + psf_binheader_readf (psf, "m", &marker) ; + switch (marker) + { case AIFC_MARKER : + case AIFF_MARKER : + found_chunk |= (marker == AIFC_MARKER) ? (HAVE_AIFC | HAVE_AIFF) : HAVE_AIFF ; + break ; + default : + break ; + } ; if (psf->fileoffset > 0 && psf->filelength > FORMsize + 8) { /* Set file length. */ psf->filelength = FORMsize + 8 ; - psf_log_printf (psf, "FORM : %u\n", FORMsize) ; + psf_log_printf (psf, "FORM : %u\n %M\n", FORMsize, marker) ; } - else if (FORMsize != psf->filelength - 2 * SIGNED_SIZEOF (dword)) - { dword = psf->filelength - 2 * sizeof (dword) ; - psf_log_printf (psf, "FORM : %u (should be %u)\n", FORMsize, dword) ; - FORMsize = dword ; + else if (FORMsize != psf->filelength - 2 * SIGNED_SIZEOF (chunk_size)) + { chunk_size = psf->filelength - 2 * sizeof (chunk_size) ; + psf_log_printf (psf, "FORM : %u (should be %u)\n %M\n", FORMsize, chunk_size, marker) ; + FORMsize = chunk_size ; } else - psf_log_printf (psf, "FORM : %u\n", FORMsize) ; - found_chunk |= HAVE_FORM ; + psf_log_printf (psf, "FORM : %u\n %M\n", FORMsize, marker) ; + /* Set this to 0, so we don't jump a byte when parsing the next marker. */ + chunk_size = 0 ; break ; - case AIFC_MARKER : - case AIFF_MARKER : - if ((found_chunk & HAVE_FORM) == 0) - return SFE_AIFF_AIFF_NO_FORM ; - psf_log_printf (psf, " %M\n", marker) ; - found_chunk |= (marker == AIFC_MARKER) ? (HAVE_AIFC | HAVE_AIFF) : HAVE_AIFF ; - break ; case COMM_MARKER : - paiff->comm_offset = psf_ftell (psf) - 4 ; - error = aiff_read_comm_chunk (psf, comm_fmt) ; - pchk4_store (&paiff->chunk4, marker, paiff->comm_offset, comm_fmt->size) ; - - - psf->sf.samplerate = tenbytefloat2int (comm_fmt->sampleRate) ; - psf->sf.frames = comm_fmt->numSampleFrames ; - psf->sf.channels = comm_fmt->numChannels ; - psf->bytewidth = BITWIDTH2BYTES (comm_fmt->sampleSize) ; - - if (error) + paiff->comm_offset = psf_ftell (psf) - 8 ; + chunk_size += chunk_size & 1 ; + comm_fmt->size = chunk_size ; + if ((error = aiff_read_comm_chunk (psf, comm_fmt)) != 0) return error ; found_chunk |= HAVE_COMM ; @@ -452,12 +478,9 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) if ((found_chunk & (HAVE_FORM | HAVE_AIFF | HAVE_COMM)) != (HAVE_FORM | HAVE_AIFF | HAVE_COMM)) return SFE_AIFF_PEAK_B4_COMM ; - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf->headindex - 8, dword) ; - - psf_log_printf (psf, "%M : %d\n", marker, dword) ; - if (dword != AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", dword) ; + psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ; + if (chunk_size != AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) + { psf_binheader_readf (psf, "j", chunk_size) ; psf_log_printf (psf, "*** File PEAK chunk too big.\n") ; return SFE_WAV_BAD_PEAK ; } ; @@ -476,19 +499,19 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) psf_log_printf (psf, " time stamp : %d\n", psf->peak_info->timestamp) ; psf_log_printf (psf, " Ch Position Value\n") ; - cptr = psf->u.cbuf ; - for (dword = 0 ; dword < (unsigned) psf->sf.channels ; dword++) + cptr = ubuf.cbuf ; + for (k = 0 ; k < psf->sf.channels ; k++) { float value ; unsigned int position ; psf_binheader_readf (psf, "Ef4", &value, &position) ; - psf->peak_info->peaks [dword].value = value ; - psf->peak_info->peaks [dword].position = position ; + psf->peak_info->peaks [k].value = value ; + psf->peak_info->peaks [k].position = position ; - snprintf (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n", - dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ; - cptr [sizeof (psf->u.scbuf) - 1] = 0 ; - psf_log_printf (psf, cptr) ; + snprintf (cptr, sizeof (ubuf.scbuf), " %2d %-12" PRId64 " %g\n", + k, psf->peak_info->peaks [k].position, psf->peak_info->peaks [k].value) ; + cptr [sizeof (ubuf.scbuf) - 1] = 0 ; + psf_log_printf (psf, "%s", cptr) ; } ; psf->peak_info->peak_loc = ((found_chunk & HAVE_SSND) == 0) ? SF_PEAK_START : SF_PEAK_END ; @@ -498,9 +521,9 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) if ((found_chunk & HAVE_AIFC) && (found_chunk & HAVE_FVER) == 0) psf_log_printf (psf, "*** Valid AIFC files should have an FVER chunk.\n") ; - paiff->ssnd_offset = psf_ftell (psf) - 4 ; - psf_binheader_readf (psf, "E444", &SSNDsize, &(ssnd_fmt.offset), &(ssnd_fmt.blocksize)) ; - pchk4_store (&paiff->chunk4, marker, paiff->ssnd_offset, SSNDsize) ; + paiff->ssnd_offset = psf_ftell (psf) - 8 ; + SSNDsize = chunk_size ; + psf_binheader_readf (psf, "E44", &(ssnd_fmt.offset), &(ssnd_fmt.blocksize)) ; psf->datalength = SSNDsize - sizeof (ssnd_fmt) ; psf->dataoffset = psf_ftell (psf) ; @@ -520,8 +543,10 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) psf->datalength -= ssnd_fmt.offset ; } else - { psf_log_printf (psf, " Offset : %u (Should be zero)\n", ssnd_fmt.offset) ; + { psf_log_printf (psf, " Offset : %u\n", ssnd_fmt.offset) ; psf_log_printf (psf, " Block Size : %u ???\n", ssnd_fmt.blocksize) ; + psf->dataoffset += ssnd_fmt.offset ; + psf->datalength -= ssnd_fmt.offset ; } ; /* Only set dataend if there really is data at the end. */ @@ -534,155 +559,146 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) break ; /* Seek to end of SSND chunk. */ - psf_fseek (psf, psf->dataoffset + psf->datalength + (SSNDsize & 1), SEEK_SET) ; + psf_fseek (psf, psf->dataoffset + psf->datalength, SEEK_SET) ; break ; case c_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword == 0) + if (chunk_size == 0) break ; - if (dword >= SIGNED_SIZEOF (psf->u.scbuf)) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ; + if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf)) + { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; return SFE_INTERNAL ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ; - cptr [dword] = 0 ; + cptr = ubuf.cbuf ; + psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; + cptr [chunk_size] = 0 ; - psf_sanitize_string (cptr, dword) ; + psf_sanitize_string (cptr, chunk_size) ; psf_log_printf (psf, " %M : %s\n", marker, cptr) ; psf_store_string (psf, SF_STR_COPYRIGHT, cptr) ; + chunk_size += chunk_size & 1 ; break ; case AUTH_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword == 0) + if (chunk_size == 0) break ; - if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 1) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ; + if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 1) + { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; return SFE_INTERNAL ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ; - cptr [dword] = 0 ; + cptr = ubuf.cbuf ; + psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; + cptr [chunk_size] = 0 ; psf_log_printf (psf, " %M : %s\n", marker, cptr) ; psf_store_string (psf, SF_STR_ARTIST, cptr) ; + chunk_size += chunk_size & 1 ; break ; case COMT_MARKER : { unsigned short count, id, len ; - unsigned int timestamp ; + unsigned int timestamp, bytes ; - psf_binheader_readf (psf, "E42", &dword, &count) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - psf_log_printf (psf, " %M : %d\n count : %d\n", marker, dword, count) ; - dword += (dword & 1) ; - if (dword == 0) + if (chunk_size == 0) break ; - dword -= 2 ; + bytes = chunk_size ; + bytes -= psf_binheader_readf (psf, "E2", &count) ; + psf_log_printf (psf, " %M : %d\n count : %d\n", marker, chunk_size, count) ; for (k = 0 ; k < count ; k++) - { dword -= psf_binheader_readf (psf, "E422", ×tamp, &id, &len) ; + { bytes -= psf_binheader_readf (psf, "E422", ×tamp, &id, &len) ; psf_log_printf (psf, " time : 0x%x\n marker : %x\n length : %d\n", timestamp, id, len) ; - if (len + 1 > SIGNED_SIZEOF (psf->u.scbuf)) + if (len + 1 > SIGNED_SIZEOF (ubuf.scbuf)) { psf_log_printf (psf, "\nError : string length (%d) too big.\n", len) ; return SFE_INTERNAL ; } ; - cptr = psf->u.cbuf ; - dword -= psf_binheader_readf (psf, "b", cptr, len) ; + cptr = ubuf.cbuf ; + bytes -= psf_binheader_readf (psf, "b", cptr, len) ; cptr [len] = 0 ; psf_log_printf (psf, " string : %s\n", cptr) ; } ; - if (dword > 0) - psf_binheader_readf (psf, "j", dword) ; + if (bytes > 0) + psf_binheader_readf (psf, "j", bytes) ; } ; break ; case APPL_MARKER : { unsigned appl_marker ; - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword == 0) + if (chunk_size == 0) break ; - if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 1) - { psf_log_printf (psf, " %M : %d (too big, skipping)\n", marker, dword) ; - psf_binheader_readf (psf, "j", dword + (dword & 1)) ; + if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 1) + { psf_log_printf (psf, " %M : %d (too big, skipping)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size + (chunk_size & 1)) ; break ; } ; - if (dword < 4) - { psf_log_printf (psf, " %M : %d (too small, skipping)\n", marker, dword) ; - psf_binheader_readf (psf, "j", dword + (dword & 1)) ; + if (chunk_size < 4) + { psf_log_printf (psf, " %M : %d (too small, skipping)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size + (chunk_size & 1)) ; break ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "mb", &appl_marker, cptr, dword + (dword & 1) - 4) ; - cptr [dword] = 0 ; + cptr = ubuf.cbuf ; + psf_binheader_readf (psf, "mb", &appl_marker, cptr, chunk_size + (chunk_size & 1) - 4) ; + cptr [chunk_size] = 0 ; - for (k = 0 ; k < (int) dword ; k++) - if (! isprint (cptr [k])) + for (k = 0 ; k < (int) chunk_size ; k++) + if (! psf_isprint (cptr [k])) { cptr [k] = 0 ; break ; } ; - psf_log_printf (psf, " %M : %d\n AppSig : %M\n Name : %s\n", marker, dword, appl_marker, cptr) ; + psf_log_printf (psf, " %M : %d\n AppSig : %M\n Name : %s\n", marker, chunk_size, appl_marker, cptr) ; psf_store_string (psf, SF_STR_SOFTWARE, cptr) ; + chunk_size += chunk_size & 1 ; } ; break ; case NAME_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword == 0) + if (chunk_size == 0) break ; - if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 2) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ; + if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 2) + { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; return SFE_INTERNAL ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ; - cptr [dword] = 0 ; + cptr = ubuf.cbuf ; + psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; + cptr [chunk_size] = 0 ; psf_log_printf (psf, " %M : %s\n", marker, cptr) ; psf_store_string (psf, SF_STR_TITLE, cptr) ; + chunk_size += chunk_size & 1 ; break ; case ANNO_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword == 0) + if (chunk_size == 0) break ; - if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 2) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ; + if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 2) + { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; return SFE_INTERNAL ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ; - cptr [dword] = 0 ; + cptr = ubuf.cbuf ; + psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; + cptr [chunk_size] = 0 ; psf_log_printf (psf, " %M : %s\n", marker, cptr) ; psf_store_string (psf, SF_STR_COMMENT, cptr) ; + chunk_size += chunk_size & 1 ; break ; case INST_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - if (dword != SIZEOF_INST_CHUNK) - { psf_log_printf (psf, " %M : %d (should be %d)\n", marker, dword, SIZEOF_INST_CHUNK) ; - psf_binheader_readf (psf, "j", dword) ; + if (chunk_size != SIZEOF_INST_CHUNK) + { psf_log_printf (psf, " %M : %d (should be %d)\n", marker, chunk_size, SIZEOF_INST_CHUNK) ; + psf_binheader_readf (psf, "j", chunk_size) ; break ; } ; - psf_log_printf (psf, " %M : %d\n", marker, dword) ; + psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; { unsigned char bytes [6] ; short gain ; @@ -743,20 +759,15 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) break ; case basc_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - psf_log_printf (psf, " basc : %u\n", dword) ; + psf_log_printf (psf, " basc : %u\n", chunk_size) ; - if ((error = aiff_read_basc_chunk (psf, dword))) + if ((error = aiff_read_basc_chunk (psf, chunk_size))) return error ; break ; case MARK_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - psf_log_printf (psf, " %M : %d\n", marker, dword) ; + psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; { unsigned short mark_id, n = 0 ; - unsigned char pstr_len ; unsigned int position ; bytesread = psf_binheader_readf (psf, "E2", &n) ; @@ -770,20 +781,31 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) if (paiff->markstr == NULL) return SFE_MALLOC_FAILED ; - for (n = 0 ; n < mark_count && bytesread < dword ; n++) - { bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &pstr_len) ; + for (n = 0 ; n < mark_count && bytesread < chunk_size ; n++) + { unsigned int pstr_len ; + unsigned char ch ; + + bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &ch) ; psf_log_printf (psf, " Mark ID : %u\n Position : %u\n", mark_id, position) ; - pstr_len += (pstr_len & 1) ? 0 : 1 ; + pstr_len = (ch & 1) ? ch : ch + 1 ; - bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf, pstr_len) ; - psf->u.scbuf [pstr_len] = 0 ; - psf_log_printf (psf, " Name : %s\n", psf->u.scbuf) ; + if (pstr_len < sizeof (ubuf.scbuf) - 1) + { bytesread += psf_binheader_readf (psf, "b", ubuf.scbuf, pstr_len) ; + ubuf.scbuf [pstr_len] = 0 ; + } + else + { unsigned int read_len = pstr_len - (sizeof (ubuf.scbuf) - 1) ; + bytesread += psf_binheader_readf (psf, "bj", ubuf.scbuf, read_len, pstr_len - read_len) ; + ubuf.scbuf [sizeof (ubuf.scbuf) - 1] = 0 ; + } + + psf_log_printf (psf, " Name : %s\n", ubuf.scbuf) ; paiff->markstr [n].markerID = mark_id ; paiff->markstr [n].position = position ; /* - ** TODO if psf->u.scbuf is equal to + ** TODO if ubuf.scbuf is equal to ** either Beg_loop, Beg loop or beg loop and spam ** if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) ** return SFE_MALLOC_FAILED ; @@ -791,7 +813,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) } ; } ; mark_found++ ; - psf_binheader_readf (psf, "j", dword - bytesread) ; + psf_binheader_readf (psf, "j", chunk_size - bytesread) ; break ; case FVER_MARKER : @@ -799,31 +821,40 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) /* Fall through to next case. */ case SFX_MARKER : - psf_binheader_readf (psf, "E4", &dword) ; - pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ; - psf_log_printf (psf, " %M : %d\n", marker, dword) ; - - psf_binheader_readf (psf, "j", dword) ; + psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size) ; break ; case NONE_MARKER : /* Fix for broken AIFC files with incorrect COMM chunk length. */ - psf_binheader_readf (psf, "1", &byte) ; - dword = byte ; - psf_binheader_readf (psf, "j", dword) ; + chunk_size = (chunk_size >> 24) - 3 ; + psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; + break ; + + case CHAN_MARKER : + if (chunk_size < 12) + { psf_log_printf (psf, " %M : %d (should be >= 12)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size) ; + break ; + } + + psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; + + if ((error = aiff_read_chanmap (psf, chunk_size))) + return error ; break ; default : - if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF) - && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF)) - { psf_binheader_readf (psf, "E4", &dword) ; - psf_log_printf (psf, " %M : %d (unknown marker)\n", marker, dword) ; + if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) + && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) + { psf_log_printf (psf, " %M : %d (unknown marker)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", dword) ; + psf_binheader_readf (psf, "j", chunk_size) ; break ; } ; - if ((dword = psf_ftell (psf)) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker %X at position %d. Resyncing.\n", marker, dword - 4) ; + if ((chunk_size = psf_ftell (psf)) & 0x03) + { psf_log_printf (psf, " Unknown chunk marker %X at position %d. Resyncing.\n", marker, chunk_size - 4) ; psf_binheader_readf (psf, "j", -3) ; break ; @@ -836,20 +867,20 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) if ((! psf->sf.seekable) && (found_chunk & HAVE_SSND)) break ; - if (psf_ftell (psf) >= psf->filelength - (2 * SIGNED_SIZEOF (dword))) + if (psf_ftell (psf) >= psf->filelength - (2 * SIGNED_SIZEOF (int32_t))) break ; } ; /* while (1) */ if (instr_found && mark_found) { int j ; - for (j = 0 ; jinstrument->loop_count ; j ++) + for (j = 0 ; j < psf->instrument->loop_count ; j ++) { if (j < ARRAY_LEN (psf->instrument->loops)) { psf->instrument->loops [j].start = marker_to_position (paiff->markstr, psf->instrument->loops [j].start, mark_count) ; psf->instrument->loops [j].end = marker_to_position (paiff->markstr, psf->instrument->loops [j].end, mark_count) ; psf->instrument->loops [j].mode = SF_LOOP_FORWARD ; } ; - } ; + } ; } ; if (! (found_chunk & HAVE_FORM)) @@ -876,7 +907,7 @@ aiff_close (SF_PRIVATE *psf) paiff->markstr = NULL ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { aiff_write_tailer (psf) ; aiff_write_header (psf, SF_TRUE) ; } ; @@ -886,25 +917,22 @@ aiff_close (SF_PRIVATE *psf) static int aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) -{ int error = 0, bytesread, subformat ; +{ BUF_UNION ubuf ; + int subformat, samplerate ; - psf->u.scbuf [0] = 0 ; - - bytesread = psf_binheader_readf (psf, "E4", &(comm_fmt->size)) ; + ubuf.scbuf [0] = 0 ; /* The COMM chunk has an int aligned to an odd word boundary. Some ** procesors are not able to deal with this (ie bus fault) so we have ** to take special care. */ - comm_fmt->size += comm_fmt->size & 1 ; - bytesread += psf_binheader_readf (psf, "E242b", &(comm_fmt->numChannels), &(comm_fmt->numSampleFrames), - &(comm_fmt->sampleSize), &(comm_fmt->sampleRate), SIGNED_SIZEOF (comm_fmt->sampleRate)) ; + &(comm_fmt->sampleSize), &(comm_fmt->sampleRate), SIGNED_SIZEOF (comm_fmt->sampleRate)) ; if (comm_fmt->size > 0x10000 && (comm_fmt->size & 0xffff) == 0) { psf_log_printf (psf, " COMM : %d (0x%x) *** should be ", comm_fmt->size, comm_fmt->size) ; - comm_fmt->size = ENDSWAP_INT (comm_fmt->size) ; + comm_fmt->size = ENDSWAP_32 (comm_fmt->size) ; psf_log_printf (psf, "%d (0x%x)\n", comm_fmt->size, comm_fmt->size) ; } else @@ -913,21 +941,23 @@ aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) if (comm_fmt->size == SIZEOF_AIFF_COMM) comm_fmt->encoding = NONE_MARKER ; else if (comm_fmt->size == SIZEOF_AIFC_COMM_MIN) - bytesread += psf_binheader_readf (psf, "Em", &(comm_fmt->encoding)) ; + psf_binheader_readf (psf, "Em", &(comm_fmt->encoding)) ; else if (comm_fmt->size >= SIZEOF_AIFC_COMM) { unsigned char encoding_len ; unsigned read_len ; - bytesread += psf_binheader_readf (psf, "Em1", &(comm_fmt->encoding), &encoding_len) ; + psf_binheader_readf (psf, "Em1", &(comm_fmt->encoding), &encoding_len) ; - comm_fmt->size = SF_MIN (sizeof (psf->u.scbuf), make_size_t (comm_fmt->size)) ; - memset (psf->u.scbuf, 0, comm_fmt->size) ; + comm_fmt->size = SF_MIN (sizeof (ubuf.scbuf), make_size_t (comm_fmt->size)) ; + memset (ubuf.scbuf, 0, comm_fmt->size) ; read_len = comm_fmt->size - SIZEOF_AIFC_COMM + 1 ; - bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf, read_len) ; - psf->u.scbuf [read_len + 1] = 0 ; + psf_binheader_readf (psf, "b", ubuf.scbuf, read_len) ; + ubuf.scbuf [read_len + 1] = 0 ; } ; - psf_log_printf (psf, " Sample Rate : %d\n", tenbytefloat2int (comm_fmt->sampleRate)) ; + samplerate = tenbytefloat2int (comm_fmt->sampleRate) ; + + psf_log_printf (psf, " Sample Rate : %d\n", samplerate) ; psf_log_printf (psf, " Frames : %u%s\n", comm_fmt->numSampleFrames, (comm_fmt->numSampleFrames == 0 && psf->filelength > 104) ? " (Should not be 0)" : "") ; psf_log_printf (psf, " Channels : %d\n", comm_fmt->numChannels) ; @@ -945,6 +975,11 @@ aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) subformat = s_bitwidth_to_subformat (comm_fmt->sampleSize) ; + psf->sf.samplerate = samplerate ; + psf->sf.frames = comm_fmt->numSampleFrames ; + psf->sf.channels = comm_fmt->numChannels ; + psf->bytewidth = BITWIDTH2BYTES (comm_fmt->sampleSize) ; + psf->endian = SF_ENDIAN_BIG ; switch (comm_fmt->encoding) @@ -1021,74 +1056,68 @@ aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) default : psf_log_printf (psf, "AIFC : Unimplemented format : %M\n", comm_fmt->encoding) ; - error = SFE_UNIMPLEMENTED ; + return SFE_UNIMPLEMENTED ; } ; - if (! psf->u.scbuf [0]) + if (! ubuf.scbuf [0]) psf_log_printf (psf, " Encoding : %M\n", comm_fmt->encoding) ; else - psf_log_printf (psf, " Encoding : %M => %s\n", comm_fmt->encoding, psf->u.scbuf) ; + psf_log_printf (psf, " Encoding : %M => %s\n", comm_fmt->encoding, ubuf.scbuf) ; - return error ; + return 0 ; } /* aiff_read_comm_chunk */ /*========================================================================================== */ -static int -aiff_rewrite_header (SF_PRIVATE *psf, AIFF_PRIVATE * paiff) +static void +aiff_rewrite_header (SF_PRIVATE *psf) { /* Assuming here that the header has already been written and just ** needs to be corrected for new data length. That means that we ** only change the length fields of the FORM and SSND chunks ; ** everything else can be skipped over. */ - int k, ch ; - int comm_size, comm_frames ; + int k, ch, comm_size, comm_frames ; psf_fseek (psf, 0, SEEK_SET) ; psf_fread (psf->header, psf->dataoffset, 1, psf) ; psf->headindex = 0 ; - for (k = 0 ; k < paiff->chunk4.count ; k++) - { switch (paiff->chunk4.l [k].chunk) - { case FORM_MARKER : - psf_binheader_writef (psf, "Etm8", FORM_MARKER, psf->filelength - 8) ; - break ; + /* FORM chunk. */ + psf_binheader_writef (psf, "Etm8", FORM_MARKER, psf->filelength - 8) ; - case COMM_MARKER : - psf->headindex = paiff->chunk4.l [k].offset ; - comm_frames = psf->sf.frames ; - comm_size = paiff->chunk4.l [k].len ; - psf_binheader_writef (psf, "Em42t4", COMM_MARKER, comm_size, psf->sf.channels, comm_frames) ; - break ; + /* COMM chunk. */ + if ((k = psf_find_read_chunk_m32 (&psf->rchunks, COMM_MARKER)) >= 0) + { psf->headindex = psf->rchunks.chunks [k].offset - 8 ; + comm_frames = psf->sf.frames ; + comm_size = psf->rchunks.chunks [k].len ; + psf_binheader_writef (psf, "Em42t4", COMM_MARKER, comm_size, psf->sf.channels, comm_frames) ; + } ; - case SSND_MARKER : - psf->headindex = paiff->chunk4.l [k].offset ; - psf_binheader_writef (psf, "Etm8", SSND_MARKER, psf->datalength + SIZEOF_SSND_CHUNK) ; - break ; + /* PEAK chunk. */ + if ((k = psf_find_read_chunk_m32 (&psf->rchunks, PEAK_MARKER)) >= 0) + { psf->headindex = psf->rchunks.chunks [k].offset - 8 ; + psf_binheader_writef (psf, "Em4", PEAK_MARKER, AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) ; + psf_binheader_writef (psf, "E44", 1, time (NULL)) ; + for (ch = 0 ; ch < psf->sf.channels ; ch++) + psf_binheader_writef (psf, "Eft8", (float) psf->peak_info->peaks [ch].value, psf->peak_info->peaks [ch].position) ; + } ; - case PEAK_MARKER : - psf->headindex = paiff->chunk4.l [k].offset ; - psf_binheader_writef (psf, "Em4", PEAK_MARKER, AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) ; - psf_binheader_writef (psf, "E44", 1, time (NULL)) ; - for (ch = 0 ; ch < psf->sf.channels ; ch++) - psf_binheader_writef (psf, "Eft8", (float) psf->peak_info->peaks [ch].value, psf->peak_info->peaks [ch].position) ; - break ; - default : - /* There are a whole bunch of chunks we should just ignore. */ - break ; - } ; + /* SSND chunk. */ + if ((k = psf_find_read_chunk_m32 (&psf->rchunks, SSND_MARKER)) >= 0) + { psf->headindex = psf->rchunks.chunks [k].offset - 8 ; + psf_binheader_writef (psf, "Etm8", SSND_MARKER, psf->datalength + SIZEOF_SSND_CHUNK) ; } ; /* Header mangling complete so write it out. */ psf_fseek (psf, 0, SEEK_SET) ; psf_fwrite (psf->header, psf->headindex, 1, psf) ; - return 0 ; + return ; } /* aiff_rewrite_header */ static int @@ -1096,7 +1125,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) { sf_count_t current ; AIFF_PRIVATE *paiff ; unsigned char comm_sample_rate [10], comm_zero_bytes [2] = { 0, 0 } ; - unsigned int comm_type, comm_size, comm_encoding, comm_frames = 0 ; + unsigned int comm_type, comm_size, comm_encoding, comm_frames = 0, uk ; int k, endian, has_data = SF_FALSE ; short bit_width ; @@ -1119,11 +1148,11 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; } ; - if (psf->mode == SFM_RDWR && psf->dataoffset > 0 && paiff->chunk4.count > 0) - { int err = aiff_rewrite_header (psf, paiff) ; + if (psf->file.mode == SFM_RDWR && psf->dataoffset > 0 && psf->rchunks.count > 0) + { aiff_rewrite_header (psf) ; if (current > 0) psf_fseek (psf, current, SEEK_SET) ; - return err ; + return 0 ; } ; endian = SF_ENDIAN (psf->sf.format) ; @@ -1134,34 +1163,72 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) bit_width = psf->bytewidth * 8 ; comm_frames = (psf->sf.frames > 0xFFFFFFFF) ? 0xFFFFFFFF : psf->sf.frames ; - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : + switch (SF_CODEC (psf->sf.format) | endian) + { case SF_FORMAT_PCM_S8 | SF_ENDIAN_BIG : + psf->endian = SF_ENDIAN_BIG ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = twos_MARKER ; + break ; + + case SF_FORMAT_PCM_S8 | SF_ENDIAN_LITTLE : + psf->endian = SF_ENDIAN_LITTLE ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = sowt_MARKER ; + break ; + + case SF_FORMAT_PCM_16 | SF_ENDIAN_BIG : + psf->endian = SF_ENDIAN_BIG ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = twos_MARKER ; + break ; + + case SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE : + psf->endian = SF_ENDIAN_LITTLE ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = sowt_MARKER ; + break ; + + case SF_FORMAT_PCM_24 | SF_ENDIAN_BIG : + psf->endian = SF_ENDIAN_BIG ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = in24_MARKER ; + break ; + + case SF_FORMAT_PCM_24 | SF_ENDIAN_LITTLE : + psf->endian = SF_ENDIAN_LITTLE ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = ni24_MARKER ; + break ; + + case SF_FORMAT_PCM_32 | SF_ENDIAN_BIG : + psf->endian = SF_ENDIAN_BIG ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = in32_MARKER ; + break ; + + case SF_FORMAT_PCM_32 | SF_ENDIAN_LITTLE : + psf->endian = SF_ENDIAN_LITTLE ; + comm_type = AIFC_MARKER ; + comm_size = SIZEOF_AIFC_COMM ; + comm_encoding = ni32_MARKER ; + break ; + + case SF_FORMAT_PCM_S8 : /* SF_ENDIAN_FILE */ case SF_FORMAT_PCM_16 : case SF_FORMAT_PCM_24 : case SF_FORMAT_PCM_32 : - switch (endian) - { case SF_ENDIAN_BIG : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = twos_MARKER ; - break ; - - case SF_ENDIAN_LITTLE : - psf->endian = SF_ENDIAN_LITTLE ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = sowt_MARKER ; - break ; - - default : /* SF_ENDIAN_FILE */ - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFF_MARKER ; - comm_size = SIZEOF_AIFF_COMM ; - comm_encoding = 0 ; - break ; - } ; - break ; + psf->endian = SF_ENDIAN_BIG ; + comm_type = AIFF_MARKER ; + comm_size = SIZEOF_AIFF_COMM ; + comm_encoding = 0 ; + break ; case SF_FORMAT_FLOAT : /* Big endian floating point. */ psf->endian = SF_ENDIAN_BIG ; @@ -1278,6 +1345,9 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) if (comm_type == AIFC_MARKER) psf_binheader_writef (psf, "mb", comm_encoding, comm_zero_bytes, sizeof (comm_zero_bytes)) ; + if (psf->channel_map && paiff->chanmap_tag) + psf_binheader_writef (psf, "Em4444", CHAN_MARKER, 12, paiff->chanmap_tag, 0, 0) ; + if (psf->instrument != NULL) { MARK_ID_POS m [4] ; INST_CHUNK ch ; @@ -1337,7 +1407,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) m [3].markerID, m [3].position, 8, "end loop", make_size_t (9)) ; } ; - if (psf->str_flags & SF_STR_LOCATE_START) + if (psf->strings.flags & SF_STR_LOCATE_START) aiff_write_strings (psf, SF_STR_LOCATE_START) ; if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) @@ -1347,6 +1417,10 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "Eft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; + /* Write custom headers. */ + for (uk = 0 ; uk < psf->wchunks.used ; uk++) + psf_binheader_writef (psf, "Em4b", psf->wchunks.chunks [uk].mark32, psf->wchunks.chunks [uk].len, psf->wchunks.chunks [uk].data, make_size_t (psf->wchunks.chunks [uk].len)) ; + /* Write SSND chunk. */ paiff->ssnd_offset = psf->headindex ; psf_binheader_writef (psf, "Etm844", SSND_MARKER, psf->datalength + SIZEOF_SSND_CHUNK, 0, 0) ; @@ -1393,7 +1467,7 @@ aiff_write_tailer (SF_PRIVATE *psf) psf_binheader_writef (psf, "Eft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; - if (psf->str_flags & SF_STR_LOCATE_END) + if (psf->strings.flags & SF_STR_LOCATE_END) aiff_write_strings (psf, SF_STR_LOCATE_END) ; /* Write the tailer. */ @@ -1408,37 +1482,37 @@ aiff_write_strings (SF_PRIVATE *psf, int location) { int k, slen ; for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings [k].type == 0) + { if (psf->strings.data [k].type == 0) break ; - if (psf->strings [k].flags != location) + if (psf->strings.data [k].flags != location) continue ; - switch (psf->strings [k].type) + switch (psf->strings.data [k].type) { case SF_STR_SOFTWARE : - slen = strlen (psf->strings [k].str) ; - psf_binheader_writef (psf, "Em4mb", APPL_MARKER, slen + 4, m3ga_MARKER, psf->strings [k].str, make_size_t (slen + (slen & 1))) ; + slen = strlen (psf->strings.storage + psf->strings.data [k].offset) ; + psf_binheader_writef (psf, "Em4mb", APPL_MARKER, slen + 4, m3ga_MARKER, psf->strings.storage + psf->strings.data [k].offset, make_size_t (slen + (slen & 1))) ; break ; case SF_STR_TITLE : - psf_binheader_writef (psf, "EmS", NAME_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "EmS", NAME_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_COPYRIGHT : - psf_binheader_writef (psf, "EmS", c_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "EmS", c_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_ARTIST : - psf_binheader_writef (psf, "EmS", AUTH_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "EmS", AUTH_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_COMMENT : - psf_binheader_writef (psf, "EmS", ANNO_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "EmS", ANNO_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; /* case SF_STR_DATE : - psf_binheader_writef (psf, "Ems", ICRD_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "Ems", ICRD_MARKER, psf->strings.data [k].str) ; break ; */ } ; @@ -1448,8 +1522,21 @@ aiff_write_strings (SF_PRIVATE *psf, int location) } /* aiff_write_strings */ static int -aiff_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (data), int UNUSED (datasize)) -{ +aiff_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize)) +{ AIFF_PRIVATE *paiff ; + + if ((paiff = psf->container_data) == NULL) + return SFE_INTERNAL ; + + switch (command) + { case SFC_SET_CHANNEL_MAP_INFO : + paiff->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ; + return (paiff->chanmap_tag != 0) ; + + default : + break ; + } ; + return 0 ; } /* aiff_command */ @@ -1610,3 +1697,82 @@ aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize) return 0 ; } /* aiff_read_basc_chunk */ + +static int +aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword) +{ const AIFF_CAF_CHANNEL_MAP * map_info ; + unsigned channel_bitmap, channel_decriptions, bytesread ; + int layout_tag ; + + bytesread = psf_binheader_readf (psf, "444", &layout_tag, &channel_bitmap, &channel_decriptions) ; + + if ((map_info = aiff_caf_of_channel_layout_tag (layout_tag)) == NULL) + return 0 ; + + psf_log_printf (psf, " Tag : %x\n", layout_tag) ; + if (map_info) + psf_log_printf (psf, " Layout : %s\n", map_info->name) ; + + if (bytesread < dword) + psf_binheader_readf (psf, "j", dword - bytesread) ; + + if (map_info->channel_map != NULL) + { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ; + + free (psf->channel_map) ; + + if ((psf->channel_map = malloc (chanmap_size)) == NULL) + return SFE_MALLOC_FAILED ; + + memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ; + } ; + + return 0 ; +} /* aiff_read_chanmap */ + +/*============================================================================== +*/ + +static int +aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) +{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; +} /* aiff_set_chunk */ + +static SF_CHUNK_ITERATOR * +aiff_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) +{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; +} /* aiff_next_chunk_iterator */ + +static int +aiff_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ int indx ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + chunk_info->datalen = psf->rchunks.chunks [indx].len ; + + return SFE_NO_ERROR ; +} /* aiff_get_chunk_size */ + +static int +aiff_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ sf_count_t pos ; + int indx ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + if (chunk_info->data == NULL) + return SFE_BAD_CHUNK_DATA_PTR ; + + chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; + memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; + + pos = psf_ftell (psf) ; + psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; + psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; + psf_fseek (psf, pos, SEEK_SET) ; + + return SFE_NO_ERROR ; +} /* aiff_get_chunk_data */ diff --git a/libs/libsndfile/src/alac.c b/libs/libsndfile/src/alac.c new file mode 100644 index 0000000000..747e032769 --- /dev/null +++ b/libs/libsndfile/src/alac.c @@ -0,0 +1,964 @@ +/* +** Copyright (C) 2011-2013 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include +#include + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" +#include "ALAC/alac_codec.h" +#include "ALAC/ALACBitUtilities.h" + +#define ALAC_MAX_FRAME_SIZE 8192 +#define ALAC_BYTE_BUFFER_SIZE 82000 + + +typedef struct +{ uint32_t current, count, allocated ; + uint32_t packet_size [] ; +} PAKT_INFO ; + +typedef struct +{ sf_count_t input_data_pos ; + + PAKT_INFO * pakt_info ; + + int channels, final_write_block ; + + uint32_t frames_this_block, partial_block_frames, frames_per_block ; + uint32_t bits_per_sample, kuki_size ; + + + /* Can't have a decoder and an encoder at the same time so stick + ** them in an un-named union. + */ + union + { ALAC_DECODER decoder ; + ALAC_ENCODER encoder ; + } ; + + char enctmpname [512] ; + FILE *enctmp ; + + int buffer [] ; + +} ALAC_PRIVATE ; + +/*============================================================================================ +*/ + +static int alac_reader_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) ; +static int alac_writer_init (SF_PRIVATE *psf) ; + +static sf_count_t alac_reader_calc_frames (SF_PRIVATE *psf, ALAC_PRIVATE *plac) ; + +static sf_count_t alac_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; +static sf_count_t alac_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; +static sf_count_t alac_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; +static sf_count_t alac_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; + +static sf_count_t alac_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; +static sf_count_t alac_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; +static sf_count_t alac_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; +static sf_count_t alac_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; + +static sf_count_t alac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; + +static int alac_close (SF_PRIVATE *psf) ; +static int alac_byterate (SF_PRIVATE *psf) ; + +static int alac_decode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac) ; +static int alac_encode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac) ; + +static uint32_t alac_kuki_read (SF_PRIVATE * psf, uint32_t kuki_offset, uint8_t * kuki, size_t kuki_maxlen) ; + +static PAKT_INFO * alac_pakt_alloc (uint32_t initial_count) ; +static PAKT_INFO * alac_pakt_read_decode (SF_PRIVATE * psf, uint32_t pakt_offset) ; +static PAKT_INFO * alac_pakt_append (PAKT_INFO * info, uint32_t value) ; +static uint8_t * alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size) ; +static sf_count_t alac_pakt_block_offset (const PAKT_INFO *info, uint32_t block) ; + +/*============================================================================================ +** ALAC Reader initialisation function. +*/ + +int +alac_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) +{ int error ; + + if ((psf->codec_data = calloc (1, sizeof (ALAC_PRIVATE) + psf->sf.channels * sizeof (int) * ALAC_MAX_FRAME_SIZE)) == NULL) + return SFE_MALLOC_FAILED ; + + psf->codec_close = alac_close ; + + switch (psf->file.mode) + { case SFM_RDWR : + return SFE_BAD_MODE_RW ; + + case SFM_READ : + if ((error = alac_reader_init (psf, info))) + return error ; + break ; + + case SFM_WRITE : + if ((error = alac_writer_init (psf))) + return error ; + break ; + + default : + psf_log_printf (psf, "%s : Bad psf->file.mode.\n", __func__) ; + return SFE_INTERNAL ; + } ; + + psf->byterate = alac_byterate ; + + return 0 ; +} /* aiff_alac_init */ + +void +alac_get_desc_chunk_items (int subformat, uint32_t *fmt_flags, uint32_t *frames_per_packet) +{ switch (subformat) + { case SF_FORMAT_ALAC_16 : + *fmt_flags = 1 ; + break ; + case SF_FORMAT_ALAC_20 : + *fmt_flags = 2 ; + break ; + case SF_FORMAT_ALAC_24 : + *fmt_flags = 3 ; + break ; + case SF_FORMAT_ALAC_32 : + *fmt_flags = 4 ; + break ; + default : + break ; + } ; + *frames_per_packet = ALAC_FRAME_LENGTH ; +} /* alac_get_desc_chunk_items */ + +static int +alac_close (SF_PRIVATE *psf) +{ ALAC_PRIVATE *plac ; + BUF_UNION ubuf ; + + plac = psf->codec_data ; + + if (psf->file.mode == SFM_WRITE) + { ALAC_ENCODER *penc = &plac->encoder ; + SF_CHUNK_INFO chunk_info ; + sf_count_t readcount ; + uint32_t pakt_size = 0, saved_partial_block_frames ; +#ifndef _MSC_VER + uint8_t *kuki_data [plac->kuki_size]; +#else + uint8_t *kuki_data = (uint8_t *)_alloca(plac->kuki_size); +#endif + + plac->final_write_block = 1 ; + saved_partial_block_frames = plac->partial_block_frames ; + + /* If a block has been partially assembled, write it out as the final block. */ + if (plac->partial_block_frames && plac->partial_block_frames < plac->frames_per_block) + alac_encode_block (psf, plac) ; + + plac->partial_block_frames = saved_partial_block_frames ; + + alac_get_magic_cookie (penc, kuki_data, &plac->kuki_size) ; + + memset (&chunk_info, 0, sizeof (chunk_info)) ; + chunk_info.id_size = snprintf (chunk_info.id, sizeof (chunk_info.id), "kuki") ; + chunk_info.data = kuki_data ; + chunk_info.datalen = plac->kuki_size ; + psf_save_write_chunk (&psf->wchunks, &chunk_info) ; + + memset (&chunk_info, 0, sizeof (chunk_info)) ; + chunk_info.id_size = snprintf (chunk_info.id, sizeof (chunk_info.id), "pakt") ; + chunk_info.data = alac_pakt_encode (psf, &pakt_size) ; + chunk_info.datalen = pakt_size ; + psf_save_write_chunk (&psf->wchunks, &chunk_info) ; + + free (chunk_info.data) ; + chunk_info.data = NULL ; + + psf->write_header (psf, 1) ; + + if (plac->enctmp != NULL) + { fseek (plac->enctmp, 0, SEEK_SET) ; + + while ((readcount = fread (ubuf.ucbuf, 1, sizeof (ubuf.ucbuf), plac->enctmp)) > 0) + psf_fwrite (ubuf.ucbuf, 1, readcount, psf) ; + fclose (plac->enctmp) ; + remove (plac->enctmpname) ; + } ; + free(kuki_data); + } ; + + if (plac->pakt_info) + free (plac->pakt_info) ; + plac->pakt_info = NULL ; + + return 0 ; +} /* alac_close */ + +static int +alac_byterate (SF_PRIVATE *psf) +{ + if (psf->file.mode == SFM_READ) + return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; + + return -1 ; +} /* alac_byterate */ + +/*============================================================================================ +** ALAC initialisation Functions. +*/ + +static int +alac_reader_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) +{ ALAC_PRIVATE *plac ; + uint32_t kuki_size ; + union { uint8_t kuki [512] ; uint32_t alignment ; } u ; + + if (info == NULL) + { psf_log_printf (psf, "%s : ALAC_DECODER_INFO is NULL.\n", __func__) ; + return SFE_INTERNAL ; + } ; + + plac = psf->codec_data ; + + plac->channels = psf->sf.channels ; + plac->frames_per_block = info->frames_per_packet ; + plac->bits_per_sample = info->bits_per_sample ; + + if (plac->pakt_info != NULL) + free (plac->pakt_info) ; + plac->pakt_info = alac_pakt_read_decode (psf, info->pakt_offset) ; + + + if (plac->pakt_info == NULL) + { psf_log_printf (psf, "%s : alac_pkt_read() returns NULL.\n", __func__) ; + return SFE_MALLOC_FAILED ; + } ; + + /* Read in the ALAC cookie data and pass it to the init function. */ + kuki_size = alac_kuki_read (psf, info->kuki_offset, u.kuki, sizeof (u.kuki)) ; + + alac_decoder_init (&plac->decoder, u.kuki, kuki_size) ; + + switch (info->bits_per_sample) + { case 16 : + case 20 : + case 24 : + case 32 : + psf->read_short = alac_read_s ; + psf->read_int = alac_read_i ; + psf->read_float = alac_read_f ; + psf->read_double = alac_read_d ; + break ; + + default : + printf ("%s : info->bits_per_sample %u\n", __func__, info->bits_per_sample) ; + return SFE_UNSUPPORTED_ENCODING ; + } ; + + psf->codec_close = alac_close ; + psf->seek = alac_seek ; + + psf->sf.frames = alac_reader_calc_frames (psf, plac) ; + alac_seek (psf, SFM_READ, 0) ; + + return 0 ; +} /* alac_reader_init */ + +static int +alac_writer_init (SF_PRIVATE *psf) +{ ALAC_PRIVATE *plac ; + uint32_t alac_format_flags = 0 ; + + plac = psf->codec_data ; + + if (psf->file.mode != SFM_WRITE) + return SFE_BAD_MODE_RW ; + + plac->channels = psf->sf.channels ; + plac->kuki_size = alac_get_magic_cookie_size (psf->sf.channels) ; + + psf->write_short = alac_write_s ; + psf->write_int = alac_write_i ; + psf->write_float = alac_write_f ; + psf->write_double = alac_write_d ; + + switch (SF_CODEC (psf->sf.format)) + { case SF_FORMAT_ALAC_16 : + alac_format_flags = 1 ; + plac->bits_per_sample = 16 ; + break ; + + case SF_FORMAT_ALAC_20 : + alac_format_flags = 2 ; + plac->bits_per_sample = 20 ; + break ; + + case SF_FORMAT_ALAC_24 : + alac_format_flags = 3 ; + plac->bits_per_sample = 24 ; + break ; + + case SF_FORMAT_ALAC_32 : + alac_format_flags = 4 ; + plac->bits_per_sample = 32 ; + break ; + + default : + psf_log_printf (psf, "%s : Can't figure out bits per sample.\n", __func__) ; + return SFE_UNIMPLEMENTED ; + } ; + + plac->frames_per_block = ALAC_FRAME_LENGTH ; + + plac->pakt_info = alac_pakt_alloc (2000) ; + + if ((plac->enctmp = psf_open_tmpfile (plac->enctmpname, sizeof (plac->enctmpname))) == NULL) + { psf_log_printf (psf, "Error : Failed to open temp file '%s' : \n", plac->enctmpname, strerror (errno)) ; + return SFE_ALAC_FAIL_TMPFILE ; + } ; + + alac_encoder_init (&plac->encoder, psf->sf.samplerate, psf->sf.channels, alac_format_flags, ALAC_FRAME_LENGTH) ; + + return 0 ; +} /* alac_writer_init */ + +/*============================================================================================ +** ALAC block decoder and encoder. +*/ + +static inline uint32_t +alac_reader_next_packet_size (PAKT_INFO * info) +{ if (info->current >= info->count) + return 0 ; + return info->packet_size [info->current++] ; +} /* alac_reader_next_packet_size */ + +static sf_count_t +alac_reader_calc_frames (SF_PRIVATE *psf, ALAC_PRIVATE *plac) +{ sf_count_t frames = 0 ; + uint32_t current_pos = 1, blocks = 0 ; + + plac->pakt_info->current = 0 ; + + while (current_pos < psf->filelength && current_pos > 0) + { current_pos = alac_reader_next_packet_size (plac->pakt_info) ; + blocks = current_pos > 0 ? blocks + 1 : blocks ; + } ; + + if (blocks == 0) + return 0 ; + + /* Only count full blocks. */ + frames = plac->frames_per_block * (blocks - 1) ; + + alac_seek (psf, SFM_READ, frames) ; + alac_decode_block (psf, plac) ; + frames += plac->frames_this_block ; + + plac->pakt_info->current = 0 ; + + return frames ; +} /* alac_reader_calc_frames */ + +static int +alac_decode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac) +{ ALAC_DECODER *pdec = &plac->decoder ; + uint8_t byte_buffer [ALAC_BYTE_BUFFER_SIZE] ; + uint32_t packet_size ; + BitBuffer bit_buffer ; + + packet_size = alac_reader_next_packet_size (plac->pakt_info) ; + if (packet_size == 0) + { if (plac->pakt_info->current < plac->pakt_info->count) + psf_log_printf (psf, "packet_size is 0 (%d of %d)\n", plac->pakt_info->current, plac->pakt_info->count) ; + return 0 ; + } ; + + psf_fseek (psf, plac->input_data_pos, SEEK_SET) ; + + if (packet_size > SIGNED_SIZEOF (byte_buffer)) + { psf_log_printf (psf, "%s : bad packet_size (%u)\n", __func__, packet_size) ; + return 0 ; + } ; + + if ((packet_size != psf_fread (byte_buffer, 1, packet_size, psf))) + return 0 ; + + BitBufferInit (&bit_buffer, byte_buffer, packet_size) ; + + plac->input_data_pos += packet_size ; + plac->frames_this_block = 0 ; + alac_decode (pdec, &bit_buffer, plac->buffer, plac->frames_per_block, psf->sf.channels, &plac->frames_this_block) ; + + plac->partial_block_frames = 0 ; + + return 1 ; +} /* alac_decode_block */ + + +static int +alac_encode_block (SF_PRIVATE * psf, ALAC_PRIVATE *plac) +{ ALAC_ENCODER *penc = &plac->encoder ; + uint32_t num_bytes = 0 ; +#ifndef _MSC_VER + uint8_t byte_buffer [psf->sf.channels * ALAC_BYTE_BUFFER_SIZE] ; +#else + uint8_t* byte_buffer = (uint8_t*)_alloca (psf->sf.channels * ALAC_BYTE_BUFFER_SIZE) ; +#endif + + alac_encode (penc, plac->channels, plac->partial_block_frames, plac->buffer, byte_buffer, &num_bytes) ; + + if (fwrite (byte_buffer, 1, num_bytes, plac->enctmp) != num_bytes) + { + free (byte_buffer); + return 0 ; + } + free(byte_buffer); + + if ((plac->pakt_info = alac_pakt_append (plac->pakt_info, num_bytes)) == NULL) + return 0 ; + + plac->partial_block_frames = 0 ; + + return 1 ; +} /* alac_encode_block */ + +/*============================================================================================ +** ALAC read functions. +*/ + +static sf_count_t +alac_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, readcount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + while (len > 0) + { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) + break ; + + readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; + readcount = readcount > len ? len : readcount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < readcount ; k++) + ptr [total + k] = iptr [k] >> 16 ; + + plac->partial_block_frames += readcount / plac->channels ; + total += readcount ; + len -= readcount ; + } ; + + return total ; +} /* alac_read_s */ + +static sf_count_t +alac_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, readcount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + while (len > 0) + { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) + break ; + + readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; + readcount = readcount > len ? len : readcount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < readcount ; k++) + ptr [total + k] = iptr [k] ; + + plac->partial_block_frames += readcount / plac->channels ; + total += readcount ; + len -= readcount ; + } ; + + return total ; +} /* alac_read_i */ + +static sf_count_t +alac_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, readcount ; + sf_count_t total = 0 ; + float normfact ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; + + while (len > 0) + { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) + break ; + + readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; + readcount = readcount > len ? len : readcount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < readcount ; k++) + ptr [total + k] = normfact * iptr [k] ; + + plac->partial_block_frames += readcount / plac->channels ; + total += readcount ; + len -= readcount ; + } ; + + return total ; +} /* alac_read_f */ + +static sf_count_t +alac_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, readcount ; + sf_count_t total = 0 ; + double normfact ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; + + while (len > 0) + { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) + break ; + + readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; + readcount = readcount > len ? len : readcount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < readcount ; k++) + ptr [total + k] = normfact * iptr [k] ; + + plac->partial_block_frames += readcount / plac->channels ; + total += readcount ; + len -= readcount ; + } ; + + return total ; +} /* alac_read_d */ + +/*============================================================================================ +*/ + +static sf_count_t +alac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) +{ ALAC_PRIVATE *plac ; + int newblock, newsample ; + + if (! psf->codec_data) + return 0 ; + plac = (ALAC_PRIVATE*) psf->codec_data ; + + if (psf->datalength < 0 || psf->dataoffset < 0) + { psf->error = SFE_BAD_SEEK ; + return PSF_SEEK_ERROR ; + } ; + + if (offset == 0) + { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + + plac->frames_this_block = 0 ; + plac->input_data_pos = psf->dataoffset ; + plac->pakt_info->current = 0 ; + return 0 ; + } ; + + if (offset < 0 || offset > plac->pakt_info->count * plac->frames_per_block) + { psf->error = SFE_BAD_SEEK ; + return PSF_SEEK_ERROR ; + } ; + + newblock = offset / plac->frames_per_block ; + newsample = offset % plac->frames_per_block ; + + if (mode == SFM_READ) + { plac->input_data_pos = psf->dataoffset + alac_pakt_block_offset (plac->pakt_info, newblock) ; + + plac->pakt_info->current = newblock ; + alac_decode_block (psf, plac) ; + plac->partial_block_frames = newsample ; + } + else + { /* What to do about write??? */ + psf->error = SFE_BAD_SEEK ; + return PSF_SEEK_ERROR ; + } ; + + return newblock * plac->frames_per_block + newsample ; +} /* alac_seek */ + +/*========================================================================================== +** ALAC Write Functions. +*/ + +static sf_count_t +alac_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, writecount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + while (len > 0) + { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; + writecount = (writecount == 0 || writecount > len) ? len : writecount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < writecount ; k++) + iptr [k] = ptr [total + k] << 16 ; + + plac->partial_block_frames += writecount / plac->channels ; + total += writecount ; + len -= writecount ; + + if (plac->partial_block_frames >= plac->frames_per_block) + alac_encode_block (psf, plac) ; + } ; + + return total ; +} /* alac_write_s */ + +static sf_count_t +alac_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + int *iptr ; + int k, writecount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + while (len > 0) + { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; + writecount = (writecount == 0 || writecount > len) ? len : writecount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + for (k = 0 ; k < writecount ; k++) + iptr [k] = ptr [total + k] ; + + plac->partial_block_frames += writecount / plac->channels ; + total += writecount ; + len -= writecount ; + + if (plac->partial_block_frames >= plac->frames_per_block) + alac_encode_block (psf, plac) ; + } ; + + return total ; +} /* alac_write_i */ + +static sf_count_t +alac_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + void (*convert) (const float *, int *t, int, int) ; + int *iptr ; + int writecount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + convert = (psf->add_clipping) ? psf_f2i_clip_array : psf_f2i_array ; + + while (len > 0) + { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; + writecount = (writecount == 0 || writecount > len) ? len : writecount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + convert (ptr, iptr, writecount, psf->norm_float) ; + + plac->partial_block_frames += writecount / plac->channels ; + total += writecount ; + len -= writecount ; + + if (plac->partial_block_frames >= plac->frames_per_block) + alac_encode_block (psf, plac) ; + } ; + + return total ; +} /* alac_write_f */ + +static sf_count_t +alac_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) +{ ALAC_PRIVATE *plac ; + void (*convert) (const double *, int *t, int, int) ; + int *iptr ; + int writecount ; + sf_count_t total = 0 ; + + if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) + return 0 ; + + convert = (psf->add_clipping) ? psf_d2i_clip_array : psf_d2i_array ; + + while (len > 0) + { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; + writecount = (writecount == 0 || writecount > len) ? len : writecount ; + + iptr = plac->buffer + plac->partial_block_frames * plac->channels ; + + convert (ptr, iptr, writecount, psf->norm_float) ; + + plac->partial_block_frames += writecount / plac->channels ; + total += writecount ; + len -= writecount ; + + if (plac->partial_block_frames >= plac->frames_per_block) + alac_encode_block (psf, plac) ; + } ; + + return total ; +} /* alac_write_d */ + +/*============================================================================== +** PAKT_INFO handling. +*/ + +static PAKT_INFO * +alac_pakt_alloc (uint32_t initial_count) +{ PAKT_INFO * info ; + + if ((info = calloc (1, sizeof (PAKT_INFO) + initial_count * sizeof (info->packet_size [0]))) == NULL) + return NULL ; + + info->allocated = initial_count ; + info->current = 0 ; + info->count = 0 ; + + return info ; +} /* alac_pakt_alloc */ + +static PAKT_INFO * +alac_pakt_append (PAKT_INFO * info, uint32_t value) +{ + if (info->count >= info->allocated) + { PAKT_INFO * temp ; + uint32_t newcount = info->allocated + info->allocated / 2 ; + + if ((temp = realloc (info, sizeof (PAKT_INFO) + newcount * sizeof (info->packet_size [0]))) == NULL) + return NULL ; + + info = temp ; + info->allocated = newcount ; + } ; + + info->packet_size [info->count++] = value ; + return info ; +} /* alac_pakt_append */ + +static PAKT_INFO * +alac_pakt_read_decode (SF_PRIVATE * psf, uint32_t UNUSED (pakt_offset)) +{ SF_CHUNK_INFO chunk_info ; + PAKT_INFO * info = NULL ; + uint8_t *pakt_data = NULL ; + uint32_t bcount, value = 1, pakt_size ; + SF_CHUNK_ITERATOR * chunk_iterator ; + + + memset (&chunk_info, 0, sizeof (chunk_info)) ; + snprintf (chunk_info.id, sizeof (chunk_info.id), "pakt") ; + chunk_info.id_size = 4 ; + + if ((chunk_iterator = psf_get_chunk_iterator (psf, chunk_info.id)) == NULL) + { printf ("%s %d : no chunk iterator found\n\n", __func__, __LINE__) ; + free (chunk_info.data) ; + chunk_info.data = NULL ; + return NULL ; + } ; + + psf->get_chunk_size (psf, chunk_iterator, &chunk_info) ; + + pakt_size = chunk_info.datalen ; + chunk_info.data = pakt_data = malloc (pakt_size + 5) ; + + if ((bcount = psf->get_chunk_data (psf, chunk_iterator, &chunk_info)) != SF_ERR_NO_ERROR) + { printf ("%s %d : %s\n\n", __func__, __LINE__, sf_error_number (bcount)) ; + while (chunk_iterator) + chunk_iterator = psf->next_chunk_iterator (psf, chunk_iterator) ; + free (chunk_info.data) ; + chunk_info.data = NULL ; + return NULL ; + } ; + + while (chunk_iterator) + chunk_iterator = psf->next_chunk_iterator (psf, chunk_iterator) ; + + info = alac_pakt_alloc (pakt_size / 4) ; + + /* Start at 24 bytes in, skipping over the 'pakt' chunks header. */ + for (bcount = 24 ; bcount < pakt_size && value != 0 ; ) + { uint8_t byte ; + int32_t count = 0 ; + + value = 0 ; + do + { byte = pakt_data [bcount + count] ; + value = (value << 7) + (byte & 0x7F) ; + + count ++ ; + if (count > 5 || bcount + count > pakt_size) + { printf ("%s %d : Ooops! count %d bcount %d\n", __func__, __LINE__, count, bcount) ; + value = 0 ; + break ; + } ; + } + while (byte & 0x80) ; + + bcount += count ; + + if ((info = alac_pakt_append (info, value)) == NULL) + goto FreeExit ; + } ; + + free (pakt_data) ; + + return info ; + +FreeExit : + free (pakt_data) ; + free (info) ; + return NULL ; +} /* alac_pakt_read_decode */ + +static uint8_t * +alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size_out) +{ const ALAC_PRIVATE *plac ; + const PAKT_INFO *info ; + uint8_t *data ; + uint32_t k, allocated, pakt_size ; + + plac = psf->codec_data ; + info = plac->pakt_info ; + + allocated = 100 + 2 * info->count ; + if ((data = calloc (1, allocated)) == NULL) + return NULL ; + + psf_put_be64 (data, 0, info->count) ; + psf_put_be64 (data, 8, psf->sf.frames) ; + psf_put_be32 (data, 20, kALACDefaultFramesPerPacket - plac->partial_block_frames) ; + + /* Real 'pakt' data starts after 24 byte header. */ + pakt_size = 24 ; + + for (k = 0 ; k < info->count ; k++) + { int32_t value = info->packet_size [k] ; + + if ((value & 0x7f) == value) + { data [pakt_size++] = value ; + continue ; + } ; + + if ((value & 0x3fff) == value) + { data [pakt_size++] = (value >> 7) | 0x80 ; + data [pakt_size++] = value & 0x7f ; + continue ; + } ; + + if ((value & 0x1fffff) == value) + { data [pakt_size++] = (value >> 14) | 0x80 ; + data [pakt_size++] = ((value >> 7) & 0x7f) | 0x80 ; + data [pakt_size++] = value & 0x7f ; + continue ; + } ; + + if ((value & 0x0fffffff) == value) + { data [pakt_size++] = (value >> 21) | 0x80 ; + data [pakt_size++] = ((value >> 14) & 0x7f) | 0x80 ; + data [pakt_size++] = ((value >> 7) & 0x7f) | 0x80 ; + data [pakt_size++] = value & 0x7f ; + continue ; + } ; + + *pakt_size_out = 0 ; + free (data) ; + return NULL ; + } ; + + *pakt_size_out = pakt_size ; + return data ; +} /* alac_pakt_encode */ + +static sf_count_t +alac_pakt_block_offset (const PAKT_INFO *info, uint32_t block) +{ sf_count_t offset = 0 ; + uint32_t k ; + + for (k = 0 ; k < block ; k++) + offset += info->packet_size [k] ; + + return offset ; +} /* alac_pakt_block_offset */ + +static uint32_t +alac_kuki_read (SF_PRIVATE * psf, uint32_t kuki_offset, uint8_t * kuki, size_t kuki_maxlen) +{ uint32_t marker ; + uint64_t kuki_size ; + + if (psf_fseek (psf, kuki_offset, SEEK_SET) != kuki_offset) + return 0 ; + + psf_fread (&marker, 1, sizeof (marker), psf) ; + if (marker != MAKE_MARKER ('k', 'u', 'k', 'i')) + return 0 ; + + psf_fread (&kuki_size, 1, sizeof (kuki_size), psf) ; + kuki_size = BE2H_64 (kuki_size) ; + + if (kuki_size == 0 || kuki_size > kuki_maxlen) + { psf_log_printf (psf, "%s : Bad size (%D) of 'kuki' chunk.\n", __func__, kuki_size) ; + return 0 ; + } ; + + psf_fread (kuki, 1, kuki_size, psf) ; + + return kuki_size ; +} /* alac_kuki_read */ diff --git a/libs/libsndfile/src/alaw.c b/libs/libsndfile/src/alaw.c index 900054aae5..81d7696863 100644 --- a/libs/libsndfile/src/alaw.c +++ b/libs/libsndfile/src/alaw.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -47,14 +47,14 @@ static void d2alaw_array (const double *buffer, int count, unsigned char *ptr, d int alaw_init (SF_PRIVATE *psf) { - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { psf->read_short = alaw_read_alaw2s ; psf->read_int = alaw_read_alaw2i ; psf->read_float = alaw_read_alaw2f ; psf->read_double = alaw_read_alaw2d ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { psf->write_short = alaw_write_s2alaw ; psf->write_int = alaw_write_i2alaw ; psf->write_float = alaw_write_f2alaw ; @@ -69,7 +69,7 @@ alaw_init (SF_PRIVATE *psf) else psf->datalength = 0 ; - psf->sf.frames = psf->datalength / psf->blockwidth ; + psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; return 0 ; } /* alaw_init */ @@ -286,7 +286,7 @@ unsigned char alaw_encode [2048 + 1] = 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa } ; /* alaw_encode */ static inline void @@ -358,16 +358,17 @@ d2alaw_array (const double *ptr, int count, unsigned char *buffer, double normfa static sf_count_t alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - alaw2s_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + alaw2s_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -379,16 +380,17 @@ alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - alaw2i_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + alaw2i_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -400,19 +402,20 @@ alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - alaw2f_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + alaw2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -424,18 +427,19 @@ alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - alaw2d_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + alaw2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -450,16 +454,17 @@ alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2alaw_array (ptr + total, bufferlen, psf->u.ucbuf) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + s2alaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -471,16 +476,17 @@ alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2alaw_array (ptr + total, bufferlen, psf->u.ucbuf) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + i2alaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -492,19 +498,20 @@ alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2alaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + f2alaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -516,19 +523,20 @@ alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t alaw_write_d2alaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2alaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + d2alaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; diff --git a/libs/libsndfile/src/au.c b/libs/libsndfile/src/au.c index cdc1c203d5..bcd869a70a 100644 --- a/libs/libsndfile/src/au.c +++ b/libs/libsndfile/src/au.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -81,8 +81,8 @@ typedef struct { int dataoffset ; int datasize ; int encoding ; - int samplerate ; - int channels ; + int samplerate ; + int channels ; } AU_FMT ; @@ -106,7 +106,7 @@ au_open (SF_PRIVATE *psf) { int subformat ; int error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = au_read_header (psf))) return error ; } ; @@ -116,7 +116,7 @@ au_open (SF_PRIVATE *psf) subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { psf->endian = SF_ENDIAN (psf->sf.format) ; if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU) psf->endian = SF_ENDIAN_LITTLE ; @@ -189,7 +189,7 @@ au_open (SF_PRIVATE *psf) static int au_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) au_write_header (psf, SF_TRUE) ; return 0 ; @@ -211,8 +211,6 @@ au_write_header (SF_PRIVATE *psf, int calc_length) psf->datalength = psf->filelength - psf->dataoffset ; if (psf->dataend) psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; } ; encoding = au_format_to_encoding (SF_CODEC (psf->sf.format)) ; diff --git a/libs/libsndfile/src/audio_detect.c b/libs/libsndfile/src/audio_detect.c index 9e73bc5d0e..9cac83bcff 100644 --- a/libs/libsndfile/src/audio_detect.c +++ b/libs/libsndfile/src/audio_detect.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -60,7 +60,7 @@ audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, in " be_int_24_32 : %d\n", vote.le_float, vote.be_float, vote.le_int_24_32, vote.be_int_24_32) ; - if (0) puts (psf->logbuffer) ; + if (0) puts (psf->parselog.buf) ; if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_float > (3 * datalen) / 4) { /* Almost certainly 32 bit floats. */ diff --git a/libs/libsndfile/src/avr.c b/libs/libsndfile/src/avr.c index 33288af5ce..a235b0d7a4 100644 --- a/libs/libsndfile/src/avr.c +++ b/libs/libsndfile/src/avr.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2004-2009 Erik de Castro Lopo +** Copyright (C) 2004-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -80,7 +80,7 @@ int avr_open (SF_PRIVATE *psf) { int error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = avr_read_header (psf))) return error ; } ; @@ -88,9 +88,8 @@ avr_open (SF_PRIVATE *psf) if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AVR) return SFE_BAD_OPEN_FORMAT ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) - { psf->endian = SF_ENDIAN (psf->sf.format) ; - psf->endian = SF_ENDIAN_BIG ; + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) + { psf->endian = SF_ENDIAN_BIG ; if (avr_write_header (psf, SF_FALSE)) return psf->error ; @@ -239,7 +238,7 @@ avr_write_header (SF_PRIVATE *psf, int calc_length) static int avr_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) avr_write_header (psf, SF_TRUE) ; return 0 ; diff --git a/libs/libsndfile/src/binheader_writef_check.py b/libs/libsndfile/src/binheader_writef_check.py index 3c5d1c8423..6ee609e010 100644 --- a/libs/libsndfile/src/binheader_writef_check.py +++ b/libs/libsndfile/src/binheader_writef_check.py @@ -1,6 +1,6 @@ -#!/usr/bin/python2.5 +#!/usr/bin/python -# Copyright (C) 2006 Erik de Castro Lopo +# Copyright (C) 2006-2011 Erik de Castro Lopo # # All rights reserved. # @@ -48,19 +48,19 @@ def find_binheader_writefs (data): def find_format_string (s): fmt = re.search ('"([^"]+)"', s) if not fmt: - print "Bad format in :\n\n\t%s\n\n" % s + print ("Bad format in :\n\n\t%s\n\n" % s) sys.exit (1) fmt = fmt.groups () if len (fmt) != 1: - print "Bad format in :\n\n\t%s\n\n" % s + print ("Bad format in :\n\n\t%s\n\n" % s) sys.exit (1) return _whitespace_re.sub ("", fmt [0]) def get_param_list (data): dlist = re.search ("\((.+)\)\s*;", data) dlist = dlist.groups ()[0] - dlist = string.split (dlist, ",") - dlist = [string.strip (x) for x in dlist] + dlist = dlist.split(",") + dlist = [x.strip() for x in dlist] return dlist [2:] def handle_file (fname): @@ -88,29 +88,30 @@ def handle_file (fname): # print item # print " param [%d] %c : %s <-> %s" % (param_index, ch, params [param_index], params [param_index + 1]) - if string.find (params [param_index + 1], "sizeof") < 0 \ - and string.find (params [param_index + 1], "make_size_t") < 0 \ - and string.find (params [param_index + 1], "strlen") < 0: - if errors == 0: print - print "\n%s :" % fname - print " param [%d] %c : %s <-> %s" % (param_index, ch, params [param_index], params [param_index + 1]) - print " %s" % item + # print (params [param_index + 1]) + if params [param_index + 1].find ("sizeof") < 0 \ + and params [param_index + 1].find ("make_size_t") < 0 \ + and params [param_index + 1].find ("strlen") < 0: + if errors == 0: sys.stdout.write ("\n") + print ("\n%s :" % fname) + print (" param [%d] %c : %s <-> %s" % (param_index, ch, params [param_index], params [param_index + 1])) + print (" %s" % item) errors += 1 param_index += 2 - + return errors #=============================================================================== if len (sys.argv) > 1: - print "%s\n binheader_writef_check :" % sys.argv [0], + sys.stdout.write ("\n binheader_writef_check :") sys.stdout.flush () errors = 0 for fname in sys.argv [1:]: errors += handle_file (fname) if errors > 0: - print "\nErrors : %d\n" % errors + print ("\nErrors : %d\n" % errors) sys.exit (1) -print "ok" +print ("ok\n") diff --git a/libs/libsndfile/src/broadcast.c b/libs/libsndfile/src/broadcast.c index 8654452dab..128a6a2c55 100644 --- a/libs/libsndfile/src/broadcast.c +++ b/libs/libsndfile/src/broadcast.c @@ -1,6 +1,6 @@ /* +** Copyright (C) 2006-2013 Erik de Castro Lopo ** Copyright (C) 2006 Paul Davis -** Copyright (C) 2006-2009 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -17,13 +17,15 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "sfconfig.h" + #include #include #include #include "common.h" -static void strncpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) ; + static int gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo) ; static inline size_t @@ -32,29 +34,16 @@ bc_min_size (const SF_BROADCAST_INFO* info) return 0 ; return offsetof (SF_BROADCAST_INFO, coding_history) + info->coding_history_size ; -} /* broadcast_size */ +} /* bc_min_size */ - -static inline size_t -bc_var_coding_hist_size (const SF_BROADCAST_VAR* var) -{ return var->size - offsetof (SF_BROADCAST_VAR, binfo.coding_history) ; -} /* broadcast_size */ - -SF_BROADCAST_VAR* -broadcast_var_alloc (size_t datasize) -{ SF_BROADCAST_VAR * data ; - - if ((data = calloc (1, datasize)) != NULL) - data->size = datasize ; - - return data ; +SF_BROADCAST_INFO_16K* +broadcast_var_alloc (void) +{ return calloc (1, sizeof (SF_BROADCAST_INFO_16K)) ; } /* broadcast_var_alloc */ - int broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize) -{ char added_history [256] ; - int added_history_len, len ; +{ size_t len ; if (info == NULL) return SF_FALSE ; @@ -64,42 +53,41 @@ broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datas return SF_FALSE ; } ; - added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ; + if (datasize >= sizeof (SF_BROADCAST_INFO_16K)) + { psf->error = SFE_BAD_BROADCAST_INFO_TOO_BIG ; + return SF_FALSE ; + } ; - if (psf->broadcast_var != NULL) - { size_t coding_hist_offset = offsetof (SF_BROADCAST_INFO, coding_history) ; - - if (psf->broadcast_var->binfo.coding_history_size + added_history_len < datasize - coding_hist_offset) - { free (psf->broadcast_var) ; - psf->broadcast_var = NULL ; + if (psf->broadcast_16k == NULL) + { if ((psf->broadcast_16k = broadcast_var_alloc ()) == NULL) + { psf->error = SFE_MALLOC_FAILED ; + return SF_FALSE ; } ; } ; - if (psf->broadcast_var == NULL) - { int size = datasize + added_history_len + 512 ; + /* Only copy the first part of the struct. */ + memcpy (psf->broadcast_16k, info, offsetof (SF_BROADCAST_INFO, coding_history)) ; - psf->broadcast_var = calloc (1, size) ; - psf->broadcast_var->size = size ; + psf_strlcpy_crlf (psf->broadcast_16k->coding_history, info->coding_history, sizeof (psf->broadcast_16k->coding_history), datasize - offsetof (SF_BROADCAST_INFO, coding_history)) ; + len = strlen (psf->broadcast_16k->coding_history) ; + + if (len > 0 && psf->broadcast_16k->coding_history [len - 1] != '\n') + psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), "\r\n") ; + + if (psf->file.mode == SFM_WRITE) + { char added_history [256] ; + + gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ; + psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), added_history) ; } ; - memcpy (&(psf->broadcast_var->binfo), info, offsetof (SF_BROADCAST_INFO, coding_history)) ; - - strncpy_crlf (psf->broadcast_var->binfo.coding_history, info->coding_history, bc_var_coding_hist_size (psf->broadcast_var), info->coding_history_size) ; - len = strlen (psf->broadcast_var->binfo.coding_history) ; - - if (len > 0 && psf->broadcast_var->binfo.coding_history [len] != '\n') - strncat (psf->broadcast_var->binfo.coding_history, "\r\n", 2) ; - - if (psf->mode == SFM_WRITE) - strncat (psf->broadcast_var->binfo.coding_history, added_history, strlen (added_history)) ; - - psf->broadcast_var->binfo.coding_history_size = strlen (psf->broadcast_var->binfo.coding_history) ; - - /* Fore coding_history_size to be even. */ - psf->broadcast_var->binfo.coding_history_size += (psf->broadcast_var->binfo.coding_history_size & 1) ? 1 : 0 ; + /* Force coding_history_size to be even. */ + len = strlen (psf->broadcast_16k->coding_history) ; + len += (len & 1) ? 1 : 0 ; + psf->broadcast_16k->coding_history_size = len ; /* Currently writing this version. */ - psf->broadcast_var->binfo.version = 1 ; + psf->broadcast_16k->version = 1 ; return SF_TRUE ; } /* broadcast_var_set */ @@ -109,54 +97,19 @@ int broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize) { size_t size ; - if (psf->broadcast_var == NULL) + if (psf->broadcast_16k == NULL) return SF_FALSE ; - size = SF_MIN (datasize, bc_min_size (&(psf->broadcast_var->binfo))) ; + size = SF_MIN (datasize, bc_min_size ((const SF_BROADCAST_INFO *) psf->broadcast_16k)) ; - memcpy (data, &(psf->broadcast_var->binfo), size) ; + memcpy (data, psf->broadcast_16k, size) ; return SF_TRUE ; -} /* broadcast_var_set */ +} /* broadcast_var_get */ /*------------------------------------------------------------------------------ -** Strncpy which converts all line endings to CR/LF. */ -static void -strncpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) -{ char * destend = dest + destmax - 1 ; - const char * srcend = src + srcmax ; - - while (dest < destend && src < srcend) - { if ((src [0] == '\r' && src [1] == '\n') || (src [0] == '\n' && src [1] == '\r')) - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 2 ; - continue ; - } ; - - if (src [0] == '\r') - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 1 ; - continue ; - } ; - - if (src [0] == '\n') - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 1 ; - continue ; - } ; - - *dest++ = *src++ ; - } ; - - /* Make sure dest is terminated. */ - *dest = 0 ; -} /* strncpy_crlf */ - static int gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo) { char chnstr [16] ; @@ -168,16 +121,16 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO * ** Parameter Variable string Unit ** ========================================================================================== ** Coding Algorithm A= + ** MPEG2L1, MPEG2L2, MPEG2L3> ** Sampling frequency F=<11000,22050,24000,32000,44100,48000> [Hz] ** Bit-rate B= + ** 13818-3)> ** Word Length W=<8, 12, 14, 16, 18, 20, 22, 24> [bits] ** Mode M= ** Text, free string T= + ** This string should contain no commas (ASCII + ** 2Chex). Examples of the contents: ID-No; codec + ** type; A/D type> */ switch (psfinfo->channels) @@ -185,11 +138,11 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO * return SF_FALSE ; case 1 : - strncpy (chnstr, "mono", sizeof (chnstr)) ; + psf_strlcpy (chnstr, sizeof (chnstr), "mono") ; break ; case 2 : - strncpy (chnstr, "stereo", sizeof (chnstr)) ; + psf_strlcpy (chnstr, sizeof (chnstr), "stereo") ; break ; default : @@ -227,7 +180,7 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO * } ; count = snprintf (added_history, added_history_max, - "A=PCM,F=%u,W=%hu,M=%s,T=%s-%s\r\n", + "A=PCM,F=%u,W=%d,M=%s,T=%s-%s\r\n", psfinfo->samplerate, width, chnstr, PACKAGE, VERSION) ; if (count >= added_history_max) diff --git a/libs/libsndfile/src/caf.c b/libs/libsndfile/src/caf.c index 93d8e9a2ee..8f95d781eb 100644 --- a/libs/libsndfile/src/caf.c +++ b/libs/libsndfile/src/caf.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -23,10 +23,14 @@ #include #include #include +#ifdef HAVE_INTTYPES_H +#include +#endif #include "sndfile.h" #include "sfendian.h" #include "common.h" +#include "chanmap.h" /*------------------------------------------------------------------------------ ** Macros to handle big/little endian issues. @@ -73,15 +77,21 @@ */ typedef struct -{ unsigned char srate [8] ; - unsigned int fmt_id ; - unsigned int fmt_flags ; - unsigned int pkt_bytes ; - unsigned int pkt_frames ; - unsigned int channels_per_frame ; - unsigned int bits_per_chan ; +{ uint8_t srate [8] ; + uint32_t fmt_id ; + uint32_t fmt_flags ; + uint32_t pkt_bytes ; + uint32_t frames_per_packet ; + uint32_t channels_per_frame ; + uint32_t bits_per_chan ; } DESC_CHUNK ; +typedef struct +{ int chanmap_tag ; + + ALAC_DECODER_INFO alac ; +} CAF_PRIVATE ; + /*------------------------------------------------------------------------------ ** Private static functions. */ @@ -89,6 +99,13 @@ typedef struct static int caf_close (SF_PRIVATE *psf) ; static int caf_read_header (SF_PRIVATE *psf) ; static int caf_write_header (SF_PRIVATE *psf, int calc_length) ; +static int caf_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; +static int caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size) ; + +static int caf_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; +static SF_CHUNK_ITERATOR * caf_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; +static int caf_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; +static int caf_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; /*------------------------------------------------------------------------------ ** Public function. @@ -96,16 +113,26 @@ static int caf_write_header (SF_PRIVATE *psf, int calc_length) ; int caf_open (SF_PRIVATE *psf) -{ int subformat, format, error = 0 ; +{ CAF_PRIVATE * pcaf ; + int subformat, format, error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if ((psf->container_data = calloc (1, sizeof (CAF_PRIVATE))) == NULL) + return SFE_MALLOC_FAILED ; + + pcaf = psf->container_data ; + + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = caf_read_header (psf))) return error ; + + psf->next_chunk_iterator = caf_next_chunk_iterator ; + psf->get_chunk_size = caf_get_chunk_size ; + psf->get_chunk_data = caf_get_chunk_data ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -115,20 +142,20 @@ caf_open (SF_PRIVATE *psf) psf->blockwidth = psf->bytewidth * psf->sf.channels ; - if (psf->mode != SFM_RDWR || psf->filelength < 44) + if (psf->file.mode != SFM_RDWR || psf->filelength < 44) { psf->filelength = 0 ; psf->datalength = 0 ; psf->dataoffset = 0 ; psf->sf.frames = 0 ; } ; - psf->str_flags = SF_STR_ALLOW_START ; + psf->strings.flags = SF_STR_ALLOW_START ; /* ** By default, add the peak chunk to floating point files. Default behaviour ** can be switched off using sf_command (SFC_SET_PEAK_CHUNK, SF_FALSE). */ - if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) + if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) return SFE_MALLOC_FAILED ; psf->peak_info->peak_loc = SF_PEAK_START ; @@ -137,11 +164,12 @@ caf_open (SF_PRIVATE *psf) if ((error = caf_write_header (psf, SF_FALSE)) != 0) return error ; - psf->write_header = caf_write_header ; + psf->write_header = caf_write_header ; + psf->set_chunk = caf_set_chunk ; } ; psf->container_close = caf_close ; - /*psf->command = caf_command ;*/ + psf->command = caf_command ; switch (subformat) { case SF_FORMAT_PCM_S8 : @@ -167,6 +195,18 @@ caf_open (SF_PRIVATE *psf) case SF_FORMAT_DOUBLE : error = double64_init (psf) ; break ; + + case SF_FORMAT_ALAC_16 : + case SF_FORMAT_ALAC_20 : + case SF_FORMAT_ALAC_24 : + case SF_FORMAT_ALAC_32 : + if (psf->file.mode == SFM_READ) + /* Only pass the ALAC_DECODER_INFO in read mode. */ + error = alac_init (psf, &pcaf->alac) ; + else + error = alac_init (psf, NULL) ; + break ; + /* Lite remove end */ default : @@ -179,22 +219,72 @@ caf_open (SF_PRIVATE *psf) static int caf_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) caf_write_header (psf, SF_TRUE) ; return 0 ; } /* caf_close */ +static int +caf_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize)) +{ CAF_PRIVATE *pcaf ; + + if ((pcaf = psf->container_data) == NULL) + return SFE_INTERNAL ; + + switch (command) + { case SFC_SET_CHANNEL_MAP_INFO : + pcaf->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ; + return (pcaf->chanmap_tag != 0) ; + + default : + break ; + } ; + + return 0 ; +} /* caf_command */ + /*------------------------------------------------------------------------------ */ static int decode_desc_chunk (SF_PRIVATE *psf, const DESC_CHUNK *desc) -{ int format ; +{ int format = SF_FORMAT_CAF ; psf->sf.channels = desc->channels_per_frame ; - format = SF_FORMAT_CAF | (psf->endian == SF_ENDIAN_LITTLE ? SF_ENDIAN_LITTLE : 0) ; + if (desc->fmt_id == alac_MARKER) + { CAF_PRIVATE *pcaf ; + + if ((pcaf = psf->container_data) != NULL) + { switch (desc->fmt_flags) + { case 1 : + pcaf->alac.bits_per_sample = 16 ; + format |= SF_FORMAT_ALAC_16 ; + break ; + case 2 : + pcaf->alac.bits_per_sample = 20 ; + format |= SF_FORMAT_ALAC_20 ; + break ; + case 3 : + pcaf->alac.bits_per_sample = 24 ; + format |= SF_FORMAT_ALAC_24 ; + break ; + case 4 : + pcaf->alac.bits_per_sample = 32 ; + format |= SF_FORMAT_ALAC_32 ; + break ; + default : + psf_log_printf (psf, "Bad ALAC format flag value of %d\n", desc->fmt_flags) ; + } ; + + pcaf->alac.frames_per_packet = desc->frames_per_packet ; + } ; + + return format ; + } ; + + format |= psf->endian == SF_ENDIAN_LITTLE ? SF_ENDIAN_LITTLE : 0 ; if (desc->fmt_id == lpcm_MARKER && desc->fmt_flags & 1) { /* Floating point data. */ @@ -208,12 +298,7 @@ decode_desc_chunk (SF_PRIVATE *psf, const DESC_CHUNK *desc) } ; } ; - if ((desc->fmt_flags & 1) != 0) - { psf_log_printf (psf, "**** Ooops, 'desc' chunk suggests float data, but other info invalid.\n") ; - return 0 ; - } ; - - if (desc->fmt_id == lpcm_MARKER) + if (desc->fmt_id == lpcm_MARKER && (desc->fmt_flags & 1) == 0) { /* Integer data. */ if (desc->bits_per_chan == 32 && desc->pkt_bytes == 4 * desc->channels_per_frame) { psf->bytewidth = 4 ; @@ -243,16 +328,23 @@ decode_desc_chunk (SF_PRIVATE *psf, const DESC_CHUNK *desc) return format | SF_FORMAT_ULAW ; } ; + psf_log_printf (psf, "**** Unknown format identifier.\n") ; + return 0 ; } /* decode_desc_chunk */ static int caf_read_header (SF_PRIVATE *psf) -{ DESC_CHUNK desc ; +{ CAF_PRIVATE *pcaf ; + BUF_UNION ubuf ; + DESC_CHUNK desc ; sf_count_t chunk_size ; double srate ; short version, flags ; - int marker, k, have_data = 0 ; + int marker, k, have_data = 0, error ; + + if ((pcaf = psf->container_data) == NULL) + return SFE_INTERNAL ; memset (&desc, 0, sizeof (desc)) ; @@ -262,10 +354,10 @@ caf_read_header (SF_PRIVATE *psf) if (marker != caff_MARKER) return SFE_CAF_NOT_CAF ; - psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, psf->u.ucbuf, 8) ; - srate = double64_be_read (psf->u.ucbuf) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%5.3f", srate) ; - psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, psf->u.cbuf) ; + psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, ubuf.ucbuf, 8) ; + srate = double64_be_read (ubuf.ucbuf) ; + snprintf (ubuf.cbuf, sizeof (ubuf.cbuf), "%5.3f", srate) ; + psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, ubuf.cbuf) ; if (marker != desc_MARKER) return SFE_CAF_NO_DESC ; @@ -276,13 +368,13 @@ caf_read_header (SF_PRIVATE *psf) psf->sf.samplerate = lrint (srate) ; - psf_binheader_readf (psf, "mE44444", &desc.fmt_id, &desc.fmt_flags, &desc.pkt_bytes, &desc.pkt_frames, + psf_binheader_readf (psf, "mE44444", &desc.fmt_id, &desc.fmt_flags, &desc.pkt_bytes, &desc.frames_per_packet, &desc.channels_per_frame, &desc.bits_per_chan) ; psf_log_printf (psf, " Format id : %M\n Format flags : %x\n Bytes / packet : %u\n" " Frames / packet : %u\n Channels / frame : %u\n Bits / channel : %u\n", - desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.pkt_frames, desc.channels_per_frame, desc.bits_per_chan) ; + desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.frames_per_packet, desc.channels_per_frame, desc.bits_per_chan) ; - if (desc.channels_per_frame > 200) + if (desc.channels_per_frame > SF_MAX_CHANNELS) { psf_log_printf (psf, "**** Bad channels per frame value %u.\n", desc.channels_per_frame) ; return SFE_MALFORMED_FILE ; } ; @@ -292,14 +384,23 @@ caf_read_header (SF_PRIVATE *psf) psf->sf.channels = desc.channels_per_frame ; - while (have_data == 0 && psf_ftell (psf) < psf->filelength - SIGNED_SIZEOF (marker)) - { psf_binheader_readf (psf, "mE8", &marker, &chunk_size) ; + while (psf_ftell (psf) < psf->filelength) + { marker = 0 ; + chunk_size = 0 ; + + psf_binheader_readf (psf, "mE8", &marker, &chunk_size) ; + if (marker == 0) + { psf_log_printf (psf, "Have 0 marker.\n") ; + break ; + } ; + + psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; switch (marker) { case peak_MARKER : psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; if (chunk_size != CAF_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", (int) chunk_size) ; + { psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; psf_log_printf (psf, "*** File PEAK chunk %D should be %d.\n", chunk_size, CAF_PEAK_CHUNK_SIZE (psf->sf.channels)) ; return SFE_CAF_BAD_PEAK ; } ; @@ -311,7 +412,7 @@ caf_read_header (SF_PRIVATE *psf) psf_binheader_readf (psf, "E4", & (psf->peak_info->edit_number)) ; psf_log_printf (psf, " edit count : %d\n", psf->peak_info->edit_number) ; - psf_log_printf (psf, " Ch Position Value\n") ; + psf_log_printf (psf, " Ch Position Value\n") ; for (k = 0 ; k < psf->sf.channels ; k++) { sf_count_t position ; float value ; @@ -320,29 +421,95 @@ caf_read_header (SF_PRIVATE *psf) psf->peak_info->peaks [k].value = value ; psf->peak_info->peaks [k].position = position ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", k, (long) position, value) ; - psf_log_printf (psf, psf->u.cbuf) ; + snprintf (ubuf.cbuf, sizeof (ubuf.cbuf), " %2d %-12" PRId64 " %g\n", k, position, value) ; + psf_log_printf (psf, ubuf.cbuf) ; } ; psf->peak_info->peak_loc = SF_PEAK_START ; break ; + case chan_MARKER : + if (chunk_size < 12) + { psf_log_printf (psf, "%M : %D (should be >= 12)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; + break ; + } + + psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; + + if ((error = caf_read_chanmap (psf, chunk_size))) + return error ; + break ; + case free_MARKER : psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", (int) chunk_size) ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; break ; case data_MARKER : - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; psf_binheader_readf (psf, "E4", &k) ; psf_log_printf (psf, " edit : %u\n", k) ; + + if (chunk_size == -1) + { psf_log_printf (psf, "%M : -1\n") ; + chunk_size = psf->filelength - psf->headindex ; + } + else if (psf->filelength > 0 && psf->filelength < psf->headindex + chunk_size - 16) + psf_log_printf (psf, "%M : %D (should be %D)\n", marker, chunk_size, psf->filelength - psf->headindex - 8) ; + else + psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; + + + psf->dataoffset = psf->headindex ; + + /* Subtract the 4 bytes of the 'edit' field above. */ + psf->datalength = chunk_size - 4 ; + + psf_binheader_readf (psf, "j", psf->datalength) ; have_data = 1 ; break ; - default : - psf_log_printf (psf, " %M : %D (skipped)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", (int) chunk_size) ; + case kuki_MARKER : + psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; + pcaf->alac.kuki_offset = psf_ftell (psf) - 12 ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; break ; + + case pakt_MARKER : + psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; + + psf_binheader_readf (psf, "E8844", &pcaf->alac.packets, &pcaf->alac.valid_frames, + &pcaf->alac.priming_frames, &pcaf->alac.remainder_frames) ; + + psf_log_printf (psf, + " Packets : %D\n" + " Valid frames : %D\n" + " Priming frames : %d\n" + " Remainder frames : %d\n", + pcaf->alac.packets, pcaf->alac.valid_frames, pcaf->alac.priming_frames, + pcaf->alac.remainder_frames + ) ; + + if (pcaf->alac.packets == 0 && pcaf->alac.valid_frames == 0 + && pcaf->alac.priming_frames == 0 && pcaf->alac.remainder_frames == 0) + psf_log_printf (psf, "*** 'pakt' chunk header is all zero.\n") ; + + pcaf->alac.pakt_offset = psf_ftell (psf) - 12 ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size) - 24) ; + break ; + + default : + psf_log_printf (psf, "%M : %D (skipped)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; + break ; + } ; + + if (! psf->sf.seekable && have_data) + break ; + + if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (chunk_size)) + { psf_log_printf (psf, "End\n") ; + break ; } ; } ; @@ -351,12 +518,10 @@ caf_read_header (SF_PRIVATE *psf) return SFE_MALFORMED_FILE ; } ; - psf_log_printf (psf, "End\n") ; - - psf->dataoffset = psf_ftell (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; psf->endian = (desc.fmt_flags & 2) ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ; + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + if ((psf->sf.format = decode_desc_chunk (psf, &desc)) == 0) return SFE_UNSUPPORTED_ENCODING ; @@ -371,9 +536,15 @@ caf_read_header (SF_PRIVATE *psf) static int caf_write_header (SF_PRIVATE *psf, int calc_length) -{ DESC_CHUNK desc ; +{ BUF_UNION ubuf ; + CAF_PRIVATE *pcaf ; + DESC_CHUNK desc ; sf_count_t current, free_len ; - int subformat ; + uint32_t uk ; + int subformat, append_free_block = SF_TRUE ; + + if ((pcaf = psf->container_data) == NULL) + return SFE_INTERNAL ; memset (&desc, 0, sizeof (desc)) ; @@ -402,8 +573,8 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) /* 'desc' marker and chunk size. */ psf_binheader_writef (psf, "Em8", desc_MARKER, (sf_count_t) (sizeof (DESC_CHUNK))) ; - double64_be_write (1.0 * psf->sf.samplerate, psf->u.ucbuf) ; - psf_binheader_writef (psf, "b", psf->u.ucbuf, make_size_t (8)) ; + double64_be_write (1.0 * psf->sf.samplerate, ubuf.ucbuf) ; + psf_binheader_writef (psf, "b", ubuf.ucbuf, make_size_t (8)) ; subformat = SF_CODEC (psf->sf.format) ; @@ -425,7 +596,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_id = lpcm_MARKER ; psf->bytewidth = 1 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 8 ; break ; @@ -434,7 +605,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_id = lpcm_MARKER ; psf->bytewidth = 2 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 16 ; break ; @@ -442,7 +613,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) case SF_FORMAT_PCM_24 : psf->bytewidth = 3 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 24 ; desc.fmt_id = lpcm_MARKER ; @@ -452,7 +623,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_id = lpcm_MARKER ; psf->bytewidth = 4 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 32 ; break ; @@ -462,7 +633,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_flags |= 1 ; psf->bytewidth = 4 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 32 ; break ; @@ -472,7 +643,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_flags |= 1 ; psf->bytewidth = 8 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 64 ; break ; @@ -481,7 +652,7 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_id = alaw_MARKER ; psf->bytewidth = 1 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 8 ; break ; @@ -490,19 +661,30 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) desc.fmt_id = ulaw_MARKER ; psf->bytewidth = 1 ; desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.pkt_frames = 1 ; + desc.frames_per_packet = 1 ; desc.channels_per_frame = psf->sf.channels ; desc.bits_per_chan = 8 ; break ; + case SF_FORMAT_ALAC_16 : + case SF_FORMAT_ALAC_20 : + case SF_FORMAT_ALAC_24 : + case SF_FORMAT_ALAC_32 : + desc.fmt_id = alac_MARKER ; + desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; + desc.channels_per_frame = psf->sf.channels ; + alac_get_desc_chunk_items (subformat, &desc.fmt_flags, &desc.frames_per_packet) ; + append_free_block = SF_FALSE ; + break ; + default : return SFE_UNIMPLEMENTED ; } ; - psf_binheader_writef (psf, "mE44444", desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.pkt_frames, desc.channels_per_frame, desc.bits_per_chan) ; + psf_binheader_writef (psf, "mE44444", desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.frames_per_packet, desc.channels_per_frame, desc.bits_per_chan) ; #if 0 - if (psf->str_flags & SF_STR_LOCATE_START) + if (psf->strings.flags & SF_STR_LOCATE_START) caf_write_strings (psf, SF_STR_LOCATE_START) ; #endif @@ -513,13 +695,22 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "Ef8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; - /* Add free chunk so that the actual audio data starts at a multiple 0x1000. */ - free_len = 0x1000 - psf->headindex - 16 - 12 ; - while (free_len < 0) - free_len += 0x1000 ; - psf_binheader_writef (psf, "Em8z", free_MARKER, free_len, (int) free_len) ; + if (psf->channel_map && pcaf->chanmap_tag) + psf_binheader_writef (psf, "Em8444", chan_MARKER, (sf_count_t) 12, pcaf->chanmap_tag, 0, 0) ; - psf_binheader_writef (psf, "Em84", data_MARKER, psf->datalength, 0) ; + /* Write custom headers. */ + for (uk = 0 ; uk < psf->wchunks.used ; uk++) + psf_binheader_writef (psf, "m44b", (int) psf->wchunks.chunks [uk].mark32, 0, psf->wchunks.chunks [uk].len, psf->wchunks.chunks [uk].data, make_size_t (psf->wchunks.chunks [uk].len)) ; + + if (append_free_block) + { /* Add free chunk so that the actual audio data starts at a multiple 0x1000. */ + free_len = 0x1000 - psf->headindex - 16 - 12 ; + while (free_len < 0) + free_len += 0x1000 ; + psf_binheader_writef (psf, "Em8z", free_MARKER, free_len, (int) free_len) ; + } ; + + psf_binheader_writef (psf, "Em84", data_MARKER, psf->datalength + 4, 0) ; psf_fwrite (psf->header, psf->headindex, 1, psf) ; if (psf->error) @@ -534,3 +725,80 @@ caf_write_header (SF_PRIVATE *psf, int calc_length) return psf->error ; } /* caf_write_header */ +static int +caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size) +{ const AIFF_CAF_CHANNEL_MAP * map_info ; + unsigned channel_bitmap, channel_decriptions, bytesread ; + int layout_tag ; + + bytesread = psf_binheader_readf (psf, "E444", &layout_tag, &channel_bitmap, &channel_decriptions) ; + + map_info = aiff_caf_of_channel_layout_tag (layout_tag) ; + + psf_log_printf (psf, " Tag : %x\n", layout_tag) ; + if (map_info) + psf_log_printf (psf, " Layout : %s\n", map_info->name) ; + + if (bytesread < chunk_size) + psf_binheader_readf (psf, "j", chunk_size - bytesread) ; + + if (map_info->channel_map != NULL) + { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ; + + free (psf->channel_map) ; + + if ((psf->channel_map = malloc (chanmap_size)) == NULL) + return SFE_MALLOC_FAILED ; + + memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ; + } ; + + return 0 ; +} /* caf_read_chanmap */ + +/*============================================================================== +*/ + +static int +caf_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) +{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; +} /* caf_set_chunk */ + +static SF_CHUNK_ITERATOR * +caf_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) +{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; +} /* caf_next_chunk_iterator */ + +static int +caf_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ int indx ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + chunk_info->datalen = psf->rchunks.chunks [indx].len ; + + return SFE_NO_ERROR ; +} /* caf_get_chunk_size */ + +static int +caf_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ int indx ; + sf_count_t pos ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + if (chunk_info->data == NULL) + return SFE_BAD_CHUNK_DATA_PTR ; + + chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; + memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; + + pos = psf_ftell (psf) ; + psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; + psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; + psf_fseek (psf, pos, SEEK_SET) ; + + return SFE_NO_ERROR ; +} /* caf_get_chunk_data */ diff --git a/libs/libsndfile/src/cart.c b/libs/libsndfile/src/cart.c new file mode 100644 index 0000000000..a56ed60e51 --- /dev/null +++ b/libs/libsndfile/src/cart.c @@ -0,0 +1,101 @@ +/* +** Copyright (C) 2012 Chris Roberts +** Copyright (C) 2006-2013 Erik de Castro Lopo +** Copyright (C) 2006 Paul Davis +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include +#include "common.h" + + + +static inline size_t +cart_min_size (const SF_CART_INFO* info) +{ if (info == NULL) + return 0 ; + + return offsetof (SF_CART_INFO, tag_text) + info->tag_text_size ; +} /* cart_min_size */ + +SF_CART_INFO_16K* +cart_var_alloc (void) +{ SF_CART_INFO_16K* thing ; + thing = malloc (sizeof (SF_CART_INFO_16K)) ; + return thing ; +} /* cart_var_alloc */ + +int +cart_var_set (SF_PRIVATE *psf, const SF_CART_INFO * info, size_t datasize) +{ size_t len ; + + if (info == NULL) + return SF_FALSE ; + + if (cart_min_size (info) > datasize) + { psf->error = SFE_BAD_CART_INFO_SIZE ; + return SF_FALSE ; + } ; + + if (datasize >= sizeof (SF_CART_INFO_16K)) + { psf->error = SFE_BAD_CART_INFO_TOO_BIG ; + return SF_FALSE ; + } ; + + if (psf->cart_16k == NULL) + { if ((psf->cart_16k = cart_var_alloc ()) == NULL) + { psf->error = SFE_MALLOC_FAILED ; + return SF_FALSE ; + } ; + } ; + + memcpy (psf->cart_16k, info, offsetof (SF_CART_INFO, tag_text)) ; + psf_strlcpy_crlf (psf->cart_16k->tag_text, info->tag_text, sizeof (psf->cart_16k->tag_text), datasize - offsetof (SF_CART_INFO, tag_text)) ; + + len = strlen (psf->cart_16k->tag_text) ; + + if (len > 0 && psf->cart_16k->tag_text [len - 1] != '\n') + psf_strlcat (psf->cart_16k->tag_text, sizeof (psf->cart_16k->tag_text), "\r\n") ; + + /* Force tag_text_size to be even. */ + len = strlen (psf->cart_16k->tag_text) ; + len += (len & 1) ? 1 : 2 ; + + psf->cart_16k->tag_text_size = len ; + + return SF_TRUE ; +} /* cart_var_set */ + + +int +cart_var_get (SF_PRIVATE *psf, SF_CART_INFO * data, size_t datasize) +{ size_t size ; + if (psf->cart_16k == NULL) + return SF_FALSE ; + + size = SF_MIN (datasize, cart_min_size ((const SF_CART_INFO *) psf->cart_16k)) ; + + memcpy (data, psf->cart_16k, size) ; + + return SF_TRUE ; +} /* cart_var_get */ + + diff --git a/libs/libsndfile/src/chanmap.c b/libs/libsndfile/src/chanmap.c new file mode 100644 index 0000000000..9a9f7f0f16 --- /dev/null +++ b/libs/libsndfile/src/chanmap.c @@ -0,0 +1,262 @@ +/* +** Copyright (C) 2009-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +** Mostly from "Apple Core Audio Format Specification 1.0": +** +** http://developer.apple.com/documentation/MusicAudio/Reference/CAFSpec/CAFSpec.pdf +*/ + +#include "sfconfig.h" + +#include +#include +#include + +#include "sndfile.h" +#include "common.h" +#include "chanmap.h" + + +static const AIFF_CAF_CHANNEL_MAP zero_chan [] = +{ { (0 << 16) | 0, NULL, "Use channel descriptions." }, + { (1 << 16) | 0, NULL, "Use channel bitmap." } +} ; /* zero_chan */ + + +static const int one_chan_mono [1] = { SF_CHANNEL_MAP_MONO } ; + +static const AIFF_CAF_CHANNEL_MAP one_chan [] = +{ { (100 << 16) | 1, one_chan_mono, "mono" } +} ; /* one_chan */ + + +static const int two_channel_stereo [2] = { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT } ; + +static const AIFF_CAF_CHANNEL_MAP two_chan [] = +{ { (101 << 16) | 2, two_channel_stereo, "stereo (L, R)" }, + { (102 << 16) | 2, two_channel_stereo, "stereo headphones (L, R)" }, +#if 0 + { (103 << 16) | 2, NULL, "matrix stereo (Lt, Rt)" }, + { (104 << 16) | 2, NULL, "2 channels (mid, side)" }, + { (105 << 16) | 2, NULL, "coincident mic pair" }, + { (106 << 16) | 2, NULL, "binaural stereo (L, R)" + } +#endif +} ; /* two_chan */ + + +static const int three_channel_mpeg_30a [3] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER } ; +static const int three_channel_mpeg_30b [3] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT } ; +static const int three_channel_itu_21 [3] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int three_channel_dvd_4 [3] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE } ; + +static const AIFF_CAF_CHANNEL_MAP three_chan [] = +{ { (113 << 16) | 3, three_channel_mpeg_30a, "MPEG 3 0 A (L, R, C)" }, + { (114 << 16) | 3, three_channel_mpeg_30b, "MPEG 3 0 B (C, L, R)" }, + { (131 << 16) | 3, three_channel_itu_21, "ITU 2.1 (L, R, Cs)" }, + { (133 << 16) | 3, three_channel_dvd_4, "DVD 4 (L, R, LFE)" } +} ; /* three_chan */ + + +static const int four_channel_ambisonc_b [4] = + { SF_CHANNEL_MAP_AMBISONIC_B_W, SF_CHANNEL_MAP_AMBISONIC_B_X, SF_CHANNEL_MAP_AMBISONIC_B_Y, SF_CHANNEL_MAP_AMBISONIC_B_Z } ; +static const int four_channel_quad [4] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int four_channel_mpeg_40a [4] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int four_channel_mpeg_40b [4] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int four_channel_itu_23 [4] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int four_channel_dvd_5 [4] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int four_channel_dvd_10 [4] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE } ; + +static const AIFF_CAF_CHANNEL_MAP four_chan [] = +{ { (107 << 16) | 4, four_channel_ambisonc_b, "ambisonic B (W, X, Y, Z)" }, + { (108 << 16) | 4, four_channel_quad, "quad (Lfront, Rfront, Lrear, Rrear)" }, + { (115 << 16) | 4, four_channel_mpeg_40a, "MPEG 4.0 A (L, R, C, Cs)" }, + { (116 << 16) | 4, four_channel_mpeg_40b, "MPEG 4.0 B (C, L, R, Cs)" }, + { (132 << 16) | 4, four_channel_itu_23, "ITU 2.3 (L, R, Ls, Rs)" }, + { (134 << 16) | 4, four_channel_dvd_5, "DVD 5 (L, R, LFE, Cs)" }, + { (136 << 16) | 4, four_channel_dvd_10, "DVD 10 (L, R, C, LFE)" } +} ; /* four_chan */ + + +static const int five_channel_pentagonal [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER } ; +static const int five_channel_mpeg_50_a [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int five_channel_mpeg_50_b [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER } ; +static const int five_channel_mpeg_50_c [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int five_channel_mpeg_50_d [5] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int five_channel_dvd_6 [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int five_channel_dvd_11 [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int five_channel_dvd_18 [5] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; + +static const AIFF_CAF_CHANNEL_MAP five_chan [] = +{ { (109 << 16) | 5, five_channel_pentagonal, "pentagonal (L, R, Lrear, Rrear, C)" }, + { (117 << 16) | 5, five_channel_mpeg_50_a, "MPEG 5.0 A (L, R, C, Ls, Rs)" }, + { (118 << 16) | 5, five_channel_mpeg_50_b, "MPEG 5.0 B (L, R, Ls, Rs, C)" }, + { (119 << 16) | 5, five_channel_mpeg_50_c, "MPEG 5.0 C (L, C, R, Ls, Rs,)" }, + { (120 << 16) | 5, five_channel_mpeg_50_d, "MPEG 5.0 D (C, L, R, Ls, Rs)" }, + { (135 << 16) | 5, five_channel_dvd_6, "DVD 6 (L, R, LFE, Ls, Rs)" }, + { (137 << 16) | 5, five_channel_dvd_11, "DVD 11 (L, R, C, LFE, Cs)" }, + { (138 << 16) | 5, five_channel_dvd_18, "DVD 18 (L, R, Ls, Rs, LFE)" } +} ; /* five_chan */ + + +static const int six_channel_mpeg_51_a [6] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; +static const int six_channel_mpeg_51_b [6] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE } ; +static const int six_channel_mpeg_51_c [6] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; +static const int six_channel_mpeg_51_d [6] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; +static const int six_channel_audio_unit_60 [6] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int six_channel_aac_60 [6] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; + +static const AIFF_CAF_CHANNEL_MAP six_chan [] = +{ { (110 << 16) | 6, NULL, "hexagonal (L, R, Lr, Rr, C, Rear)" }, + { (121 << 16) | 6, six_channel_mpeg_51_a, "MPEG 5.1 A (L, R, C, LFE, Ls, Rs)" }, + { (122 << 16) | 6, six_channel_mpeg_51_b, "MPEG 5.1 B (L, R, Ls, Rs, C, LFE)" }, + { (123 << 16) | 6, six_channel_mpeg_51_c, "MPEG 5.1 C (L, C, R, Ls, Rs, LFE)" }, + { (124 << 16) | 6, six_channel_mpeg_51_d, "MPEG 5.1 D (C, L, R, Ls, Rs, LFE)" }, + { (139 << 16) | 6, six_channel_audio_unit_60, "AudioUnit 6.0 (L, R, Ls, Rs, C, Cs)" }, + { (141 << 16) | 6, six_channel_aac_60, "AAC 6.0 (C, L, R, Ls, Rs, Cs)" } +} ; /* six_chan */ + + +static const int six_channel_mpeg_61a [7] = + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; +static const int six_channel_aac_61 [7] = + { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER, SF_CHANNEL_MAP_LFE } ; + +static const AIFF_CAF_CHANNEL_MAP seven_chan [] = +{ { (125 << 16) | 7, six_channel_mpeg_61a, "MPEG 6.1 A (L, R, C, LFE, Ls, Rs, Cs)" }, + { (140 << 16) | 7, NULL, "AudioUnit 7.0 (L, R, Ls, Rs, C, Rls, Rrs)" }, + { (142 << 16) | 7, six_channel_aac_61, "AAC 6.1 (C, L, R, Ls, Rs, Cs, Lfe)" }, + { (143 << 16) | 7, NULL, "AAC 7.0 (C, L, R, Ls, Rs, Rls, Rrs,)" } +} ; /* seven_chan */ + + +static const AIFF_CAF_CHANNEL_MAP eight_chan [] = +{ { (111 << 16) | 8, NULL, + // front left, front right, rear left, rear right, + // front center, rear center, side left, side right + "octagonal (Lf, Rf, Lr, Rr, Cf, Cr, Ls, Rs)" + }, + { (112 << 16) | 8, NULL, + // left, right, rear left, rear right + // top left, top right, top rear left, top rear right + "cube (L, R, Lrear, Rrear, Ltop, Rtop, Ltoprear, Rtoprear)" + }, + { (126 << 16) | 8, NULL, "MPEG 7.1 A (L, R, C, LFE, Ls, Rs, Lc, Rc)" }, + { (127 << 16) | 8, NULL, "MPEG 7.1 B (C, Lc, Rc, L, R, Ls, Rs, LFE)" }, + { (128 << 16) | 8, NULL, "MPEG 7.1 C (L, R, C, LFE, Ls, R, Rls, Rrs)" }, + { (129 << 16) | 8, NULL, "Emagic Default 7.1 (L, R, Ls, Rs, C, LFE, Lc, Rc)" }, + { (130 << 16) | 8, NULL, + // (ITU_5_1 plus a matrix encoded stereo mix) + "SMPTE DTV (L, R, C, LFE, Ls, Rs, Lt, Rt)" + }, + { (144 << 16) | 8, NULL, "AAC octagonal (C, L, R, Ls, Rs, Rls, Rrs, Cs)" } +} ; /* eight_chan */ + + + +#if 0 + +TMH_10_2_std = (145 << 16) | 16, +// L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 + +TMH_10_2_full = (146 << 16) | 21, +// TMH_10_2_std plus: Lc Rc HI VI Haptic + +#endif + + +typedef struct +{ const AIFF_CAF_CHANNEL_MAP * map ; + int len ; +} MAP_MAP ; + +static const MAP_MAP map [] = +{ { zero_chan, ARRAY_LEN (zero_chan) }, + { one_chan, ARRAY_LEN (one_chan) }, + { two_chan, ARRAY_LEN (two_chan) }, + { three_chan, ARRAY_LEN (three_chan) }, + { four_chan, ARRAY_LEN (four_chan) }, + { five_chan, ARRAY_LEN (five_chan) }, + { six_chan, ARRAY_LEN (six_chan) }, + { seven_chan, ARRAY_LEN (seven_chan) }, + { eight_chan, ARRAY_LEN (eight_chan) } +} ; /* map */ + + +int +aiff_caf_find_channel_layout_tag (const int *chan_map, int channels) +{ const AIFF_CAF_CHANNEL_MAP * curr_map ; + unsigned k, len ; + + if (channels < 1 || channels > ARRAY_LEN (map)) + return 0 ; + + curr_map = map [channels].map ; + len = map [channels].len ; + + for (k = 0 ; k < len ; k++) + if (curr_map [k].channel_map != NULL) + if (memcmp (chan_map, curr_map [k].channel_map, channels * sizeof (chan_map [0])) == 0) + return curr_map [k].channel_layout_tag ; + + return 0 ; +} /* aiff_caf_find_channel_layout_tag */ + +const AIFF_CAF_CHANNEL_MAP * +aiff_caf_of_channel_layout_tag (int tag) +{ const AIFF_CAF_CHANNEL_MAP * curr_map ; + unsigned k, len ; + int channels = tag & 0xffff ; + + if (channels < 0 || channels > ARRAY_LEN (map)) + return NULL ; + + curr_map = map [channels].map ; + len = map [channels].len ; + + for (k = 0 ; k < len ; k++) + if (curr_map [k].channel_layout_tag == tag) + return curr_map + k ; + + return NULL ; +} /* aiff_caf_of_channel_layout_tag */ diff --git a/libs/libsndfile/src/chanmap.h b/libs/libsndfile/src/chanmap.h new file mode 100644 index 0000000000..8af409dbac --- /dev/null +++ b/libs/libsndfile/src/chanmap.h @@ -0,0 +1,32 @@ +/* +** Copyright (C) 2009-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +typedef struct +{ /* The tag in the AIFF or CAF file. */ + int channel_layout_tag ; + + /* The equivalent array of SF_CHANNEL_MAP_* entries. */ + const int * channel_map ; + + const char * name ; +} AIFF_CAF_CHANNEL_MAP ; + + +int aiff_caf_find_channel_layout_tag (const int *chan_map, int channels) ; + +const AIFF_CAF_CHANNEL_MAP * aiff_caf_of_channel_layout_tag (int tag) ; diff --git a/libs/libsndfile/src/chunk.c b/libs/libsndfile/src/chunk.c index 98ff05ae54..b661ce5c2b 100644 --- a/libs/libsndfile/src/chunk.c +++ b/libs/libsndfile/src/chunk.c @@ -1,5 +1,6 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2012 Erik de Castro Lopo +** Copyright (C) 2012 IOhannes m zmoelnig, IEM ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -25,30 +26,230 @@ #include "sfendian.h" #include "common.h" +static int64_t +hash_of_str (const char * str) +{ int64_t marker = 0 ; + int k ; -void -pchk4_store (PRIV_CHUNK4 * pchk, int marker, sf_count_t offset, sf_count_t len) -{ - if (pchk->count >= ARRAY_LEN (pchk->l)) - return ; + for (k = 0 ; str [k] ; k++) + marker = marker * 0x7f + ((const uint8_t *) str) [k] ; - pchk->l [pchk->count].chunk = marker ; - pchk->l [pchk->count].offset = offset ; - pchk->l [pchk->count].len = len ; + return marker ; +} /* hash_of_str */ - pchk->count ++ ; +SF_CHUNK_ITERATOR * +psf_get_chunk_iterator (SF_PRIVATE * psf, const char * marker_str) +{ const READ_CHUNKS * pchk = &psf->rchunks ; + int idx ; - return ; -} /* pchk4_store */ + if (marker_str) + idx = psf_find_read_chunk_str (pchk, marker_str) ; + else + idx = pchk->used > 0 ? 0 : -1 ; + + if (idx < 0) + return NULL ; + + if (psf->iterator == NULL) + { psf->iterator = calloc (1, sizeof (SF_CHUNK_ITERATOR)) ; + if (psf->iterator == NULL) + return NULL ; + } ; + + psf->iterator->sndfile = (SNDFILE *) psf ; + + if (marker_str) + { int64_t hash ; + size_t marker_len ; + union + { uint32_t marker ; + char str [5] ; + } u ; + + snprintf (u.str, sizeof (u.str), "%s", marker_str) ; + + marker_len = strlen (marker_str) ; + if (marker_len > 64) + marker_len = 64 ; + + hash = marker_len > 4 ? hash_of_str (marker_str) : u.marker ; + + memcpy (psf->iterator->id, marker_str, marker_len) ; + psf->iterator->id_size = marker_len ; + psf->iterator->hash = hash ; + } + + psf->iterator->current = idx ; + + return psf->iterator ; +} /* psf_get_chunk_iterator */ + +SF_CHUNK_ITERATOR * +psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR * iterator) +{ int64_t hash = iterator->hash ; + uint32_t k ; + + iterator->current++ ; + + if (hash) + { for (k = iterator->current ; k < pchk->used ; k++) + if (pchk->chunks [k].hash == hash) + { iterator->current = k ; + return iterator ; + } + } + else if (iterator->current < pchk->used) + return iterator ; + + /* No match, clear iterator and return NULL */ + memset (iterator, 0, sizeof (*iterator)) ; + return NULL ; +} /* psf_next_chunk_iterator */ + +static int +psf_store_read_chunk (READ_CHUNKS * pchk, const READ_CHUNK * rchunk) +{ if (pchk->count == 0) + { pchk->used = 0 ; + pchk->count = 20 ; + pchk->chunks = calloc (pchk->count, sizeof (READ_CHUNK)) ; + } + else if (pchk->used > pchk->count) + return SFE_INTERNAL ; + else if (pchk->used == pchk->count) + { READ_CHUNK * old_ptr = pchk->chunks ; + int new_count = 3 * (pchk->count + 1) / 2 ; + + pchk->chunks = realloc (old_ptr, new_count * sizeof (READ_CHUNK)) ; + if (pchk->chunks == NULL) + { pchk->chunks = old_ptr ; + return SFE_MALLOC_FAILED ; + } ; + pchk->count = new_count ; + } ; + + pchk->chunks [pchk->used] = *rchunk ; + + pchk->used ++ ; + + return SFE_NO_ERROR ; +} /* psf_store_read_chunk */ int -pchk4_find (PRIV_CHUNK4 * pchk, int marker) -{ int k ; +psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len) +{ READ_CHUNK rchunk ; - for (k = 0 ; k < pchk->count ; k++) - if (pchk->l [k].chunk == marker) + memset (&rchunk, 0, sizeof (rchunk)) ; + + rchunk.hash = marker ; + rchunk.mark32 = marker ; + rchunk.offset = offset ; + rchunk.len = len ; + + rchunk.id_size = 4 ; + memcpy (rchunk.id, &marker, rchunk.id_size) ; + + return psf_store_read_chunk (pchk, &rchunk) ; +} /* psf_store_read_chunk_u32 */ + +int +psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker_str) +{ int64_t hash ; + uint32_t k ; + union + { uint32_t marker ; + char str [5] ; + } u ; + + snprintf (u.str, sizeof (u.str), "%s", marker_str) ; + + hash = strlen (marker_str) > 4 ? hash_of_str (marker_str) : u.marker ; + + for (k = 0 ; k < pchk->used ; k++) + if (pchk->chunks [k].hash == hash) return k ; return -1 ; -} /* pchk4_find */ +} /* psf_find_read_chunk_str */ + +int +psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker) +{ uint32_t k ; + + for (k = 0 ; k < pchk->used ; k++) + if (pchk->chunks [k].mark32 == marker) + return k ; + + return -1 ; +} /* psf_find_read_chunk_m32 */ +int +psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker) +{ if (marker->current < pchk->used) + return marker->current ; + + return -1 ; +} /* psf_find_read_chunk_iterator */ + +int +psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker_str, sf_count_t offset, uint32_t len) +{ READ_CHUNK rchunk ; + union + { uint32_t marker ; + char str [5] ; + } u ; + size_t marker_len ; + + memset (&rchunk, 0, sizeof (rchunk)) ; + snprintf (u.str, sizeof (u.str), "%s", marker_str) ; + + marker_len = strlen (marker_str) ; + + rchunk.hash = marker_len > 4 ? hash_of_str (marker_str) : u.marker ; + rchunk.mark32 = u.marker ; + rchunk.offset = offset ; + rchunk.len = len ; + + rchunk.id_size = marker_len > 64 ? 64 : marker_len ; + memcpy (rchunk.id, marker_str, rchunk.id_size) ; + + return psf_store_read_chunk (pchk, &rchunk) ; +} /* psf_store_read_chunk_str */ + +int +psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info) +{ union + { uint32_t marker ; + char str [5] ; + } u ; + uint32_t len ; + + if (pchk->count == 0) + { pchk->used = 0 ; + pchk->count = 20 ; + pchk->chunks = calloc (pchk->count, sizeof (WRITE_CHUNK)) ; + } + else if (pchk->used >= pchk->count) + { WRITE_CHUNK * old_ptr = pchk->chunks ; + int new_count = 3 * (pchk->count + 1) / 2 ; + + pchk->chunks = realloc (old_ptr, new_count * sizeof (WRITE_CHUNK)) ; + if (pchk->chunks == NULL) + { pchk->chunks = old_ptr ; + return SFE_MALLOC_FAILED ; + } ; + } ; + + len = chunk_info->datalen ; + while (len & 3) len ++ ; + + snprintf (u.str, sizeof (u.str), "%s", chunk_info->id) ; + + pchk->chunks [pchk->used].hash = strlen (chunk_info->id) > 4 ? hash_of_str (chunk_info->id) : u.marker ; + pchk->chunks [pchk->used].mark32 = u.marker ; + pchk->chunks [pchk->used].len = len ; + pchk->chunks [pchk->used].data = psf_memdup (chunk_info->data, chunk_info->datalen) ; + + pchk->used ++ ; + + return SFE_NO_ERROR ; +} /* psf_save_write_chunk */ diff --git a/libs/libsndfile/src/command.c b/libs/libsndfile/src/command.c index 72c892c40f..6db7315415 100644 --- a/libs/libsndfile/src/command.c +++ b/libs/libsndfile/src/command.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -47,6 +47,10 @@ static SF_FORMAT_INFO const simple_formats [] = "AU (Sun/Next 8-bit u-law)", "au" }, + { SF_FORMAT_CAF | SF_FORMAT_ALAC_16, + "CAF (Apple 16 bit ALAC)", "caf" + }, + { SF_FORMAT_CAF | SF_FORMAT_PCM_16, "CAF (Apple 16 bit PCM)", "caf" }, @@ -115,28 +119,30 @@ static SF_FORMAT_INFO const major_formats [] = { { SF_FORMAT_AIFF, "AIFF (Apple/SGI)", "aiff" }, { SF_FORMAT_AU, "AU (Sun/NeXT)", "au" }, - { SF_FORMAT_AVR, "AVR (Audio Visual Research)", "avr" }, - { SF_FORMAT_CAF, "CAF (Apple Core Audio File)", "caf" }, + { SF_FORMAT_AVR, "AVR (Audio Visual Research)", "avr" }, + { SF_FORMAT_CAF, "CAF (Apple Core Audio File)", "caf" }, #if HAVE_EXTERNAL_LIBS - { SF_FORMAT_FLAC, "FLAC (FLAC Lossless Audio Codec)", "flac" }, + { SF_FORMAT_FLAC, "FLAC (Free Lossless Audio Codec)", "flac" }, #endif { SF_FORMAT_HTK, "HTK (HMM Tool Kit)", "htk" }, { SF_FORMAT_SVX, "IFF (Amiga IFF/SVX8/SV16)", "iff" }, { SF_FORMAT_MAT4, "MAT4 (GNU Octave 2.0 / Matlab 4.2)", "mat" }, { SF_FORMAT_MAT5, "MAT5 (GNU Octave 2.1 / Matlab 5.0)", "mat" }, + { SF_FORMAT_MPC2K, "MPC (Akai MPC 2k)", "mpc" }, #if HAVE_EXTERNAL_LIBS - { SF_FORMAT_OGG, "OGG (OGG Container format)", "oga" }, + { SF_FORMAT_OGG, "OGG (OGG Container format)", "oga" }, #endif { SF_FORMAT_PAF, "PAF (Ensoniq PARIS)", "paf" }, { SF_FORMAT_PVF, "PVF (Portable Voice Format)", "pvf" }, - { SF_FORMAT_RAW, "RAW (header-less)", "raw" }, + { SF_FORMAT_RAW, "RAW (header-less)", "raw" }, + { SF_FORMAT_RF64, "RF64 (RIFF 64)", "rf64" }, { SF_FORMAT_SD2, "SD2 (Sound Designer II)", "sd2" }, { SF_FORMAT_SDS, "SDS (Midi Sample Dump Standard)", "sds" }, { SF_FORMAT_IRCAM, "SF (Berkeley/IRCAM/CARL)", "sf" }, { SF_FORMAT_VOC, "VOC (Creative Labs)", "voc" }, { SF_FORMAT_W64, "W64 (SoundFoundry WAVE 64)", "w64" }, { SF_FORMAT_WAV, "WAV (Microsoft)", "wav" }, - { SF_FORMAT_NIST, "WAV (NIST Sphere)", "wav" }, + { SF_FORMAT_NIST, "WAV (NIST Sphere)", "wav" }, { SF_FORMAT_WAVEX, "WAVEX (Microsoft)", "wav" }, { SF_FORMAT_WVE, "WVE (Psion Series 3)", "wve" }, { SF_FORMAT_XI, "XI (FastTracker 2)", "xi" }, @@ -198,6 +204,11 @@ static SF_FORMAT_INFO subtype_formats [] = #if HAVE_EXTERNAL_LIBS { SF_FORMAT_VORBIS, "Vorbis", NULL }, #endif + + { SF_FORMAT_ALAC_16, "16 bit ALAC", NULL }, + { SF_FORMAT_ALAC_20, "20 bit ALAC", NULL }, + { SF_FORMAT_ALAC_24, "24 bit ALAC", NULL }, + { SF_FORMAT_ALAC_32, "32 bit ALAC", NULL }, } ; /* subtype_formats */ int @@ -210,7 +221,9 @@ psf_get_format_subtype (SF_FORMAT_INFO *data) { int indx ; if (data->format < 0 || data->format >= (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO))) + { data->format = 0 ; return SFE_BAD_COMMAND_PARAM ; + } ; indx = data->format ; memcpy (data, &(subtype_formats [indx]), sizeof (SF_FORMAT_INFO)) ; @@ -256,7 +269,8 @@ psf_get_format_info (SF_FORMAT_INFO *data) double psf_calc_signal_max (SF_PRIVATE *psf, int normalize) -{ sf_count_t position ; +{ BUF_UNION ubuf ; + sf_count_t position ; double max_val, temp, *data ; int k, len, readcount, save_state ; @@ -280,8 +294,9 @@ psf_calc_signal_max (SF_PRIVATE *psf, int normalize) /* Go to start of file. */ sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; - data = psf->u.dbuf ; - len = ARRAY_LEN (psf->u.dbuf) ; + data = ubuf.dbuf ; + /* Make sure len is an integer multiple of the channel count. */ + len = ARRAY_LEN (ubuf.dbuf) - (ARRAY_LEN (ubuf.dbuf) % psf->sf.channels) ; for (readcount = 1, max_val = 0.0 ; readcount > 0 ; /* nothing */) { readcount = sf_read_double ((SNDFILE*) psf, data, len) ; @@ -300,7 +315,8 @@ psf_calc_signal_max (SF_PRIVATE *psf, int normalize) int psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) -{ sf_count_t position ; +{ BUF_UNION ubuf ; + sf_count_t position ; double temp, *data ; int k, len, readcount, save_state ; int chan ; @@ -321,9 +337,9 @@ psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ; /* Get current position in file */ sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; /* Go to start of file. */ - len = ARRAY_LEN (psf->u.dbuf) ; + len = ARRAY_LEN (ubuf.dbuf) ; - data = psf->u.dbuf ; + data = ubuf.dbuf ; chan = 0 ; readcount = len ; diff --git a/libs/libsndfile/src/common.c b/libs/libsndfile/src/common.c index 3b937f90e9..f42bc91575 100644 --- a/libs/libsndfile/src/common.c +++ b/libs/libsndfile/src/common.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -20,30 +20,35 @@ #include #include + +#ifndef _MSC_VER +#include +#endif #include #include #include #ifndef _MSC_VER #include #endif + #include "sndfile.h" #include "sfendian.h" #include "common.h" /*----------------------------------------------------------------------------------------------- -** psf_log_printf allows libsndfile internal functions to print to an internal logbuffer which +** psf_log_printf allows libsndfile internal functions to print to an internal parselog which ** can later be displayed. ** The format specifiers are as for printf but without the field width and other modifiers. -** Printing is performed to the logbuffer char array of the SF_PRIVATE struct. +** Printing is performed to the parselog char array of the SF_PRIVATE struct. ** Printing is done in such a way as to guarantee that the log never overflows the end of the -** logbuffer array. +** parselog array. */ static inline void log_putchar (SF_PRIVATE *psf, char ch) -{ if (psf->logindex < SIGNED_SIZEOF (psf->logbuffer) - 1) - { psf->logbuffer [psf->logindex++] = ch ; - psf->logbuffer [psf->logindex] = 0 ; +{ if (psf->parselog.indx < SIGNED_SIZEOF (psf->parselog.buf) - 1) + { psf->parselog.buf [psf->parselog.indx++] = ch ; + psf->parselog.buf [psf->parselog.indx] = 0 ; } ; return ; } /* log_putchar */ @@ -757,37 +762,37 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) #if (CPU_IS_BIG_ENDIAN == 1) #define GET_MARKER(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \ - ((ptr) [2] << 8) | ((ptr) [3]) ) + ((ptr) [2] << 8) | ((ptr) [3])) #elif (CPU_IS_LITTLE_ENDIAN == 1) #define GET_MARKER(ptr) ( ((ptr) [0]) | ((ptr) [1] << 8) | \ - ((ptr) [2] << 16) | ((ptr) [3] << 24) ) + ((ptr) [2] << 16) | ((ptr) [3] << 24)) #else # error "Cannot determine endian-ness of processor." #endif -#define GET_LE_SHORT(ptr) ( ((ptr) [1] << 8) | ((ptr) [0]) ) -#define GET_BE_SHORT(ptr) ( ((ptr) [0] << 8) | ((ptr) [1]) ) +#define GET_LE_SHORT(ptr) (((ptr) [1] << 8) | ((ptr) [0])) +#define GET_BE_SHORT(ptr) (((ptr) [0] << 8) | ((ptr) [1])) -#define GET_LE_3BYTE(ptr) ( ((ptr) [2] << 16) | ((ptr) [1] << 8) | ((ptr) [0]) ) -#define GET_BE_3BYTE(ptr) ( ((ptr) [0] << 16) | ((ptr) [1] << 8) | ((ptr) [2]) ) +#define GET_LE_3BYTE(ptr) ( ((ptr) [2] << 16) | ((ptr) [1] << 8) | ((ptr) [0])) +#define GET_BE_3BYTE(ptr) ( ((ptr) [0] << 16) | ((ptr) [1] << 8) | ((ptr) [2])) -#define GET_LE_INT(ptr) ( ((ptr) [3] << 24) | ((ptr) [2] << 16) | \ - ((ptr) [1] << 8) | ((ptr) [0]) ) +#define GET_LE_INT(ptr) ( ((ptr) [3] << 24) | ((ptr) [2] << 16) | \ + ((ptr) [1] << 8) | ((ptr) [0])) -#define GET_BE_INT(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \ - ((ptr) [2] << 8) | ((ptr) [3]) ) +#define GET_BE_INT(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \ + ((ptr) [2] << 8) | ((ptr) [3])) -#define GET_LE_8BYTE(ptr) ( (((sf_count_t) (ptr) [7]) << 56) | (((sf_count_t) (ptr) [6]) << 48) | \ - (((sf_count_t) (ptr) [5]) << 40) | (((sf_count_t) (ptr) [4]) << 32) | \ - (((sf_count_t) (ptr) [3]) << 24) | (((sf_count_t) (ptr) [2]) << 16) | \ - (((sf_count_t) (ptr) [1]) << 8 ) | ((ptr) [0])) +#define GET_LE_8BYTE(ptr) ( (((sf_count_t) (ptr) [7]) << 56) | (((sf_count_t) (ptr) [6]) << 48) | \ + (((sf_count_t) (ptr) [5]) << 40) | (((sf_count_t) (ptr) [4]) << 32) | \ + (((sf_count_t) (ptr) [3]) << 24) | (((sf_count_t) (ptr) [2]) << 16) | \ + (((sf_count_t) (ptr) [1]) << 8) | ((ptr) [0])) -#define GET_BE_8BYTE(ptr) ( (((sf_count_t) (ptr) [0]) << 56) | (((sf_count_t) (ptr) [1]) << 48) | \ - (((sf_count_t) (ptr) [2]) << 40) | (((sf_count_t) (ptr) [3]) << 32) | \ - (((sf_count_t) (ptr) [4]) << 24) | (((sf_count_t) (ptr) [5]) << 16) | \ - (((sf_count_t) (ptr) [6]) << 8 ) | ((ptr) [7])) +#define GET_BE_8BYTE(ptr) ( (((sf_count_t) (ptr) [0]) << 56) | (((sf_count_t) (ptr) [1]) << 48) | \ + (((sf_count_t) (ptr) [2]) << 40) | (((sf_count_t) (ptr) [3]) << 32) | \ + (((sf_count_t) (ptr) [4]) << 24) | (((sf_count_t) (ptr) [5]) << 16) | \ + (((sf_count_t) (ptr) [6]) << 8) | ((ptr) [7])) @@ -1026,7 +1031,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) strptr = va_arg (argptr, char *) ; size = strlen (strptr) + 1 ; size += (size & 1) ; - longdata = H2LE_INT (size) ; + longdata = H2LE_32 (size) ; get_int (psf, longdata) ; memcpy (&(psf->header [psf->headindex]), strptr, size) ; psf->headindex += size ; @@ -1035,14 +1040,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) case 'b' : charptr = va_arg (argptr, char*) ; - count = va_arg (argptr, int) ; + count = va_arg (argptr, size_t) ; if (count > 0) byte_count += header_read (psf, charptr, count) ; break ; case 'G' : charptr = va_arg (argptr, char*) ; - count = va_arg (argptr, int) ; + count = va_arg (argptr, size_t) ; if (count > 0) byte_count += header_gets (psf, charptr, count) ; break ; @@ -1061,14 +1066,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) case 'p' : /* Get the seek position first. */ - count = va_arg (argptr, int) ; + count = va_arg (argptr, size_t) ; header_seek (psf, count, SEEK_SET) ; byte_count = count ; break ; case 'j' : /* Get the seek position first. */ - count = va_arg (argptr, int) ; + count = va_arg (argptr, size_t) ; header_seek (psf, count, SEEK_CUR) ; byte_count += count ; break ; @@ -1133,7 +1138,7 @@ psf_hexdump (const void *ptr, int len) printf ("%08X: ", k) ; for (m = 0 ; m < 16 && k + m < len ; m++) { printf (m == 8 ? " %02X " : "%02X ", data [k + m] & 0xFF) ; - ascii [m] = isprint (data [k + m]) ? data [k + m] : '.' ; + ascii [m] = psf_isprint (data [k + m]) ? data [k + m] : '.' ; } ; if (m <= 8) printf (" ") ; @@ -1151,7 +1156,10 @@ psf_log_SF_INFO (SF_PRIVATE *psf) { psf_log_printf (psf, "---------------------------------\n") ; psf_log_printf (psf, " Sample rate : %d\n", psf->sf.samplerate) ; - psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; + if (psf->sf.frames == SF_COUNT_MAX) + psf_log_printf (psf, " Frames : unknown\n") ; + else + psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; psf_log_printf (psf, " Channels : %d\n", psf->sf.channels) ; psf_log_printf (psf, " Format : 0x%X\n", psf->sf.format) ; @@ -1208,7 +1216,7 @@ psf_sanitize_string (char * cptr, int len) do { len -- ; - cptr [len] = isprint (cptr [len]) ? cptr [len] : '.' ; + cptr [len] = psf_isprint (cptr [len]) ? cptr [len] : '.' ; } while (len > 0) ; } /* psf_sanitize_string */ @@ -1315,6 +1323,79 @@ psf_rand_int32 (void) return value ; } /* psf_rand_int32 */ +void +append_snprintf (char * dest, size_t maxlen, const char * fmt, ...) +{ size_t len = strlen (dest) ; + + if (len < maxlen) + { va_list ap ; + + va_start (ap, fmt) ; + vsnprintf (dest + len, maxlen - len, fmt, ap) ; + va_end (ap) ; + } ; + + return ; +} /* append_snprintf */ + + +void +psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) +{ /* Must be minus 2 so it can still expand a single trailing '\n' or '\r'. */ + char * destend = dest + destmax - 2 ; + const char * srcend = src + srcmax ; + + while (dest < destend && src < srcend) + { if ((src [0] == '\r' && src [1] == '\n') || (src [0] == '\n' && src [1] == '\r')) + { *dest++ = '\r' ; + *dest++ = '\n' ; + src += 2 ; + continue ; + } ; + + if (src [0] == '\r') + { *dest++ = '\r' ; + *dest++ = '\n' ; + src += 1 ; + continue ; + } ; + + if (src [0] == '\n') + { *dest++ = '\r' ; + *dest++ = '\n' ; + src += 1 ; + continue ; + } ; + + *dest++ = *src++ ; + } ; + + /* Make sure dest is terminated. */ + *dest = 0 ; +} /* psf_strlcpy_crlf */ + +sf_count_t +psf_decode_frame_count (SF_PRIVATE *psf) +{ sf_count_t count, readlen, total = 0 ; + BUF_UNION ubuf ; + + /* If we're reading from a pipe or the file is too long, just return SF_COUNT_MAX. */ + if (psf_is_pipe (psf) || psf->datalength > 0x1000000) + return SF_COUNT_MAX ; + + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + + readlen = ARRAY_LEN (ubuf.ibuf) / psf->sf.channels ; + readlen *= psf->sf.channels ; + + while ((count = psf->read_int (psf, ubuf.ibuf, readlen)) > 0) + total += count ; + + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + + return total / psf->sf.channels ; +} /* psf_decode_frame_count */ + /*============================================================================== */ @@ -1413,3 +1494,169 @@ str_of_endianness (int end) /* Zero length string for SF_ENDIAN_FILE. */ return "" ; } /* str_of_endianness */ + +/*============================================================================== +*/ + +void +psf_f2s_array (const float *src, short *dest, int count, int normalize) +{ float normfact ; + + normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; + while (--count >= 0) + dest [count] = lrintf (src [count] * normfact) ; + + return ; +} /* psf_f2s_array */ + +void +psf_f2s_clip_array (const float *src, short *dest, int count, int normalize) +{ float normfact, scaled_value ; + + normfact = normalize ? (1.0 * 0x8000) : 1.0 ; + + while (--count >= 0) + { scaled_value = src [count] * normfact ; + if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF)) + { dest [count] = 0x7FFF ; + continue ; + } ; + if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000)) + { dest [count] = 0x8000 ; + continue ; + } ; + + dest [count] = lrintf (scaled_value) ; + } ; + + return ; +} /* psf_f2s_clip_array */ + +void +psf_d2s_array (const double *src, short *dest, int count, int normalize) +{ double normfact ; + + normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; + while (--count >= 0) + dest [count] = lrint (src [count] * normfact) ; + + return ; +} /* psf_f2s_array */ + +void +psf_d2s_clip_array (const double *src, short *dest, int count, int normalize) +{ double normfact, scaled_value ; + + normfact = normalize ? (1.0 * 0x8000) : 1.0 ; + + while (--count >= 0) + { scaled_value = src [count] * normfact ; + if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF)) + { dest [count] = 0x7FFF ; + continue ; + } ; + if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000)) + { dest [count] = 0x8000 ; + continue ; + } ; + + dest [count] = lrint (scaled_value) ; + } ; + + return ; +} /* psf_d2s_clip_array */ + + +void +psf_f2i_array (const float *src, int *dest, int count, int normalize) +{ float normfact ; + + normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; + while (--count >= 0) + dest [count] = lrintf (src [count] * normfact) ; + + return ; +} /* psf_f2i_array */ + +void +psf_f2i_clip_array (const float *src, int *dest, int count, int normalize) +{ float normfact, scaled_value ; + + normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; + + while (--count >= 0) + { scaled_value = src [count] * normfact ; + if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF)) + { dest [count] = 0x7FFFFFFF ; + continue ; + } ; + if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000)) + { dest [count] = 0x80000000 ; + continue ; + } ; + + dest [count] = lrintf (scaled_value) ; + } ; + + return ; +} /* psf_f2i_clip_array */ + +void +psf_d2i_array (const double *src, int *dest, int count, int normalize) +{ double normfact ; + + normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; + while (--count >= 0) + dest [count] = lrint (src [count] * normfact) ; + + return ; +} /* psf_f2i_array */ + +void +psf_d2i_clip_array (const double *src, int *dest, int count, int normalize) +{ double normfact, scaled_value ; + + normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; + + while (--count >= 0) + { scaled_value = src [count] * normfact ; + if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF)) + { dest [count] = 0x7FFFFFFF ; + continue ; + } ; + if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000)) + { dest [count] = 0x80000000 ; + continue ; + } ; + + dest [count] = lrint (scaled_value) ; + } ; + + return ; +} /* psf_d2i_clip_array */ + +FILE * +psf_open_tmpfile (char * fname, size_t fnamelen) +{ const char * tmpdir ; + FILE * file ; + + if (OS_IS_WIN32) + tmpdir = getenv ("TEMP") ; + else + { tmpdir = getenv ("TMPDIR") ; + tmpdir = tmpdir == NULL ? "/tmp" : tmpdir ; + } ; + +// if (tmpdir && access (tmpdir, R_OK | W_OK | X_OK) == 0) + { snprintf (fname, fnamelen, "%s/%x%x-alac.tmp", tmpdir, psf_rand_int32 (), psf_rand_int32 ()) ; + if ((file = fopen (fname, "wb+")) != NULL) + return file ; + } ; + + snprintf (fname, fnamelen, "%x%x-alac.tmp", psf_rand_int32 (), psf_rand_int32 ()) ; + if ((file = fopen (fname, "wb+")) != NULL) + return file ; + + memset (fname, 0, fnamelen) ; + return NULL ; +} /* psf_open_tmpfile */ diff --git a/libs/libsndfile/src/common.h b/libs/libsndfile/src/common.h index 3e3aec0cbc..4d61619804 100644 --- a/libs/libsndfile/src/common.h +++ b/libs/libsndfile/src/common.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -22,15 +22,16 @@ #include "sfconfig.h" #include +#include #if HAVE_STDINT_H #include +#elif HAVE_INTTYPES_H +#include #endif #ifndef SNDFILE_H #include "sndfile.h" -#elif HAVE_INTTYPES_H -#include #endif #ifdef __cplusplus @@ -39,7 +40,9 @@ #if (SIZEOF_LONG == 8) # define SF_PLATFORM_S64(x) x##l -#elif COMPILER_IS_GCC || __SUNPRO_C +#elif (SIZEOF_LONG_LONG == 8) +# define SF_PLATFORM_S64(x) x##ll +#elif COMPILER_IS_GCC # define SF_PLATFORM_S64(x) x##ll #elif OS_IS_WIN32 # define SF_PLATFORM_S64(x) x##I64 @@ -67,16 +70,15 @@ # define WARN_UNUSED #endif -#define SF_BUFFER_LEN (8192*2) +#define SF_BUFFER_LEN (8192) #define SF_FILENAME_LEN (512) #define SF_SYSERR_LEN (256) #define SF_MAX_STRINGS (32) -#define SF_STR_BUFFER_LEN (8192) -#define SF_HEADER_LEN (4100 + SF_STR_BUFFER_LEN) +#define SF_HEADER_LEN (12292) +#define SF_PARSELOG_LEN (2048) #define PSF_SEEK_ERROR ((sf_count_t) -1) - #define BITWIDTH2BYTES(x) (((x) + 7) / 8) /* For some reason sizeof returns an unsigned value which causes @@ -87,32 +89,40 @@ #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0]))) +#define NOT(x) (! (x)) + #if (COMPILER_IS_GCC == 1) -#define SF_MAX(x,y) ({ \ +#define SF_MAX(x, y) ({ \ typeof (x) sf_max_x1 = (x) ; \ typeof (y) sf_max_y1 = (y) ; \ (void) (&sf_max_x1 == &sf_max_y1) ; \ sf_max_x1 > sf_max_y1 ? sf_max_x1 : sf_max_y1 ; }) -#define SF_MIN(x,y) ({ \ +#define SF_MIN(x, y) ({ \ typeof (x) sf_min_x2 = (x) ; \ typeof (y) sf_min_y2 = (y) ; \ (void) (&sf_min_x2 == &sf_min_y2) ; \ sf_min_x2 < sf_min_y2 ? sf_min_x2 : sf_min_y2 ; }) #else -#define SF_MAX(a,b) ((a) > (b) ? (a) : (b)) -#define SF_MIN(a,b) ((a) < (b) ? (a) : (b)) +#define SF_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define SF_MIN(a, b) ((a) < (b) ? (a) : (b)) #endif + +#define COMPILE_TIME_ASSERT(e) (sizeof (struct { int : - !! (e) ; })) + + +#define SF_MAX_CHANNELS 256 + + /* -* Macros for spliting the format file of SF_INFI into contrainer type, +* Macros for spliting the format file of SF_INFO into container type, ** codec type and endian-ness. */ #define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK) #define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK) #define SF_ENDIAN(x) ((x) & SF_FORMAT_ENDMASK) - enum { /* PEAK chunk location. */ SF_PEAK_START = 42, @@ -143,6 +153,8 @@ enum enum { /* Work in progress. */ + SF_FORMAT_SPEEX = 0x5000000, + SF_FORMAT_OGGFLAC = 0x5000001, /* Formats supported read only. */ SF_FORMAT_TXW = 0x4030000, /* Yamaha TX16 sampler file */ @@ -162,6 +174,22 @@ enum SF_FORMAT_PCM_N = 0x1030 } ; +/*--------------------------------------------------------------------------------------- +*/ + +typedef struct +{ unsigned kuki_offset ; + unsigned pakt_offset ; + + unsigned bits_per_sample ; + unsigned frames_per_packet ; + + int64_t packets ; + int64_t valid_frames ; + int32_t priming_frames ; + int32_t remainder_frames ; +} ALAC_DECODER_INFO ; + /*--------------------------------------------------------------------------------------- ** PEAK_CHUNK - This chunk type is common to both AIFF and WAVE files although their ** endian encodings are different. @@ -183,19 +211,8 @@ typedef struct /* CAF */ unsigned int edit_number ; -#if HAVE_FLEXIBLE_ARRAY /* the per channel peak info */ PEAK_POS peaks [] ; -#else - /* - ** This is not ISO compliant C. It works on some compilers which - ** don't support the ISO standard flexible struct array which is - ** used above. If your compiler doesn't like this I suggest you find - ** youself a 1999 ISO C standards compilant compiler. GCC-3.X is - ** highly recommended. - */ - PEAK_POS peaks [0] ; -#endif } PEAK_INFO ; static inline PEAK_INFO * @@ -206,94 +223,180 @@ peak_info_calloc (int channels) typedef struct { int type ; int flags ; - char *str ; + size_t offset ; } STR_DATA ; +typedef struct +{ int64_t hash ; + char id [64] ; + unsigned id_size ; + uint32_t mark32 ; + sf_count_t offset ; + uint32_t len ; +} READ_CHUNK ; + +typedef struct +{ int64_t hash ; + uint32_t mark32 ; + uint32_t len ; + void *data ; +} WRITE_CHUNK ; + +typedef struct +{ uint32_t count ; + uint32_t used ; + READ_CHUNK *chunks ; +} READ_CHUNKS ; +typedef struct +{ uint32_t count ; + uint32_t used ; + WRITE_CHUNK *chunks ; +} WRITE_CHUNKS ; + +struct SF_CHUNK_ITERATOR +{ uint32_t current ; + int64_t hash ; + char id [64] ; + unsigned id_size ; + SNDFILE *sndfile ; +} ; + static inline size_t make_size_t (int x) { return (size_t) x ; } /* size_t_of_int */ +typedef SF_BROADCAST_INFO_VAR (16 * 1024) SF_BROADCAST_INFO_16K ; + +typedef SF_CART_INFO_VAR (16 * 1024) SF_CART_INFO_16K ; + +#if SIZEOF_WCHAR_T == 2 +typedef wchar_t sfwchar_t ; +#else +typedef int16_t sfwchar_t ; +#endif + + +static inline void * +psf_memdup (const void *src, size_t n) +{ void * mem = calloc (1, n & 3 ? n + 4 - (n & 3) : n) ; + return memcpy (mem, src, n) ; +} /* psf_memdup */ + +/* +** This version of isprint specifically ignores any locale info. Its used for +** determining which characters can be printed in things like hexdumps. +*/ +static inline int +psf_isprint (int ch) +{ return (ch >= ' ' && ch <= '~') ; +} /* psf_isprint */ + /*======================================================================================= ** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the ** sf_open_XXXX functions. The caller however has no knowledge of the struct's ** contents. */ - typedef struct -{ int size ; - SF_BROADCAST_INFO binfo ; -} SF_BROADCAST_VAR ; - -typedef struct sf_private_tag { - /* Canary in a coal mine. */ - char canary [64] ; - - /* Force the compiler to double align the start of buffer. */ union - { double dbuf [SF_BUFFER_LEN / sizeof (double)] ; -#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8)) - int64_t lbuf [SF_BUFFER_LEN / sizeof (int64_t)] ; -#else - long lbuf [SF_BUFFER_LEN / sizeof (double)] ; -#endif - float fbuf [SF_BUFFER_LEN / sizeof (float)] ; - int ibuf [SF_BUFFER_LEN / sizeof (int)] ; - short sbuf [SF_BUFFER_LEN / sizeof (short)] ; - char cbuf [SF_BUFFER_LEN / sizeof (char)] ; - signed char scbuf [SF_BUFFER_LEN / sizeof (signed char)] ; - unsigned char ucbuf [SF_BUFFER_LEN / sizeof (signed char)] ; - } u ; + { char c [SF_FILENAME_LEN] ; + sfwchar_t wc [SF_FILENAME_LEN] ; + } path ; - char filepath [SF_FILENAME_LEN] ; - char rsrcpath [SF_FILENAME_LEN] ; - char directory [SF_FILENAME_LEN] ; - char filename [SF_FILENAME_LEN / 4] ; + union + { char c [SF_FILENAME_LEN] ; + sfwchar_t wc [SF_FILENAME_LEN] ; + } dir ; - char syserr [SF_SYSERR_LEN] ; - - /* logbuffer and logindex should only be changed within the logging functions - ** of common.c - */ - char logbuffer [SF_BUFFER_LEN] ; - unsigned char header [SF_HEADER_LEN] ; /* Must be unsigned */ - int rwf_endian ; /* Header endian-ness flag. */ - - /* Storage and housekeeping data for adding/reading strings from - ** sound files. - */ - STR_DATA strings [SF_MAX_STRINGS] ; - char str_storage [SF_STR_BUFFER_LEN] ; - char *str_end ; - int str_flags ; - - /* Guard value. If this changes the buffers above have overflowed. */ - int Magick ; - - unsigned unique_id ; - - /* Index variables for maintaining logbuffer and header above. */ - int logindex ; - int headindex, headend ; - int has_text ; - int do_not_close_descriptor ; + union + { char c [SF_FILENAME_LEN / 4] ; + sfwchar_t wc [SF_FILENAME_LEN / 4] ; + } name ; #if USE_WINDOWS_API /* ** These fields can only be used in src/file_io.c. ** They are basically the same as a windows file HANDLE. */ - void *hfile, *hrsrc, *hsaved ; + void *handle, *hsaved ; + + int use_wchar ; #else /* These fields can only be used in src/file_io.c. */ - int filedes, rsrcdes, savedes ; + int filedes, savedes ; #endif + int do_not_close_descriptor ; + int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */ +} PSF_FILE ; + + + +typedef union +{ double dbuf [SF_BUFFER_LEN / sizeof (double)] ; +#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8)) + int64_t lbuf [SF_BUFFER_LEN / sizeof (int64_t)] ; +#else + long lbuf [SF_BUFFER_LEN / sizeof (double)] ; +#endif + float fbuf [SF_BUFFER_LEN / sizeof (float)] ; + int ibuf [SF_BUFFER_LEN / sizeof (int)] ; + short sbuf [SF_BUFFER_LEN / sizeof (short)] ; + char cbuf [SF_BUFFER_LEN / sizeof (char)] ; + signed char scbuf [SF_BUFFER_LEN / sizeof (signed char)] ; + unsigned char ucbuf [SF_BUFFER_LEN / sizeof (signed char)] ; +} BUF_UNION ; + + + +typedef struct sf_private_tag +{ + /* Canary in a coal mine. */ + union + { /* Place a double here to encourage double alignment. */ + double d [2] ; + char c [16] ; + } canary ; + + PSF_FILE file, rsrc ; + + char syserr [SF_SYSERR_LEN] ; + + /* parselog and indx should only be changed within the logging functions + ** of common.c + */ + struct + { char buf [SF_PARSELOG_LEN] ; + int indx ; + } parselog ; + + unsigned char header [SF_HEADER_LEN] ; /* Must be unsigned */ + int rwf_endian ; /* Header endian-ness flag. */ + + /* Storage and housekeeping data for adding/reading strings from + ** sound files. + */ + struct + { STR_DATA data [SF_MAX_STRINGS] ; + char *storage ; + size_t storage_len ; + size_t storage_used ; + uint32_t flags ; + } strings ; + + /* Guard value. If this changes the buffers above have overflowed. */ + int Magick ; + + unsigned unique_id ; + + /* Index variables for maintaining parselog and header above. */ + int headindex, headend ; + int has_text ; + int error ; - int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */ int endian ; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */ int data_endswap ; /* Need to endswap data? */ @@ -323,7 +426,10 @@ typedef struct sf_private_tag SF_INSTRUMENT *instrument ; /* Broadcast (EBU) Info */ - SF_BROADCAST_VAR *broadcast_var ; + SF_BROADCAST_INFO_16K *broadcast_16k ; + + /* Cart (AES46) Info */ + SF_CART_INFO_16K *cart_16k ; /* Channel map data (if present) : an array of ints. */ int *channel_map ; @@ -379,6 +485,7 @@ typedef struct sf_private_tag sf_count_t (*seek) (struct sf_private_tag*, int mode, sf_count_t samples_from_start) ; int (*write_header) (struct sf_private_tag*, int calc_length) ; int (*command) (struct sf_private_tag*, int command, void *data, int datasize) ; + int (*byterate) (struct sf_private_tag*) ; /* ** Separate close functions for the codec and the container. @@ -393,6 +500,17 @@ typedef struct sf_private_tag int virtual_io ; SF_VIRTUAL_IO vio ; void *vio_user_data ; + + /* Chunk get/set. */ + SF_CHUNK_ITERATOR *iterator ; + + READ_CHUNKS rchunks ; + WRITE_CHUNKS wchunks ; + + int (*set_chunk) (struct sf_private_tag*, const SF_CHUNK_INFO * chunk_info) ; + SF_CHUNK_ITERATOR * (*next_chunk_iterator) (struct sf_private_tag*, SF_CHUNK_ITERATOR * iterator) ; + int (*get_chunk_size) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; + int (*get_chunk_data) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; } SF_PRIVATE ; @@ -415,6 +533,7 @@ enum SFE_BAD_FILE_PTR, SFE_BAD_INT_PTR, SFE_BAD_STAT_SIZE, + SFE_NO_TEMP_DIR, SFE_MALLOC_FAILED, SFE_UNIMPLEMENTED, SFE_BAD_READ_ALIGN, @@ -453,6 +572,9 @@ enum SFE_RDWR_BAD_HEADER, SFE_CMD_HAS_DATA, SFE_BAD_BROADCAST_INFO_SIZE, + SFE_BAD_BROADCAST_INFO_TOO_BIG, + SFE_BAD_CART_INFO_SIZE, + SFE_BAD_CART_INFO_TOO_BIG, SFE_STR_NO_SUPPORT, SFE_STR_NOT_WRITE, @@ -506,6 +628,7 @@ enum SFE_PAF_VERSION, SFE_PAF_UNKNOWN_FORMAT, SFE_PAF_SHORT_HEADER, + SFE_PAF_BAD_CHANNELS, SFE_SVX_NO_FORM, SFE_SVX_NO_BODY, @@ -584,6 +707,13 @@ enum SFE_VORBIS_ENCODER_BUG, SFE_RF64_NOT_RF64, + SFE_BAD_CHUNK_PTR, + SFE_UNKNOWN_CHUNK, + SFE_BAD_CHUNK_FORMAT, + SFE_BAD_CHUNK_MARKER, + SFE_BAD_CHUNK_DATA_PTR, + + SFE_ALAC_FAIL_TMPFILE, SFE_MAX_ERROR /* This must be last in list. */ } ; @@ -595,13 +725,13 @@ int u_bitwidth_to_subformat (int bits) ; /* Functions for reading and writing floats and doubles on processors ** with non-IEEE floats/doubles. */ -float float32_be_read (unsigned char *cptr) ; -float float32_le_read (unsigned char *cptr) ; +float float32_be_read (const unsigned char *cptr) ; +float float32_le_read (const unsigned char *cptr) ; void float32_be_write (float in, unsigned char *out) ; void float32_le_write (float in, unsigned char *out) ; -double double64_be_read (unsigned char *cptr) ; -double double64_le_read (unsigned char *cptr) ; +double double64_be_read (const unsigned char *cptr) ; +double double64_le_read (const unsigned char *cptr) ; void double64_be_write (double in, unsigned char *out) ; void double64_le_write (double in, unsigned char *out) ; @@ -612,6 +742,11 @@ void psf_log_SF_INFO (SF_PRIVATE *psf) ; int32_t psf_rand_int32 (void) ; +void append_snprintf (char * dest, size_t maxlen, const char * fmt, ...) ; +void psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) ; + +sf_count_t psf_decode_frame_count (SF_PRIVATE *psf) ; + /* Functions used when writing file headers. */ int psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) ; @@ -665,13 +800,15 @@ int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ; ** some 32 bit OSes. Implementation in file_io.c. */ -int psf_fopen (SF_PRIVATE *psf, const char *pathname, int flags) ; -int psf_set_stdio (SF_PRIVATE *psf, int mode) ; +int psf_fopen (SF_PRIVATE *psf) ; +int psf_set_stdio (SF_PRIVATE *psf) ; int psf_file_valid (SF_PRIVATE *psf) ; void psf_set_file (SF_PRIVATE *psf, int fd) ; void psf_init_files (SF_PRIVATE *psf) ; void psf_use_rsrc (SF_PRIVATE *psf, int on_off) ; +SNDFILE * psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo) ; + sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ; sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; @@ -687,7 +824,7 @@ int psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ; int psf_fclose (SF_PRIVATE *psf) ; /* Open and close the resource fork of a file. */ -int psf_open_rsrc (SF_PRIVATE *psf, int mode) ; +int psf_open_rsrc (SF_PRIVATE *psf) ; int psf_close_rsrc (SF_PRIVATE *psf) ; /* @@ -722,10 +859,16 @@ int caf_open (SF_PRIVATE *psf) ; int mpc2k_open (SF_PRIVATE *psf) ; int rf64_open (SF_PRIVATE *psf) ; +int ogg_vorbis_open (SF_PRIVATE *psf) ; +int ogg_speex_open (SF_PRIVATE *psf) ; +int ogg_pcm_open (SF_PRIVATE *psf) ; +int ogg_opus_open (SF_PRIVATE *psf) ; +int ogg_open (SF_PRIVATE *psf) ; + + /* In progress. Do not currently work. */ int mpeg_open (SF_PRIVATE *psf) ; -int ogg_open (SF_PRIVATE *psf) ; int rx2_open (SF_PRIVATE *psf) ; int txw_open (SF_PRIVATE *psf) ; int wve_open (SF_PRIVATE *psf) ; @@ -747,6 +890,7 @@ int gsm610_init (SF_PRIVATE *psf) ; int vox_adpcm_init (SF_PRIVATE *psf) ; int flac_init (SF_PRIVATE *psf) ; int g72x_init (SF_PRIVATE * psf) ; +int alac_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) ; int dither_init (SF_PRIVATE *psf, int mode) ; @@ -761,18 +905,51 @@ int interleave_init (SF_PRIVATE *psf) ; ** Chunk logging functions. */ -typedef struct -{ struct - { int chunk ; - sf_count_t offset ; - sf_count_t len ; - } l [100] ; +SF_CHUNK_ITERATOR * psf_get_chunk_iterator (SF_PRIVATE * psf, const char * marker_str) ; +SF_CHUNK_ITERATOR * psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR *iterator) ; +int psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len) ; +int psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker, sf_count_t offset, uint32_t len) ; +int psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info) ; +int psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker) ; +int psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker) ; +int psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker) ; - int count ; -} PRIV_CHUNK4 ; +int psf_find_write_chunk (WRITE_CHUNKS * pchk, const char * marker) ; -void pchk4_store (PRIV_CHUNK4 * pchk, int marker, sf_count_t offset, sf_count_t len) ; -int pchk4_find (PRIV_CHUNK4 * pchk, int marker) ; +static inline int +fourcc_to_marker (const SF_CHUNK_INFO * chunk_info) +{ const unsigned char * cptr ; + + if (chunk_info->id_size != 4) + return 0 ; + + cptr = (const unsigned char *) chunk_info->id ; + return (cptr [3] << 24) + (cptr [2] << 16) + (cptr [1] << 8) + cptr [0] ; +} /* fourcc_to_marker */ + +/*------------------------------------------------------------------------------------ +** Functions that work like OpenBSD's strlcpy/strlcat to replace strncpy/strncat. +** +** See : http://www.gratisoft.us/todd/papers/strlcpy.html +** +** These functions are available on *BSD, but are not avaialble everywhere so we +** implement them here. +** +** The argument order has been changed to that of strncpy/strncat to cause +** compiler errors if code is carelessly converted from one to the other. +*/ + +static inline void +psf_strlcat (char *dest, size_t n, const char *src) +{ strncat (dest, src, n - strlen (dest) - 1) ; + dest [n - 1] = 0 ; +} /* psf_strlcat */ + +static inline void +psf_strlcpy (char *dest, size_t n, const char *src) +{ strncpy (dest, src, n - 1) ; + dest [n - 1] = 0 ; +} /* psf_strlcpy */ /*------------------------------------------------------------------------------------ ** Other helper functions. @@ -787,18 +964,26 @@ void psf_sanitize_string (char * cptr, int len) ; /* Generate the current date as a string. */ void psf_get_date_str (char *str, int maxlen) ; -SF_BROADCAST_VAR* broadcast_var_alloc (size_t datasize) ; +SF_BROADCAST_INFO_16K * broadcast_var_alloc (void) ; int broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * data, size_t datasize) ; int broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize) ; +SF_CART_INFO_16K * cart_var_alloc (void) ; +int cart_var_set (SF_PRIVATE *psf, const SF_CART_INFO * date, size_t datasize) ; +int cart_var_get (SF_PRIVATE *psf, SF_CART_INFO * data, size_t datasize) ; + typedef struct { int channels ; int endianness ; } AUDIO_DETECT ; int audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) ; +int id3_skip (SF_PRIVATE * psf) ; +void alac_get_desc_chunk_items (int subformat, uint32_t *fmt_flags, uint32_t *frames_per_packet) ; + +FILE * psf_open_tmpfile (char * fname, size_t fnamelen) ; /*------------------------------------------------------------------------------------ ** Helper/debug functions. @@ -834,5 +1019,26 @@ int sf_dither_float (const SF_DITHER_INFO *dither, const float *in, float *out, int sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double *out, int count) ; #endif +/*------------------------------------------------------------------------------------ +** Data conversion functions. +*/ + +static inline short +psf_short_of_int (int x) +{ return (x >> 16) ; +} + +void psf_f2s_array (const float *src, short *dest, int count, int normalize) ; +void psf_f2s_clip_array (const float *src, short *dest, int count, int normalize) ; + +void psf_d2s_array (const double *src, short *dest, int count, int normalize) ; +void psf_d2s_clip_array (const double *src, short *dest, int count, int normalize) ; + +void psf_f2i_array (const float *src, int *dest, int count, int normalize) ; +void psf_f2i_clip_array (const float *src, int *dest, int count, int normalize) ; + +void psf_d2i_array (const double *src, int *dest, int count, int normalize) ; +void psf_d2i_clip_array (const double *src, int *dest, int count, int normalize) ; + #endif /* SNDFILE_COMMON_H */ diff --git a/libs/libsndfile/src/create_symbols_file.py b/libs/libsndfile/src/create_symbols_file.py index a91e89edb2..15b1ccaf4b 100755 --- a/libs/libsndfile/src/create_symbols_file.py +++ b/libs/libsndfile/src/create_symbols_file.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright (C) 2003-2007 Erik de Castro Lopo +# Copyright (C) 2003-2012 Erik de Castro Lopo # # All rights reserved. # @@ -39,89 +39,107 @@ import re, sys # the ordinal values in the second column. ALL_SYMBOLS = ( - ( "sf_command", 1 ), - ( "sf_open", 2 ), - ( "sf_close", 3 ), - ( "sf_seek", 4 ), - ( "sf_error", 7 ), - ( "sf_perror", 8 ), - ( "sf_error_str", 9 ), - ( "sf_error_number", 10 ), - ( "sf_format_check", 11 ), - ( "sf_read_raw", 16 ), - ( "sf_readf_short", 17 ), - ( "sf_readf_int", 18 ), - ( "sf_readf_float", 19 ), - ( "sf_readf_double", 20 ), - ( "sf_read_short", 21 ), - ( "sf_read_int", 22 ), - ( "sf_read_float", 23 ), - ( "sf_read_double", 24 ), - ( "sf_write_raw", 32 ), - ( "sf_writef_short", 33 ), - ( "sf_writef_int", 34 ), - ( "sf_writef_float", 35 ), - ( "sf_writef_double", 36 ), - ( "sf_write_short", 37 ), - ( "sf_write_int", 38 ), - ( "sf_write_float", 39 ), - ( "sf_write_double", 40 ), - ( "sf_strerror", 50 ), - ( "sf_get_string", 60 ), - ( "sf_set_string", 61 ), - ( "sf_open_fd", 70 ), - ( "sf_open_virtual", 80 ), - ( "sf_write_sync", 90 ) + ( "sf_command", 1 ), + ( "sf_open", 2 ), + ( "sf_close", 3 ), + ( "sf_seek", 4 ), + ( "sf_error", 7 ), + ( "sf_perror", 8 ), + ( "sf_error_str", 9 ), + ( "sf_error_number", 10 ), + ( "sf_format_check", 11 ), + ( "sf_read_raw", 16 ), + ( "sf_readf_short", 17 ), + ( "sf_readf_int", 18 ), + ( "sf_readf_float", 19 ), + ( "sf_readf_double", 20 ), + ( "sf_read_short", 21 ), + ( "sf_read_int", 22 ), + ( "sf_read_float", 23 ), + ( "sf_read_double", 24 ), + ( "sf_write_raw", 32 ), + ( "sf_writef_short", 33 ), + ( "sf_writef_int", 34 ), + ( "sf_writef_float", 35 ), + ( "sf_writef_double", 36 ), + ( "sf_write_short", 37 ), + ( "sf_write_int", 38 ), + ( "sf_write_float", 39 ), + ( "sf_write_double", 40 ), + ( "sf_strerror", 50 ), + ( "sf_get_string", 60 ), + ( "sf_set_string", 61 ), + ( "sf_version_string", 68 ), + ( "sf_open_fd", 70 ), + ( "sf_wchar_open", 71 ), + ( "sf_open_virtual", 80 ), + ( "sf_write_sync", 90 ), + ( "sf_set_chunk", 100 ), + ( "sf_get_chunk_size", 101 ), + ( "sf_get_chunk_data", 102 ), + ( "sf_get_chunk_iterator", 103 ), + ( "sf_next_chunk_iterator", 104 ), + ( "sf_current_byterate", 110 ) ) #------------------------------------------------------------------------------- def linux_symbols (progname, version): - print "# Auto-generated by %s\n" %progname - print "libsndfile.so.%s" % version - print "{" - print " global:" + print ("# Auto-generated by %s\n" %progname) + print ("libsndfile.so.%s" % version) + print ("{") + print (" global:") for name, ordinal in ALL_SYMBOLS: - print " %s ;" % name - print " local:" - print " * ;" - print "} ;" - print + if name == "sf_wchar_open": + continue + print (" %s ;" % name) + print (" local:") + print (" * ;") + print ("} ;") + sys.stdout.write ("\n") return def darwin_symbols (progname, version): - print "# Auto-generated by %s\n" %progname + print ("# Auto-generated by %s\n" %progname) for name, ordinal in ALL_SYMBOLS: - print "_%s" % name - print + if name == "sf_wchar_open": + continue + print ("_%s" % name) + sys.stdout.write ("\n") return def win32_symbols (progname, version, name): - print "; Auto-generated by %s\n" %progname - print "LIBRARY %s-%s.dll" % (name, re.sub ("\..*", "", version)) - print "EXPORTS\n" + print ("; Auto-generated by %s\n" %progname) + print ("LIBRARY %s-%s.dll" % (name, re.sub ("\..*", "", version))) + print ("EXPORTS\n") for name, ordinal in ALL_SYMBOLS: - print "%-20s @%s" % (name, ordinal) - print + print ("%-20s @%s" % (name, ordinal)) + sys.stdout.write ("\n") return def os2_symbols (progname, version, name): - print "; Auto-generated by %s\n" %progname - print "LIBRARY %s%s.dll" % (name, re.sub ("\..*", "", version)) - print "INITINSTANCE TERMINSTANCE" - print "CODE PRELOAD MOVEABLE DISCARDABLE" - print "DATA PRELOAD MOVEABLE MULTIPLE NONSHARED" - print "EXPORTS\n" + print ("; Auto-generated by %s\n" %progname) + print ("LIBRARY %s%s" % (name, re.sub ("\..*", "", version))) + print ("INITINSTANCE TERMINSTANCE") + print ("CODE PRELOAD MOVEABLE DISCARDABLE") + print ("DATA PRELOAD MOVEABLE MULTIPLE NONSHARED") + print ("EXPORTS\n") for name, ordinal in ALL_SYMBOLS: - print "_%-20s @%s" % (name, ordinal) - print + if name == "sf_wchar_open": + continue + print ("_%-20s @%s" % (name, ordinal)) + sys.stdout.write ("\n") return +def plain_symbols (progname, version, name): + for name, ordinal in ALL_SYMBOLS: + print (name) + def no_symbols (os_name): - print - print "No known way of restricting exported symbols on '%s'." % os_name - print "If you know a way, please contact the author." - print + sys.stdout.write ("\n") + print ("No known way of restricting exported symbols on '%s'." % os_name) + print ("If you know a way, please contact the author.") + sys.stdout.write ("\n") return #------------------------------------------------------------------------------- @@ -129,22 +147,23 @@ def no_symbols (os_name): progname = re.sub (".*[\\/]", "", sys.argv [0]) if len (sys.argv) != 3: - print - print "Usage : %s ." % progname - print - print " Currently supported values for target OS are:" - print " linux" - print " darwin (ie MacOSX)" - print " win32 (ie wintendo)" - print " cygwin (Cygwin on wintendo)" - print " os2 (OS/2)" - print + sys.stdout.write ("\n") + print ("Usage : %s ." % progname) + sys.stdout.write ("\n") + print (" Currently supported values for target OS are:") + print (" linux") + print (" darwin (ie MacOSX)") + print (" win32 (ie wintendo)") + print (" cygwin (Cygwin on wintendo)") + print (" os2 (OS/2)") + print (" plain (plain list of symbols)") + sys.stdout.write ("\n") sys.exit (1) os_name = sys.argv [1] version = re.sub ("\.[a-z0-9]+$", "", sys.argv [2]) -if os_name == "linux": +if os_name == "linux" or os_name == "gnu" or os_name == "binutils": linux_symbols (progname, version) elif os_name == "darwin": darwin_symbols (progname, version) @@ -154,6 +173,8 @@ elif os_name == "cygwin": win32_symbols (progname, version, "cygsndfile") elif os_name == "os2": os2_symbols (progname, version, "sndfile") +elif os_name == "static": + plain_symbols (progname, version, "") else: no_symbols (os_name) diff --git a/libs/libsndfile/src/dither.c b/libs/libsndfile/src/dither.c index d6284ac72b..d149bc1b68 100644 --- a/libs/libsndfile/src/dither.c +++ b/libs/libsndfile/src/dither.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/double64.c b/libs/libsndfile/src/double64.c index 7f5e107fbb..ce60699e61 100644 --- a/libs/libsndfile/src/double64.c +++ b/libs/libsndfile/src/double64.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -95,7 +95,7 @@ double64_init (SF_PRIVATE *psf) psf->blockwidth = sizeof (double) * psf->sf.channels ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { switch (psf->endian + double64_caps) { case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) : psf->data_endswap = SF_FALSE ; @@ -166,7 +166,7 @@ double64_init (SF_PRIVATE *psf) } ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { switch (psf->endian + double64_caps) { case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) : psf->data_endswap = SF_FALSE ; @@ -276,7 +276,7 @@ double64_init (SF_PRIVATE *psf) */ double -double64_be_read (unsigned char *cptr) +double64_be_read (const unsigned char *cptr) { int exponent, negative, upper, lower ; double dvalue ; @@ -309,7 +309,7 @@ double64_be_read (unsigned char *cptr) } /* double64_be_read */ double -double64_le_read (unsigned char *cptr) +double64_le_read (const unsigned char *cptr) { int exponent, negative, upper, lower ; double dvalue ; @@ -554,24 +554,25 @@ f2d_array (const float *src, double *dest, int count) static sf_count_t host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ void (*convert) (const double *, int, short *, double) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, int, short *, double) ; int bufferlen, readcount ; sf_count_t total = 0 ; double scale ; convert = (psf->add_clipping) ? d2s_clip_array : d2s_array ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, readcount) ; + endswap_double_array (ubuf.dbuf, readcount) ; - convert (psf->u.dbuf, readcount, ptr + total, scale) ; + convert (ubuf.dbuf, readcount, ptr + total, scale) ; total += readcount ; len -= readcount ; if (readcount < bufferlen) @@ -583,24 +584,25 @@ host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ void (*convert) (const double *, int, int *, double) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, int, int *, double) ; int bufferlen, readcount ; sf_count_t total = 0 ; double scale ; convert = (psf->add_clipping) ? d2i_clip_array : d2i_array ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - convert (psf->u.dbuf, readcount, ptr + total, scale) ; + convert (ubuf.dbuf, readcount, ptr + total, scale) ; total += readcount ; len -= readcount ; if (readcount < bufferlen) @@ -612,20 +614,21 @@ host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - d2f_array (psf->u.dbuf, readcount, ptr + total) ; + d2f_array (ubuf.dbuf, readcount, ptr + total) ; total += readcount ; len -= readcount ; if (readcount < bufferlen) @@ -667,26 +670,27 @@ host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ; + s2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; if (psf->peak_info) - double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ; + double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -698,25 +702,26 @@ host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ; + i2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; if (psf->peak_info) - double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ; + double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -728,23 +733,24 @@ host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2d_array (ptr + total, psf->u.dbuf, bufferlen) ; + f2d_array (ptr + total, ubuf.dbuf, bufferlen) ; if (psf->peak_info) - double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ; + double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -756,7 +762,8 @@ host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (psf->peak_info) @@ -765,15 +772,15 @@ host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) if (psf->data_endswap != SF_TRUE) return psf_fwrite (ptr, sizeof (double), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_double_copy (psf->u.dbuf, ptr + total, bufferlen) ; + endswap_double_copy (ubuf.dbuf, ptr + total, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -788,24 +795,25 @@ host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) static sf_count_t replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double scale ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - d2bd_read (psf->u.dbuf, bufferlen) ; + d2bd_read (ubuf.dbuf, bufferlen) ; - d2s_array (psf->u.dbuf, readcount, ptr + total, scale) ; + d2s_array (ubuf.dbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -817,24 +825,25 @@ replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double scale ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - d2bd_read (psf->u.dbuf, bufferlen) ; + d2bd_read (ubuf.dbuf, bufferlen) ; - d2i_array (psf->u.dbuf, readcount, ptr + total, scale) ; + d2i_array (ubuf.dbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -846,22 +855,23 @@ replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - d2bd_read (psf->u.dbuf, bufferlen) ; + d2bd_read (ubuf.dbuf, bufferlen) ; - memcpy (ptr + total, psf->u.dbuf, bufferlen * sizeof (double)) ; + memcpy (ptr + total, ubuf.dbuf, bufferlen * sizeof (double)) ; total += readcount ; if (readcount < bufferlen) @@ -874,23 +884,24 @@ replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; /* FIXME : This is probably nowhere near optimal. */ - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, readcount) ; + endswap_double_array (ubuf.dbuf, readcount) ; - d2bd_read (psf->u.dbuf, readcount) ; + d2bd_read (ubuf.dbuf, readcount) ; - memcpy (ptr + total, psf->u.dbuf, readcount * sizeof (double)) ; + memcpy (ptr + total, ubuf.dbuf, readcount * sizeof (double)) ; total += readcount ; if (readcount < bufferlen) @@ -903,27 +914,28 @@ replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ; + s2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; if (psf->peak_info) - double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ; + double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - bd2d_write (psf->u.dbuf, bufferlen) ; + bd2d_write (ubuf.dbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -935,27 +947,28 @@ replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ; + i2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; if (psf->peak_info) - double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ; + double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - bd2d_write (psf->u.dbuf, bufferlen) ; + bd2d_write (ubuf.dbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -967,22 +980,23 @@ replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2d_array (ptr + total, psf->u.dbuf, bufferlen) ; + f2d_array (ptr + total, ubuf.dbuf, bufferlen) ; - bd2d_write (psf->u.dbuf, bufferlen) ; + bd2d_write (ubuf.dbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -994,27 +1008,28 @@ replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; /* FIXME : This is probably nowhere near optimal. */ if (psf->peak_info) double64_peak_update (psf, ptr, len, 0) ; - bufferlen = ARRAY_LEN (psf->u.dbuf) ; + bufferlen = ARRAY_LEN (ubuf.dbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - memcpy (psf->u.dbuf, ptr + total, bufferlen * sizeof (double)) ; + memcpy (ubuf.dbuf, ptr + total, bufferlen * sizeof (double)) ; - bd2d_write (psf->u.dbuf, bufferlen) ; + bd2d_write (ubuf.dbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_double_array (psf->u.dbuf, bufferlen) ; + endswap_double_array (ubuf.dbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; diff --git a/libs/libsndfile/src/dwd.c b/libs/libsndfile/src/dwd.c index 943c6d0a9e..af4d9f0e41 100644 --- a/libs/libsndfile/src/dwd.c +++ b/libs/libsndfile/src/dwd.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -69,9 +69,9 @@ static int dwd_close (SF_PRIVATE *psf) ; int dwd_open (SF_PRIVATE *psf) -{ int subformat, error = 0 ; +{ int error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = dwd_read_header (psf))) return error ; } ; @@ -79,9 +79,7 @@ dwd_open (SF_PRIVATE *psf) if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_DWD) return SFE_BAD_OPEN_FORMAT ; - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { /*-psf->endian = SF_ENDIAN (psf->sf.format) ; if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU) @@ -124,16 +122,17 @@ typedef struct static int dwd_read_header (SF_PRIVATE *psf) -{ DWD_HEADER dwdh ; +{ BUF_UNION ubuf ; + DWD_HEADER dwdh ; - memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ; + memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, DWD_IDENTIFIER_LEN) ; + psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, DWD_IDENTIFIER_LEN) ; - if (memcmp (psf->u.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0) + if (memcmp (ubuf.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0) return SFE_DWD_NO_DWD ; - psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", psf->u.cbuf) ; + psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", ubuf.cbuf) ; psf_binheader_readf (psf, "11", &dwdh.major, &dwdh.minor) ; psf_binheader_readf (psf, "e4j1", &dwdh.id, 1, &dwdh.compression) ; @@ -152,9 +151,9 @@ dwd_read_header (SF_PRIVATE *psf) else psf_log_printf (psf, "None\n") ; - psf_log_printf (psf, " Sample Rate : %d\n Channels : %d\n" - " Bit Width : %d\n", - dwdh.srate, dwdh.channels, dwdh.bitwidth) ; + psf_log_printf (psf, " Sample Rate : %d\n Channels : %d\n" + " Bit Width : %d\n", + dwdh.srate, dwdh.channels, dwdh.bitwidth) ; switch (dwdh.bitwidth) { case 8 : diff --git a/libs/libsndfile/src/dwvw.c b/libs/libsndfile/src/dwvw.c index d5537f1a23..ddf86f63d5 100644 --- a/libs/libsndfile/src/dwvw.c +++ b/libs/libsndfile/src/dwvw.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -38,7 +38,7 @@ #include "common.h" typedef struct -{ int dwm_maxsize, bit_width, max_delta, span ; +{ int bit_width, dwm_maxsize, max_delta, span ; int samplecount ; int bit_count, bits, last_delta_width, last_sample ; struct @@ -61,7 +61,8 @@ static sf_count_t dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t le static sf_count_t dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; static sf_count_t dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static int dwvw_close (SF_PRIVATE *psf) ; +static int dwvw_close (SF_PRIVATE *psf) ; +static int dwvw_byterate (SF_PRIVATE *psf) ; static int dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) ; static int dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) ; @@ -86,29 +87,24 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth) if (bitwidth > 24) return SFE_DWVW_BAD_BITWIDTH ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; if ((pdwvw = calloc (1, sizeof (DWVW_PRIVATE))) == NULL) return SFE_MALLOC_FAILED ; psf->codec_data = (void*) pdwvw ; - pdwvw->bit_width = bitwidth ; - pdwvw->dwm_maxsize = bitwidth / 2 ; - pdwvw->max_delta = 1 << (bitwidth - 1) ; - pdwvw->span = 1 << bitwidth ; - dwvw_read_reset (pdwvw) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->read_short = dwvw_read_s ; psf->read_int = dwvw_read_i ; psf->read_float = dwvw_read_f ; psf->read_double = dwvw_read_d ; } ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->write_short = dwvw_write_s ; psf->write_int = dwvw_write_i ; psf->write_float = dwvw_write_f ; @@ -117,11 +113,12 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth) psf->codec_close = dwvw_close ; psf->seek = dwvw_seek ; + psf->byterate = dwvw_byterate ; - /* FIXME : This is bogus. */ - psf->sf.frames = SF_COUNT_MAX ; - psf->datalength = psf->sf.frames ; - /* EMXIF : This is bogus. */ + if (psf->file.mode == SFM_READ) + { psf->sf.frames = psf_decode_frame_count (psf) ; + dwvw_read_reset (pdwvw) ; + } ; return 0 ; } /* dwvw_init */ @@ -137,7 +134,7 @@ dwvw_close (SF_PRIVATE *psf) return 0 ; pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { static int last_values [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ; /* Write 8 zero samples to fully flush output. */ @@ -174,6 +171,14 @@ dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) return PSF_SEEK_ERROR ; } /* dwvw_seek */ +static int +dwvw_byterate (SF_PRIVATE *psf) +{ + if (psf->file.mode == SFM_READ) + return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; + + return -1 ; +} /* dwvw_byterate */ /*============================================================================== */ @@ -181,6 +186,7 @@ dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) static sf_count_t dwvw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; + BUF_UNION ubuf ; int *iptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -189,8 +195,8 @@ dwvw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) return 0 ; pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; @@ -234,8 +240,9 @@ dwvw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; - int *iptr ; - int k, bufferlen, readcount = 0, count ; + BUF_UNION ubuf ; + int *iptr ; + int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; float normfact ; @@ -245,8 +252,8 @@ dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; @@ -265,8 +272,9 @@ dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; - int *iptr ; - int k, bufferlen, readcount = 0, count ; + BUF_UNION ubuf ; + int *iptr ; + int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; double normfact ; @@ -276,8 +284,8 @@ dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; @@ -307,7 +315,7 @@ dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) delta_width_modifier = dwvw_decode_load_bits (psf, pdwvw, -1) ; /* Check for end of input bit stream. Break loop if end. */ - if (delta_width_modifier < 0) + if (delta_width_modifier < 0 || (pdwvw->b.end == 0 && count == 0)) break ; if (delta_width_modifier && dwvw_decode_load_bits (psf, pdwvw, 1)) @@ -406,13 +414,14 @@ dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) static void dwvw_read_reset (DWVW_PRIVATE *pdwvw) -{ pdwvw->samplecount = 0 ; - pdwvw->b.index = 0 ; - pdwvw->b.end = 0 ; - pdwvw->bit_count = 0 ; - pdwvw->bits = 0 ; - pdwvw->last_delta_width = 0 ; - pdwvw->last_sample = 0 ; +{ int bitwidth = pdwvw->bit_width ; + + memset (pdwvw, 0, sizeof (DWVW_PRIVATE)) ; + + pdwvw->bit_width = bitwidth ; + pdwvw->dwm_maxsize = bitwidth / 2 ; + pdwvw->max_delta = 1 << (bitwidth - 1) ; + pdwvw->span = 1 << bitwidth ; } /* dwvw_read_reset */ static void @@ -461,9 +470,9 @@ dump_bits (DWVW_PRIVATE *pdwvw) } /* dump_bits */ #endif -#define HIGHEST_BIT(x,count) \ +#define HIGHEST_BIT(x, count) \ { int y = x ; \ - (count) = 0 ; \ + (count) = 0 ; \ while (y) \ { (count) ++ ; \ y >>= 1 ; \ @@ -548,6 +557,7 @@ dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len) static sf_count_t dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; + BUF_UNION ubuf ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -556,8 +566,8 @@ dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) return 0 ; pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -601,6 +611,7 @@ dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; + BUF_UNION ubuf ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -612,8 +623,8 @@ dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -632,6 +643,7 @@ dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { DWVW_PRIVATE *pdwvw ; + BUF_UNION ubuf ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -643,8 +655,8 @@ dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) diff --git a/libs/libsndfile/src/file_io.c b/libs/libsndfile/src/file_io.c index b5ec7c39ce..26d3d6d6ae 100644 --- a/libs/libsndfile/src/file_io.c +++ b/libs/libsndfile/src/file_io.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2013 Erik de Castro Lopo ** Copyright (C) 2003 Ross Bencina ** ** This program is free software; you can redistribute it and/or modify @@ -73,26 +73,24 @@ static void psf_log_syserr (SF_PRIVATE *psf, int error) ; */ static int psf_close_fd (int fd) ; -static int psf_open_fd (const char * path, int mode) ; +static int psf_open_fd (PSF_FILE * pfile) ; static sf_count_t psf_get_filelen_fd (int fd) ; int -psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode) +psf_fopen (SF_PRIVATE *psf) { psf->error = 0 ; - psf->filedes = psf_open_fd (pathname, open_mode) ; + psf->file.filedes = psf_open_fd (&psf->file) ; - if (psf->filedes == - SFE_BAD_OPEN_MODE) + if (psf->file.filedes == - SFE_BAD_OPEN_MODE) { psf->error = SFE_BAD_OPEN_MODE ; - psf->filedes = -1 ; + psf->file.filedes = -1 ; return psf->error ; } ; - if (psf->filedes == -1) + if (psf->file.filedes == -1) psf_log_syserr (psf, errno) ; - psf->mode = open_mode ; - return psf->error ; } /* psf_fopen */ @@ -100,43 +98,40 @@ int psf_fclose (SF_PRIVATE *psf) { int retval ; - if (psf->filedes == -1) - return -1; /* already closed */ - if (psf->virtual_io) return 0 ; - if (psf->do_not_close_descriptor) - { psf->filedes = -1 ; + if (psf->file.do_not_close_descriptor) + { psf->file.filedes = -1 ; return 0 ; } ; - if ((retval = psf_close_fd (psf->filedes)) == -1) + if ((retval = psf_close_fd (psf->file.filedes)) == -1) psf_log_syserr (psf, errno) ; - psf->filedes = -1 ; + psf->file.filedes = -1 ; return retval ; } /* psf_fclose */ int -psf_open_rsrc (SF_PRIVATE *psf, int open_mode) +psf_open_rsrc (SF_PRIVATE *psf) { - if (psf->rsrcdes > 0) + if (psf->rsrc.filedes > 0) return 0 ; /* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s/..namedfork/rsrc", psf->file.path.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ; - if (psf->rsrclength > 0 || (open_mode & SFM_WRITE)) + if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) + { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; + if (psf->rsrclength > 0 || (psf->rsrc.mode & SFM_WRITE)) return SFE_NO_ERROR ; - psf_close_fd (psf->rsrcdes) ; - psf->rsrcdes = -1 ; + psf_close_fd (psf->rsrc.filedes) ; + psf->rsrc.filedes = -1 ; } ; - if (psf->rsrcdes == - SFE_BAD_OPEN_MODE) + if (psf->rsrc.filedes == - SFE_BAD_OPEN_MODE) { psf->error = SFE_BAD_OPEN_MODE ; return psf->error ; } ; @@ -145,10 +140,10 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode) ** Now try for a resource fork stored as a separate file in the same ** directory, but preceded with a dot underscore. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s._%s", psf->file.dir.c, psf->file.name.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ; + if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) + { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; return SFE_NO_ERROR ; } ; @@ -156,18 +151,18 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode) ** Now try for a resource fork stored in a separate file in the ** .AppleDouble/ directory. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s.AppleDouble/%s", psf->file.dir.c, psf->file.name.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ; + if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) + { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; return SFE_NO_ERROR ; } ; /* No resource file found. */ - if (psf->rsrcdes == -1) + if (psf->rsrc.filedes == -1) psf_log_syserr (psf, errno) ; - psf->rsrcdes = -1 ; + psf->rsrc.filedes = -1 ; return psf->error ; } /* psf_open_rsrc */ @@ -179,7 +174,7 @@ psf_get_filelen (SF_PRIVATE *psf) if (psf->virtual_io) return psf->vio.get_filelen (psf->vio_user_data) ; - filelen = psf_get_filelen_fd (psf->filedes) ; + filelen = psf_get_filelen_fd (psf->file.filedes) ; if (filelen == -1) { psf_log_syserr (psf, errno) ; @@ -191,7 +186,7 @@ psf_get_filelen (SF_PRIVATE *psf) return (sf_count_t) -1 ; } ; - switch (psf->mode) + switch (psf->file.mode) { case SFM_WRITE : filelen = filelen - psf->fileoffset ; break ; @@ -219,28 +214,26 @@ psf_get_filelen (SF_PRIVATE *psf) int psf_close_rsrc (SF_PRIVATE *psf) -{ - if (psf->rsrcdes >= 0) - psf_close_fd (psf->rsrcdes) ; - psf->rsrcdes = -1 ; +{ psf_close_fd (psf->rsrc.filedes) ; + psf->rsrc.filedes = -1 ; return 0 ; } /* psf_close_rsrc */ int -psf_set_stdio (SF_PRIVATE *psf, int mode) +psf_set_stdio (SF_PRIVATE *psf) { int error = 0 ; - switch (mode) + switch (psf->file.mode) { case SFM_RDWR : error = SFE_OPEN_PIPE_RDWR ; break ; case SFM_READ : - psf->filedes = 0 ; + psf->file.filedes = 0 ; break ; case SFM_WRITE : - psf->filedes = 1 ; + psf->file.filedes = 1 ; break ; default : @@ -254,29 +247,31 @@ psf_set_stdio (SF_PRIVATE *psf, int mode) void psf_set_file (SF_PRIVATE *psf, int fd) -{ psf->filedes = fd ; +{ psf->file.filedes = fd ; } /* psf_set_file */ int psf_file_valid (SF_PRIVATE *psf) -{ return (psf->filedes >= 0) ? SF_TRUE : SF_FALSE ; +{ return (psf->file.filedes >= 0) ? SF_TRUE : SF_FALSE ; } /* psf_set_file */ sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) -{ sf_count_t new_position ; +{ sf_count_t current_pos, new_position ; if (psf->virtual_io) return psf->vio.seek (offset, whence, psf->vio_user_data) ; + current_pos = psf_ftell (psf) ; + switch (whence) { case SEEK_SET : offset += psf->fileoffset ; break ; case SEEK_END : - if (psf->mode == SFM_WRITE) - { new_position = lseek (psf->filedes, offset, whence) ; + if (psf->file.mode == SFM_WRITE) + { new_position = lseek (psf->file.filedes, offset, whence) ; if (new_position < 0) psf_log_syserr (psf, errno) ; @@ -289,15 +284,25 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ** get the offset wrt the start of file. */ whence = SEEK_SET ; - offset = lseek (psf->filedes, 0, SEEK_END) + offset ; + offset = lseek (psf->file.filedes, 0, SEEK_END) + offset ; + break ; + + case SEEK_CUR : + /* Translate a SEEK_CUR into a SEEK_SET. */ + offset += current_pos ; + whence = SEEK_SET ; break ; default : - /* No need to do anything about SEEK_CUR. */ - break ; + /* We really should not be here. */ + psf_log_printf (psf, "psf_fseek : whence is %d *****.\n", whence) ; + return 0 ; } ; - new_position = lseek (psf->filedes, offset, whence) ; + if (current_pos != offset) + new_position = lseek (psf->file.filedes, offset, whence) ; + else + new_position = offset ; if (new_position < 0) psf_log_syserr (psf, errno) ; @@ -325,7 +330,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { /* Break the read down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - count = read (psf->filedes, ((char*) ptr) + total, (size_t) count) ; + count = read (psf->file.filedes, ((char*) ptr) + total, (size_t) count) ; if (count == -1) { if (errno == EINTR) @@ -366,7 +371,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf { /* Break the writes down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ; - count = write (psf->filedes, ((const char*) ptr) + total, count) ; + count = write (psf->file.filedes, ((const char*) ptr) + total, count) ; if (count == -1) { if (errno == EINTR) @@ -399,7 +404,7 @@ psf_ftell (SF_PRIVATE *psf) if (psf->is_pipe) return psf->pipeoffset ; - pos = lseek (psf->filedes, 0, SEEK_CUR) ; + pos = lseek (psf->file.filedes, 0, SEEK_CUR) ; if (pos == ((sf_count_t) -1)) { psf_log_syserr (psf, errno) ; @@ -413,6 +418,9 @@ static int psf_close_fd (int fd) { int retval ; + if (fd < 0) + return 0 ; + while ((retval = close (fd)) == -1 && errno == EINTR) /* Do nothing. */ ; @@ -425,7 +433,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) sf_count_t count ; while (k < bufsize - 1) - { count = read (psf->filedes, &(buffer [k]), 1) ; + { count = read (psf->file.filedes, &(buffer [k]), 1) ; if (count == -1) { if (errno == EINTR) @@ -451,7 +459,7 @@ psf_is_pipe (SF_PRIVATE *psf) if (psf->virtual_io) return SF_FALSE ; - if (fstat (psf->filedes, &statbuf) == -1) + if (fstat (psf->file.filedes, &statbuf) == -1) { psf_log_syserr (psf, errno) ; /* Default to maximum safety. */ return SF_TRUE ; @@ -465,19 +473,22 @@ psf_is_pipe (SF_PRIVATE *psf) static sf_count_t psf_get_filelen_fd (int fd) -{ struct stat statbuf ; +{ +#if (SIZEOF_OFF_T == 4 && SIZEOF_SF_COUNT_T == 8 && HAVE_FSTAT64) + struct stat64 statbuf ; - /* - ** Sanity check. - ** If everything is OK, this will be optimised out. - */ - if (sizeof (statbuf.st_size) == 4 && sizeof (sf_count_t) == 8) - return (sf_count_t) -SFE_BAD_STAT_SIZE ; + if (fstat64 (fd, &statbuf) == -1) + return (sf_count_t) -1 ; + + return statbuf.st_size ; +#else + struct stat statbuf ; if (fstat (fd, &statbuf) == -1) return (sf_count_t) -1 ; return statbuf.st_size ; +#endif } /* psf_get_filelen_fd */ int @@ -491,7 +502,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) if ((sizeof (off_t) < sizeof (sf_count_t)) && len > 0x7FFFFFFF) return -1 ; - retval = ftruncate (psf->filedes, len) ; + retval = ftruncate (psf->file.filedes, len) ; if (retval == -1) psf_log_syserr (psf, errno) ; @@ -501,28 +512,28 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) void psf_init_files (SF_PRIVATE *psf) -{ psf->filedes = -1 ; - psf->rsrcdes = -1 ; - psf->savedes = -1 ; +{ psf->file.filedes = -1 ; + psf->rsrc.filedes = -1 ; + psf->file.savedes = -1 ; } /* psf_init_files */ void psf_use_rsrc (SF_PRIVATE *psf, int on_off) { if (on_off) - { if (psf->filedes != psf->rsrcdes) - { psf->savedes = psf->filedes ; - psf->filedes = psf->rsrcdes ; + { if (psf->file.filedes != psf->rsrc.filedes) + { psf->file.savedes = psf->file.filedes ; + psf->file.filedes = psf->rsrc.filedes ; } ; } - else if (psf->filedes == psf->rsrcdes) - psf->filedes = psf->savedes ; + else if (psf->file.filedes == psf->rsrc.filedes) + psf->file.filedes = psf->file.savedes ; return ; } /* psf_use_rsrc */ static int -psf_open_fd (const char * pathname, int open_mode) +psf_open_fd (PSF_FILE * pfile) { int fd, oflag, mode ; /* @@ -530,13 +541,13 @@ psf_open_fd (const char * pathname, int open_mode) ** be optimised out. This is meant to catch the problems caused by ** "sfconfig.h" being included after . */ - if (sizeof (off_t) != sizeof (sf_count_t)) - { puts ("\n\n*** Fatal error : sizeof (off_t) != sizeof (sf_count_t)") ; + if (sizeof (sf_count_t) != 8) + { puts ("\n\n*** Fatal error : sizeof (sf_count_t) != 8") ; puts ("*** This means that libsndfile was not configured correctly.\n") ; exit (1) ; } ; - switch (open_mode) + switch (pfile->mode) { case SFM_READ : oflag = O_RDONLY | O_BINARY ; mode = 0 ; @@ -558,9 +569,9 @@ psf_open_fd (const char * pathname, int open_mode) } ; if (mode == 0) - fd = open (pathname, oflag) ; + fd = open (pfile->path.c, oflag) ; else - fd = open (pathname, oflag, mode) ; + fd = open (pfile->path.c, oflag, mode) ; return fd ; } /* psf_open_fd */ @@ -581,10 +592,10 @@ void psf_fsync (SF_PRIVATE *psf) { #if HAVE_FSYNC - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) - fsync (psf->filedes) ; + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) + fsync (psf->file.filedes) ; #else - psf = NULL ; + psf = NULL ; #endif } /* psf_fsync */ @@ -596,20 +607,18 @@ psf_fsync (SF_PRIVATE *psf) #include static int psf_close_handle (HANDLE handle) ; -static HANDLE psf_open_handle (const char * path, int mode) ; +static HANDLE psf_open_handle (PSF_FILE * pfile) ; static sf_count_t psf_get_filelen_handle (HANDLE handle) ; /* USE_WINDOWS_API */ int -psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode) +psf_fopen (SF_PRIVATE *psf) { psf->error = 0 ; - psf->hfile = psf_open_handle (pathname, open_mode) ; + psf->file.handle = psf_open_handle (&psf->file) ; - if (psf->hfile == NULL) + if (psf->file.handle == NULL) psf_log_syserr (psf, GetLastError ()) ; - psf->mode = open_mode ; - return psf->error ; } /* psf_fopen */ @@ -620,30 +629,30 @@ psf_fclose (SF_PRIVATE *psf) if (psf->virtual_io) return 0 ; - if (psf->do_not_close_descriptor) - { psf->hfile = NULL ; + if (psf->file.do_not_close_descriptor) + { psf->file.handle = NULL ; return 0 ; } ; - if ((retval = psf_close_handle (psf->hfile)) == -1) + if ((retval = psf_close_handle (psf->file.handle)) == -1) psf_log_syserr (psf, GetLastError ()) ; - psf->hfile = NULL ; + psf->file.handle = NULL ; return retval ; } /* psf_fclose */ /* USE_WINDOWS_API */ int -psf_open_rsrc (SF_PRIVATE *psf, int open_mode) +psf_open_rsrc (SF_PRIVATE *psf) { - if (psf->hrsrc != NULL) + if (psf->rsrc.handle != NULL) return 0 ; /* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s/rsrc", psf->file.path.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL) - { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ; + if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL) + { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; return SFE_NO_ERROR ; } ; @@ -651,10 +660,10 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode) ** Now try for a resource fork stored as a separate file in the same ** directory, but preceded with a dot underscore. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s._%s", psf->file.dir.c, psf->file.name.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL) - { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ; + if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL) + { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; return SFE_NO_ERROR ; } ; @@ -662,18 +671,18 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode) ** Now try for a resource fork stored in a separate file in the ** .AppleDouble/ directory. */ - snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ; + snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s.AppleDouble/%s", psf->file.dir.c, psf->file.name.c) ; psf->error = SFE_NO_ERROR ; - if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL) - { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ; + if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL) + { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; return SFE_NO_ERROR ; } ; /* No resource file found. */ - if (psf->hrsrc == NULL) + if (psf->rsrc.handle == NULL) psf_log_syserr (psf, GetLastError ()) ; - psf->hrsrc = NULL ; + psf->rsrc.handle = NULL ; return psf->error ; } /* psf_open_rsrc */ @@ -685,7 +694,7 @@ psf_get_filelen (SF_PRIVATE *psf) if (psf->virtual_io) return psf->vio.get_filelen (psf->vio_user_data) ; - filelen = psf_get_filelen_handle (psf->hfile) ; + filelen = psf_get_filelen_handle (psf->file.handle) ; if (filelen == -1) { psf_log_syserr (psf, errno) ; @@ -697,7 +706,7 @@ psf_get_filelen (SF_PRIVATE *psf) return (sf_count_t) -1 ; } ; - switch (psf->mode) + switch (psf->file.mode) { case SFM_WRITE : filelen = filelen - psf->fileoffset ; break ; @@ -725,34 +734,34 @@ psf_get_filelen (SF_PRIVATE *psf) /* USE_WINDOWS_API */ void psf_init_files (SF_PRIVATE *psf) -{ psf->hfile = NULL ; - psf->hrsrc = NULL ; - psf->hsaved = NULL ; +{ psf->file.handle = NULL ; + psf->rsrc.handle = NULL ; + psf->file.hsaved = NULL ; } /* psf_init_files */ /* USE_WINDOWS_API */ void psf_use_rsrc (SF_PRIVATE *psf, int on_off) { if (on_off) - { if (psf->hfile != psf->hrsrc) - { psf->hsaved = psf->hfile ; - psf->hfile = psf->hrsrc ; + { if (psf->file.handle != psf->rsrc.handle) + { psf->file.hsaved = psf->file.handle ; + psf->file.handle = psf->rsrc.handle ; } ; } - else if (psf->hfile == psf->hrsrc) - psf->hfile = psf->hsaved ; + else if (psf->file.handle == psf->rsrc.handle) + psf->file.handle = psf->file.hsaved ; return ; } /* psf_use_rsrc */ /* USE_WINDOWS_API */ static HANDLE -psf_open_handle (const char * pathname, int open_mode) +psf_open_handle (PSF_FILE * pfile) { DWORD dwDesiredAccess ; DWORD dwShareMode ; DWORD dwCreationDistribution ; HANDLE handle ; - switch (open_mode) + switch (pfile->mode) { case SFM_READ : dwDesiredAccess = GENERIC_READ ; dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE ; @@ -775,15 +784,26 @@ psf_open_handle (const char * pathname, int open_mode) return NULL ; } ; - handle = CreateFile ( - pathname, /* pointer to name of the file */ - dwDesiredAccess, /* access (read-write) mode */ - dwShareMode, /* share mode */ - 0, /* pointer to security attributes */ - dwCreationDistribution, /* how to create */ - FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ - NULL /* handle to file with attributes to copy */ - ) ; + if (pfile->use_wchar) + handle = CreateFileW ( + pfile->path.wc, /* pointer to name of the file */ + dwDesiredAccess, /* access (read-write) mode */ + dwShareMode, /* share mode */ + 0, /* pointer to security attributes */ + dwCreationDistribution, /* how to create */ + FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ + NULL /* handle to file with attributes to copy */ + ) ; + else + handle = CreateFile ( + pfile->path.c, /* pointer to name of the file */ + dwDesiredAccess, /* access (read-write) mode */ + dwShareMode, /* share mode */ + 0, /* pointer to security attributes */ + dwCreationDistribution, /* how to create */ + FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ + NULL /* handle to file with attributes to copy */ + ) ; if (handle == INVALID_HANDLE_VALUE) return NULL ; @@ -819,32 +839,30 @@ psf_log_syserr (SF_PRIVATE *psf, int error) /* USE_WINDOWS_API */ int psf_close_rsrc (SF_PRIVATE *psf) -{ - if (psf->hrsrc != NULL) - psf_close_handle (psf->hrsrc) ; - psf->hrsrc = NULL ; +{ psf_close_handle (psf->rsrc.handle) ; + psf->rsrc.handle = NULL ; return 0 ; } /* psf_close_rsrc */ /* USE_WINDOWS_API */ int -psf_set_stdio (SF_PRIVATE *psf, int mode) +psf_set_stdio (SF_PRIVATE *psf) { HANDLE handle = NULL ; int error = 0 ; - switch (mode) + switch (psf->file.mode) { case SFM_RDWR : error = SFE_OPEN_PIPE_RDWR ; break ; case SFM_READ : handle = GetStdHandle (STD_INPUT_HANDLE) ; - psf->do_not_close_descriptor = 1 ; + psf->file.do_not_close_descriptor = 1 ; break ; case SFM_WRITE : handle = GetStdHandle (STD_OUTPUT_HANDLE) ; - psf->do_not_close_descriptor = 1 ; + psf->file.do_not_close_descriptor = 1 ; break ; default : @@ -852,7 +870,7 @@ psf_set_stdio (SF_PRIVATE *psf, int mode) break ; } ; - psf->hfile = handle ; + psf->file.handle = handle ; psf->filelength = 0 ; return error ; @@ -866,14 +884,14 @@ psf_set_file (SF_PRIVATE *psf, int fd) osfhandle = _get_osfhandle (fd) ; handle = (HANDLE) osfhandle ; - psf->hfile = handle ; + psf->file.handle = handle ; } /* psf_set_file */ /* USE_WINDOWS_API */ int psf_file_valid (SF_PRIVATE *psf) -{ if (psf->hfile == NULL) +{ if (psf->file.handle == NULL) return SF_FALSE ; - if (psf->hfile == INVALID_HANDLE_VALUE) + if (psf->file.handle == INVALID_HANDLE_VALUE) return SF_FALSE ; return SF_TRUE ; } /* psf_set_file */ @@ -906,7 +924,7 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) lDistanceToMove = (DWORD) (offset & 0xFFFFFFFF) ; lDistanceToMoveHigh = (DWORD) ((offset >> 32) & 0xFFFFFFFF) ; - dwResult = SetFilePointer (psf->hfile, lDistanceToMove, &lDistanceToMoveHigh, dwMoveMethod) ; + dwResult = SetFilePointer (psf->file.handle, lDistanceToMove, &lDistanceToMoveHigh, dwMoveMethod) ; if (dwResult == 0xFFFFFFFF) dwError = GetLastError () ; @@ -942,7 +960,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { /* Break the writes down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - if (ReadFile (psf->hfile, ((char*) ptr) + total, count, &dwNumberOfBytesRead, 0) == 0) + if (ReadFile (psf->file.handle, ((char*) ptr) + total, count, &dwNumberOfBytesRead, 0) == 0) { psf_log_syserr (psf, GetLastError ()) ; break ; } @@ -965,7 +983,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) /* USE_WINDOWS_API */ sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { sf_count_t total = 0 ; - ssize_t count ; + ssize_t count ; DWORD dwNumberOfBytesWritten ; if (psf->virtual_io) @@ -981,7 +999,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf { /* Break the writes down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - if (WriteFile (psf->hfile, ((const char*) ptr) + total, count, &dwNumberOfBytesWritten, 0) == 0) + if (WriteFile (psf->file.handle, ((const char*) ptr) + total, count, &dwNumberOfBytesWritten, 0) == 0) { psf_log_syserr (psf, GetLastError ()) ; break ; } @@ -1016,7 +1034,7 @@ psf_ftell (SF_PRIVATE *psf) lDistanceToMoveLow = 0 ; lDistanceToMoveHigh = 0 ; - dwResult = SetFilePointer (psf->hfile, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_CURRENT) ; + dwResult = SetFilePointer (psf->file.handle, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_CURRENT) ; if (dwResult == 0xFFFFFFFF) dwError = GetLastError () ; @@ -1035,7 +1053,10 @@ psf_ftell (SF_PRIVATE *psf) /* USE_WINDOWS_API */ static int psf_close_handle (HANDLE handle) -{ if (CloseHandle (handle) == 0) +{ if (handle == NULL) + return 0 ; + + if (CloseHandle (handle) == 0) return -1 ; return 0 ; @@ -1048,7 +1069,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) DWORD dwNumberOfBytesRead ; while (k < bufsize - 1) - { if (ReadFile (psf->hfile, &(buffer [k]), 1, &dwNumberOfBytesRead, 0) == 0) + { if (ReadFile (psf->file.handle, &(buffer [k]), 1, &dwNumberOfBytesRead, 0) == 0) { psf_log_syserr (psf, GetLastError ()) ; break ; } @@ -1071,7 +1092,7 @@ psf_is_pipe (SF_PRIVATE *psf) if (psf->virtual_io) return SF_FALSE ; - if (GetFileType (psf->hfile) == FILE_TYPE_DISK) + if (GetFileType (psf->file.handle) == FILE_TYPE_DISK) return SF_FALSE ; /* Default to maximum safety. */ @@ -1098,7 +1119,7 @@ psf_get_filelen_handle (HANDLE handle) /* USE_WINDOWS_API */ void psf_fsync (SF_PRIVATE *psf) -{ FlushFileBuffers (psf->hfile) ; +{ FlushFileBuffers (psf->file.handle) ; } /* psf_fsync */ @@ -1120,7 +1141,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) lDistanceToMoveLow = (DWORD) (len & 0xFFFFFFFF) ; lDistanceToMoveHigh = (DWORD) ((len >> 32) & 0xFFFFFFFF) ; - dwResult = SetFilePointer (psf->hfile, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_BEGIN) ; + dwResult = SetFilePointer (psf->file.handle, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_BEGIN) ; if (dwResult == 0xFFFFFFFF) dwError = GetLastError () ; @@ -1135,7 +1156,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ** which guarantees that the new portion of the file will be zeroed. ** Not sure if this is important or not. */ - if (SetEndOfFile (psf->hfile) == 0) + if (SetEndOfFile (psf->file.handle) == 0) { retval = -1 ; psf_log_syserr (psf, GetLastError ()) ; } ; @@ -1191,14 +1212,14 @@ psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode) } ; if (mode == 0) - psf->filedes = open (pathname, oflag) ; + psf->file.filedes = open (pathname, oflag) ; else - psf->filedes = open (pathname, oflag, mode) ; + psf->file.filedes = open (pathname, oflag, mode) ; - if (psf->filedes == -1) + if (psf->file.filedes == -1) psf_log_syserr (psf, errno) ; - return psf->filedes ; + return psf->file.filedes ; } /* psf_fopen */ /* Win32 */ sf_count_t @@ -1214,8 +1235,8 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) break ; case SEEK_END : - if (psf->mode == SFM_WRITE) - { new_position = _lseeki64 (psf->filedes, offset, whence) ; + if (psf->file.mode == SFM_WRITE) + { new_position = _lseeki64 (psf->file.filedes, offset, whence) ; if (new_position < 0) psf_log_syserr (psf, errno) ; @@ -1228,7 +1249,7 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ** get the offset wrt the start of file. */ whence = SEEK_SET ; - offset = _lseeki64 (psf->filedes, 0, SEEK_END) + offset ; + offset = _lseeki64 (psf->file.filedes, 0, SEEK_END) + offset ; break ; default : @@ -1243,9 +1264,9 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) *** Use the _telli64() function instead. */ if (offset == 0 && whence == SEEK_CUR) - new_position = _telli64 (psf->filedes) ; + new_position = _telli64 (psf->file.filedes) ; else - new_position = _lseeki64 (psf->filedes, offset, whence) ; + new_position = _lseeki64 (psf->file.filedes, offset, whence) ; if (new_position < 0) psf_log_syserr (psf, errno) ; @@ -1258,7 +1279,7 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) /* Win32 */ sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { sf_count_t total = 0 ; - ssize_t count ; + ssize_t count ; if (psf->virtual_io) return psf->vio.read (ptr, bytes*items, psf->vio_user_data) / bytes ; @@ -1273,7 +1294,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { /* Break the writes down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - count = read (psf->filedes, ((char*) ptr) + total, (size_t) count) ; + count = read (psf->file.filedes, ((char*) ptr) + total, (size_t) count) ; if (count == -1) { if (errno == EINTR) @@ -1296,7 +1317,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) /* Win32 */ sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) { sf_count_t total = 0 ; - ssize_t count ; + ssize_t count ; if (psf->virtual_io) return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ; @@ -1311,7 +1332,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf { /* Break the writes down to a sensible size. */ count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ; - count = write (psf->filedes, ((const char*) ptr) + total, count) ; + count = write (psf->file.filedes, ((const char*) ptr) + total, count) ; if (count == -1) { if (errno == EINTR) @@ -1338,7 +1359,7 @@ psf_ftell (SF_PRIVATE *psf) if (psf->virtual_io) return psf->vio.tell (psf->vio_user_data) ; - pos = _telli64 (psf->filedes) ; + pos = _telli64 (psf->file.filedes) ; if (pos == ((sf_count_t) -1)) { psf_log_syserr (psf, errno) ; @@ -1352,13 +1373,13 @@ psf_ftell (SF_PRIVATE *psf) psf_fclose (SF_PRIVATE *psf) { int retval ; - while ((retval = close (psf->filedes)) == -1 && errno == EINTR) + while ((retval = close (psf->file.filedes)) == -1 && errno == EINTR) /* Do nothing. */ ; if (retval == -1) psf_log_syserr (psf, errno) ; - psf->filedes = -1 ; + psf->file.filedes = -1 ; return retval ; } /* psf_fclose */ @@ -1369,7 +1390,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) sf_count_t count ; while (k < bufsize - 1) - { count = read (psf->filedes, &(buffer [k]), 1) ; + { count = read (psf->file.filedes, &(buffer [k]), 1) ; if (count == -1) { if (errno == EINTR) @@ -1396,7 +1417,7 @@ psf_is_pipe (SF_PRIVATE *psf) return SF_FALSE ; /* Not sure if this works. */ - if (fstat (psf->filedes, &statbuf) == -1) + if (fstat (psf->file.filedes, &statbuf) == -1) { psf_log_syserr (psf, errno) ; /* Default to maximum safety. */ return SF_TRUE ; @@ -1420,7 +1441,7 @@ psf_get_filelen (SF_PRIVATE *psf) */ struct _stati64 statbuf ; - if (_fstati64 (psf->filedes, &statbuf)) + if (_fstati64 (psf->file.filedes, &statbuf)) { psf_log_syserr (psf, errno) ; return (sf_count_t) -1 ; } ; @@ -1432,7 +1453,7 @@ psf_get_filelen (SF_PRIVATE *psf) if (psf->virtual_io) return psf->vio.get_filelen (psf->vio_user_data) ; - if ((current = _telli64 (psf->filedes)) < 0) + if ((current = _telli64 (psf->file.filedes)) < 0) { psf_log_syserr (psf, errno) ; return (sf_count_t) -1 ; } ; @@ -1450,17 +1471,17 @@ psf_get_filelen (SF_PRIVATE *psf) ** by libsndfile and changing the license to GPL at the same time. */ - _lseeki64 (psf->filedes, 0, SEEK_END) ; + _lseeki64 (psf->file.filedes, 0, SEEK_END) ; - if ((filelen = _lseeki64 (psf->filedes, 0, SEEK_END)) < 0) + if ((filelen = _lseeki64 (psf->file.filedes, 0, SEEK_END)) < 0) { psf_log_syserr (psf, errno) ; return (sf_count_t) -1 ; } ; if (filelen > current) - _lseeki64 (psf->filedes, current, SEEK_SET) ; + _lseeki64 (psf->file.filedes, current, SEEK_SET) ; - switch (psf->mode) + switch (psf->file.mode) { case SFM_WRITE : filelen = filelen - psf->fileoffset ; break ; @@ -1504,7 +1525,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) if (len > 0x7FFFFFFF) return -1 ; - retval = chsize (psf->filedes, len) ; + retval = chsize (psf->file.filedes, len) ; if (retval == -1) psf_log_syserr (psf, errno) ; diff --git a/libs/libsndfile/src/flac.c b/libs/libsndfile/src/flac.c index 9b580156d1..bb74e94bc0 100644 --- a/libs/libsndfile/src/flac.c +++ b/libs/libsndfile/src/flac.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2004-2009 Erik de Castro Lopo +** Copyright (C) 2004-2013 Erik de Castro Lopo ** Copyright (C) 2004 Tobias Gehrig ** ** This program is free software ; you can redistribute it and/or modify @@ -35,12 +35,12 @@ #include #include -#include "sfendian.h" - /*------------------------------------------------------------------------------ ** Private static functions. */ +#define FLAC_DEFAULT_COMPRESSION_LEVEL 5 + #define ENC_BUFFER_SIZE 8192 typedef enum @@ -69,6 +69,8 @@ typedef struct const FLAC__Frame *frame ; FLAC__bool bufferbackup ; + + unsigned compression ; } FLAC_PRIVATE ; typedef struct @@ -77,6 +79,7 @@ typedef struct } FLAC_TAG ; static sf_count_t flac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; +static int flac_byterate (SF_PRIVATE *psf) ; static int flac_close (SF_PRIVATE *psf) ; static int flac_enc_init (SF_PRIVATE *psf) ; @@ -122,10 +125,6 @@ static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__Stre static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ; -static const int legal_sample_rates [] = -{ 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000 -} ; - static void s2flac8_array (const short *src, FLAC__int32 *dest, int count) { while (--count >= 0) @@ -153,8 +152,8 @@ i2flac8_array (const int *src, FLAC__int32 *dest, int count) static void i2flac16_array (const int *src, FLAC__int32 *dest, int count) { - while (--count >= 0) - dest [count] = src [count] >> 16 ; + while (--count >= 0) + dest [count] = src [count] >> 16 ; } /* i2flac16_array */ static void @@ -306,7 +305,7 @@ sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte if (*bytes > 0 && psf->error == 0) return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ; - return FLAC__STREAM_DECODER_READ_STATUS_ABORT ; + return FLAC__STREAM_DECODER_READ_STATUS_ABORT ; } /* sf_flac_read_callback */ static FLAC__StreamDecoderSeekStatus @@ -348,7 +347,7 @@ sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_ if (psf_ftell (psf) == psf->filelength) return SF_TRUE ; - return SF_FALSE ; + return SF_FALSE ; } /* sf_flac_eof_callback */ static FLAC__StreamDecoderWriteStatus @@ -377,7 +376,9 @@ sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *me { "comment", SF_STR_COMMENT }, { "date", SF_STR_DATE }, { "album", SF_STR_ALBUM }, - { "license", SF_STR_LICENSE } + { "license", SF_STR_LICENSE }, + { "tracknumber", SF_STR_TRACKNUMBER }, + { "genre", SF_STR_GENRE } } ; const char *value, *cptr ; @@ -411,7 +412,14 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_ psf->sf.samplerate = metadata->data.stream_info.sample_rate ; psf->sf.frames = metadata->data.stream_info.total_samples ; - psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n Frames : %D\n", psf->sf.channels, psf->sf.samplerate, psf->sf.frames) ; + psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n", psf->sf.channels, psf->sf.samplerate) ; + + if (psf->sf.frames == 0) + { psf_log_printf (psf, " Frames : 0 (bumping to SF_COUNT_MAX)\n") ; + psf->sf.frames = SF_COUNT_MAX ; + } + else + psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; switch (metadata->data.stream_info.bits_per_sample) { case 8 : @@ -501,7 +509,7 @@ sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__u if (psf->error) return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ; - return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ; + return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ; } /* sf_flac_enc_seek_callback */ static FLAC__StreamEncoderTellStatus @@ -531,7 +539,7 @@ flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac) int k, string_count = 0 ; for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings [k].type != 0) + { if (psf->strings.data [k].type != 0) string_count ++ ; } ; @@ -543,10 +551,10 @@ flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac) return ; } ; - for (k = 0 ; k < SF_MAX_STRINGS && psf->strings [k].type != 0 ; k++) + for (k = 0 ; k < SF_MAX_STRINGS && psf->strings.data [k].type != 0 ; k++) { const char * key, * value ; - switch (psf->strings [k].type) + switch (psf->strings.data [k].type) { case SF_STR_SOFTWARE : key = "software" ; break ; @@ -571,11 +579,17 @@ flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac) case SF_STR_LICENSE : key = "license" ; break ; + case SF_STR_TRACKNUMBER : + key = "tracknumber" ; + break ; + case SF_STR_GENRE : + key = "genre" ; + break ; default : continue ; } ; - value = psf->strings [k].str ; + value = psf->strings.storage + psf->strings.data [k].offset ; FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair (&entry, key, value) ; FLAC__metadata_object_vorbiscomment_append_comment (pflac->metadata, entry, /* copy */ SF_FALSE) ; @@ -620,24 +634,28 @@ flac_open (SF_PRIVATE *psf) FLAC_PRIVATE* pflac = calloc (1, sizeof (FLAC_PRIVATE)) ; psf->codec_data = pflac ; - if (psf->mode == SFM_RDWR) + /* Set the default value here. Over-ridden later if necessary. */ + pflac->compression = FLAC_DEFAULT_COMPRESSION_LEVEL ; + + + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { if ((error = flac_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_FLAC) return SFE_BAD_OPEN_FORMAT ; psf->endian = SF_ENDIAN_BIG ; psf->sf.seekable = 0 ; - psf->str_flags = SF_STR_ALLOW_START ; + psf->strings.flags = SF_STR_ALLOW_START ; if ((error = flac_enc_init (psf))) return error ; @@ -647,14 +665,12 @@ flac_open (SF_PRIVATE *psf) psf->datalength = psf->filelength ; psf->dataoffset = 0 ; - psf->blockwidth = 0 ; - psf->bytewidth = 1 ; psf->container_close = flac_close ; psf->seek = flac_seek ; - psf->command = flac_command ; + psf->byterate = flac_byterate ; - psf->blockwidth = psf->bytewidth * psf->sf.channels ; + psf->command = flac_command ; switch (subformat) { case SF_FORMAT_PCM_S8 : /* 8-bit FLAC. */ @@ -683,7 +699,7 @@ flac_close (SF_PRIVATE *psf) if (pflac->metadata != NULL) FLAC__metadata_object_delete (pflac->metadata) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { FLAC__stream_encoder_finish (pflac->fse) ; FLAC__stream_encoder_delete (pflac->fse) ; @@ -691,7 +707,7 @@ flac_close (SF_PRIVATE *psf) free (pflac->encbuffer) ; } ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { FLAC__stream_decoder_finish (pflac->fsd) ; FLAC__stream_decoder_delete (pflac->fsd) ; } ; @@ -709,17 +725,16 @@ static int flac_enc_init (SF_PRIVATE *psf) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; unsigned bps ; - int k, found ; - found = 0 ; - for (k = 0 ; k < ARRAY_LEN (legal_sample_rates) ; k++) - if (psf->sf.samplerate == legal_sample_rates [k]) - { found = 1 ; - break ; - } ; - - if (found == 0) + /* To cite the flac FAQ at + ** http://flac.sourceforge.net/faq.html#general__samples + ** "FLAC supports linear sample rates from 1Hz - 655350Hz in 1Hz + ** increments." + */ + if (psf->sf.samplerate < 1 || psf->sf.samplerate > 655350) + { psf_log_printf (psf, "flac sample rate out of range.\n", psf->sf.samplerate) ; return SFE_FLAC_BAD_SAMPLE_RATE ; + } ; psf_fseek (psf, 0, SEEK_SET) ; @@ -739,6 +754,8 @@ flac_enc_init (SF_PRIVATE *psf) break ; } ; + if (pflac->fse) + FLAC__stream_encoder_delete (pflac->fse) ; if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL) return SFE_FLAC_NEW_DECODER ; @@ -757,6 +774,11 @@ flac_enc_init (SF_PRIVATE *psf) return SFE_FLAC_INIT_DECODER ; } ; + if (! FLAC__stream_encoder_set_compression_level (pflac->fse, pflac->compression)) + { psf_log_printf (psf, "FLAC__stream_encoder_set_compression_level (%d) return false.\n", pflac->compression) ; + return SFE_FLAC_INIT_DECODER ; + } ; + return 0 ; } /* flac_enc_init */ @@ -765,6 +787,8 @@ flac_read_header (SF_PRIVATE *psf) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; psf_fseek (psf, 0, SEEK_SET) ; + if (pflac->fsd) + FLAC__stream_decoder_delete (pflac->fsd) ; if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL) return SFE_FLAC_NEW_DECODER ; @@ -788,34 +812,59 @@ flac_read_header (SF_PRIVATE *psf) } /* flac_read_header */ static int -flac_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (data), int UNUSED (datasize)) -{ - return 0 ; +flac_command (SF_PRIVATE * psf, int command, void * data, int datasize) +{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; + double quality ; + + switch (command) + { case SFC_SET_COMPRESSION_LEVEL : + if (data == NULL || datasize != sizeof (double)) + return SF_FALSE ; + + if (psf->have_written) + return SF_FALSE ; + + /* FLAC compression level is in the range [0, 8] while libsndfile takes + ** values in the range [0.0, 1.0]. Massage the libsndfile value here. + */ + quality = (*((double *) data)) * 8.0 ; + /* Clip range. */ + pflac->compression = lrint (SF_MAX (0.0, SF_MIN (8.0, quality))) ; + + psf_log_printf (psf, "%s : Setting SFC_SET_COMPRESSION_LEVEL to %u.\n", __func__, pflac->compression) ; + + if (flac_enc_init (psf)) + return SF_FALSE ; + + return SF_TRUE ; + + default : + return SF_FALSE ; + } ; + + return SF_FALSE ; } /* flac_command */ int flac_init (SF_PRIVATE *psf) { - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->read_short = flac_read_flac2s ; psf->read_int = flac_read_flac2i ; psf->read_float = flac_read_flac2f ; psf->read_double = flac_read_flac2d ; } ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->write_short = flac_write_s2flac ; psf->write_int = flac_write_i2flac ; psf->write_float = flac_write_f2flac ; psf->write_double = flac_write_d2flac ; } ; - psf->bytewidth = 1 ; - psf->blockwidth = psf->sf.channels ; - if (psf->filelength > psf->dataoffset) psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ; else @@ -954,7 +1003,7 @@ flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; convert (ptr + total, buffer, writecount) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) + if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) thiswrite = writecount ; else break ; @@ -996,7 +1045,7 @@ flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; convert (ptr + total, buffer, writecount) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) + if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) thiswrite = writecount ; else break ; @@ -1038,7 +1087,7 @@ flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; convert (ptr + total, buffer, writecount, psf->norm_float) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) + if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) thiswrite = writecount ; else break ; @@ -1076,23 +1125,22 @@ f2flac8_clip_array (const float *src, FLAC__int32 *dest, int count, int normaliz static void f2flac16_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) -{ - float normfact, scaled_value ; +{ float normfact, scaled_value ; - normfact = normalize ? (8.0 * 0x1000) : 1.0 ; + normfact = normalize ? (8.0 * 0x1000) : 1.0 ; - while (--count >= 0) { - scaled_value = src [count] * normfact ; - if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF)) { - dest [count] = 0x7FFF ; - continue ; - } - if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000)) { - dest [count] = 0x8000 ; - continue ; - } - dest [count] = lrintf (scaled_value) ; - } + while (--count >= 0) + { scaled_value = src [count] * normfact ; + if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFF)) + { dest [count] = 0x7FFF ; + continue ; + } ; + if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x1000)) + { dest [count] = 0x8000 ; + continue ; + } ; + dest [count] = lrintf (scaled_value) ; + } ; } /* f2flac16_clip_array */ static void @@ -1170,7 +1218,7 @@ flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; convert (ptr + total, buffer, writecount, psf->norm_double) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) + if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) thiswrite = writecount ; else break ; @@ -1288,13 +1336,24 @@ flac_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) pflac->frame = NULL ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { FLAC__uint64 position ; + if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset)) { FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ; return offset ; } ; + if (offset == psf->sf.frames) + { /* + ** If we've been asked to seek to the very end of the file, libFLAC + ** will return an error. However, we know the length of the file so + ** instead of returning an error, we can return the offset. + */ + return offset ; + } ; + + psf->error = SFE_BAD_SEEK ; return ((sf_count_t) -1) ; } ; @@ -1304,6 +1363,16 @@ flac_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) return ((sf_count_t) -1) ; } /* flac_seek */ +static int +flac_byterate (SF_PRIVATE *psf) +{ + if (psf->file.mode == SFM_READ) + return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; + + return -1 ; +} /* flac_byterate */ + + #else /* HAVE_EXTERNAL_LIBS */ int diff --git a/libs/libsndfile/src/float32.c b/libs/libsndfile/src/float32.c index 2ab4450f84..89bcf6b754 100644 --- a/libs/libsndfile/src/float32.c +++ b/libs/libsndfile/src/float32.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -92,7 +92,7 @@ float32_init (SF_PRIVATE *psf) psf->blockwidth = sizeof (float) * psf->sf.channels ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { switch (psf->endian + float_caps) { case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) : psf->data_endswap = SF_FALSE ; @@ -163,7 +163,7 @@ float32_init (SF_PRIVATE *psf) } ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { switch (psf->endian + float_caps) { case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) : psf->data_endswap = SF_FALSE ; @@ -241,13 +241,13 @@ float32_init (SF_PRIVATE *psf) else psf->datalength = 0 ; - psf->sf.frames = psf->datalength / psf->blockwidth ; + psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; return 0 ; } /* float32_init */ float -float32_be_read (unsigned char *cptr) +float32_be_read (const unsigned char *cptr) { int exponent, mantissa, negative ; float fvalue ; @@ -275,7 +275,7 @@ float32_be_read (unsigned char *cptr) } /* float32_be_read */ float -float32_le_read (unsigned char *cptr) +float32_le_read (const unsigned char *cptr) { int exponent, mantissa, negative ; float fvalue ; @@ -444,7 +444,7 @@ f2s_clip_array (const float *src, int count, short *dest, float scale) if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0) dest [count] = SHRT_MAX ; - else if (CPU_CLIPS_NEGATIVE == 0 && tmp < 32768.0) + else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0) dest [count] = SHRT_MIN ; else dest [count] = lrintf (tmp) ; @@ -505,25 +505,26 @@ d2f_array (const double *src, float *dest, int count) static sf_count_t host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ void (*convert) (const float *, int, short *, float) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, int, short *, float) ; int bufferlen, readcount ; sf_count_t total = 0 ; float scale ; convert = (psf->add_clipping) ? f2s_clip_array : f2s_array ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; /* Fix me : Need lef2s_array */ if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ; + convert (ubuf.fbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -535,24 +536,25 @@ host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ void (*convert) (const float *, int, int *, float) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, int, int *, float) ; int bufferlen, readcount ; sf_count_t total = 0 ; float scale ; convert = (psf->add_clipping) ? f2i_clip_array : f2i_array ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - convert (psf->u.fbuf, readcount, ptr + total, scale) ; + convert (ubuf.fbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -564,20 +566,21 @@ host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; if (psf->data_endswap != SF_TRUE) return psf_fread (ptr, sizeof (float), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - endswap_int_copy ((int*) (ptr + total), psf->u.ibuf, readcount) ; + endswap_int_copy ((int*) (ptr + total), ubuf.ibuf, readcount) ; total += readcount ; if (readcount < bufferlen) @@ -590,21 +593,22 @@ host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; /* Fix me : Need lef2d_array */ - f2d_array (psf->u.fbuf, readcount, ptr + total) ; + f2d_array (ubuf.fbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -616,26 +620,27 @@ host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float scale ; /* Erik */ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ; + s2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -647,25 +652,26 @@ host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ; + i2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -677,7 +683,8 @@ host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (psf->peak_info) @@ -686,15 +693,15 @@ host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) if (psf->data_endswap != SF_TRUE) return psf_fwrite (ptr, sizeof (float), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_int_copy (psf->u.ibuf, (const int*) (ptr + total), bufferlen) ; + endswap_int_copy (ubuf.ibuf, (const int*) (ptr + total), bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -706,24 +713,25 @@ host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2f_array (ptr + total, psf->u.fbuf, bufferlen) ; + d2f_array (ptr + total, ubuf.fbuf, bufferlen) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -738,24 +746,25 @@ host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) static sf_count_t replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float scale ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - bf2f_array (psf->u.fbuf, bufferlen) ; + bf2f_array (ubuf.fbuf, bufferlen) ; - f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ; + f2s_array (ubuf.fbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -767,24 +776,25 @@ replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float scale ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - bf2f_array (psf->u.fbuf, bufferlen) ; + bf2f_array (ubuf.fbuf, bufferlen) ; - f2i_array (psf->u.fbuf, readcount, ptr + total, scale) ; + f2i_array (ubuf.fbuf, readcount, ptr + total, scale) ; total += readcount ; if (readcount < bufferlen) break ; @@ -796,24 +806,25 @@ replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; /* FIX THIS */ - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - bf2f_array (psf->u.fbuf, bufferlen) ; + bf2f_array (ubuf.fbuf, bufferlen) ; - memcpy (ptr + total, psf->u.fbuf, bufferlen * sizeof (float)) ; + memcpy (ptr + total, ubuf.fbuf, bufferlen * sizeof (float)) ; total += readcount ; if (readcount < bufferlen) @@ -826,22 +837,23 @@ replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + readcount = psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - bf2f_array (psf->u.fbuf, bufferlen) ; + bf2f_array (ubuf.fbuf, bufferlen) ; - f2d_array (psf->u.fbuf, readcount, ptr + total) ; + f2d_array (ubuf.fbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -853,27 +865,28 @@ replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ; + s2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - f2bf_array (psf->u.fbuf, bufferlen) ; + f2bf_array (ubuf.fbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -885,27 +898,28 @@ replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float scale ; scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ; + i2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - f2bf_array (psf->u.fbuf, bufferlen) ; + f2bf_array (ubuf.fbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -917,27 +931,28 @@ replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; /* FIX THIS */ if (psf->peak_info) float32_peak_update (psf, ptr, len, 0) ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - memcpy (psf->u.fbuf, ptr + total, bufferlen * sizeof (float)) ; + memcpy (ubuf.fbuf, ptr + total, bufferlen * sizeof (float)) ; - f2bf_array (psf->u.fbuf, bufferlen) ; + f2bf_array (ubuf.fbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -949,25 +964,26 @@ replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.fbuf) ; + bufferlen = ARRAY_LEN (ubuf.fbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2f_array (ptr + total, psf->u.fbuf, bufferlen) ; + d2f_array (ptr + total, ubuf.fbuf, bufferlen) ; if (psf->peak_info) - float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ; + float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - f2bf_array (psf->u.fbuf, bufferlen) ; + f2bf_array (ubuf.fbuf, bufferlen) ; if (psf->data_endswap == SF_TRUE) - endswap_int_array (psf->u.ibuf, bufferlen) ; + endswap_int_array (ubuf.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ; + writecount = psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; diff --git a/libs/libsndfile/src/float_cast.h b/libs/libsndfile/src/float_cast.h index 2c06aaf233..98c7de74b1 100644 --- a/libs/libsndfile/src/float_cast.h +++ b/libs/libsndfile/src/float_cast.h @@ -158,6 +158,7 @@ } #elif defined(_WIN64) +#if (_MSC_VER < 1800) __inline long int lrint(double x) { return (long int) (x); @@ -166,6 +167,7 @@ { return (long int) (x); } +#endif #elif (defined (__MWERKS__) && defined (macintosh)) /* This MacOS 9 solution was provided by Stephane Letz */ diff --git a/libs/libsndfile/src/g72x.c b/libs/libsndfile/src/g72x.c index a6b5fffde2..fec5d3f336 100644 --- a/libs/libsndfile/src/g72x.c +++ b/libs/libsndfile/src/g72x.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -112,8 +112,6 @@ g72x_init (SF_PRIVATE * psf) default : return SFE_UNIMPLEMENTED ; } ; - psf->blockwidth = psf->bytewidth = 1 ; - psf->filelength = psf_get_filelen (psf) ; if (psf->filelength < psf->dataoffset) psf->filelength = psf->dataoffset ; @@ -122,7 +120,7 @@ g72x_init (SF_PRIVATE * psf) if (psf->dataend > 0) psf->datalength -= psf->filelength - psf->dataend ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { pg72x->private = g72x_reader_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ; if (pg72x->private == NULL) return SFE_MALLOC_FAILED ; @@ -134,7 +132,7 @@ g72x_init (SF_PRIVATE * psf) psf->read_float = g72x_read_f ; psf->read_double = g72x_read_d ; - psf->seek = g72x_seek ; + psf->seek = g72x_seek ; if (psf->datalength % pg72x->blocksize) { psf_log_printf (psf, "*** Odd psf->datalength (%D) should be a multiple of %d\n", psf->datalength, pg72x->blocksize) ; @@ -147,7 +145,7 @@ g72x_init (SF_PRIVATE * psf) psf_g72x_decode_block (psf, pg72x) ; } - else if (psf->mode == SFM_WRITE) + else if (psf->file.mode == SFM_WRITE) { pg72x->private = g72x_writer_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ; if (pg72x->private == NULL) return SFE_MALLOC_FAILED ; @@ -253,7 +251,8 @@ g72x_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -262,7 +261,7 @@ g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) return 0 ; pg72x = (G72x_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; + sptr = ubuf.sbuf ; bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; @@ -282,7 +281,8 @@ g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -294,7 +294,7 @@ g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; + sptr = ubuf.sbuf ; bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; @@ -313,7 +313,8 @@ g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -325,7 +326,7 @@ g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; + sptr = ubuf.sbuf ; bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; @@ -401,7 +402,7 @@ g72x_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t UNUSED (offset)) ** return PSF_SEEK_ERROR ; ** } ; ** -** if (psf->mode == SFM_READ) +** if (psf->file.mode == SFM_READ) ** { psf_fseek (psf, psf->dataoffset + newblock * pg72x->blocksize, SEEK_SET) ; ** pg72x->block_curr = newblock ; ** psf_g72x_decode_block (psf, pg72x) ; @@ -491,7 +492,8 @@ g72x_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t g72x_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -500,8 +502,8 @@ g72x_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return 0 ; pg72x = (G72x_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ; + sptr = ubuf.sbuf ; + bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -518,7 +520,8 @@ g72x_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t g72x_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -530,8 +533,8 @@ g72x_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ; + sptr = ubuf.sbuf ; + bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -549,7 +552,8 @@ g72x_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t g72x_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; +{ BUF_UNION ubuf ; + G72x_PRIVATE *pg72x ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -561,8 +565,8 @@ g72x_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ; + sptr = ubuf.sbuf ; + bufferlen = SF_BUFFER_LEN / sizeof (short) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -584,7 +588,7 @@ g72x_close (SF_PRIVATE *psf) pg72x = (G72x_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* If a block has been partially assembled, write it out ** as the final block. */ diff --git a/libs/libsndfile/src/gsm610.c b/libs/libsndfile/src/gsm610.c index a459cb1e04..0d2800d92b 100644 --- a/libs/libsndfile/src/gsm610.c +++ b/libs/libsndfile/src/gsm610.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -84,7 +84,7 @@ gsm610_init (SF_PRIVATE *psf) return SFE_INTERNAL ; } ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; psf->sf.seekable = SF_FALSE ; @@ -132,7 +132,7 @@ Need separate gsm_data structs for encode and decode. break ; } ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { if (psf->datalength % pgsm610->blocksize == 0) pgsm610->blocks = psf->datalength / pgsm610->blocksize ; else if (psf->datalength % pgsm610->blocksize == 1 && pgsm610->blocksize == GSM610_BLOCKSIZE) @@ -162,7 +162,7 @@ Need separate gsm_data structs for encode and decode. psf->read_double = gsm610_read_d ; } ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { pgsm610->blockcount = 0 ; pgsm610->samplecount = 0 ; @@ -194,7 +194,7 @@ gsm610_wav_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) pgsm610->samplecount = 0 ; if (pgsm610->blockcount > pgsm610->blocks) - { memset (pgsm610->samples, 0, WAV_W64_GSM610_SAMPLES * sizeof (short)) ; + { memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; return 1 ; } ; @@ -222,7 +222,7 @@ gsm610_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) pgsm610->samplecount = 0 ; if (pgsm610->blockcount > pgsm610->blocks) - { memset (pgsm610->samples, 0, GSM610_SAMPLES * sizeof (short)) ; + { memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; return 1 ; } ; @@ -243,7 +243,7 @@ gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len while (indx < len) { if (pgsm610->blockcount >= pgsm610->blocks && pgsm610->samplecount >= pgsm610->samplesperblock) - { memset (&(ptr [indx]), 0, (len - indx) * sizeof (short)) ; + { memset (ptr + indx, 0, (len - indx) * sizeof (short)) ; return total ; } ; @@ -290,6 +290,7 @@ gsm610_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -298,8 +299,8 @@ gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) return 0 ; pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; @@ -315,6 +316,7 @@ gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -326,8 +328,8 @@ gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; @@ -343,6 +345,7 @@ gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -354,8 +357,8 @@ gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) return 0 ; pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; @@ -406,7 +409,7 @@ gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) newblock = offset / pgsm610->samplesperblock ; newsample = offset % pgsm610->samplesperblock ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { if (psf->read_current != newblock * pgsm610->samplesperblock + newsample) { psf_fseek (psf, psf->dataoffset + newblock * pgsm610->samplesperblock, SEEK_SET) ; pgsm610->blockcount = newblock ; @@ -441,7 +444,7 @@ gsm610_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) pgsm610->blockcount ++ ; /* Set samples to zero for next block. */ - memset (pgsm610->samples, 0, WAV_W64_GSM610_SAMPLES * sizeof (short)) ; + memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; return 1 ; } /* gsm610_encode_block */ @@ -452,7 +455,7 @@ gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) /* Encode the samples. */ gsm_encode (pgsm610->gsm_data, pgsm610->samples, pgsm610->block) ; - gsm_encode (pgsm610->gsm_data, pgsm610->samples+WAV_W64_GSM610_SAMPLES/2, pgsm610->block+WAV_W64_GSM610_BLOCKSIZE/2) ; + gsm_encode (pgsm610->gsm_data, pgsm610->samples+WAV_W64_GSM610_SAMPLES / 2, pgsm610->block+WAV_W64_GSM610_BLOCKSIZE / 2) ; /* Write the block to disk. */ if ((k = psf_fwrite (pgsm610->block, 1, WAV_W64_GSM610_BLOCKSIZE, psf)) != WAV_W64_GSM610_BLOCKSIZE) @@ -462,7 +465,7 @@ gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) pgsm610->blockcount ++ ; /* Set samples to zero for next block. */ - memset (pgsm610->samples, 0, WAV_W64_GSM610_SAMPLES * sizeof (short)) ; + memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; return 1 ; } /* gsm610_wav_encode_block */ @@ -517,6 +520,7 @@ gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -525,8 +529,8 @@ gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return 0 ; pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -542,6 +546,7 @@ gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -553,8 +558,8 @@ gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -570,6 +575,7 @@ gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { GSM610_PRIVATE *pgsm610 ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -581,8 +587,8 @@ gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -604,7 +610,7 @@ gsm610_close (SF_PRIVATE *psf) pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* If a block has been partially assembled, write it out ** as the final block. */ diff --git a/libs/libsndfile/src/htk.c b/libs/libsndfile/src/htk.c index c503042804..25390f1dc1 100644 --- a/libs/libsndfile/src/htk.c +++ b/libs/libsndfile/src/htk.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -55,14 +55,14 @@ htk_open (SF_PRIVATE *psf) if (psf->is_pipe) return SFE_HTK_NO_PIPE ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = htk_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_HTK) return SFE_BAD_OPEN_FORMAT ; @@ -95,7 +95,7 @@ htk_open (SF_PRIVATE *psf) static int htk_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) htk_write_header (psf, SF_TRUE) ; return 0 ; @@ -195,10 +195,17 @@ htk_read_header (SF_PRIVATE *psf) return SFE_HTK_NOT_WAVEFORM ; psf->sf.channels = 1 ; - psf->sf.samplerate = 10000000 / sample_period ; - psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d => %d Hz\n", - sample_count, sample_period, psf->sf.samplerate) ; + if (sample_period > 0) + { psf->sf.samplerate = 10000000 / sample_period ; + psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d => %d Hz\n", + sample_count, sample_period, psf->sf.samplerate) ; + } + else + { psf->sf.samplerate = 16000 ; + psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d (should be > 0) => Guessed sample rate %d Hz\n", + sample_count, sample_period, psf->sf.samplerate) ; + } ; psf->sf.format = SF_FORMAT_HTK | SF_FORMAT_PCM_16 ; psf->bytewidth = 2 ; diff --git a/libs/libsndfile/src/id3.c b/libs/libsndfile/src/id3.c new file mode 100644 index 0000000000..2fd0a0b971 --- /dev/null +++ b/libs/libsndfile/src/id3.c @@ -0,0 +1,57 @@ +/* +** Copyright (C) 2010-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +int +id3_skip (SF_PRIVATE * psf) +{ unsigned char buf [10] ; + + memset (buf, 0, sizeof (buf)) ; + psf_binheader_readf (psf, "pb", 0, buf, 10) ; + + if (buf [0] == 'I' && buf [1] == 'D' && buf [2] == '3') + { int offset = buf [6] & 0x7f ; + offset = (offset << 7) | (buf [7] & 0x7f) ; + offset = (offset << 7) | (buf [8] & 0x7f) ; + offset = (offset << 7) | (buf [9] & 0x7f) ; + + psf_log_printf (psf, "ID3 length : %d\n--------------------\n", offset) ; + + /* Never want to jump backwards in a file. */ + if (offset < 0) + return 0 ; + + /* Calculate new file offset and position ourselves there. */ + psf->fileoffset += offset + 10 ; + psf_binheader_readf (psf, "p", psf->fileoffset) ; + + return 1 ; + } ; + + return 0 ; +} /* id3_skip */ diff --git a/libs/libsndfile/src/ima_adpcm.c b/libs/libsndfile/src/ima_adpcm.c index e3ab38d752..0ba4513758 100644 --- a/libs/libsndfile/src/ima_adpcm.c +++ b/libs/libsndfile/src/ima_adpcm.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -37,11 +37,7 @@ typedef struct IMA_ADPCM_PRIVATE_tag int stepindx [2] ; unsigned char *block ; short *samples ; -#if HAVE_FLEXIBLE_ARRAY short data [] ; /* ISO C99 struct flexible array. */ -#else - short data [0] ; /* This is a hack and might not work. */ -#endif } IMA_ADPCM_PRIVATE ; /*============================================================================================ @@ -50,9 +46,9 @@ typedef struct IMA_ADPCM_PRIVATE_tag static int ima_indx_adjust [16] = { -1, -1, -1, -1, /* +0 - +3, decrease the step size */ - 2, 4, 6, 8, /* +4 - +7, increase the step size */ - -1, -1, -1, -1, /* -0 - -3, decrease the step size */ - 2, 4, 6, 8, /* -4 - -7, increase the step size */ + +2, +4, +6, +8, /* +4 - +7, increase the step size */ + -1, -1, -1, -1, /* -0 - -3, decrease the step size */ + +2, +4, +6, +8, /* -4 - -7, increase the step size */ } ; static int ima_step_size [89] = @@ -116,14 +112,14 @@ wav_w64_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) return SFE_INTERNAL ; } ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) if ((error = ima_reader_init (psf, blockalign, samplesperblock))) return error ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) if ((error = ima_writer_init (psf, blockalign))) return error ; @@ -137,14 +133,14 @@ int aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) { int error ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) if ((error = ima_reader_init (psf, blockalign, samplesperblock))) return error ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) if ((error = ima_writer_init (psf, blockalign))) return error ; @@ -159,7 +155,7 @@ ima_close (SF_PRIVATE *psf) pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* If a block has been partially assembled, write it out ** as the final block. */ @@ -181,18 +177,16 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) { IMA_ADPCM_PRIVATE *pima ; int pimasize, count ; - if (psf->mode != SFM_READ) + if (psf->file.mode != SFM_READ) return SFE_BAD_MODE_RW ; pimasize = sizeof (IMA_ADPCM_PRIVATE) + blockalign * psf->sf.channels + 3 * psf->sf.channels * samplesperblock ; - if (! (pima = malloc (pimasize))) + if (! (pima = calloc (1, pimasize))) return SFE_MALLOC_FAILED ; psf->codec_data = (void*) pima ; - memset (pima, 0, pimasize) ; - pima->samples = pima->data ; pima->block = (unsigned char*) (pima->data + samplesperblock * psf->sf.channels) ; @@ -204,7 +198,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ; - if (pima->blocksize == 0) + if (pima->blocksize == 0) { psf_log_printf (psf, "*** Error : pima->blocksize should not be zero.\n") ; return SFE_INTERNAL ; } ; @@ -238,7 +232,6 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) default : psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ; return SFE_INTERNAL ; - break ; } ; pima->decode_block (psf, pima) ; /* Read first block. */ @@ -254,8 +247,8 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) static int aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) { unsigned char *blockdata ; - int chan, k, diff, bytecode ; - short step, stepindx, predictor, *sampledata ; + int chan, k, diff, bytecode, predictor ; + short step, stepindx, *sampledata ; static int count = 0 ; count ++ ; @@ -307,6 +300,11 @@ count ++ ; if (bytecode & 8) diff = -diff ; predictor += diff ; + if (predictor < -32768) + predictor = -32768 ; + else if (predictor > 32767) + predictor = 32767 ; + pima->samples [pima->channels * k + chan] = predictor ; } ; } ; @@ -376,7 +374,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) { blockindx = chan * pima->blocksize + 2 + indx / 2 ; pima->block [blockindx] = pima->samples [indx] & 0x0F ; - pima->block [blockindx] |= (pima->samples [indx + pima->channels] << 4) & 0xF0 ; + pima->block [blockindx] |= (pima->samples [indx + chan] << 4) & 0xF0 ; } ; } ; @@ -394,7 +392,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) static int wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) -{ int chan, k, current, blockindx, indx, indxstart, diff ; +{ int chan, k, predictor, blockindx, indx, indxstart, diff ; short step, bytecode, stepindx [2] ; pima->blockcount ++ ; @@ -411,9 +409,9 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) /* Read and check the block header. */ for (chan = 0 ; chan < pima->channels ; chan++) - { current = pima->block [chan*4] | (pima->block [chan*4+1] << 8) ; - if (current & 0x8000) - current -= 0x10000 ; + { predictor = pima->block [chan*4] | (pima->block [chan*4+1] << 8) ; + if (predictor & 0x8000) + predictor -= 0x10000 ; stepindx [chan] = pima->block [chan*4+2] ; stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ; @@ -422,7 +420,7 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) if (pima->block [chan*4+3] != 0) psf_log_printf (psf, "IMA ADPCM synchronisation error.\n") ; - pima->samples [chan] = current ; + pima->samples [chan] = predictor ; } ; /* @@ -455,7 +453,7 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) bytecode = pima->samples [k] & 0xF ; step = ima_step_size [stepindx [chan]] ; - current = pima->samples [k - pima->channels] ; + predictor = pima->samples [k - pima->channels] ; diff = step >> 3 ; if (bytecode & 1) @@ -467,17 +465,17 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) if (bytecode & 8) diff = -diff ; - current += diff ; + predictor += diff ; - if (current > 32767) - current = 32767 ; - else if (current < -32768) - current = -32768 ; + if (predictor > 32767) + predictor = 32767 ; + else if (predictor < -32768) + predictor = -32768 ; stepindx [chan] += ima_indx_adjust [bytecode] ; stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ; - pima->samples [k] = current ; + pima->samples [k] = predictor ; } ; return 1 ; @@ -623,6 +621,7 @@ ima_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -631,8 +630,8 @@ ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) return 0 ; pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = ima_read_block (psf, pima, sptr, readcount) ; @@ -650,6 +649,7 @@ ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -661,8 +661,8 @@ ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = ima_read_block (psf, pima, sptr, readcount) ; @@ -680,6 +680,7 @@ ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -691,8 +692,8 @@ ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = ima_read_block (psf, pima, sptr, readcount) ; @@ -724,9 +725,7 @@ ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) if (offset == 0) { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; pima->blockcount = 0 ; - if (pima->decode_block) { - pima->decode_block (psf, pima) ; - } + pima->decode_block (psf, pima) ; pima->samplecount = 0 ; return 0 ; } ; @@ -764,7 +763,7 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign) int samplesperblock ; unsigned int pimasize ; - if (psf->mode != SFM_WRITE) + if (psf->file.mode != SFM_WRITE) return SFE_BAD_MODE_RW ; samplesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ; @@ -798,7 +797,6 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign) default : psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ; return SFE_INTERNAL ; - break ; } ; psf->write_short = ima_write_s ; @@ -861,6 +859,7 @@ ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -869,8 +868,8 @@ ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return 0 ; pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) @@ -888,6 +887,7 @@ ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -899,8 +899,8 @@ ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) @@ -918,6 +918,7 @@ ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { IMA_ADPCM_PRIVATE *pima ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -929,8 +930,8 @@ ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) diff --git a/libs/libsndfile/src/ima_oki_adpcm.c b/libs/libsndfile/src/ima_oki_adpcm.c index ca943c9b90..26db9f65fb 100644 --- a/libs/libsndfile/src/ima_oki_adpcm.c +++ b/libs/libsndfile/src/ima_oki_adpcm.c @@ -1,6 +1,6 @@ /* +** Copyright (C) 2007-2012 Erik de Castro Lopo ** Copyright (c) 2007 -** Copyright (C) 2007-2009 Erik de Castro Lopo ** ** This library is free software; you can redistribute it and/or modify it ** under the terms of the GNU Lesser General Public License as published by @@ -19,6 +19,8 @@ /* ADPCM: IMA, OKI <==> 16-bit PCM. */ +#include "sfconfig.h" + #include /* Set up for libsndfile environment: */ @@ -75,7 +77,7 @@ adpcm_decode (IMA_OKI_ADPCM * state, int code) s = ((state->steps [state->step_index] * s) >> 3) & state->mask ; if (code & 8) - s = -s ; + s = -s ; s += state->last_output ; if (s < MIN_SAMPLE || s > MAX_SAMPLE) @@ -137,7 +139,7 @@ ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) /* ** The codec expects an even number of input samples. - ** + ** ** Samples should always be passed in even length blocks. If the last block to ** be encoded is odd length, extend that block by one zero valued sample. */ diff --git a/libs/libsndfile/src/ima_oki_adpcm.h b/libs/libsndfile/src/ima_oki_adpcm.h index 52d348647f..86241e7a2c 100644 --- a/libs/libsndfile/src/ima_oki_adpcm.h +++ b/libs/libsndfile/src/ima_oki_adpcm.h @@ -1,6 +1,6 @@ /* +** Copyright (C) 2007-2011 Erik de Castro Lopo ** Copyright (c) 2007 -** Copyright (C) 2007-2009 Erik de Castro Lopo ** ** This library is free software; you can redistribute it and/or modify it ** under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/interleave.c b/libs/libsndfile/src/interleave.c index 30578ba24f..5f799444c6 100644 --- a/libs/libsndfile/src/interleave.c +++ b/libs/libsndfile/src/interleave.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -53,7 +53,7 @@ int interleave_init (SF_PRIVATE *psf) { INTERLEAVE_DATA *pdata ; - if (psf->mode != SFM_READ) + if (psf->file.mode != SFM_READ) return SFE_INTERLEAVE_MODE ; if (psf->interleave) @@ -287,9 +287,8 @@ interleave_read_double (SF_PRIVATE *psf, double *ptr, sf_count_t len) */ static sf_count_t -interleave_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) -{ psf = psf ; mode = mode ; - +interleave_seek (SF_PRIVATE * UNUSED (psf), int UNUSED (mode), sf_count_t samples_from_start) +{ /* ** Do nothing here. This is a place holder to prevent the default ** seek function from being called. diff --git a/libs/libsndfile/src/ircam.c b/libs/libsndfile/src/ircam.c index 4bae7015bd..6a6c7fc606 100644 --- a/libs/libsndfile/src/ircam.c +++ b/libs/libsndfile/src/ircam.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -80,14 +80,14 @@ ircam_open (SF_PRIVATE *psf) { int subformat ; int error = SFE_NO_ERROR ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = ircam_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_IRCAM) return SFE_BAD_OPEN_FORMAT ; @@ -95,7 +95,7 @@ ircam_open (SF_PRIVATE *psf) if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU) psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ; - psf->dataoffset = IRCAM_DATA_OFFSET ; + psf->dataoffset = IRCAM_DATA_OFFSET ; if ((error = ircam_write_header (psf, SF_FALSE))) return error ; @@ -163,9 +163,10 @@ ircam_read_header (SF_PRIVATE *psf) psf->sf.samplerate = (int) samplerate ; - psf_log_printf (psf, " Sample Rate : %d\n" - " Channels : %d\n" - " Encoding : %X => %s\n", psf->sf.samplerate, psf->sf.channels, encoding, get_encoding_str (encoding)) ; + psf_log_printf (psf, " Sample Rate : %d\n" + " Channels : %d\n" + " Encoding : %X => %s\n", + psf->sf.samplerate, psf->sf.channels, encoding, get_encoding_str (encoding)) ; switch (encoding) { case IRCAM_PCM_16 : diff --git a/libs/libsndfile/src/libsndfile-1.def b/libs/libsndfile/src/libsndfile-1.def index 7b144538fc..93cab02d98 100644 --- a/libs/libsndfile/src/libsndfile-1.def +++ b/libs/libsndfile/src/libsndfile-1.def @@ -33,7 +33,9 @@ sf_write_double @40 sf_strerror @50 sf_get_string @60 sf_set_string @61 +sf_version_string @68 sf_open_fd @70 +sf_wchar_open @71 sf_open_virtual @80 sf_write_sync @90 diff --git a/libs/libsndfile/src/macbinary3.c b/libs/libsndfile/src/macbinary3.c index d9b1ad43a4..3ad71e68b8 100644 --- a/libs/libsndfile/src/macbinary3.c +++ b/libs/libsndfile/src/macbinary3.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -25,7 +25,7 @@ #include "sfendian.h" #include "common.h" -#if (OS_IS_MACOSX == 1) +#if (OSX_DARWIN_VERSION >= 1) int macbinary3_open (SF_PRIVATE * UNUSED (psf)) @@ -41,5 +41,5 @@ macbinary3_open (SF_PRIVATE * UNUSED (psf)) return 0 ; } /* macbinary3_open */ -#endif /* OS_IS_MACOSX */ +#endif /* OSX_DARWIN_VERSION */ diff --git a/libs/libsndfile/src/macos.c b/libs/libsndfile/src/macos.c index cbedb890cf..5f6c53191c 100644 --- a/libs/libsndfile/src/macos.c +++ b/libs/libsndfile/src/macos.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/make-static-lib-hidden-privates.sh b/libs/libsndfile/src/make-static-lib-hidden-privates.sh new file mode 100644 index 0000000000..5bfd485d26 --- /dev/null +++ b/libs/libsndfile/src/make-static-lib-hidden-privates.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +# This script takes a static library and removes all non-public symbols. +# Ie, it makes a static lib whose symbols are far less likely to clash with +# the symbols of another shared or static library. + +grep sf_ Symbols.gnu-binutils | sed -e "s/[ ;]//g" > Symbols.static + +ld -r --whole-archive .libs/libsndfile.a -o libsndfile_a.o + +objcopy --keep-global-symbols=Symbols.static libsndfile_a.o libsndfile.o + +rm -f libsndfile.a +ar cru libsndfile.a libsndfile.o diff --git a/libs/libsndfile/src/mat4.c b/libs/libsndfile/src/mat4.c index a4919a4668..77ece264b1 100644 --- a/libs/libsndfile/src/mat4.c +++ b/libs/libsndfile/src/mat4.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -76,7 +76,7 @@ int mat4_open (SF_PRIVATE *psf) { int subformat, error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = mat4_read_header (psf))) return error ; } ; @@ -86,7 +86,7 @@ mat4_open (SF_PRIVATE *psf) subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -135,7 +135,7 @@ mat4_open (SF_PRIVATE *psf) static int mat4_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) mat4_write_header (psf, SF_TRUE) ; return 0 ; @@ -206,8 +206,9 @@ mat4_write_header (SF_PRIVATE *psf, int calc_length) static int mat4_read_header (SF_PRIVATE *psf) -{ int marker, rows, cols, imag ; - unsigned namesize ; +{ char buffer [256] ; + uint32_t marker, namesize ; + int rows, cols, imag ; double value ; const char *marker_str ; char name [64] ; @@ -244,8 +245,8 @@ mat4_read_header (SF_PRIVATE *psf) psf_binheader_readf (psf, "d", &value) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ; - psf_log_printf (psf, psf->u.cbuf) ; + snprintf (buffer, sizeof (buffer), " Value : %f\n", value) ; + psf_log_printf (psf, buffer) ; if ((rows != 1) || (cols != 1)) return SFE_MAT4_NO_SAMPLERATE ; diff --git a/libs/libsndfile/src/mat5.c b/libs/libsndfile/src/mat5.c index 40ffe0a73f..164fb29a21 100644 --- a/libs/libsndfile/src/mat5.c +++ b/libs/libsndfile/src/mat5.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -86,7 +86,7 @@ int mat5_open (SF_PRIVATE *psf) { int subformat, error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = mat5_read_header (psf))) return error ; } ; @@ -96,7 +96,7 @@ mat5_open (SF_PRIVATE *psf) subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -143,7 +143,7 @@ mat5_open (SF_PRIVATE *psf) static int mat5_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) mat5_write_header (psf, SF_TRUE) ; return 0 ; @@ -157,6 +157,7 @@ mat5_write_header (SF_PRIVATE *psf, int calc_length) { static const char *filename = "MATLAB 5.0 MAT-file, written by " PACKAGE "-" VERSION ", " ; static const char *sr_name = "samplerate\0\0\0\0\0\0\0\0\0\0\0" ; static const char *wd_name = "wavedata\0" ; + char buffer [256] ; sf_count_t current, datasize ; int encoding ; @@ -204,11 +205,11 @@ mat5_write_header (SF_PRIVATE *psf, int calc_length) psf->headindex = 0 ; psf_fseek (psf, 0, SEEK_SET) ; - psf_get_date_str (psf->u.cbuf, sizeof (psf->u.scbuf)) ; - psf_binheader_writef (psf, "bb", filename, strlen (filename), psf->u.cbuf, strlen (psf->u.cbuf) + 1) ; + psf_get_date_str (buffer, sizeof (buffer)) ; + psf_binheader_writef (psf, "bb", filename, strlen (filename), buffer, strlen (buffer) + 1) ; - memset (psf->u.scbuf, ' ', 124 - psf->headindex) ; - psf_binheader_writef (psf, "b", psf->u.scbuf, make_size_t (124 - psf->headindex)) ; + memset (buffer, ' ', 124 - psf->headindex) ; + psf_binheader_writef (psf, "b", buffer, make_size_t (124 - psf->headindex)) ; psf->rwf_endian = psf->endian ; @@ -257,38 +258,39 @@ mat5_write_header (SF_PRIVATE *psf, int calc_length) static int mat5_read_header (SF_PRIVATE *psf) -{ char name [32] ; +{ char buffer [256], name [32] ; short version, endian ; int type, flags1, flags2, rows, cols ; unsigned size ; + int have_samplerate = 1 ; - psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, 124) ; + psf_binheader_readf (psf, "pb", 0, buffer, 124) ; - psf->u.scbuf [125] = 0 ; + buffer [125] = 0 ; - if (strlen (psf->u.cbuf) >= 124) + if (strlen (buffer) >= 124) return SFE_UNIMPLEMENTED ; - if (strstr (psf->u.cbuf, "MATLAB 5.0 MAT-file") == psf->u.cbuf) - psf_log_printf (psf, "%s\n", psf->u.scbuf) ; + if (strstr (buffer, "MATLAB 5.0 MAT-file") == buffer) + psf_log_printf (psf, "%s\n", buffer) ; psf_binheader_readf (psf, "E22", &version, &endian) ; if (endian == MI_MARKER) { psf->endian = psf->rwf_endian = SF_ENDIAN_BIG ; - if (CPU_IS_LITTLE_ENDIAN) version = ENDSWAP_SHORT (version) ; + if (CPU_IS_LITTLE_ENDIAN) version = ENDSWAP_16 (version) ; } else if (endian == IM_MARKER) { psf->endian = psf->rwf_endian = SF_ENDIAN_LITTLE ; - if (CPU_IS_BIG_ENDIAN) version = ENDSWAP_SHORT (version) ; + if (CPU_IS_BIG_ENDIAN) version = ENDSWAP_16 (version) ; } else return SFE_MAT5_BAD_ENDIAN ; if ((CPU_IS_LITTLE_ENDIAN && endian == IM_MARKER) || (CPU_IS_BIG_ENDIAN && endian == MI_MARKER)) - version = ENDSWAP_SHORT (version) ; + version = ENDSWAP_16 (version) ; psf_log_printf (psf, "Version : 0x%04X\n", version) ; psf_log_printf (psf, "Endian : 0x%04X => %s\n", endian, @@ -317,11 +319,13 @@ mat5_read_header (SF_PRIVATE *psf) return SFE_MAT5_NO_BLOCK ; psf_binheader_readf (psf, "44", &rows, &cols) ; - psf_log_printf (psf, " Rows : %X Cols : %d\n", rows, cols) ; + psf_log_printf (psf, " Rows : %d Cols : %d\n", rows, cols) ; if (rows != 1 || cols != 1) - return SFE_MAT5_SAMPLE_RATE ; - + { if (psf->sf.samplerate == 0) + psf->sf.samplerate = 44100 ; + have_samplerate = 0 ; + } psf_binheader_readf (psf, "4", &type) ; if (type == MAT5_TYPE_SCHAR) @@ -355,6 +359,9 @@ mat5_read_header (SF_PRIVATE *psf) psf_binheader_readf (psf, "44", &type, &size) ; + if (!have_samplerate) + goto skip_samplerate ; + switch (type) { case MAT5_TYPE_DOUBLE : { double samplerate ; @@ -445,6 +452,7 @@ mat5_read_header (SF_PRIVATE *psf) psf_binheader_readf (psf, "44", &type, &size) ; psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; +skip_samplerate : /*++++++++++++++++++++++++++++++++++++++++++++++++++*/ if (rows == 0 && cols == 0) diff --git a/libs/libsndfile/src/mpc2k.c b/libs/libsndfile/src/mpc2k.c index ad782ed6e0..0170f7ccfb 100644 --- a/libs/libsndfile/src/mpc2k.c +++ b/libs/libsndfile/src/mpc2k.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -38,7 +38,7 @@ ** 1 byte: loopMode (0 no loop, 1 forward looping) ** 1 byte: number of beat in loop ** 1 uint16: sampleRate -** +** ** DATA ** Data are always non compressed 16 bits interleaved */ @@ -63,10 +63,9 @@ static int mpc2k_read_header (SF_PRIVATE *psf) ; int mpc2k_open (SF_PRIVATE *psf) -{ int subformat ; - int error = 0 ; +{ int error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = mpc2k_read_header (psf))) return error ; } ; @@ -74,9 +73,7 @@ mpc2k_open (SF_PRIVATE *psf) if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MPC2K) return SFE_BAD_OPEN_FORMAT ; - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (mpc2k_write_header (psf, SF_FALSE)) return psf->error ; @@ -98,7 +95,7 @@ mpc2k_open (SF_PRIVATE *psf) static int mpc2k_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) mpc2k_write_header (psf, SF_TRUE) ; return 0 ; @@ -134,7 +131,7 @@ mpc2k_write_header (SF_PRIVATE *psf, int calc_length) if (psf->is_pipe == SF_FALSE) psf_fseek (psf, 0, SEEK_SET) ; - snprintf (sample_name, sizeof (sample_name), "%s ", psf->filename) ; + snprintf (sample_name, sizeof (sample_name), "%s ", psf->file.name.c) ; psf_binheader_writef (psf, "e11b", 1, 4, sample_name, make_size_t (HEADER_NAME_LEN)) ; psf_binheader_writef (psf, "e111", 100, 0, (psf->sf.channels - 1) & 1) ; diff --git a/libs/libsndfile/src/ms_adpcm.c b/libs/libsndfile/src/ms_adpcm.c index f276c602c1..1643ddf443 100644 --- a/libs/libsndfile/src/ms_adpcm.c +++ b/libs/libsndfile/src/ms_adpcm.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -44,11 +44,7 @@ typedef struct sf_count_t samplecount ; short *samples ; unsigned char *block ; -#if HAVE_FLEXIBLE_ARRAY short dummydata [] ; /* ISO C99 struct flexible array. */ -#else - short dummydata [0] ; /* This is a hack an might not work. */ -#endif } MSADPCM_PRIVATE ; /*============================================================================================ @@ -137,15 +133,14 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) return SFE_INTERNAL ; } ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ; pmssize = sizeof (MSADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ; - if (! (psf->codec_data = malloc (pmssize))) + if (! (psf->codec_data = calloc (1, pmssize))) return SFE_MALLOC_FAILED ; pms = (MSADPCM_PRIVATE*) psf->codec_data ; - memset (pms, 0, pmssize) ; pms->samples = pms->dummydata ; pms->block = (unsigned char*) (pms->dummydata + psf->sf.channels * samplesperblock) ; @@ -159,8 +154,8 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) return SFE_INTERNAL ; } ; - if (psf->mode == SFM_READ) - { pms->dataremaining = psf->datalength ; + if (psf->file.mode == SFM_READ) + { pms->dataremaining = psf->datalength ; if (psf->datalength % pms->blocksize) pms->blocks = psf->datalength / pms->blocksize + 1 ; @@ -185,7 +180,7 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) psf->read_double = msadpcm_read_d ; } ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { pms->samples = pms->dummydata ; pms->samplecount = 0 ; @@ -207,9 +202,9 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) { int chan, k, blockindx, sampleindx ; short bytecode, bpred [2], chan_idelta [2] ; - int predict ; - int current ; - int idelta ; + int predict ; + int current ; + int idelta ; pms->blockcount ++ ; pms->samplecount = 0 ; @@ -278,7 +273,7 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) sampleindx = 2 * pms->channels ; while (blockindx < pms->blocksize) { bytecode = pms->block [blockindx++] ; - pms->samples [sampleindx++] = (bytecode >> 4) & 0x0F ; + pms->samples [sampleindx++] = (bytecode >> 4) & 0x0F ; pms->samples [sampleindx++] = bytecode & 0x0F ; } ; @@ -297,7 +292,7 @@ msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) if (bytecode & 0x8) bytecode -= 0x10 ; - predict = ((pms->samples [k - pms->channels] * AdaptCoeff1 [bpred [chan]]) + predict = ((pms->samples [k - pms->channels] * AdaptCoeff1 [bpred [chan]]) + (pms->samples [k - 2 * pms->channels] * AdaptCoeff2 [bpred [chan]])) >> 8 ; /* => / 256 => FIXED_POINT_COEFF_BASE == 256 */ current = (bytecode * idelta) + predict ; @@ -364,6 +359,7 @@ msadpcm_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t msadpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -372,8 +368,8 @@ msadpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) return 0 ; pms = (MSADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = msadpcm_read_block (psf, pms, sptr, readcount) ; @@ -390,6 +386,7 @@ msadpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t msadpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -400,8 +397,8 @@ msadpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) pms = (MSADPCM_PRIVATE*) psf->codec_data ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = msadpcm_read_block (psf, pms, sptr, readcount) ; @@ -418,6 +415,7 @@ msadpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t msadpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount = 0, count ; sf_count_t total = 0 ; @@ -429,8 +427,8 @@ msadpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) return 0 ; pms = (MSADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = msadpcm_read_block (psf, pms, sptr, readcount) ; @@ -674,6 +672,7 @@ msadpcm_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t msadpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -682,8 +681,8 @@ msadpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return 0 ; pms = (MSADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -700,6 +699,7 @@ msadpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t msadpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -711,8 +711,8 @@ msadpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -729,6 +729,7 @@ msadpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t msadpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { MSADPCM_PRIVATE *pms ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -740,8 +741,8 @@ msadpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) return 0 ; pms = (MSADPCM_PRIVATE*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -764,7 +765,7 @@ msadpcm_close (SF_PRIVATE *psf) pms = (MSADPCM_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* Now we know static int for certain the length of the file we can ** re-write the header. */ diff --git a/libs/libsndfile/src/new.c b/libs/libsndfile/src/new.c new file mode 100644 index 0000000000..23f3087f12 --- /dev/null +++ b/libs/libsndfile/src/new.c @@ -0,0 +1,116 @@ +/* +** Copyright (C) 2002-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +#if (ENABLE_EXPERIMENTAL_CODE == 0) + +int +new_open (SF_PRIVATE *psf) +{ if (psf) + return SFE_UNIMPLEMENTED ; + return (psf && 0) ; +} /* new_open */ + +#else + +/*------------------------------------------------------------------------------ +** Macros to handle big/little endian issues. +*/ + +/*------------------------------------------------------------------------------ +** Typedefs. +*/ + +/*------------------------------------------------------------------------------ +** Private static functions. +*/ + +static int new_read_header (SF_PRIVATE *psf) ; + +/*------------------------------------------------------------------------------ +** Public function. +*/ + +int +new_open (SF_PRIVATE *psf) +{ int subformat, error = 0 ; + + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) + return SFE_UNIMPLEMENTED ; + + if ((error = new_read_header (psf))) + return error ; + + if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE) + return SFE_BAD_OPEN_FORMAT ; + + subformat = SF_CODEC (psf->sf.format) ; + + return error ; +} /* new_open */ + +/*------------------------------------------------------------------------------ +*/ + +static int +new_read_header (SF_PRIVATE *psf) +{ int marker ; + + /* Set position to start of file to begin reading header. */ + psf_binheader_readf (psf, "pm", 0, &marker) ; + if (marker != ALAW_MARKER) + return SFE_WVE_NOT_WVE ; + + psf_binheader_readf (psf, "m", &marker) ; + if (marker != SOUN_MARKER) + return SFE_WVE_NOT_WVE ; + + psf_binheader_readf (psf, "m", &marker) ; + if (marker != DFIL_MARKER) + return SFE_WVE_NOT_WVE ; + + psf_log_printf (psf, "Read only : Psion Alaw\n" + " Sample Rate : 8000\n" + " Channels : 1\n" + " Encoding : A-law\n") ; + + psf->dataoffset = 0x20 ; + psf->datalength = psf->filelength - psf->dataoffset ; + + psf->sf.format = SF_FORMAT_WVE | SF_FORMAT_ALAW ; + psf->sf.samplerate = 8000 ; + psf->sf.frames = psf->datalength ; + psf->sf.channels = 1 ; + + return alaw_init (psf) ; +} /* new_read_header */ + +/*------------------------------------------------------------------------------ +*/ + +#endif diff --git a/libs/libsndfile/src/nist.c b/libs/libsndfile/src/nist.c index 1993f00b3e..2aa679e55c 100644 --- a/libs/libsndfile/src/nist.c +++ b/libs/libsndfile/src/nist.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -54,12 +54,12 @@ int nist_open (SF_PRIVATE *psf) { int error ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = nist_read_header (psf))) return error ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -118,15 +118,12 @@ static char bad_header [] = static int nist_read_header (SF_PRIVATE *psf) -{ char *psf_header ; - int bitwidth = 0, bytes = 0, count, encoding ; +{ char psf_header [NIST_HEADER_LENGTH + 2] ; + int bitwidth = 0, count, encoding ; + unsigned bytes = 0 ; char str [64], *cptr ; long samples ; - psf->sf.format = SF_FORMAT_NIST ; - - psf_header = psf->u.cbuf ; - if (sizeof (psf->header) <= NIST_HEADER_LENGTH) return SFE_INTERNAL ; @@ -164,7 +161,9 @@ nist_read_header (SF_PRIVATE *psf) { sscanf (cptr, "sample_coding -s%d %63s", &count, str) ; if (strcmp (str, "pcm") == 0) + { /* Correct this later when we find out the bitwidth. */ encoding = SF_FORMAT_PCM_U8 ; + } else if (strcmp (str, "alaw") == 0) encoding = SF_FORMAT_ALAW ; else if ((strcmp (str, "ulaw") == 0) || (strcmp (str, "mu-law") == 0)) @@ -193,19 +192,23 @@ nist_read_header (SF_PRIVATE *psf) psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ; /* This is where we figure out endian-ness. */ - if ((cptr = strstr (psf_header, "sample_byte_format -s"))) - { sscanf (cptr, "sample_byte_format -s%d %8s", &bytes, str) ; + if ((cptr = strstr (psf_header, "sample_byte_format -s")) + && sscanf (cptr, "sample_byte_format -s%u %8s", &bytes, str) == 2) + { + if (bytes != strlen (str)) + psf_log_printf (psf, "Weird sample_byte_format : strlen '%s' != %d\n", str, bytes) ; + if (bytes > 1) { if (psf->bytewidth == 0) psf->bytewidth = bytes ; - else if (psf->bytewidth != bytes) + else if (psf->bytewidth - bytes != 0) { psf_log_printf (psf, "psf->bytewidth (%d) != bytes (%d)\n", psf->bytewidth, bytes) ; return SFE_NIST_BAD_ENCODING ; } ; - if (strstr (str, "01") == str) + if (strcmp (str, "01") == 0) psf->endian = SF_ENDIAN_LITTLE ; - else if (strstr (str, "10")) + else if (strcmp (str, "10") == 0) psf->endian = SF_ENDIAN_BIG ; else { psf_log_printf (psf, "Weird endian-ness : %s\n", str) ; @@ -255,13 +258,26 @@ nist_read_header (SF_PRIVATE *psf) else return SFE_UNIMPLEMENTED ; + /* Sanitize psf->sf.format. */ + switch (SF_CODEC (psf->sf.format)) + { case SF_FORMAT_ULAW : + case SF_FORMAT_ALAW : + case SF_FORMAT_PCM_U8 : + /* Blank out endian bits. */ + psf->sf.format = SF_FORMAT_NIST | SF_CODEC (psf->sf.format) ; + break ; + + default : + break ; + } ; + return 0 ; } /* nist_read_header */ static int nist_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) nist_write_header (psf, SF_TRUE) ; return 0 ; diff --git a/libs/libsndfile/src/ogg.c b/libs/libsndfile/src/ogg.c index 50484ac60c..7bc4b31f9f 100644 --- a/libs/libsndfile/src/ogg.c +++ b/libs/libsndfile/src/ogg.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** Copyright (C) 2007 John ffitch ** ** This program is free software ; you can redistribute it and/or modify @@ -17,39 +17,6 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* -** Much of this code is based on the examples in libvorbis from the -** XIPHOPHORUS Company http://www.xiph.org/ which has a BSD-style Licence -** Copyright (c) 2002, Xiph.org Foundation -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** - Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** -** - Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** -** - Neither the name of the Xiph.org Foundation nor the names of its -** contributors may be used to endorse or promote products derived from -** this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION -** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE, -** DATA, OR PROFITS ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - #include "sfconfig.h" #include @@ -69,85 +36,89 @@ #if HAVE_EXTERNAL_LIBS -#include -#include +#include -typedef int convert_func (int, void *, int, int, float **) ; +#include "ogg.h" -static int ogg_read_header (SF_PRIVATE *psf, int log_data) ; -static int ogg_write_header (SF_PRIVATE *psf, int calc_length) ; static int ogg_close (SF_PRIVATE *psf) ; -static int ogg_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; -static sf_count_t ogg_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static sf_count_t ogg_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t ogg_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t ogg_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t ogg_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t ogg_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t ogg_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t ogg_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t ogg_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t ogg_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ; -static sf_count_t ogg_length (SF_PRIVATE *psf) ; +static int ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE * odata) ; +static int ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og) ; -typedef struct -{ int id ; - const char *name ; -} STR_PAIRS ; +int +ogg_open (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = calloc (1, sizeof (OGG_PRIVATE)) ; + sf_count_t pos = psf_ftell (psf) ; + int error = 0 ; -static STR_PAIRS vorbis_metatypes [] = -{ { SF_STR_TITLE, "Title" }, - { SF_STR_COPYRIGHT, "Copyright" }, - { SF_STR_SOFTWARE, "Software" }, - { SF_STR_ARTIST, "Artist" }, - { SF_STR_COMMENT, "Comment" }, - { SF_STR_DATE, "Date" }, - { SF_STR_ALBUM, "Album" }, - { SF_STR_LICENSE, "License" }, -} ; + psf->container_data = odata ; + psf->container_close = ogg_close ; -typedef struct -{ /* Sync and verify incoming physical bitstream */ - ogg_sync_state oy ; - /* Take physical pages, weld into a logical stream of packets */ - ogg_stream_state os ; - /* One Ogg bitstream page. Vorbis packets are inside */ - ogg_page og ; - /* One raw packet of data for decode */ - ogg_packet op ; - int eos ; -} OGG_PRIVATE ; + if (psf->file.mode == SFM_RDWR) + return SFE_BAD_MODE_RW ; -typedef struct -{ /* Count current location */ - sf_count_t loc ; - /* Struct that stores all the static vorbis bitstream settings */ - vorbis_info vi ; - /* Struct that stores all the bitstream user comments */ - vorbis_comment vc ; - /* Ventral working state for the packet->PCM decoder */ - vorbis_dsp_state vd ; - /* Local working space for packet->PCM decode */ - vorbis_block vb ; + if (psf->file.mode == SFM_READ) + if ((error = ogg_stream_classify (psf, odata)) != 0) + return error ; + + /* Reset everything to an initial state. */ + ogg_sync_clear (&odata->osync) ; + ogg_stream_clear (&odata->ostream) ; + psf_fseek (psf, pos, SEEK_SET) ; + + if (SF_ENDIAN (psf->sf.format) != 0) + return SFE_BAD_ENDIAN ; + + switch (psf->sf.format) + { case SF_FORMAT_OGG | SF_FORMAT_VORBIS : + return ogg_vorbis_open (psf) ; + + case SF_FORMAT_OGGFLAC : + free (psf->container_data) ; + psf->container_data = NULL ; + psf->container_close = NULL ; + return flac_open (psf) ; + +#if ENABLE_EXPERIMENTAL_CODE + case SF_FORMAT_OGG | SF_FORMAT_SPEEX : + return ogg_speex_open (psf) ; + + case SF_FORMAT_OGG | SF_FORMAT_PCM_16 : + case SF_FORMAT_OGG | SF_FORMAT_PCM_24 : + return ogg_pcm_open (psf) ; +#endif + + default : + break ; + } ; + + psf_log_printf (psf, "%s : bad psf->sf.format 0x%x.\n", __func__, psf->sf.format) ; + return SFE_INTERNAL ; +} /* ogg_open */ - /* Encoding quality in range [0.0, 1.0]. */ - double quality ; -} VORBIS_PRIVATE ; static int -ogg_read_header (SF_PRIVATE *psf, int log_data) -{ - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - char *buffer ; - int bytes ; - int i, nn ; +ogg_close (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + + ogg_sync_clear (&odata->osync) ; + ogg_stream_clear (&odata->ostream) ; + + return 0 ; +} /* ogg_close */ + +static int +ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata) +{ char *buffer ; + int bytes, nn ; + + /* Call this here so it only gets called once, so no memory is leaked. */ + ogg_sync_init (&odata->osync) ; odata->eos = 0 ; /* Weird stuff happens if these aren't called. */ - ogg_stream_reset (&odata->os) ; - ogg_sync_reset (&odata->oy) ; + ogg_stream_reset (&odata->ostream) ; + ogg_sync_reset (&odata->osync) ; /* ** Grab some data at the head of the stream. We want the first page @@ -157,7 +128,7 @@ ogg_read_header (SF_PRIVATE *psf, int log_data) */ /* Expose the buffer */ - buffer = ogg_sync_buffer (&odata->oy, 4096L) ; + buffer = ogg_sync_buffer (&odata->osync, 4096L) ; /* Grab the part of the header that has already been read. */ memcpy (buffer, psf->header, psf->headindex) ; @@ -165,10 +136,10 @@ ogg_read_header (SF_PRIVATE *psf, int log_data) /* Submit a 4k block to libvorbis' Ogg layer */ bytes += psf_fread (buffer + psf->headindex, 1, 4096 - psf->headindex, psf) ; - ogg_sync_wrote (&odata->oy, bytes) ; + ogg_sync_wrote (&odata->osync, bytes) ; /* Get the first page. */ - if ((nn = ogg_sync_pageout (&odata->oy, &odata->og)) != 1) + if ((nn = ogg_sync_pageout (&odata->osync, &odata->opage)) != 1) { /* Have we simply run out of data? If so, we're done. */ if (bytes < 4096) @@ -183,968 +154,92 @@ ogg_read_header (SF_PRIVATE *psf, int log_data) ** Get the serial number and set up the rest of decode. ** Serialno first ; use it to set up a logical stream. */ - ogg_stream_clear (&odata->os) ; - ogg_stream_init (&odata->os, ogg_page_serialno (&odata->og)) ; + ogg_stream_clear (&odata->ostream) ; + ogg_stream_init (&odata->ostream, ogg_page_serialno (&odata->opage)) ; - /* - ** This function (ogg_read_header) gets called multiple times, so the OGG - ** and vorbis structs have to be cleared every time we pass through to - ** prevent memory leaks. - */ - vorbis_block_clear (&vdata->vb) ; - vorbis_dsp_clear (&vdata->vd) ; - vorbis_comment_clear (&vdata->vc) ; - vorbis_info_clear (&vdata->vi) ; - - /* - ** Extract the initial header from the first page and verify that the - ** Ogg bitstream is in fact Vorbis data. - ** - ** I handle the initial header first instead of just having the code - ** read all three Vorbis headers at once because reading the initial - ** header is an easy way to identify a Vorbis bitstream and it's - ** useful to see that functionality seperated out. - */ - vorbis_info_init (&vdata->vi) ; - vorbis_comment_init (&vdata->vc) ; - - if (ogg_stream_pagein (&odata->os, &odata->og) < 0) + if (ogg_stream_pagein (&odata->ostream, &odata->opage) < 0) { /* Error ; stream version mismatch perhaps. */ psf_log_printf (psf, "Error reading first page of Ogg bitstream data\n") ; return SFE_MALFORMED_FILE ; } ; - if (ogg_stream_packetout (&odata->os, &odata->op) != 1) + if (ogg_stream_packetout (&odata->ostream, &odata->opacket) != 1) { /* No page? must not be vorbis. */ psf_log_printf (psf, "Error reading initial header packet.\n") ; return SFE_MALFORMED_FILE ; } ; - if (vorbis_synthesis_headerin (&vdata->vi, &vdata->vc, &odata->op) < 0) - { /* Error case ; not a vorbis header. */ - psf_log_printf (psf, "This Ogg bitstream does not contain Vorbis audio data.\n") ; - return SFE_MALFORMED_FILE ; - } ; + odata->codec = ogg_page_classify (psf, &odata->opage) ; - /* - ** Common Ogg metadata fields? - ** TITLE, VERSION, ALBUM, TRACKNUMBER, ARTIST, PERFORMER, COPYRIGHT, LICENSE, - ** ORGANIZATION, DESCRIPTION, GENRE, DATE, LOCATION, CONTACT, ISRC, - */ + switch (odata->codec) + { case OGG_VORBIS : + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; + return 0 ; - if (log_data) - { int k ; + case OGG_FLAC : + case OGG_FLAC0 : + psf->sf.format = SF_FORMAT_OGGFLAC ; + return 0 ; - for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++) - { char *dd ; + case OGG_SPEEX : + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; + return 0 ; - dd = vorbis_comment_query (&vdata->vc, vorbis_metatypes [k].name, 0) ; - if (dd == NULL) - continue ; - psf_store_string (psf, vorbis_metatypes [k].id, dd) ; - } ; - } ; - - /* - ** At this point, we're sure we're Vorbis. We've set up the logical (Ogg) - ** bitstream decoder. Get the comment and codebook headers and set up the - ** Vorbis decoder. - ** - ** The next two packets in order are the comment and codebook headers. - ** They're likely large and may span multiple pages. Thus we reead - ** and submit data until we get our two pacakets, watching that no - ** pages are missing. If a page is missing, error out ; losing a - ** header page is the only place where missing data is fatal. - */ - - i = 0 ; /* Count of number of packets read */ - while (i < 2) - { int result = ogg_sync_pageout (&odata->oy, &odata->og) ; - if (result == 0) - { /* Need more data */ - buffer = ogg_sync_buffer (&odata->oy, 4096) ; - bytes = psf_fread (buffer, 1, 4096, psf) ; - - if (bytes == 0 && i < 2) - { psf_log_printf (psf, "End of file before finding all Vorbis headers!\n") ; - return SFE_MALFORMED_FILE ; - } ; - nn = ogg_sync_wrote (&odata->oy, bytes) ; - } - else if (result == 1) - { /* - ** Don't complain about missing or corrupt data yet. We'll - ** catch it at the packet output phase. - ** - ** We can ignore any errors here as they'll also become apparent - ** at packetout. - */ - nn = ogg_stream_pagein (&odata->os, &odata->og) ; - while (i < 2) - { result = ogg_stream_packetout (&odata->os, &odata->op) ; - if (result == 0) - break ; - if (result < 0) - { /* Uh oh ; data at some point was corrupted or missing! - ** We can't tolerate that in a header. Die. */ - psf_log_printf (psf, "Corrupt secondary header. Exiting.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - vorbis_synthesis_headerin (&vdata->vi, &vdata->vc, &odata->op) ; - i++ ; - } ; - } ; - } ; - - if (log_data) - { int printed_metadata_msg = 0 ; - int k ; - - psf_log_printf (psf, "\nBitstream is %d channel, %D Hz\n", vdata->vi.channels, vdata->vi.rate) ; - psf_log_printf (psf, "Encoded by: %s\n", vdata->vc.vendor) ; - - /* Throw the comments plus a few lines about the bitstream we're decoding. */ - for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++) - { char *dd ; - - dd = vorbis_comment_query (&vdata->vc, vorbis_metatypes [k].name, 0) ; - if (dd == NULL) - continue ; - - if (printed_metadata_msg == 0) - { psf_log_printf (psf, "Metadata :\n") ; - printed_metadata_msg = 1 ; - } ; - - psf_store_string (psf, vorbis_metatypes [k].id, dd) ; - psf_log_printf (psf, " %-10s : %s\n", vorbis_metatypes [k].name, dd) ; - } ; - - psf_log_printf (psf, "End\n") ; - } ; - - psf->sf.samplerate = vdata->vi.rate ; - psf->sf.channels = vdata->vi.channels ; - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - - /* OK, got and parsed all three headers. Initialize the Vorbis - ** packet->PCM decoder. - ** Central decode state. */ - vorbis_synthesis_init (&vdata->vd, &vdata->vi) ; - - /* Local state for most of the decode so multiple block decodes can - ** proceed in parallel. We could init multiple vorbis_block structures - ** for vd here. */ - vorbis_block_init (&vdata->vd, &vdata->vb) ; - - vdata->loc = 0 ; - - return 0 ; -} /* ogg_read_header */ - -static int -ogg_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int k, ret ; - - vorbis_info_init (&vdata->vi) ; - - /* The style of encoding should be selectable here, VBR quality mode. */ - ret = vorbis_encode_init_vbr (&vdata->vi, psf->sf.channels, psf->sf.samplerate, vdata->quality) ; - -#if 0 - ret = vorbis_encode_init (&vdata->vi, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */ - ret = ( vorbis_encode_setup_managed (&vdata->vi, psf->sf.channels, - psf->sf.samplerate, -1, 128000, -1) || - vorbis_encode_ctl (&vdata->vi, OV_ECTL_RATEMANAGE_AVG, NULL) || - vorbis_encode_setup_init (&vdata->vi)) ; -#endif - if (ret) - return SFE_BAD_OPEN_FORMAT ; - - vdata->loc = 0 ; - - /* add a comment */ - vorbis_comment_init (&vdata->vc) ; - - vorbis_comment_add_tag (&vdata->vc, "ENCODER", "libsndfile") ; - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { const char * name ; - - if (psf->strings [k].type == 0) - break ; - - switch (psf->strings [k].type) - { case SF_STR_TITLE : name = "TITLE" ; break ; - case SF_STR_COPYRIGHT : name = "COPYRIGHT" ; break ; - case SF_STR_SOFTWARE : name = "SOFTWARE" ; break ; - case SF_STR_ARTIST : name = "ARTIST" ; break ; - case SF_STR_COMMENT : name = "COMMENT" ; break ; - case SF_STR_DATE : name = "DATE" ; break ; - case SF_STR_ALBUM : name = "ALBUM" ; break ; - case SF_STR_LICENSE : name = "LICENSE" ; break ; - default : continue ; - } ; - - vorbis_comment_add_tag (&vdata->vc, name, psf->strings [k].str) ; - } ; - - /* set up the analysis state and auxiliary encoding storage */ - vorbis_analysis_init (&vdata->vd, &vdata->vi) ; - vorbis_block_init (&vdata->vd, &vdata->vb) ; - - /* - ** Set up our packet->stream encoder. - ** Pick a random serial number ; that way we can more likely build - ** chained streams just by concatenation. - */ - - ogg_stream_init (&odata->os, psf_rand_int32 ()) ; - - /* Vorbis streams begin with three headers ; the initial header (with - most of the codec setup parameters) which is mandated by the Ogg - bitstream spec. The second header holds any comment fields. The - third header holds the bitstream codebook. We merely need to - make the headers, then pass them to libvorbis one at a time ; - libvorbis handles the additional Ogg bitstream constraints */ - - { ogg_packet header ; - ogg_packet header_comm ; - ogg_packet header_code ; - int result ; - - vorbis_analysis_headerout (&vdata->vd, &vdata->vc, &header, &header_comm, &header_code) ; - ogg_stream_packetin (&odata->os, &header) ; /* automatically placed in its own page */ - ogg_stream_packetin (&odata->os, &header_comm) ; - ogg_stream_packetin (&odata->os, &header_code) ; - - /* This ensures the actual - * audio data will start on a new page, as per spec - */ - while ((result = ogg_stream_flush (&odata->os, &odata->og)) != 0) - { psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ; - psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ; - } ; - } - - return 0 ; -} /* ogg_write_header */ - -static int -ogg_close (SF_PRIVATE *psf) -{ - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - - if (odata == NULL || vdata == NULL) - return 0 ; - - /* Clean up this logical bitstream ; before exit we shuld see if we're - ** followed by another [chained]. */ - - if (psf->mode == SFM_WRITE) - { - if (psf->write_current <= 0) - ogg_write_header (psf, 0) ; - - vorbis_analysis_wrote (&vdata->vd, 0) ; - while (vorbis_analysis_blockout (&vdata->vd, &vdata->vb) == 1) - { - - /* analysis, assume we want to use bitrate management */ - vorbis_analysis (&vdata->vb, NULL) ; - vorbis_bitrate_addblock (&vdata->vb) ; - - while (vorbis_bitrate_flushpacket (&vdata->vd, &odata->op)) - { /* weld the packet into the bitstream */ - ogg_stream_packetin (&odata->os, &odata->op) ; - - /* write out pages (if any) */ - while (!odata->eos) - { int result = ogg_stream_pageout (&odata->os, &odata->og) ; - if (result == 0) break ; - psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ; - psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ; - - /* this could be set above, but for illustrative purposes, I do - it here (to show that vorbis does know where the stream ends) */ - - if (ogg_page_eos (&odata->og)) odata->eos = 1 ; - } - } - } - } - - /* ogg_page and ogg_packet structs always point to storage in - libvorbis. They are never freed or manipulated directly */ - - vorbis_block_clear (&vdata->vb) ; - vorbis_dsp_clear (&vdata->vd) ; - vorbis_comment_clear (&vdata->vc) ; - vorbis_info_clear (&vdata->vi) ; /* must be called last */ - /* should look here to reopen if chained */ - - /* OK, clean up the framer */ - ogg_sync_clear (&odata->oy) ; - ogg_stream_clear (&odata->os) ; - - return 0 ; -} /* ogg_close */ - -int -ogg_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = calloc (1, sizeof (OGG_PRIVATE)) ; - VORBIS_PRIVATE* vdata = calloc (1, sizeof (VORBIS_PRIVATE)) ; - int error = 0 ; - - psf->container_data = odata ; - psf->codec_data = vdata ; - - if (psf->mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - -#if HAVE_VORBIS_VERSION_STRING - psf_log_printf (psf, "Vorbis library version : %s\n", vorbis_version_string ()) ; -#endif - - if (psf->mode == SFM_READ) - { /* Call this here so it only gets called once, so no memory is leaked. */ - ogg_sync_init (&odata->oy) ; - - if ((error = ogg_read_header (psf, 1))) - return error ; - - psf->read_short = ogg_read_s ; - psf->read_int = ogg_read_i ; - psf->read_float = ogg_read_f ; - psf->read_double = ogg_read_d ; - psf->sf.frames = ogg_length (psf) ; - } ; - - psf->container_close = ogg_close ; - if (psf->mode == SFM_WRITE) - { - /* Set the default vorbis quality here. */ - vdata->quality = 0.4 ; - - psf->write_header = ogg_write_header ; - psf->write_short = ogg_write_s ; - psf->write_int = ogg_write_i ; - psf->write_float = ogg_write_f ; - psf->write_double = ogg_write_d ; - - psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ - psf->str_flags = SF_STR_ALLOW_START ; - } ; - - psf->bytewidth = 1 ; - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - psf->seek = ogg_seek ; - psf->command = ogg_command ; - - /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - psf->sf.sections = 1 ; - - psf->datalength = 1 ; - psf->dataoffset = 0 ; - /* End FIXME. */ - - return error ; -} /* ogg_open */ - -static int -ogg_command (SF_PRIVATE *psf, int command, void * data, int datasize) -{ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - - switch (command) - { case SFC_SET_VBR_ENCODING_QUALITY : - if (data == NULL || datasize != sizeof (double)) - return 1 ; - - if (psf->have_written) - return 1 ; - - vdata->quality = *((double *) data) ; - - /* Clip range. */ - vdata->quality = SF_MAX (0.0, SF_MIN (1.0, vdata->quality)) ; - - psf_log_printf (psf, "%s : Setting SFC_SET_VBR_ENCODING_QUALITY to %f.\n", __func__, vdata->quality) ; - break ; + case OGG_PCM : + psf_log_printf (psf, "Detected Ogg/PCM data. This is not supported yet.\n") ; + return SFE_UNIMPLEMENTED ; default : - return 0 ; - } ; - - return 0 ; -} /* ogg_command */ - -static int -ogg_rnull (int samples, void *UNUSED (vptr), int UNUSED (off) , int channels, float **UNUSED (pcm)) -{ - return samples * channels ; -} /* ogg_rnull */ - -static int -ogg_rshort (int samples, void *vptr, int off, int channels, float **pcm) -{ - short *ptr = (short*) vptr + off ; - int i = 0, j, n ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = lrintf (pcm [n][j] * 32767.0f) ; - return i ; -} /* ogg_rshort */ - -static int -ogg_rint (int samples, void *vptr, int off, int channels, float **pcm) -{ - int *ptr = (int*) vptr + off ; - int i = 0, j, n ; - - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = lrintf (pcm [n][j] * 2147483647.0f) ; - return i ; -} /* ogg_rint */ - -static int -ogg_rfloat (int samples, void *vptr, int off, int channels, float **pcm) -{ - float *ptr = (float*) vptr + off ; - int i = 0, j, n ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = pcm [n][j] ; - return i ; -} /* ogg_rfloat */ - -static int -ogg_rdouble (int samples, void *vptr, int off, int channels, float **pcm) -{ - double *ptr = (double*) vptr + off ; - int i = 0, j, n ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = pcm [n][j] ; - return i ; -} /* ogg_rdouble */ - - -static sf_count_t -ogg_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) -{ - VORBIS_PRIVATE *vdata = psf->codec_data ; - OGG_PRIVATE *odata = psf->container_data ; - int len, samples, i = 0 ; - float **pcm ; - - len = lens / psf->sf.channels ; - - while ((samples = vorbis_synthesis_pcmout (&vdata->vd, &pcm)) > 0) - { if (samples > len) samples = len ; - i += transfn (samples, ptr, i, psf->sf.channels, pcm) ; - len -= samples ; - /* tell libvorbis how many samples we actually consumed */ - vorbis_synthesis_read (&vdata->vd, samples) ; - vdata->loc += samples ; - if (len == 0) - return i ; /* Is this necessary */ - } - goto start0 ; /* Jump into the nasty nest */ - while (len > 0 && !odata->eos) - { - while (len > 0 && !odata->eos) - { int result = ogg_sync_pageout (&odata->oy, &odata->og) ; - if (result == 0) break ; /* need more data */ - if (result < 0) - { /* missing or corrupt data at this page position */ - psf_log_printf (psf, "Corrupt or missing data in bitstream ; continuing...\n") ; - } - else - { /* can safely ignore errors at this point */ - ogg_stream_pagein (&odata->os, &odata->og) ; - start0: - while (1) - { result = ogg_stream_packetout (&odata->os, &odata->op) ; - if (result == 0) - break ; /* need more data */ - if (result < 0) - { /* missing or corrupt data at this page position */ - /* no reason to complain ; already complained above */ - } - else - { /* we have a packet. Decode it */ - if (vorbis_synthesis (&vdata->vb, &odata->op) == 0) /* test for success! */ - vorbis_synthesis_blockin (&vdata->vd, &vdata->vb) ; - /* - **pcm is a multichannel float vector. In stereo, for - example, pcm [0] is left, and pcm [1] is right. samples is - the size of each channel. Convert the float values - (-1.<=range<=1.) to whatever PCM format and write it out */ - - while ((samples = vorbis_synthesis_pcmout (&vdata->vd, &pcm)) > 0) - { if (samples>len) samples = len ; - i += transfn (samples, ptr, i, psf->sf.channels, pcm) ; - len -= samples ; - /* tell libvorbis how many samples we actually consumed */ - vorbis_synthesis_read (&vdata->vd, samples) ; - vdata->loc += samples ; - if (len == 0) - return i ; /* Is this necessary */ - } ; - } - } - if (ogg_page_eos (&odata->og)) odata->eos = 1 ; - } - } - if (!odata->eos) - { char *buffer ; - int bytes ; - buffer = ogg_sync_buffer (&odata->oy, 4096) ; - bytes = psf_fread (buffer, 1, 4096, psf) ; - ogg_sync_wrote (&odata->oy, bytes) ; - if (bytes == 0) odata->eos = 1 ; - } - } - return i ; -} /* ogg_read_sample */ - -static sf_count_t -ogg_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens) -{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rshort) ; -} /* ogg_read_s */ - -static sf_count_t -ogg_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens) -{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rint) ; -} /* ogg_read_i */ - -static sf_count_t -ogg_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens) -{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rfloat) ; -} /* ogg_read_f */ - -static sf_count_t -ogg_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens) -{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rdouble) ; -} /* ogg_read_d */ - -/*============================================================================== -*/ - -static void -ogg_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) -{ - vorbis_analysis_wrote (&vdata->vd, in_frames) ; - - /* - ** Vorbis does some data preanalysis, then divvies up blocks for - ** more involved (potentially parallel) processing. Get a single - ** block for encoding now. - */ - while (vorbis_analysis_blockout (&vdata->vd, &vdata->vb) == 1) - { - /* analysis, assume we want to use bitrate management */ - vorbis_analysis (&vdata->vb, NULL) ; - vorbis_bitrate_addblock (&vdata->vb) ; - - while (vorbis_bitrate_flushpacket (&vdata->vd, &odata->op)) - { - /* weld the packet into the bitstream */ - ogg_stream_packetin (&odata->os, &odata->op) ; - - /* write out pages (if any) */ - while (!odata->eos) - { int result = ogg_stream_pageout (&odata->os, &odata->og) ; - if (result == 0) - break ; - psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ; - psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ; - - /* This could be set above, but for illustrative purposes, I do - ** it here (to show that vorbis does know where the stream ends) */ - if (ogg_page_eos (&odata->og)) - odata->eos = 1 ; - } ; - } ; - } ; - - vdata->loc += in_frames ; -} /* ogg_write_data */ - - -static sf_count_t -ogg_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) -{ - int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) (ptr [j++]) / 32767.0f ; - - ogg_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* ogg_write_s */ - -static sf_count_t -ogg_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ; - - ogg_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* ogg_write_i */ - -static sf_count_t -ogg_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = ptr [j++] ; - - ogg_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* ogg_write_f */ - -static sf_count_t -ogg_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) ptr [j++] ; - - ogg_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* ogg_write_d */ - -static sf_count_t -ogg_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) -{ - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - - if (odata == NULL || vdata == NULL) - return 0 ; - - if (offset < 0) - { psf->error = SFE_BAD_SEEK ; - return ((sf_count_t) -1) ; - } ; - - if (psf->mode == SFM_READ) - { sf_count_t target = offset - vdata->loc ; - - if (target < 0) - { /* 12 to allow for OggS bit */ - psf_fseek (psf, 12, SEEK_SET) ; - ogg_read_header (psf, 0) ; /* Reset state */ - target = offset ; - } ; - - while (target > 0) - { sf_count_t m = target > 4096 ? 4096 : target ; - - /* - ** Need to multiply by channels here because the seek is done in - ** terms of frames and the read function is done in terms of - ** samples. - */ - ogg_read_sample (psf, (void *) NULL, m * psf->sf.channels, ogg_rnull) ; - - target -= m ; - } ; - - return vdata->loc ; - } ; - - return 0 ; -} /* ogg_seek */ - -/*============================================================================== -** Most of the following code was snipped from Mike Smith's ogginfo utility -** which is part of vorbis-tools. -** Vorbis tools is released under the GPL but Mike has kindly allowed the -** following to be relicensed as LGPL for libsndfile. -*/ - -typedef struct -{ - int isillegal ; - int shownillegal ; - int isnew ; - int end ; - - uint32_t serial ; /* must be 32 bit unsigned */ - ogg_stream_state os ; - - vorbis_info vi ; - vorbis_comment vc ; - sf_count_t lastgranulepos ; - int doneheaders ; -} stream_processor ; - -typedef struct -{ - stream_processor *streams ; - int allocated ; - int used ; - int in_headers ; -} stream_set ; - -static stream_set * -create_stream_set (void) -{ stream_set *set = calloc (1, sizeof (stream_set)) ; - - set->streams = calloc (5, sizeof (stream_processor)) ; - set->allocated = 5 ; - set->used = 0 ; - - return set ; -} /* create_stream_set */ - -static void -vorbis_end (stream_processor *stream, sf_count_t * len) -{ *len += stream->lastgranulepos ; - vorbis_comment_clear (&stream->vc) ; - vorbis_info_clear (&stream->vi) ; -} /* vorbis_end */ - -static void -free_stream_set (stream_set *set, sf_count_t * len) -{ int i ; - - for (i = 0 ; i < set->used ; i++) - { if (!set->streams [i].end) - vorbis_end (&set->streams [i], len) ; - ogg_stream_clear (&set->streams [i].os) ; - } ; - - free (set->streams) ; - free (set) ; -} /* free_stream_set */ - -static int -streams_open (stream_set *set) -{ int i, res = 0 ; - - for (i = 0 ; i < set->used ; i++) - if (!set->streams [i].end) - res ++ ; - return res ; -} /* streams_open */ - -static stream_processor * -find_stream_processor (stream_set *set, ogg_page *page) -{ uint32_t serial = ogg_page_serialno (page) ; - int i, found = 0 ; - int invalid = 0 ; - - stream_processor *stream ; - - for (i = 0 ; i < set->used ; i++) - { - if (serial == set->streams [i].serial) - { /* We have a match! */ - found = 1 ; - stream = & (set->streams [i]) ; - - set->in_headers = 0 ; - /* if we have detected EOS, then this can't occur here. */ - if (stream->end) - { stream->isillegal = 1 ; - return stream ; - } - - stream->isnew = 0 ; - stream->end = ogg_page_eos (page) ; - stream->serial = serial ; - return stream ; - } ; - } ; - - /* If there are streams open, and we've reached the end of the - ** headers, then we can't be starting a new stream. - ** XXX: might this sometimes catch ok streams if EOS flag is missing, - ** but the stream is otherwise ok? - */ - if (streams_open (set) && !set->in_headers) - invalid = 1 ; - - set->in_headers = 1 ; - - if (set->allocated < set->used) - stream = &set->streams [set->used] ; - else - { set->allocated += 5 ; - set->streams = realloc (set->streams, sizeof (stream_processor) * set->allocated) ; - stream = &set->streams [set->used] ; - } ; - - set->used++ ; - - stream->isnew = 1 ; - stream->isillegal = invalid ; - - { - int res ; - ogg_packet packet ; - - /* We end up processing the header page twice, but that's ok. */ - ogg_stream_init (&stream->os, serial) ; - ogg_stream_pagein (&stream->os, page) ; - res = ogg_stream_packetout (&stream->os, &packet) ; - if (res <= 0) - return NULL ; - else if (packet.bytes >= 7 && memcmp (packet.packet, "\x01vorbis", 7) == 0) - { - stream->lastgranulepos = 0 ; - vorbis_comment_init (&stream->vc) ; - vorbis_info_init (&stream->vi) ; - } ; - - res = ogg_stream_packetout (&stream->os, &packet) ; - - /* re-init, ready for processing */ - ogg_stream_clear (&stream->os) ; - ogg_stream_init (&stream->os, serial) ; - } - - stream->end = ogg_page_eos (page) ; - stream->serial = serial ; - - return stream ; -} /* find_stream_processor */ - -static int -ogg_length_get_next_page (SF_PRIVATE *psf, ogg_sync_state * osync, ogg_page *page) -{ static const int CHUNK_SIZE = 4500 ; - - while (ogg_sync_pageout (osync, page) <= 0) - { char * buffer = ogg_sync_buffer (osync, CHUNK_SIZE) ; - int bytes = psf_fread (buffer, 1, 4096, psf) ; - - if (bytes <= 0) - { ogg_sync_wrote (osync, 0) ; - return 0 ; - } ; - - ogg_sync_wrote (osync, bytes) ; - } ; - - return 1 ; -} /* ogg_length_get_next_page */ - -static sf_count_t -ogg_length_aux (SF_PRIVATE * psf) -{ - ogg_sync_state osync ; - ogg_page page ; - int gotpage = 0 ; - sf_count_t len = 0 ; - stream_set *processors ; - - processors = create_stream_set () ; - if (processors == NULL) - return 0 ; // out of memory? - - ogg_sync_init (&osync) ; - - while (ogg_length_get_next_page (psf, &osync, &page)) - { - stream_processor *p = find_stream_processor (processors, &page) ; - gotpage = 1 ; - - if (!p) - { len = 0 ; break ; - } ; + } ; - if (p->isillegal && !p->shownillegal) - { - p->shownillegal = 1 ; - /* If it's a new stream, we want to continue processing this page - ** anyway to suppress additional spurious errors - */ - if (!p->isnew) continue ; - } ; + psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ; + return SFE_UNIMPLEMENTED ; +} /* ogg_stream_classify */ - if (!p->isillegal) - { ogg_packet packet ; - int header = 0 ; +/*============================================================================== +*/ - ogg_stream_pagein (&p->os, &page) ; - if (p->doneheaders < 3) - header = 1 ; +static struct +{ const char *str, *name ; + int len, codec ; +} codec_lookup [] = +{ { "Annodex", "Annodex", 8, OGG_ANNODEX }, + { "AnxData", "AnxData", 7, OGG_ANXDATA }, + { "\177FLAC", "Flac1", 5, OGG_FLAC }, + { "fLaC", "Flac0", 4, OGG_FLAC0 }, + { "PCM ", "PCM", 8, OGG_PCM }, + { "Speex", "Speex", 5, OGG_SPEEX }, + { "\001vorbis", "Vorbis", 7, OGG_VORBIS }, +} ; - while (ogg_stream_packetout (&p->os, &packet) > 0) - { - if (p->doneheaders < 3) - { if (vorbis_synthesis_headerin (&p->vi, &p->vc, &packet) < 0) - continue ; - p->doneheaders ++ ; - } ; - } ; - if (!header) - { sf_count_t gp = ogg_page_granulepos (&page) ; - if (gp > 0) p->lastgranulepos = gp ; - } ; - if (p->end) - { vorbis_end (p, &len) ; - p->isillegal = 1 ; - } ; +static int +ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og) +{ int k, len ; + + for (k = 0 ; k < ARRAY_LEN (codec_lookup) ; k++) + { if (codec_lookup [k].len > og->body_len) + continue ; + + if (memcmp (og->body, codec_lookup [k].str, codec_lookup [k].len) == 0) + { psf_log_printf (psf, "Ogg stream data : %s\n", codec_lookup [k].name) ; + psf_log_printf (psf, "Stream serialno : %u\n", (uint32_t) ogg_page_serialno (og)) ; + return codec_lookup [k].codec ; } ; } ; - ogg_sync_clear (&osync) ; - free_stream_set (processors, &len) ; + len = og->body_len < 8 ? og->body_len : 8 ; - return len ; -} /* ogg_length_aux */ + psf_log_printf (psf, "Ogg_stream data : '") ; + for (k = 0 ; k < len ; k++) + psf_log_printf (psf, "%c", isprint (og->body [k]) ? og->body [k] : '.') ; + psf_log_printf (psf, "' ") ; + for (k = 0 ; k < len ; k++) + psf_log_printf (psf, " %02x", og->body [k] & 0xff) ; + psf_log_printf (psf, "\n") ; -static sf_count_t -ogg_length (SF_PRIVATE *psf) -{ sf_count_t length ; - int error ; - - if (psf->sf.seekable == 0) - return SF_COUNT_MAX ; - - psf_fseek (psf, 0, SEEK_SET) ; - length = ogg_length_aux (psf) ; - - psf_fseek (psf, 12, SEEK_SET) ; - if ((error = ogg_read_header (psf, 0)) != 0) - psf->error = error ; - - return length ; -} /* ogg_length */ + return 0 ; +} /* ogg_page_classify */ #else /* HAVE_EXTERNAL_LIBS */ diff --git a/libs/libsndfile/src/ogg.h b/libs/libsndfile/src/ogg.h new file mode 100644 index 0000000000..88544bb141 --- /dev/null +++ b/libs/libsndfile/src/ogg.h @@ -0,0 +1,52 @@ +/* +** Copyright (C) 2008-2011 Erik de Castro Lopo +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation ; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef SF_SRC_OGG_H + +enum +{ OGG_ANNODEX = 300, + OGG_ANXDATA, + OGG_FLAC, + OGG_FLAC0, + OGG_PCM, + OGG_SPEEX, + OGG_VORBIS, +} ; + +typedef struct +{ /* Sync and verify incoming physical bitstream */ + ogg_sync_state osync ; + /* Take physical pages, weld into a logical stream of packets */ + ogg_stream_state ostream ; + /* One Ogg bitstream page. Vorbis packets are inside */ + ogg_page opage ; + /* One raw packet of data for decode */ + ogg_packet opacket ; + int eos ; + int codec ; +} OGG_PRIVATE ; + + +#define readint(buf, base) (((buf [base + 3] << 24) & 0xff000000) | \ + ((buf [base + 2] <<16) & 0xff0000) | \ + ((buf [base + 1] << 8) & 0xff00) | \ + (buf [base] & 0xff)) + + + +#endif /* SF_SRC_OGG_H */ diff --git a/libs/libsndfile/src/ogg_opus.c b/libs/libsndfile/src/ogg_opus.c new file mode 100644 index 0000000000..0824810c0d --- /dev/null +++ b/libs/libsndfile/src/ogg_opus.c @@ -0,0 +1,149 @@ +/* +** Copyright (C) 2013 Erik de Castro Lopo +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation ; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#include "sfconfig.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +#if (ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS) + +#include + +#include "ogg.h" + +typedef struct +{ int32_t serialno ; + + + void * state ; +} OPUS_PRIVATE ; + +static int ogg_opus_read_header (SF_PRIVATE * psf) ; +static int ogg_opus_close (SF_PRIVATE *psf) ; + +int +ogg_opus_open (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + OPUS_PRIVATE* oopus = calloc (1, sizeof (OPUS_PRIVATE)) ; + int error = 0 ; + + if (odata == NULL) + { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; + return SFE_INTERNAL ; + } ; + + psf->codec_data = oopus ; + if (oopus == NULL) + return SFE_MALLOC_FAILED ; + + if (psf->file.mode == SFM_RDWR) + return SFE_BAD_MODE_RW ; + + if (psf->file.mode == SFM_READ) + { /* Call this here so it only gets called once, so no memory is leaked. */ + ogg_sync_init (&odata->osync) ; + + if ((error = ogg_opus_read_header (psf))) + return error ; + +#if 0 + psf->read_short = ogg_opus_read_s ; + psf->read_int = ogg_opus_read_i ; + psf->read_float = ogg_opus_read_f ; + psf->read_double = ogg_opus_read_d ; + psf->sf.frames = ogg_opus_length (psf) ; +#endif + } ; + + psf->codec_close = ogg_opus_close ; + + if (psf->file.mode == SFM_WRITE) + { +#if 0 + /* Set the default oopus quality here. */ + vdata->quality = 0.4 ; + + psf->write_header = ogg_opus_write_header ; + psf->write_short = ogg_opus_write_s ; + psf->write_int = ogg_opus_write_i ; + psf->write_float = ogg_opus_write_f ; + psf->write_double = ogg_opus_write_d ; +#endif + + psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ + psf->strings.flags = SF_STR_ALLOW_START ; + } ; + + psf->bytewidth = 1 ; + psf->blockwidth = psf->bytewidth * psf->sf.channels ; + +#if 0 + psf->seek = ogg_opus_seek ; + psf->command = ogg_opus_command ; +#endif + + /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; + psf->sf.sections = 1 ; + + psf->datalength = 1 ; + psf->dataoffset = 0 ; + /* End FIXME. */ + + return error ; +} /* ogg_opus_open */ + +static int +ogg_opus_read_header (SF_PRIVATE * UNUSED (psf)) +{ + return 0 ; +} /* ogg_opus_read_header */ + +static int +ogg_opus_close (SF_PRIVATE * UNUSED (psf)) +{ + + + return 0 ; +} /* ogg_opus_close */ + + +#else /* ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS */ + +int +ogg_opus_open (SF_PRIVATE *psf) +{ + psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Opus support.\n") ; + return SFE_UNIMPLEMENTED ; +} /* ogg_opus_open */ + +#endif diff --git a/libs/libsndfile/src/ogg_pcm.c b/libs/libsndfile/src/ogg_pcm.c new file mode 100644 index 0000000000..2e3b7f251c --- /dev/null +++ b/libs/libsndfile/src/ogg_pcm.c @@ -0,0 +1,164 @@ +/* +** Copyright (C) 2008-2012 Erik de Castro Lopo +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation ; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#include "sfconfig.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +#if (ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS) + +#include + +#include "ogg.h" + +typedef struct +{ int32_t serialno ; + + + void * state ; +} OPCM_PRIVATE ; + +static int opcm_read_header (SF_PRIVATE * psf) ; +static int opcm_close (SF_PRIVATE *psf) ; + +int +ogg_pcm_open (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + OPCM_PRIVATE* opcm = calloc (1, sizeof (OPCM_PRIVATE)) ; + int error = 0 ; + + if (odata == NULL) + { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; + return SFE_INTERNAL ; + } ; + + psf->codec_data = opcm ; + if (opcm == NULL) + return SFE_MALLOC_FAILED ; + + if (psf->file.mode == SFM_RDWR) + return SFE_BAD_MODE_RW ; + + if (psf->file.mode == SFM_READ) + { /* Call this here so it only gets called once, so no memory is leaked. */ + ogg_sync_init (&odata->osync) ; + + if ((error = opcm_read_header (psf))) + return error ; + +#if 0 + psf->read_short = opcm_read_s ; + psf->read_int = opcm_read_i ; + psf->read_float = opcm_read_f ; + psf->read_double = opcm_read_d ; + psf->sf.frames = opcm_length (psf) ; +#endif + } ; + + psf->codec_close = opcm_close ; + + if (psf->file.mode == SFM_WRITE) + { +#if 0 + /* Set the default opcm quality here. */ + vdata->quality = 0.4 ; + + psf->write_header = opcm_write_header ; + psf->write_short = opcm_write_s ; + psf->write_int = opcm_write_i ; + psf->write_float = opcm_write_f ; + psf->write_double = opcm_write_d ; +#endif + + psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ + psf->strings.flags = SF_STR_ALLOW_START ; + } ; + + psf->bytewidth = 1 ; + psf->blockwidth = psf->bytewidth * psf->sf.channels ; + +#if 0 + psf->seek = opcm_seek ; + psf->command = opcm_command ; +#endif + + /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; + psf->sf.sections = 1 ; + + psf->datalength = 1 ; + psf->dataoffset = 0 ; + /* End FIXME. */ + + return error ; +} /* ogg_pcm_open */ + +static int +opcm_read_header (SF_PRIVATE * UNUSED (psf)) +{ + return 0 ; +} /* opcm_read_header */ + +static int +opcm_close (SF_PRIVATE * UNUSED (psf)) +{ + + + return 0 ; +} /* opcm_close */ + + + +/* +encoded_speex_frames = (frames_per_packet * Packets) + = 1 * 272 + = 272 + +audio_samples = encoded_speex_frames * frame_size + = 272 * 640 + = 174080 + +duration = audio_samples / rate + = 174080 / 44100 + = 3.947 +*/ + +#else /* ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS */ + +int +ogg_pcm_open (SF_PRIVATE *psf) +{ + psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Speex support.\n") ; + return SFE_UNIMPLEMENTED ; +} /* ogg_pcm_open */ + +#endif diff --git a/libs/libsndfile/src/ogg_speex.c b/libs/libsndfile/src/ogg_speex.c new file mode 100644 index 0000000000..f24e242e57 --- /dev/null +++ b/libs/libsndfile/src/ogg_speex.c @@ -0,0 +1,425 @@ +/* +** Copyright (C) 2008-2012 Erik de Castro Lopo +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation ; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#include "sfconfig.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +#if (ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS) + +#include + +#include +#include +#include +#include + +#include "ogg.h" + +#define OGG_SPX_READ_SIZE 200 + +typedef struct +{ SpeexBits bits ; + + int32_t serialno ; + + int frame_size, granule_frame_size, nframes ; + int force_mode ; + + SpeexStereoState stereo ; + SpeexHeader header ; + + void * state ; +} SPX_PRIVATE ; + +static int spx_read_header (SF_PRIVATE * psf) ; +static int spx_close (SF_PRIVATE *psf) ; +static void *spx_header_read (SF_PRIVATE * psf, ogg_packet *op, spx_int32_t enh_enabled, int force_mode) ; +static void spx_print_comments (const char *comments, int length) ; + +int +ogg_speex_open (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + SPX_PRIVATE* spx = calloc (1, sizeof (SPX_PRIVATE)) ; + int error = 0 ; + + if (odata == NULL) + { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; + return SFE_INTERNAL ; + } ; + + psf->codec_data = spx ; + if (spx == NULL) + return SFE_MALLOC_FAILED ; + + if (psf->file.mode == SFM_RDWR) + return SFE_BAD_MODE_RW ; + + if (psf->file.mode == SFM_READ) + { /* Call this here so it only gets called once, so no memory is leaked. */ + ogg_sync_init (&odata->osync) ; + + if ((error = spx_read_header (psf))) + return error ; + +#if 0 + psf->read_short = spx_read_s ; + psf->read_int = spx_read_i ; + psf->read_float = spx_read_f ; + psf->read_double = spx_read_d ; + psf->sf.frames = spx_length (psf) ; +#endif + } ; + + psf->codec_close = spx_close ; + + if (psf->file.mode == SFM_WRITE) + { +#if 0 + /* Set the default spx quality here. */ + vdata->quality = 0.4 ; + + psf->write_header = spx_write_header ; + psf->write_short = spx_write_s ; + psf->write_int = spx_write_i ; + psf->write_float = spx_write_f ; + psf->write_double = spx_write_d ; +#endif + + psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ + psf->strings.flags = SF_STR_ALLOW_START ; + } ; + + psf->bytewidth = 1 ; + psf->blockwidth = psf->bytewidth * psf->sf.channels ; + +#if 0 + psf->seek = spx_seek ; + psf->command = spx_command ; +#endif + + /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; + psf->sf.sections = 1 ; + + psf->datalength = 1 ; + psf->dataoffset = 0 ; + /* End FIXME. */ + + return error ; +} /* ogg_speex_open */ + +#define le_short (x) (x) + +static int +spx_read_header (SF_PRIVATE * psf) +{ static SpeexStereoState STEREO_INIT = SPEEX_STEREO_STATE_INIT ; + + OGG_PRIVATE* odata = psf->container_data ; + SPX_PRIVATE* spx = psf->codec_data ; + + ogg_int64_t page_granule = 0 ; + int stream_init = 0 ; + int page_nb_packets = 0 ; + int packet_count = 0 ; + int enh_enabled = 1 ; + int force_mode = -1 ; + char * data ; + int nb_read ; + int lookahead ; + +printf ("%s %d\n", __func__, __LINE__) ; + + psf_log_printf (psf, "Speex header\n") ; + odata->eos = 0 ; + + /* Reset ogg stuff which has already been used in src/ogg.c. */ + ogg_stream_reset (&odata->ostream) ; + ogg_sync_reset (&odata->osync) ; + + /* Seek to start of stream. */ + psf_fseek (psf, 0, SEEK_SET) ; + + /* Initialize. */ + ogg_sync_init (&odata->osync) ; + speex_bits_init (&spx->bits) ; + + /* Set defaults. */ + psf->sf.channels = -1 ; + psf->sf.samplerate = 0 ; + spx->stereo = STEREO_INIT ; + + /* Get a pointer to the ogg buffer and read data into it. */ + data = ogg_sync_buffer (&odata->osync, OGG_SPX_READ_SIZE) ; + nb_read = psf_fread (data, 1, OGG_SPX_READ_SIZE, psf) ; + ogg_sync_wrote (&odata->osync, nb_read) ; + + /* Now we chew on Ogg packets. */ + while (ogg_sync_pageout (&odata->osync, &odata->opage) == 1) + { if (stream_init == 0) + { ogg_stream_init (&odata->ostream, ogg_page_serialno (&odata->opage)) ; + stream_init = 1 ; + } ; + + if (ogg_page_serialno (&odata->opage) != odata->ostream.serialno) + { /* so all streams are read. */ + ogg_stream_reset_serialno (&odata->ostream, ogg_page_serialno (&odata->opage)) ; + } ; + + /*Add page to the bitstream*/ + ogg_stream_pagein (&odata->ostream, &odata->opage) ; + page_granule = ogg_page_granulepos (&odata->opage) ; + page_nb_packets = ogg_page_packets (&odata->opage) ; + + /*Extract all available packets*/ + while (odata->eos == 0 && ogg_stream_packetout (&odata->ostream, &odata->opacket) == 1) + { if (odata->opacket.bytes >= 8 && memcmp (odata->opacket.packet, "Speex ", 8) == 0) + { spx->serialno = odata->ostream.serialno ; + } ; + + if (spx->serialno == -1 || odata->ostream.serialno != spx->serialno) + break ; + + if (packet_count == 0) + { spx->state = spx_header_read (psf, &odata->opacket, enh_enabled, force_mode) ; + if (! spx->state) + break ; + + speex_decoder_ctl (spx->state, SPEEX_GET_LOOKAHEAD, &lookahead) ; + if (spx->nframes == 0) + spx->nframes = 1 ; + } + else if (packet_count == 1) + { spx_print_comments ((const char*) odata->opacket.packet, odata->opacket.bytes) ; + } + else if (packet_count < 2 + spx->header.extra_headers) + { /* Ignore extra headers */ + } + packet_count ++ ; + } ; + } ; + + psf_log_printf (psf, "End\n") ; + + psf_log_printf (psf, "packet_count %d\n", packet_count) ; + psf_log_printf (psf, "page_nb_packets %d\n", page_nb_packets) ; + psf_log_printf (psf, "page_granule %lld\n", page_granule) ; + + return 0 ; +} /* spx_read_header */ + +static int +spx_close (SF_PRIVATE *psf) +{ SPX_PRIVATE* spx = psf->codec_data ; + + if (spx->state) + speex_decoder_destroy (spx->state) ; + + if (spx) + speex_bits_destroy (&spx->bits) ; + + return 0 ; +} /* spx_close */ + + + +static void * +spx_header_read (SF_PRIVATE * psf, ogg_packet *op, spx_int32_t enh_enabled, int force_mode) +{ SPX_PRIVATE* spx = psf->codec_data ; + void *st ; + const SpeexMode *mode ; + SpeexHeader *tmp_header ; + int modeID ; + SpeexCallback callback ; + + tmp_header = speex_packet_to_header ((char*) op->packet, op->bytes) ; + if (tmp_header == NULL) + { psf_log_printf (psf, "Cannot read Speex header\n") ; + return NULL ; + } ; + + memcpy (&spx->header, tmp_header, sizeof (spx->header)) ; + free (tmp_header) ; + tmp_header = NULL ; + + if (spx->header.mode >= SPEEX_NB_MODES || spx->header.mode < 0) + { psf_log_printf (psf, "Mode number %d does not (yet/any longer) exist in this version\n", spx->header.mode) ; + return NULL ; + } ; + + modeID = spx->header.mode ; + if (force_mode != -1) + modeID = force_mode ; + + mode = speex_lib_get_mode (modeID) ; + + if (spx->header.speex_version_id > 1) + { psf_log_printf (psf, "This file was encoded with Speex bit-stream version %d, which I don't know how to decode\n", spx->header.speex_version_id) ; + return NULL ; + } ; + + if (mode->bitstream_version < spx->header.mode_bitstream_version) + { psf_log_printf (psf, "The file was encoded with a newer version of Speex. You need to upgrade in order to play it.\n") ; + return NULL ; + } ; + + if (mode->bitstream_version > spx->header.mode_bitstream_version) + { psf_log_printf (psf, "The file was encoded with an older version of Speex. You would need to downgrade the version in order to play it.\n") ; + return NULL ; + } ; + + st = speex_decoder_init (mode) ; + if (!st) + { psf_log_printf (psf, "Decoder initialization failed.\n") ; + return NULL ; + } ; + + speex_decoder_ctl (st, SPEEX_SET_ENH, &enh_enabled) ; + speex_decoder_ctl (st, SPEEX_GET_FRAME_SIZE, &spx->frame_size) ; + spx->granule_frame_size = spx->frame_size ; + + if (!psf->sf.samplerate) + psf->sf.samplerate = spx->header.rate ; + /* Adjust rate if --force-* options are used */ + if (force_mode != -1) + { if (spx->header.mode < force_mode) + { psf->sf.samplerate <<= (force_mode - spx->header.mode) ; + spx->granule_frame_size >>= (force_mode - spx->header.mode) ; + } ; + if (spx->header.mode > force_mode) + { psf->sf.samplerate >>= (spx->header.mode - force_mode) ; + spx->granule_frame_size <<= (spx->header.mode - force_mode) ; + } ; + } ; + + speex_decoder_ctl (st, SPEEX_SET_SAMPLING_RATE, &psf->sf.samplerate) ; + + spx->nframes = spx->header.frames_per_packet ; + + if (psf->sf.channels == -1) + psf->sf.channels = spx->header.nb_channels ; + + if (! (psf->sf.channels == 1)) + { psf->sf.channels = 2 ; + callback.callback_id = SPEEX_INBAND_STEREO ; + callback.func = speex_std_stereo_request_handler ; + callback.data = &spx->stereo ; + speex_decoder_ctl (st, SPEEX_SET_HANDLER, &callback) ; + } ; + + spx->header.speex_version [sizeof (spx->header.speex_version) - 1] = 0 ; + + psf_log_printf (psf, " Encoder ver : %s\n Frames/packet : %d\n", + spx->header.speex_version, spx->header.frames_per_packet) ; + + if (spx->header.bitrate > 0) + psf_log_printf (psf, " Bit rate : %d\n", spx->header.bitrate) ; + + psf_log_printf (psf, " Sample rate : %d\n Mode : %s\n VBR : %s\n Channels : %d\n", + psf->sf.samplerate, mode->modeName, (spx->header.vbr ? "yes" : "no"), psf->sf.channels) ; + + psf_log_printf (psf, " Extra headers : %d\n", spx->header.extra_headers) ; + + return st ; +} /* spx_header_read */ + + +static void +spx_print_comments (const char *c, int length) +{ + const char *end ; + int len, i, nb_fields ; + +printf ("%s %d\n", __func__, __LINE__) ; + if (length < 8) + { fprintf (stderr, "Invalid/corrupted comments\n") ; + return ; + } + end = c + length ; + len = readint (c, 0) ; + c += 4 ; + if (len < 0 || c + len > end) + { fprintf (stderr, "Invalid/corrupted comments\n") ; + return ; + } + (void) fwrite (c, 1, len, stderr) ; + c += len ; + fprintf (stderr, "\n") ; + if (c + 4 > end) + { fprintf (stderr, "Invalid/corrupted comments\n") ; + return ; + } + nb_fields = readint (c, 0) ; + c += 4 ; + for (i = 0 ; i < nb_fields ; i++) + { if (c + 4 > end) + { fprintf (stderr, "Invalid/corrupted comments\n") ; + return ; + } ; + len = readint (c, 0) ; + c += 4 ; + if (len < 0 || c + len > end) + { fprintf (stderr, "Invalid/corrupted comments\n") ; + return ; + } + (void) fwrite (c, 1, len, stderr) ; + c += len ; + fprintf (stderr, "\n") ; + } ; + return ; +} /* spx_print_comments */ + + +/* +encoded_speex_frames = (frames_per_packet * Packets) + = 1 * 272 + = 272 + +audio_samples = encoded_speex_frames * frame_size + = 272 * 640 + = 174080 + +duration = audio_samples / rate + = 174080 / 44100 + = 3.947 +*/ + +#else /* ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_LIBS */ + +int +ogg_speex_open (SF_PRIVATE *psf) +{ + psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Speex support.\n") ; + return SFE_UNIMPLEMENTED ; +} /* ogg_speex_open */ + +#endif diff --git a/libs/libsndfile/src/ogg_vorbis.c b/libs/libsndfile/src/ogg_vorbis.c new file mode 100644 index 0000000000..4d1adef20f --- /dev/null +++ b/libs/libsndfile/src/ogg_vorbis.c @@ -0,0 +1,1172 @@ +/* +** Copyright (C) 2002-2012 Erik de Castro Lopo +** Copyright (C) 2002-2005 Michael Smith +** Copyright (C) 2007 John ffitch +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation ; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +** Much of this code is based on the examples in libvorbis from the +** XIPHOPHORUS Company http://www.xiph.org/ which has a BSD-style Licence +** Copyright (c) 2002, Xiph.org Foundation +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** - Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** - Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** - Neither the name of the Xiph.org Foundation nor the names of its +** contributors may be used to endorse or promote products derived from +** this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE, +** DATA, OR PROFITS ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include "sndfile.h" +#include "sfendian.h" +#include "common.h" + +#if HAVE_EXTERNAL_LIBS + +#include +#include +#include + +#include "ogg.h" + +typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ; + +static int vorbis_read_header (SF_PRIVATE *psf, int log_data) ; +static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ; +static int vorbis_close (SF_PRIVATE *psf) ; +static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; +static int vorbis_byterate (SF_PRIVATE *psf) ; +static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; +static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; +static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; +static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; +static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; +static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; +static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; +static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; +static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; +static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ; +static sf_count_t vorbis_length (SF_PRIVATE *psf) ; + +typedef struct +{ int id ; + const char *name ; +} STR_PAIRS ; + +static STR_PAIRS vorbis_metatypes [] = +{ { SF_STR_TITLE, "Title" }, + { SF_STR_COPYRIGHT, "Copyright" }, + { SF_STR_SOFTWARE, "Software" }, + { SF_STR_ARTIST, "Artist" }, + { SF_STR_COMMENT, "Comment" }, + { SF_STR_DATE, "Date" }, + { SF_STR_ALBUM, "Album" }, + { SF_STR_LICENSE, "License" }, +} ; + +typedef struct +{ /* Count current location */ + sf_count_t loc ; + /* Struct that stores all the static vorbis bitstream settings */ + vorbis_info vinfo ; + /* Struct that stores all the bitstream user comments */ + vorbis_comment vcomment ; + /* Ventral working state for the packet->PCM decoder */ + vorbis_dsp_state vdsp ; + /* Local working space for packet->PCM decode */ + vorbis_block vblock ; + + /* Encoding quality in range [0.0, 1.0]. */ + double quality ; +} VORBIS_PRIVATE ; + +static int +vorbis_read_header (SF_PRIVATE *psf, int log_data) +{ + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + char *buffer ; + int bytes ; + int i, nn ; + + odata->eos = 0 ; + + /* Weird stuff happens if these aren't called. */ + ogg_stream_reset (&odata->ostream) ; + ogg_sync_reset (&odata->osync) ; + + /* + ** Grab some data at the head of the stream. We want the first page + ** (which is guaranteed to be small and only contain the Vorbis + ** stream initial header) We need the first page to get the stream + ** serialno. + */ + + /* Expose the buffer */ + buffer = ogg_sync_buffer (&odata->osync, 4096L) ; + + /* Grab the part of the header that has already been read. */ + memcpy (buffer, psf->header, psf->headindex) ; + bytes = psf->headindex ; + + /* Submit a 4k block to libvorbis' Ogg layer */ + bytes += psf_fread (buffer + psf->headindex, 1, 4096 - psf->headindex, psf) ; + ogg_sync_wrote (&odata->osync, bytes) ; + + /* Get the first page. */ + if ((nn = ogg_sync_pageout (&odata->osync, &odata->opage)) != 1) + { + /* Have we simply run out of data? If so, we're done. */ + if (bytes < 4096) + return 0 ; + + /* Error case. Must not be Vorbis data */ + psf_log_printf (psf, "Input does not appear to be an Ogg bitstream.\n") ; + return SFE_MALFORMED_FILE ; + } ; + + /* + ** Get the serial number and set up the rest of decode. + ** Serialno first ; use it to set up a logical stream. + */ + ogg_stream_clear (&odata->ostream) ; + ogg_stream_init (&odata->ostream, ogg_page_serialno (&odata->opage)) ; + + if (ogg_stream_pagein (&odata->ostream, &odata->opage) < 0) + { /* Error ; stream version mismatch perhaps. */ + psf_log_printf (psf, "Error reading first page of Ogg bitstream data\n") ; + return SFE_MALFORMED_FILE ; + } ; + + if (ogg_stream_packetout (&odata->ostream, &odata->opacket) != 1) + { /* No page? must not be vorbis. */ + psf_log_printf (psf, "Error reading initial header packet.\n") ; + return SFE_MALFORMED_FILE ; + } ; + + /* + ** This function (vorbis_read_header) gets called multiple times, so the OGG + ** and vorbis structs have to be cleared every time we pass through to + ** prevent memory leaks. + */ + vorbis_block_clear (&vdata->vblock) ; + vorbis_dsp_clear (&vdata->vdsp) ; + vorbis_comment_clear (&vdata->vcomment) ; + vorbis_info_clear (&vdata->vinfo) ; + + /* + ** Extract the initial header from the first page and verify that the + ** Ogg bitstream is in fact Vorbis data. + ** + ** I handle the initial header first instead of just having the code + ** read all three Vorbis headers at once because reading the initial + ** header is an easy way to identify a Vorbis bitstream and it's + ** useful to see that functionality seperated out. + */ + vorbis_info_init (&vdata->vinfo) ; + vorbis_comment_init (&vdata->vcomment) ; + + if (vorbis_synthesis_headerin (&vdata->vinfo, &vdata->vcomment, &odata->opacket) < 0) + { /* Error case ; not a vorbis header. */ + psf_log_printf (psf, "Found Vorbis in stream header, but vorbis_synthesis_headerin failed.\n") ; + return SFE_MALFORMED_FILE ; + } ; + + /* + ** Common Ogg metadata fields? + ** TITLE, VERSION, ALBUM, TRACKNUMBER, ARTIST, PERFORMER, COPYRIGHT, LICENSE, + ** ORGANIZATION, DESCRIPTION, GENRE, DATE, LOCATION, CONTACT, ISRC, + */ + + if (log_data) + { int k ; + + for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++) + { char *dd ; + + dd = vorbis_comment_query (&vdata->vcomment, vorbis_metatypes [k].name, 0) ; + if (dd == NULL) + continue ; + psf_store_string (psf, vorbis_metatypes [k].id, dd) ; + } ; + } ; + + /* + ** At this point, we're sure we're Vorbis. We've set up the logical (Ogg) + ** bitstream decoder. Get the comment and codebook headers and set up the + ** Vorbis decoder. + ** + ** The next two packets in order are the comment and codebook headers. + ** They're likely large and may span multiple pages. Thus we reead + ** and submit data until we get our two pacakets, watching that no + ** pages are missing. If a page is missing, error out ; losing a + ** header page is the only place where missing data is fatal. + */ + + i = 0 ; /* Count of number of packets read */ + while (i < 2) + { int result = ogg_sync_pageout (&odata->osync, &odata->opage) ; + if (result == 0) + { /* Need more data */ + buffer = ogg_sync_buffer (&odata->osync, 4096) ; + bytes = psf_fread (buffer, 1, 4096, psf) ; + + if (bytes == 0 && i < 2) + { psf_log_printf (psf, "End of file before finding all Vorbis headers!\n") ; + return SFE_MALFORMED_FILE ; + } ; + nn = ogg_sync_wrote (&odata->osync, bytes) ; + } + else if (result == 1) + { /* + ** Don't complain about missing or corrupt data yet. We'll + ** catch it at the packet output phase. + ** + ** We can ignore any errors here as they'll also become apparent + ** at packetout. + */ + nn = ogg_stream_pagein (&odata->ostream, &odata->opage) ; + while (i < 2) + { result = ogg_stream_packetout (&odata->ostream, &odata->opacket) ; + if (result == 0) + break ; + if (result < 0) + { /* Uh oh ; data at some point was corrupted or missing! + ** We can't tolerate that in a header. Die. */ + psf_log_printf (psf, "Corrupt secondary header. Exiting.\n") ; + return SFE_MALFORMED_FILE ; + } ; + + vorbis_synthesis_headerin (&vdata->vinfo, &vdata->vcomment, &odata->opacket) ; + i++ ; + } ; + } ; + } ; + + if (log_data) + { int printed_metadata_msg = 0 ; + int k ; + + psf_log_printf (psf, "Bitstream is %d channel, %D Hz\n", vdata->vinfo.channels, vdata->vinfo.rate) ; + psf_log_printf (psf, "Encoded by : %s\n", vdata->vcomment.vendor) ; + + /* Throw the comments plus a few lines about the bitstream we're decoding. */ + for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++) + { char *dd ; + + dd = vorbis_comment_query (&vdata->vcomment, vorbis_metatypes [k].name, 0) ; + if (dd == NULL) + continue ; + + if (printed_metadata_msg == 0) + { psf_log_printf (psf, "Metadata :\n") ; + printed_metadata_msg = 1 ; + } ; + + psf_store_string (psf, vorbis_metatypes [k].id, dd) ; + psf_log_printf (psf, " %-10s : %s\n", vorbis_metatypes [k].name, dd) ; + } ; + + psf_log_printf (psf, "End\n") ; + } ; + + psf->sf.samplerate = vdata->vinfo.rate ; + psf->sf.channels = vdata->vinfo.channels ; + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; + + /* OK, got and parsed all three headers. Initialize the Vorbis + ** packet->PCM decoder. + ** Central decode state. */ + vorbis_synthesis_init (&vdata->vdsp, &vdata->vinfo) ; + + /* Local state for most of the decode so multiple block decodes can + ** proceed in parallel. We could init multiple vorbis_block structures + ** for vd here. */ + vorbis_block_init (&vdata->vdsp, &vdata->vblock) ; + + vdata->loc = 0 ; + + return 0 ; +} /* vorbis_read_header */ + +static int +vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) +{ + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int k, ret ; + + vorbis_info_init (&vdata->vinfo) ; + + /* The style of encoding should be selectable here, VBR quality mode. */ + ret = vorbis_encode_init_vbr (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality) ; + +#if 0 + ret = vorbis_encode_init (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */ + ret = ( vorbis_encode_setup_managed (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) + || vorbis_encode_ctl (&vdata->vinfo, OV_ECTL_RATEMANAGE_AVG, NULL) + || vorbis_encode_setup_init (&vdata->vinfo) + ) ; +#endif + if (ret) + return SFE_BAD_OPEN_FORMAT ; + + vdata->loc = 0 ; + + /* add a comment */ + vorbis_comment_init (&vdata->vcomment) ; + + vorbis_comment_add_tag (&vdata->vcomment, "ENCODER", "libsndfile") ; + for (k = 0 ; k < SF_MAX_STRINGS ; k++) + { const char * name ; + + if (psf->strings.data [k].type == 0) + break ; + + switch (psf->strings.data [k].type) + { case SF_STR_TITLE : name = "TITLE" ; break ; + case SF_STR_COPYRIGHT : name = "COPYRIGHT" ; break ; + case SF_STR_SOFTWARE : name = "SOFTWARE" ; break ; + case SF_STR_ARTIST : name = "ARTIST" ; break ; + case SF_STR_COMMENT : name = "COMMENT" ; break ; + case SF_STR_DATE : name = "DATE" ; break ; + case SF_STR_ALBUM : name = "ALBUM" ; break ; + case SF_STR_LICENSE : name = "LICENSE" ; break ; + default : continue ; + } ; + + vorbis_comment_add_tag (&vdata->vcomment, name, psf->strings.storage + psf->strings.data [k].offset) ; + } ; + + /* set up the analysis state and auxiliary encoding storage */ + vorbis_analysis_init (&vdata->vdsp, &vdata->vinfo) ; + vorbis_block_init (&vdata->vdsp, &vdata->vblock) ; + + /* + ** Set up our packet->stream encoder. + ** Pick a random serial number ; that way we can more likely build + ** chained streams just by concatenation. + */ + + ogg_stream_init (&odata->ostream, psf_rand_int32 ()) ; + + /* Vorbis streams begin with three headers ; the initial header (with + most of the codec setup parameters) which is mandated by the Ogg + bitstream spec. The second header holds any comment fields. The + third header holds the bitstream codebook. We merely need to + make the headers, then pass them to libvorbis one at a time ; + libvorbis handles the additional Ogg bitstream constraints */ + + { ogg_packet header ; + ogg_packet header_comm ; + ogg_packet header_code ; + int result ; + + vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ; + ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */ + ogg_stream_packetin (&odata->ostream, &header_comm) ; + ogg_stream_packetin (&odata->ostream, &header_code) ; + + /* This ensures the actual + * audio data will start on a new page, as per spec + */ + while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0) + { psf_fwrite (odata->opage.header, 1, odata->opage.header_len, psf) ; + psf_fwrite (odata->opage.body, 1, odata->opage.body_len, psf) ; + } ; + } + + return 0 ; +} /* vorbis_write_header */ + +static int +vorbis_close (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + VORBIS_PRIVATE *vdata = psf->codec_data ; + + if (odata == NULL || vdata == NULL) + return 0 ; + + /* Clean up this logical bitstream ; before exit we shuld see if we're + ** followed by another [chained]. */ + + if (psf->file.mode == SFM_WRITE) + { + if (psf->write_current <= 0) + vorbis_write_header (psf, 0) ; + + vorbis_analysis_wrote (&vdata->vdsp, 0) ; + while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) + { + + /* analysis, assume we want to use bitrate management */ + vorbis_analysis (&vdata->vblock, NULL) ; + vorbis_bitrate_addblock (&vdata->vblock) ; + + while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) + { /* weld the packet into the bitstream */ + ogg_stream_packetin (&odata->ostream, &odata->opacket) ; + + /* write out pages (if any) */ + while (!odata->eos) + { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; + if (result == 0) break ; + psf_fwrite (odata->opage.header, 1, odata->opage.header_len, psf) ; + psf_fwrite (odata->opage.body, 1, odata->opage.body_len, psf) ; + + /* this could be set above, but for illustrative purposes, I do + it here (to show that vorbis does know where the stream ends) */ + + if (ogg_page_eos (&odata->opage)) odata->eos = 1 ; + } + } + } + } + + /* ogg_page and ogg_packet structs always point to storage in + libvorbis. They are never freed or manipulated directly */ + + vorbis_block_clear (&vdata->vblock) ; + vorbis_dsp_clear (&vdata->vdsp) ; + vorbis_comment_clear (&vdata->vcomment) ; + vorbis_info_clear (&vdata->vinfo) ; + + return 0 ; +} /* vorbis_close */ + +int +ogg_vorbis_open (SF_PRIVATE *psf) +{ OGG_PRIVATE* odata = psf->container_data ; + VORBIS_PRIVATE* vdata = calloc (1, sizeof (VORBIS_PRIVATE)) ; + int error = 0 ; + + if (odata == NULL) + { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; + return SFE_INTERNAL ; + } ; + + psf->codec_data = vdata ; + + if (psf->file.mode == SFM_RDWR) + return SFE_BAD_MODE_RW ; + + psf_log_printf (psf, "Vorbis library version : %s\n", vorbis_version_string ()) ; + + if (psf->file.mode == SFM_READ) + { /* Call this here so it only gets called once, so no memory is leaked. */ + ogg_sync_init (&odata->osync) ; + + if ((error = vorbis_read_header (psf, 1))) + return error ; + + psf->read_short = vorbis_read_s ; + psf->read_int = vorbis_read_i ; + psf->read_float = vorbis_read_f ; + psf->read_double = vorbis_read_d ; + psf->sf.frames = vorbis_length (psf) ; + } ; + + psf->codec_close = vorbis_close ; + if (psf->file.mode == SFM_WRITE) + { + /* Set the default vorbis quality here. */ + vdata->quality = 0.4 ; + + psf->write_header = vorbis_write_header ; + psf->write_short = vorbis_write_s ; + psf->write_int = vorbis_write_i ; + psf->write_float = vorbis_write_f ; + psf->write_double = vorbis_write_d ; + + psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ + psf->strings.flags = SF_STR_ALLOW_START ; + } ; + + psf->seek = vorbis_seek ; + psf->command = vorbis_command ; + psf->byterate = vorbis_byterate ; + + /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ + psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; + psf->sf.sections = 1 ; + + psf->datalength = 1 ; + psf->dataoffset = 0 ; + /* End FIXME. */ + + return error ; +} /* ogg_vorbis_open */ + +static int +vorbis_command (SF_PRIVATE *psf, int command, void * data, int datasize) +{ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + + switch (command) + { case SFC_SET_COMPRESSION_LEVEL : + if (data == NULL || datasize != sizeof (double)) + return SF_FALSE ; + + if (psf->have_written) + return SF_FALSE ; + + vdata->quality = 1.0 - *((double *) data) ; + + /* Clip range. */ + vdata->quality = SF_MAX (0.0, SF_MIN (1.0, vdata->quality)) ; + + psf_log_printf (psf, "%s : Setting SFC_SET_VBR_ENCODING_QUALITY to %f.\n", __func__, vdata->quality) ; + return SF_TRUE ; + + default : + return SF_FALSE ; + } ; + + return SF_FALSE ; +} /* vorbis_command */ + +static int +vorbis_rnull (SF_PRIVATE *UNUSED (psf), int samples, void *UNUSED (vptr), int UNUSED (off) , int channels, float **UNUSED (pcm)) +{ + return samples * channels ; +} /* vorbis_rnull */ + +static int +vorbis_rshort (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm) +{ + short *ptr = (short*) vptr + off ; + int i = 0, j, n ; + if (psf->float_int_mult) + { + float inverse = 1.0 / psf->float_max ; + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = lrintf ((pcm [n][j] * inverse) * 32767.0f) ; + } + else + { + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = lrintf (pcm [n][j] * 32767.0f) ; + } + return i ; +} /* vorbis_rshort */ + +static int +vorbis_rint (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm) +{ + int *ptr = (int*) vptr + off ; + int i = 0, j, n ; + + if (psf->float_int_mult) + { + float inverse = 1.0 / psf->float_max ; + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = lrintf ((pcm [n][j] * inverse) * 2147483647.0f) ; + } + else + { + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = lrintf (pcm [n][j] * 2147483647.0f) ; + } + return i ; +} /* vorbis_rint */ + +static int +vorbis_rfloat (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm) +{ + float *ptr = (float*) vptr + off ; + int i = 0, j, n ; + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = pcm [n][j] ; + return i ; +} /* vorbis_rfloat */ + +static int +vorbis_rdouble (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm) +{ + double *ptr = (double*) vptr + off ; + int i = 0, j, n ; + for (j = 0 ; j < samples ; j++) + for (n = 0 ; n < channels ; n++) + ptr [i++] = pcm [n][j] ; + return i ; +} /* vorbis_rdouble */ + + +static sf_count_t +vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) +{ + VORBIS_PRIVATE *vdata = psf->codec_data ; + OGG_PRIVATE *odata = psf->container_data ; + int len, samples, i = 0 ; + float **pcm ; + + len = lens / psf->sf.channels ; + + while ((samples = vorbis_synthesis_pcmout (&vdata->vdsp, &pcm)) > 0) + { if (samples > len) samples = len ; + i += transfn (psf, samples, ptr, i, psf->sf.channels, pcm) ; + len -= samples ; + /* tell libvorbis how many samples we actually consumed */ + vorbis_synthesis_read (&vdata->vdsp, samples) ; + vdata->loc += samples ; + if (len == 0) + return i ; /* Is this necessary */ + } + goto start0 ; /* Jump into the nasty nest */ + while (len > 0 && !odata->eos) + { + while (len > 0 && !odata->eos) + { int result = ogg_sync_pageout (&odata->osync, &odata->opage) ; + if (result == 0) break ; /* need more data */ + if (result < 0) + { /* missing or corrupt data at this page position */ + psf_log_printf (psf, "Corrupt or missing data in bitstream ; continuing...\n") ; + } + else + { /* can safely ignore errors at this point */ + ogg_stream_pagein (&odata->ostream, &odata->opage) ; + start0: + while (1) + { result = ogg_stream_packetout (&odata->ostream, &odata->opacket) ; + if (result == 0) + break ; /* need more data */ + if (result < 0) + { /* missing or corrupt data at this page position */ + /* no reason to complain ; already complained above */ + } + else + { /* we have a packet. Decode it */ + if (vorbis_synthesis (&vdata->vblock, &odata->opacket) == 0) /* test for success! */ + vorbis_synthesis_blockin (&vdata->vdsp, &vdata->vblock) ; + /* + ** pcm is a multichannel float vector. In stereo, for + ** example, pcm [0] is left, and pcm [1] is right. samples is + ** the size of each channel. Convert the float values + ** (-1.<=range<=1.) to whatever PCM format and write it out. + */ + + while ((samples = vorbis_synthesis_pcmout (&vdata->vdsp, &pcm)) > 0) + { if (samples > len) samples = len ; + i += transfn (psf, samples, ptr, i, psf->sf.channels, pcm) ; + len -= samples ; + /* tell libvorbis how many samples we actually consumed */ + vorbis_synthesis_read (&vdata->vdsp, samples) ; + vdata->loc += samples ; + if (len == 0) + return i ; /* Is this necessary */ + } ; + } + } + if (ogg_page_eos (&odata->opage)) odata->eos = 1 ; + } + } + if (!odata->eos) + { char *buffer ; + int bytes ; + buffer = ogg_sync_buffer (&odata->osync, 4096) ; + bytes = psf_fread (buffer, 1, 4096, psf) ; + ogg_sync_wrote (&odata->osync, bytes) ; + if (bytes == 0) odata->eos = 1 ; + } + } + return i ; +} /* vorbis_read_sample */ + +static sf_count_t +vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens) +{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rshort) ; +} /* vorbis_read_s */ + +static sf_count_t +vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens) +{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rint) ; +} /* vorbis_read_i */ + +static sf_count_t +vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens) +{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rfloat) ; +} /* vorbis_read_f */ + +static sf_count_t +vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens) +{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rdouble) ; +} /* vorbis_read_d */ + +/*============================================================================== +*/ + +static void +vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) +{ + vorbis_analysis_wrote (&vdata->vdsp, in_frames) ; + + /* + ** Vorbis does some data preanalysis, then divvies up blocks for + ** more involved (potentially parallel) processing. Get a single + ** block for encoding now. + */ + while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) + { + /* analysis, assume we want to use bitrate management */ + vorbis_analysis (&vdata->vblock, NULL) ; + vorbis_bitrate_addblock (&vdata->vblock) ; + + while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) + { + /* weld the packet into the bitstream */ + ogg_stream_packetin (&odata->ostream, &odata->opacket) ; + + /* write out pages (if any) */ + while (!odata->eos) + { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; + if (result == 0) + break ; + psf_fwrite (odata->opage.header, 1, odata->opage.header_len, psf) ; + psf_fwrite (odata->opage.body, 1, odata->opage.body_len, psf) ; + + /* This could be set above, but for illustrative purposes, I do + ** it here (to show that vorbis does know where the stream ends) */ + if (ogg_page_eos (&odata->opage)) + odata->eos = 1 ; + } ; + } ; + } ; + + vdata->loc += in_frames ; +} /* vorbis_write_data */ + + +static sf_count_t +vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) +{ + int i, m, j = 0 ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; + float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; + for (i = 0 ; i < in_frames ; i++) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) (ptr [j++]) / 32767.0f ; + + vorbis_write_samples (psf, odata, vdata, in_frames) ; + + return lens ; +} /* vorbis_write_s */ + +static sf_count_t +vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) +{ int i, m, j = 0 ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; + float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; + for (i = 0 ; i < in_frames ; i++) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ; + + vorbis_write_samples (psf, odata, vdata, in_frames) ; + + return lens ; +} /* vorbis_write_i */ + +static sf_count_t +vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) +{ int i, m, j = 0 ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; + float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; + for (i = 0 ; i < in_frames ; i++) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = ptr [j++] ; + + vorbis_write_samples (psf, odata, vdata, in_frames) ; + + return lens ; +} /* vorbis_write_f */ + +static sf_count_t +vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) +{ int i, m, j = 0 ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; + float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; + for (i = 0 ; i < in_frames ; i++) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) ptr [j++] ; + + vorbis_write_samples (psf, odata, vdata, in_frames) ; + + return lens ; +} /* vorbis_write_d */ + +static sf_count_t +vorbis_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) +{ + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + + if (odata == NULL || vdata == NULL) + return 0 ; + + if (offset < 0) + { psf->error = SFE_BAD_SEEK ; + return ((sf_count_t) -1) ; + } ; + + if (psf->file.mode == SFM_READ) + { sf_count_t target = offset - vdata->loc ; + + if (target < 0) + { /* 12 to allow for OggS bit */ + psf_fseek (psf, 12, SEEK_SET) ; + vorbis_read_header (psf, 0) ; /* Reset state */ + target = offset ; + } ; + + while (target > 0) + { sf_count_t m = target > 4096 ? 4096 : target ; + + /* + ** Need to multiply by channels here because the seek is done in + ** terms of frames and the read function is done in terms of + ** samples. + */ + vorbis_read_sample (psf, (void *) NULL, m * psf->sf.channels, vorbis_rnull) ; + + target -= m ; + } ; + + return vdata->loc ; + } ; + + return 0 ; +} /* vorbis_seek */ + + +static int +vorbis_byterate (SF_PRIVATE *psf) +{ + if (psf->file.mode == SFM_READ) + return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; + + return -1 ; +} /* vorbis_byterate */ + +/*============================================================================== +** Most of the following code was snipped from Mike Smith's ogginfo utility +** which is part of vorbis-tools. +** Vorbis tools is released under the GPL but Mike has kindly allowed the +** following to be relicensed as LGPL for libsndfile. +*/ + +typedef struct +{ + int isillegal ; + int shownillegal ; + int isnew ; + int end ; + + uint32_t serial ; /* must be 32 bit unsigned */ + ogg_stream_state ostream ; + + vorbis_info vinfo ; + vorbis_comment vcomment ; + sf_count_t lastgranulepos ; + int doneheaders ; +} stream_processor ; + +typedef struct +{ + stream_processor *streams ; + int allocated ; + int used ; + int in_headers ; +} stream_set ; + +static stream_set * +create_stream_set (void) +{ stream_set *set = calloc (1, sizeof (stream_set)) ; + + set->streams = calloc (5, sizeof (stream_processor)) ; + set->allocated = 5 ; + set->used = 0 ; + + return set ; +} /* create_stream_set */ + +static void +vorbis_end (stream_processor *stream, sf_count_t * len) +{ *len += stream->lastgranulepos ; + vorbis_comment_clear (&stream->vcomment) ; + vorbis_info_clear (&stream->vinfo) ; +} /* vorbis_end */ + +static void +free_stream_set (stream_set *set, sf_count_t * len) +{ int i ; + + for (i = 0 ; i < set->used ; i++) + { if (!set->streams [i].end) + vorbis_end (&set->streams [i], len) ; + ogg_stream_clear (&set->streams [i].ostream) ; + } ; + + free (set->streams) ; + free (set) ; +} /* free_stream_set */ + +static int +streams_open (stream_set *set) +{ int i, res = 0 ; + + for (i = 0 ; i < set->used ; i++) + if (!set->streams [i].end) + res ++ ; + return res ; +} /* streams_open */ + +static stream_processor * +find_stream_processor (stream_set *set, ogg_page *page) +{ uint32_t serial = ogg_page_serialno (page) ; + int i, invalid = 0 ; + + stream_processor *stream ; + + for (i = 0 ; i < set->used ; i++) + { + if (serial == set->streams [i].serial) + { /* We have a match! */ + stream = & (set->streams [i]) ; + + set->in_headers = 0 ; + /* if we have detected EOS, then this can't occur here. */ + if (stream->end) + { stream->isillegal = 1 ; + return stream ; + } + + stream->isnew = 0 ; + stream->end = ogg_page_eos (page) ; + stream->serial = serial ; + return stream ; + } ; + } ; + + /* If there are streams open, and we've reached the end of the + ** headers, then we can't be starting a new stream. + ** XXX: might this sometimes catch ok streams if EOS flag is missing, + ** but the stream is otherwise ok? + */ + if (streams_open (set) && !set->in_headers) + invalid = 1 ; + + set->in_headers = 1 ; + + if (set->allocated < set->used) + stream = &set->streams [set->used] ; + else + { set->allocated += 5 ; + set->streams = realloc (set->streams, sizeof (stream_processor) * set->allocated) ; + stream = &set->streams [set->used] ; + } ; + + set->used++ ; + + stream->isnew = 1 ; + stream->isillegal = invalid ; + + { + int res ; + ogg_packet packet ; + + /* We end up processing the header page twice, but that's ok. */ + ogg_stream_init (&stream->ostream, serial) ; + ogg_stream_pagein (&stream->ostream, page) ; + res = ogg_stream_packetout (&stream->ostream, &packet) ; + if (res <= 0) + return NULL ; + else if (packet.bytes >= 7 && memcmp (packet.packet, "\x01vorbis", 7) == 0) + { + stream->lastgranulepos = 0 ; + vorbis_comment_init (&stream->vcomment) ; + vorbis_info_init (&stream->vinfo) ; + } ; + + res = ogg_stream_packetout (&stream->ostream, &packet) ; + + /* re-init, ready for processing */ + ogg_stream_clear (&stream->ostream) ; + ogg_stream_init (&stream->ostream, serial) ; + } + + stream->end = ogg_page_eos (page) ; + stream->serial = serial ; + + return stream ; +} /* find_stream_processor */ + +static int +vorbis_length_get_next_page (SF_PRIVATE *psf, ogg_sync_state * osync, ogg_page *page) +{ static const int CHUNK_SIZE = 4500 ; + + while (ogg_sync_pageout (osync, page) <= 0) + { char * buffer = ogg_sync_buffer (osync, CHUNK_SIZE) ; + int bytes = psf_fread (buffer, 1, 4096, psf) ; + + if (bytes <= 0) + { ogg_sync_wrote (osync, 0) ; + return 0 ; + } ; + + ogg_sync_wrote (osync, bytes) ; + } ; + + return 1 ; +} /* vorbis_length_get_next_page */ + +static sf_count_t +vorbis_length_aux (SF_PRIVATE * psf) +{ + ogg_sync_state osync ; + ogg_page page ; + sf_count_t len = 0 ; + stream_set *processors ; + + processors = create_stream_set () ; + if (processors == NULL) + return 0 ; // out of memory? + + ogg_sync_init (&osync) ; + + while (vorbis_length_get_next_page (psf, &osync, &page)) + { + stream_processor *p = find_stream_processor (processors, &page) ; + + if (!p) + { len = 0 ; + break ; + } ; + + if (p->isillegal && !p->shownillegal) + { + p->shownillegal = 1 ; + /* If it's a new stream, we want to continue processing this page + ** anyway to suppress additional spurious errors + */ + if (!p->isnew) continue ; + } ; + + if (!p->isillegal) + { ogg_packet packet ; + int header = 0 ; + + ogg_stream_pagein (&p->ostream, &page) ; + if (p->doneheaders < 3) + header = 1 ; + + while (ogg_stream_packetout (&p->ostream, &packet) > 0) + { + if (p->doneheaders < 3) + { if (vorbis_synthesis_headerin (&p->vinfo, &p->vcomment, &packet) < 0) + continue ; + p->doneheaders ++ ; + } ; + } ; + if (!header) + { sf_count_t gp = ogg_page_granulepos (&page) ; + if (gp > 0) p->lastgranulepos = gp ; + } ; + if (p->end) + { vorbis_end (p, &len) ; + p->isillegal = 1 ; + } ; + } ; + } ; + + ogg_sync_clear (&osync) ; + free_stream_set (processors, &len) ; + + return len ; +} /* vorbis_length_aux */ + +static sf_count_t +vorbis_length (SF_PRIVATE *psf) +{ sf_count_t length ; + int error ; + + if (psf->sf.seekable == 0) + return SF_COUNT_MAX ; + + psf_fseek (psf, 0, SEEK_SET) ; + length = vorbis_length_aux (psf) ; + + psf_fseek (psf, 12, SEEK_SET) ; + if ((error = vorbis_read_header (psf, 0)) != 0) + psf->error = error ; + + return length ; +} /* vorbis_length */ + +#else /* HAVE_EXTERNAL_LIBS */ + +int +ogg_vorbis_open (SF_PRIVATE *psf) +{ + psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Vorbis support.\n") ; + return SFE_UNIMPLEMENTED ; +} /* ogg_vorbis_open */ + +#endif diff --git a/libs/libsndfile/src/paf.c b/libs/libsndfile/src/paf.c index b4737dc316..1360c33710 100644 --- a/libs/libsndfile/src/paf.c +++ b/libs/libsndfile/src/paf.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -52,23 +52,19 @@ typedef struct { int version ; int endianness ; - int samplerate ; - int format ; + int samplerate ; + int format ; int channels ; int source ; } PAF_FMT ; typedef struct -{ int max_blocks, channels, samplesperblock, blocksize ; +{ int max_blocks, channels, blocksize ; int read_block, write_block, read_count, write_count ; sf_count_t sample_count ; int *samples ; unsigned char *block ; -#if HAVE_FLEXIBLE_ARRAY int data [] ; /* ISO C99 struct flexible array. */ -#else - int data [1] ; /* This is a hack and may not work. */ -#endif } PAF24_PRIVATE ; /*------------------------------------------------------------------------------ @@ -108,14 +104,14 @@ paf_open (SF_PRIVATE *psf) psf->dataoffset = PAF_HEADER_LENGTH ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = paf_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PAF) return SFE_BAD_OPEN_FORMAT ; @@ -163,6 +159,9 @@ paf_read_header (SF_PRIVATE *psf) { PAF_FMT paf_fmt ; int marker ; + if (psf->filelength < PAF_HEADER_LENGTH) + return SFE_PAF_SHORT_HEADER ; + memset (&paf_fmt, 0, sizeof (paf_fmt)) ; psf_binheader_readf (psf, "pm", 0, &marker) ; @@ -199,8 +198,8 @@ paf_read_header (SF_PRIVATE *psf) psf->endian = SF_ENDIAN_BIG ; } ; - if (psf->filelength < PAF_HEADER_LENGTH) - return SFE_PAF_SHORT_HEADER ; + if (paf_fmt.channels < 1 || paf_fmt.channels > SF_MAX_CHANNELS) + return SFE_PAF_BAD_CHANNELS ; psf->datalength = psf->filelength - psf->dataoffset ; @@ -356,20 +355,18 @@ paf24_init (SF_PRIVATE *psf) */ psf->last_op = 0 ; - if (! (psf->codec_data = malloc (paf24size))) + if (! (psf->codec_data = calloc (1, paf24size))) return SFE_MALLOC_FAILED ; ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - memset (ppaf24, 0, paf24size) ; ppaf24->channels = psf->sf.channels ; ppaf24->samples = ppaf24->data ; ppaf24->block = (unsigned char*) (ppaf24->data + PAF24_SAMPLES_PER_BLOCK * ppaf24->channels) ; ppaf24->blocksize = PAF24_BLOCK_SIZE * ppaf24->channels ; - ppaf24->samplesperblock = PAF24_SAMPLES_PER_BLOCK ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { paf24_read_block (psf, ppaf24) ; /* Read first block. */ psf->read_short = paf24_read_s ; @@ -378,7 +375,7 @@ paf24_init (SF_PRIVATE *psf) psf->read_double = paf24_read_d ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { psf->write_short = paf24_write_s ; psf->write_int = paf24_write_i ; psf->write_float = paf24_write_f ; @@ -392,7 +389,7 @@ paf24_init (SF_PRIVATE *psf) psf->datalength = psf->filelength - psf->dataoffset ; if (psf->datalength % PAF24_BLOCK_SIZE) - { if (psf->mode == SFM_READ) + { if (psf->file.mode == SFM_READ) psf_log_printf (psf, "*** Warning : file seems to be truncated.\n") ; ppaf24->max_blocks = psf->datalength / ppaf24->blocksize + 1 ; } @@ -400,12 +397,12 @@ paf24_init (SF_PRIVATE *psf) ppaf24->max_blocks = psf->datalength / ppaf24->blocksize ; ppaf24->read_block = 0 ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) ppaf24->write_block = ppaf24->max_blocks ; else ppaf24->write_block = 0 ; - psf->sf.frames = ppaf24->samplesperblock * ppaf24->max_blocks ; + psf->sf.frames = PAF24_SAMPLES_PER_BLOCK * ppaf24->max_blocks ; ppaf24->sample_count = psf->sf.frames ; return 0 ; @@ -426,8 +423,8 @@ paf24_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) if (mode == SFM_READ && ppaf24->write_count > 0) paf24_write_block (psf, ppaf24) ; - newblock = offset / ppaf24->samplesperblock ; - newsample = offset % ppaf24->samplesperblock ; + newblock = offset / PAF24_SAMPLES_PER_BLOCK ; + newsample = offset % PAF24_SAMPLES_PER_BLOCK ; switch (mode) { case SFM_READ : @@ -460,7 +457,7 @@ paf24_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) return PSF_SEEK_ERROR ; } ; - return newblock * ppaf24->samplesperblock + newsample ; + return newblock * PAF24_SAMPLES_PER_BLOCK + newsample ; } /* paf24_seek */ static int @@ -472,7 +469,7 @@ paf24_close (SF_PRIVATE *psf) ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (ppaf24->write_count > 0) paf24_write_block (psf, ppaf24) ; } ; @@ -490,8 +487,8 @@ paf24_read_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) ppaf24->read_block ++ ; ppaf24->read_count = 0 ; - if (ppaf24->read_block * ppaf24->samplesperblock > ppaf24->sample_count) - { memset (ppaf24->samples, 0, ppaf24->samplesperblock * ppaf24->channels) ; + if (ppaf24->read_block * PAF24_SAMPLES_PER_BLOCK > ppaf24->sample_count) + { memset (ppaf24->samples, 0, PAF24_SAMPLES_PER_BLOCK * ppaf24->channels) ; return 1 ; } ; @@ -500,29 +497,15 @@ paf24_read_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, ppaf24->blocksize) ; - if (CPU_IS_LITTLE_ENDIAN) - { /* Do endian swapping if necessary. */ - if (psf->endian == SF_ENDIAN_BIG) - endswap_int_array (ppaf24->data, 8 * ppaf24->channels) ; + /* Do endian swapping if necessary. */ + if (psf->endian == SF_ENDIAN_BIG) + endswap_int_array (ppaf24->data, 8 * ppaf24->channels) ; - /* Unpack block. */ - for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) - { channel = k % ppaf24->channels ; - cptr = ppaf24->block + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; - ppaf24->samples [k] = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ; - } ; - } - else - { /* Do endian swapping if necessary. */ - if (psf->endian == SF_ENDIAN_BIG) - endswap_int_array (ppaf24->data, 8 * ppaf24->channels) ; - - /* Unpack block. */ - for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) - { channel = k % ppaf24->channels ; - cptr = ppaf24->block + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; - ppaf24->samples [k] = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ; - } ; + /* Unpack block. */ + for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) + { channel = k % ppaf24->channels ; + cptr = ppaf24->block + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; + ppaf24->samples [k] = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ; } ; return 1 ; @@ -533,15 +516,15 @@ paf24_read (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len) { int count, total = 0 ; while (total < len) - { if (ppaf24->read_block * ppaf24->samplesperblock >= ppaf24->sample_count) + { if (ppaf24->read_block * PAF24_SAMPLES_PER_BLOCK >= ppaf24->sample_count) { memset (&(ptr [total]), 0, (len - total) * sizeof (int)) ; return total ; } ; - if (ppaf24->read_count >= ppaf24->samplesperblock) + if (ppaf24->read_count >= PAF24_SAMPLES_PER_BLOCK) paf24_read_block (psf, ppaf24) ; - count = (ppaf24->samplesperblock - ppaf24->read_count) * ppaf24->channels ; + count = (PAF24_SAMPLES_PER_BLOCK - ppaf24->read_count) * ppaf24->channels ; count = (len - total > count) ? count : len - total ; memcpy (&(ptr [total]), &(ppaf24->samples [ppaf24->read_count * ppaf24->channels]), count * sizeof (int)) ; @@ -554,7 +537,8 @@ paf24_read (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len) static sf_count_t paf24_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -563,8 +547,8 @@ paf24_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) return 0 ; ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = paf24_read (psf, ppaf24, iptr, readcount) ; @@ -592,7 +576,8 @@ paf24_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t paf24_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -604,8 +589,8 @@ paf24_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 / 0x80000000) : (1.0 / 0x100) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = paf24_read (psf, ppaf24, iptr, readcount) ; @@ -619,7 +604,8 @@ paf24_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t paf24_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -631,8 +617,8 @@ paf24_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 / 0x80000000) : (1.0 / 0x100) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = paf24_read (psf, ppaf24, iptr, readcount) ; @@ -686,10 +672,10 @@ paf24_write_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) if ((k = psf_fwrite (ppaf24->block, 1, ppaf24->blocksize, psf)) != ppaf24->blocksize) psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, ppaf24->blocksize) ; - if (ppaf24->sample_count < ppaf24->write_block * ppaf24->samplesperblock + ppaf24->write_count) - ppaf24->sample_count = ppaf24->write_block * ppaf24->samplesperblock + ppaf24->write_count ; + if (ppaf24->sample_count < ppaf24->write_block * PAF24_SAMPLES_PER_BLOCK + ppaf24->write_count) + ppaf24->sample_count = ppaf24->write_block * PAF24_SAMPLES_PER_BLOCK + ppaf24->write_count ; - if (ppaf24->write_count == ppaf24->samplesperblock) + if (ppaf24->write_count == PAF24_SAMPLES_PER_BLOCK) { ppaf24->write_block ++ ; ppaf24->write_count = 0 ; } ; @@ -702,7 +688,7 @@ paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, const int *ptr, int len) { int count, total = 0 ; while (total < len) - { count = (ppaf24->samplesperblock - ppaf24->write_count) * ppaf24->channels ; + { count = (PAF24_SAMPLES_PER_BLOCK - ppaf24->write_count) * ppaf24->channels ; if (count > len - total) count = len - total ; @@ -711,7 +697,7 @@ paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, const int *ptr, int len) total += count ; ppaf24->write_count += count / ppaf24->channels ; - if (ppaf24->write_count >= ppaf24->samplesperblock) + if (ppaf24->write_count >= PAF24_SAMPLES_PER_BLOCK) paf24_write_block (psf, ppaf24) ; } ; @@ -720,7 +706,8 @@ paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, const int *ptr, int len) static sf_count_t paf24_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -729,8 +716,8 @@ paf24_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) return 0 ; ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -770,7 +757,8 @@ paf24_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t paf24_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -782,8 +770,8 @@ paf24_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : (1.0 / 0x100) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -800,7 +788,8 @@ paf24_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t paf24_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; +{ BUF_UNION ubuf ; + PAF24_PRIVATE *ppaf24 ; int *iptr ; int k, bufferlen, writecount = 0, count ; sf_count_t total = 0 ; @@ -812,8 +801,8 @@ paf24_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : (1.0 / 0x100) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) diff --git a/libs/libsndfile/src/pcm.c b/libs/libsndfile/src/pcm.c index 76cb58b5da..8a06858b2a 100644 --- a/libs/libsndfile/src/pcm.c +++ b/libs/libsndfile/src/pcm.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -137,7 +137,7 @@ pcm_init (SF_PRIVATE *psf) else psf->data_endswap = (psf->endian == SF_ENDIAN_LITTLE) ? SF_FALSE : SF_TRUE ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { switch (psf->bytewidth * 0x10000 + psf->endian + chars) { case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) : case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) : @@ -198,7 +198,7 @@ pcm_init (SF_PRIVATE *psf) } ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { switch (psf->bytewidth * 0x10000 + psf->endian + chars) { case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) : case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) : @@ -271,7 +271,7 @@ pcm_init (SF_PRIVATE *psf) else psf->datalength = 0 ; - psf->sf.frames = psf->datalength / psf->blockwidth ; + psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; return 0 ; } /* pcm_init */ @@ -300,7 +300,7 @@ let2s_array (tribyte *src, int count, short *dest) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - dest [count] = LET2H_SHORT_PTR (ucptr) ; + dest [count] = LET2H_16_PTR (ucptr) ; } ; } /* let2s_array */ @@ -311,7 +311,7 @@ bet2s_array (tribyte *src, int count, short *dest) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - dest [count] = BET2H_SHORT_PTR (ucptr) ; + dest [count] = BET2H_16_PTR (ucptr) ; } ; } /* bet2s_array */ @@ -320,7 +320,7 @@ lei2s_array (int *src, int count, short *dest) { int value ; while (--count >= 0) - { value = LEI2H_INT (src [count]) ; + { value = LE2H_32 (src [count]) ; dest [count] = value >> 16 ; } ; } /* lei2s_array */ @@ -330,7 +330,7 @@ bei2s_array (int *src, int count, short *dest) { int value ; while (--count >= 0) - { value = BEI2H_INT (src [count]) ; + { value = BE2H_32 (src [count]) ; dest [count] = value >> 16 ; } ; } /* bei2s_array */ @@ -357,7 +357,7 @@ bes2i_array (short *src, int count, int *dest) { short value ; while (--count >= 0) - { value = BES2H_SHORT (src [count]) ; + { value = BE2H_16 (src [count]) ; dest [count] = value << 16 ; } ; } /* bes2i_array */ @@ -367,7 +367,7 @@ les2i_array (short *src, int count, int *dest) { short value ; while (--count >= 0) - { value = LES2H_SHORT (src [count]) ; + { value = LE2H_16 (src [count]) ; dest [count] = value << 16 ; } ; } /* les2i_array */ @@ -379,7 +379,7 @@ bet2i_array (tribyte *src, int count, int *dest) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - dest [count] = BET2H_INT_PTR (ucptr) ; + dest [count] = BET2H_32_PTR (ucptr) ; } ; } /* bet2i_array */ @@ -390,7 +390,7 @@ let2i_array (tribyte *src, int count, int *dest) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - dest [count] = LET2H_INT_PTR (ucptr) ; + dest [count] = LET2H_32_PTR (ucptr) ; } ; } /* let2i_array */ @@ -415,7 +415,7 @@ les2f_array (short *src, int count, float *dest, float normfact) while (--count >= 0) { value = src [count] ; - value = LES2H_SHORT (value) ; + value = LE2H_16 (value) ; dest [count] = ((float) value) * normfact ; } ; } /* les2f_array */ @@ -426,7 +426,7 @@ bes2f_array (short *src, int count, float *dest, float normfact) while (--count >= 0) { value = src [count] ; - value = BES2H_SHORT (value) ; + value = BE2H_16 (value) ; dest [count] = ((float) value) * normfact ; } ; } /* bes2f_array */ @@ -439,7 +439,7 @@ let2f_array (tribyte *src, int count, float *dest, float normfact) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - value = LET2H_INT_PTR (ucptr) ; + value = LET2H_32_PTR (ucptr) ; dest [count] = ((float) value) * normfact ; } ; } /* let2f_array */ @@ -452,7 +452,7 @@ bet2f_array (tribyte *src, int count, float *dest, float normfact) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - value = BET2H_INT_PTR (ucptr) ; + value = BET2H_32_PTR (ucptr) ; dest [count] = ((float) value) * normfact ; } ; } /* bet2f_array */ @@ -463,7 +463,7 @@ lei2f_array (int *src, int count, float *dest, float normfact) while (--count >= 0) { value = src [count] ; - value = LEI2H_INT (value) ; + value = LE2H_32 (value) ; dest [count] = ((float) value) * normfact ; } ; } /* lei2f_array */ @@ -474,7 +474,7 @@ bei2f_array (int *src, int count, float *dest, float normfact) while (--count >= 0) { value = src [count] ; - value = BEI2H_INT (value) ; + value = BE2H_32 (value) ; dest [count] = ((float) value) * normfact ; } ; } /* bei2f_array */ @@ -500,7 +500,7 @@ les2d_array (short *src, int count, double *dest, double normfact) while (--count >= 0) { value = src [count] ; - value = LES2H_SHORT (value) ; + value = LE2H_16 (value) ; dest [count] = ((double) value) * normfact ; } ; } /* les2d_array */ @@ -511,7 +511,7 @@ bes2d_array (short *src, int count, double *dest, double normfact) while (--count >= 0) { value = src [count] ; - value = BES2H_SHORT (value) ; + value = BE2H_16 (value) ; dest [count] = ((double) value) * normfact ; } ; } /* bes2d_array */ @@ -524,7 +524,7 @@ let2d_array (tribyte *src, int count, double *dest, double normfact) ucptr = ((unsigned char*) src) + 3 * count ; while (--count >= 0) { ucptr -= 3 ; - value = LET2H_INT_PTR (ucptr) ; + value = LET2H_32_PTR (ucptr) ; dest [count] = ((double) value) * normfact ; } ; } /* let2d_array */ @@ -548,7 +548,7 @@ lei2d_array (int *src, int count, double *dest, double normfact) while (--count >= 0) { value = src [count] ; - value = LEI2H_INT (value) ; + value = LE2H_32 (value) ; dest [count] = ((double) value) * normfact ; } ; } /* lei2d_array */ @@ -559,7 +559,7 @@ bei2d_array (int *src, int count, double *dest, double normfact) while (--count >= 0) { value = src [count] ; - value = BEI2H_INT (value) ; + value = BE2H_32 (value) ; dest [count] = ((double) value) * normfact ; } ; } /* bei2d_array */ @@ -707,16 +707,17 @@ i2bet_array (const int *src, tribyte *dest, int count) static sf_count_t pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2s_array (psf->u.scbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + sc2s_array (ubuf.scbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -728,16 +729,17 @@ pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_uc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2s_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + uc2s_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -771,16 +773,17 @@ pcm_read_les2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2s_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + bet2s_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -792,16 +795,17 @@ pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_let2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2s_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + let2s_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -813,16 +817,17 @@ pcm_read_let2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - bei2s_array (psf->u.ibuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + bei2s_array (ubuf.ibuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -834,16 +839,17 @@ pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - lei2s_array (psf->u.ibuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + lei2s_array (ubuf.ibuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -858,16 +864,17 @@ pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2i_array (psf->u.scbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + sc2i_array (ubuf.scbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -879,16 +886,17 @@ pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2i_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + uc2i_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -900,16 +908,17 @@ pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - bes2i_array (psf->u.sbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + bes2i_array (ubuf.sbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -921,16 +930,17 @@ pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_les2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - les2i_array (psf->u.sbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + les2i_array (ubuf.sbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -942,16 +952,17 @@ pcm_read_les2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2i_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + bet2i_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -963,16 +974,17 @@ pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_let2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2i_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + let2i_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1009,19 +1021,20 @@ pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t pcm_read_sc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2f_array (psf->u.scbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + sc2f_array (ubuf.scbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1033,19 +1046,20 @@ pcm_read_sc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_uc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2f_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + uc2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1057,19 +1071,20 @@ pcm_read_uc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - bes2f_array (psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + bes2f_array (ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1081,19 +1096,20 @@ pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_les2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - les2f_array (psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + les2f_array (ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1105,20 +1121,21 @@ pcm_read_les2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; /* Special normfactor because tribyte value is read into an int. */ normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 / 256.0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2f_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + bet2f_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1130,20 +1147,21 @@ pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_let2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; /* Special normfactor because tribyte value is read into an int. */ normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 / 256.0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2f_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + let2f_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1155,19 +1173,20 @@ pcm_read_let2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - bei2f_array (psf->u.ibuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + bei2f_array (ubuf.ibuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1179,19 +1198,20 @@ pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - lei2f_array (psf->u.ibuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + lei2f_array (ubuf.ibuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1206,19 +1226,20 @@ pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2d_array (psf->u.scbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + sc2d_array (ubuf.scbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1230,19 +1251,20 @@ pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2d_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + uc2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1254,19 +1276,20 @@ pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - bes2d_array (psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + bes2d_array (ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1278,19 +1301,20 @@ pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_les2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - les2d_array (psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + les2d_array (ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1302,19 +1326,20 @@ pcm_read_les2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 / 256.0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2d_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + bet2d_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1326,20 +1351,21 @@ pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_let2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; /* Special normfactor because tribyte value is read into an int. */ normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 / 256.0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2d_array ((tribyte*) (psf->u.ucbuf), readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + let2d_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1351,19 +1377,20 @@ pcm_read_let2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - bei2d_array (psf->u.ibuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + bei2d_array (ubuf.ibuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1375,19 +1402,20 @@ pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ibuf, sizeof (int), bufferlen, psf) ; - lei2d_array (psf->u.ibuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; + lei2d_array (ubuf.ibuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -1404,16 +1432,17 @@ pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t pcm_write_s2sc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2sc_array (ptr + total, psf->u.scbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + s2sc_array (ptr + total, ubuf.scbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1425,16 +1454,17 @@ pcm_write_s2sc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2uc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2uc_array (ptr + total, psf->u.ucbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + s2uc_array (ptr + total, ubuf.ucbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1446,20 +1476,21 @@ pcm_write_s2uc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2bes (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (CPU_IS_BIG_ENDIAN) return psf_fwrite (ptr, sizeof (short), len, psf) ; else - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_short_copy (psf->u.sbuf, ptr + total, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + endswap_short_copy (ubuf.sbuf, ptr + total, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1471,19 +1502,20 @@ pcm_write_s2bes (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2les (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (CPU_IS_LITTLE_ENDIAN) return psf_fwrite (ptr, sizeof (short), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_short_copy (psf->u.sbuf, ptr + total, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + endswap_short_copy (ubuf.sbuf, ptr + total, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1495,16 +1527,17 @@ pcm_write_s2les (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2bet (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2bet_array (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + s2bet_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1516,16 +1549,17 @@ pcm_write_s2bet (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2let (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2let_array (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + s2let_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1537,16 +1571,17 @@ pcm_write_s2let (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2bei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2bei_array (ptr + total, psf->u.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + s2bei_array (ptr + total, ubuf.ibuf, bufferlen) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1558,16 +1593,17 @@ pcm_write_s2bei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_s2lei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2lei_array (ptr + total, psf->u.ibuf, bufferlen) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + s2lei_array (ptr + total, ubuf.ibuf, bufferlen) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1582,16 +1618,17 @@ pcm_write_s2lei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t pcm_write_i2sc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2sc_array (ptr + total, psf->u.scbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + i2sc_array (ptr + total, ubuf.scbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1603,16 +1640,17 @@ pcm_write_i2sc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2uc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2uc_array (ptr + total, psf->u.ucbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, sizeof (signed char), bufferlen, psf) ; + i2uc_array (ptr + total, ubuf.ucbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1624,16 +1662,17 @@ pcm_write_i2uc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2bes (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2bes_array (ptr + total, psf->u.sbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + i2bes_array (ptr + total, ubuf.sbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1645,16 +1684,17 @@ pcm_write_i2bes (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2les (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2les_array (ptr + total, psf->u.sbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + i2les_array (ptr + total, ubuf.sbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1666,16 +1706,17 @@ pcm_write_i2les (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2bet (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2bet_array (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + i2bet_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1687,16 +1728,17 @@ pcm_write_i2bet (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2let (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2let_array (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + i2let_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1708,19 +1750,20 @@ pcm_write_i2let (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2bei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (CPU_IS_BIG_ENDIAN) return psf_fwrite (ptr, sizeof (int), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_int_copy (psf->u.ibuf, ptr + total, bufferlen) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + endswap_int_copy (ubuf.ibuf, ptr + total, bufferlen) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1732,19 +1775,20 @@ pcm_write_i2bei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t pcm_write_i2lei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; if (CPU_IS_LITTLE_ENDIAN) return psf_fwrite (ptr, sizeof (int), len, psf) ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - endswap_int_copy (psf->u.ibuf, ptr + total, bufferlen) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + endswap_int_copy (ubuf.ibuf, ptr + total, bufferlen) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1793,18 +1837,19 @@ f2sc_clip_array (const float *src, signed char *dest, int count, int normalize) static sf_count_t pcm_write_f2sc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, signed char *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, signed char *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2sc_clip_array : f2sc_array ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.scbuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + convert (ptr + total, ubuf.scbuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1851,18 +1896,19 @@ f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize static sf_count_t pcm_write_f2uc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, unsigned char *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, unsigned char *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2uc_clip_array : f2uc_array ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ucbuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + convert (ptr + total, ubuf.ucbuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1923,18 +1969,19 @@ f2bes_clip_array (const float *src, short *dest, int count, int normalize) static sf_count_t pcm_write_f2bes (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, short *t, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, short *t, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2bes_clip_array : f2bes_array ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1995,18 +2042,19 @@ f2les_clip_array (const float *src, short *dest, int count, int normalize) static sf_count_t pcm_write_f2les (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, short *t, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, short *t, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2les_clip_array : f2les_array ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2071,18 +2119,19 @@ f2let_clip_array (const float *src, tribyte *dest, int count, int normalize) static sf_count_t pcm_write_f2let (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, tribyte *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, tribyte *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2let_clip_array : f2let_array ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2147,18 +2196,19 @@ f2bet_clip_array (const float *src, tribyte *dest, int count, int normalize) static sf_count_t pcm_write_f2bet (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, tribyte *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, tribyte *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2bet_clip_array : f2bet_array ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2226,18 +2276,19 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize) static sf_count_t pcm_write_f2bei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, int *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, int *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2bei_clip_array : f2bei_array ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2306,18 +2357,19 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize) static sf_count_t pcm_write_f2lei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ void (*convert) (const float *, int *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const float *, int *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? f2lei_clip_array : f2lei_array ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_float) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_float) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2364,18 +2416,19 @@ d2sc_clip_array (const double *src, signed char *dest, int count, int normalize) static sf_count_t pcm_write_d2sc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, signed char *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, signed char *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2sc_clip_array : d2sc_array ; - bufferlen = ARRAY_LEN (psf->u.scbuf) ; + bufferlen = ARRAY_LEN (ubuf.scbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.scbuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + convert (ptr + total, ubuf.scbuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2422,18 +2475,19 @@ d2uc_clip_array (const double *src, unsigned char *dest, int count, int normaliz static sf_count_t pcm_write_d2uc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, unsigned char *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, unsigned char *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2uc_clip_array : d2uc_array ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ucbuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.ucbuf, sizeof (unsigned char), bufferlen, psf) ; + convert (ptr + total, ubuf.ucbuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2494,18 +2548,19 @@ d2bes_clip_array (const double *src, short *dest, int count, int normalize) static sf_count_t pcm_write_d2bes (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, short *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, short *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2bes_clip_array : d2bes_array ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2566,18 +2621,19 @@ d2les_clip_array (const double *src, short *dest, int count, int normalize) static sf_count_t pcm_write_d2les (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, short *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, short *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2les_clip_array : d2les_array ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2642,18 +2698,19 @@ d2let_clip_array (const double *src, tribyte *dest, int count, int normalize) static sf_count_t pcm_write_d2let (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, tribyte *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, tribyte *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2let_clip_array : d2let_array ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2718,18 +2775,19 @@ d2bet_clip_array (const double *src, tribyte *dest, int count, int normalize) static sf_count_t pcm_write_d2bet (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, tribyte *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, tribyte *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2bet_clip_array : d2bet_array ; - bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ; + bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; + convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2798,18 +2856,19 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize) static sf_count_t pcm_write_d2bei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, int *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, int *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2bei_clip_array : d2bei_array ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -2878,18 +2937,19 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize) static sf_count_t pcm_write_d2lei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ void (*convert) (const double *, int *, int, int) ; +{ BUF_UNION ubuf ; + void (*convert) (const double *, int *, int, int) ; int bufferlen, writecount ; sf_count_t total = 0 ; convert = (psf->add_clipping) ? d2lei_clip_array : d2lei_array ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_double) ; - writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ; + convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_double) ; + writecount = psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; diff --git a/libs/libsndfile/src/pvf.c b/libs/libsndfile/src/pvf.c index 5e027cb66b..4ea24b6b68 100644 --- a/libs/libsndfile/src/pvf.c +++ b/libs/libsndfile/src/pvf.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -51,14 +51,14 @@ pvf_open (SF_PRIVATE *psf) { int subformat ; int error = 0 ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = pvf_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PVF) return SFE_BAD_OPEN_FORMAT ; diff --git a/libs/libsndfile/src/raw.c b/libs/libsndfile/src/raw.c index 99e19d0ebf..e5dc49e2ff 100644 --- a/libs/libsndfile/src/raw.c +++ b/libs/libsndfile/src/raw.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/rf64.c b/libs/libsndfile/src/rf64.c index ad29ce347c..7f14ef89ba 100644 --- a/libs/libsndfile/src/rf64.c +++ b/libs/libsndfile/src/rf64.c @@ -1,5 +1,6 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2013 Erik de Castro Lopo +** Copyright (C) 2009 Uli Franke ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -19,6 +20,9 @@ /* ** This format documented at: ** http://www.sr.se/utveckling/tu/bwf/prog/RF_64v1_4.pdf +** +** But this may be a better reference: +** http://www.ebu.ch/CMSimages/en/tec_doc_t3306-2007_tcm6-42570.pdf */ #include "sfconfig.h" @@ -44,6 +48,11 @@ #define fact_MARKER MAKE_MARKER ('f', 'a', 'c', 't') #define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a') +#define bext_MARKER MAKE_MARKER ('b', 'e', 'x', 't') +#define cart_MARKER MAKE_MARKER ('c', 'a', 'r', 't') +#define OggS_MARKER MAKE_MARKER ('O', 'g', 'g', 'S') +#define wvpk_MARKER MAKE_MARKER ('w', 'v', 'p', 'k') + /*------------------------------------------------------------------------------ ** Typedefs. */ @@ -52,9 +61,10 @@ ** Private static functions. */ -static int rf64_read_header (SF_PRIVATE *psf) ; +static int rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; static int rf64_write_header (SF_PRIVATE *psf, int calc_length) ; static int rf64_close (SF_PRIVATE *psf) ; +static int rf64_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) ; /*------------------------------------------------------------------------------ ** Public function. @@ -64,17 +74,19 @@ int rf64_open (SF_PRIVATE *psf) { WAV_PRIVATE *wpriv ; int subformat, error = 0 ; + int blockalign, framesperblock ; if ((wpriv = calloc (1, sizeof (WAV_PRIVATE))) == NULL) return SFE_MALLOC_FAILED ; psf->container_data = wpriv ; + wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; /* All RF64 files are little endian. */ psf->endian = SF_ENDIAN_LITTLE ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = rf64_read_header (psf)) != 0) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) + { if ((error = rf64_read_header (psf, &blockalign, &framesperblock)) != 0) return error ; } ; @@ -83,7 +95,7 @@ rf64_open (SF_PRIVATE *psf) subformat = psf->sf.format & SF_FORMAT_SUBMASK ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -96,6 +108,7 @@ rf64_open (SF_PRIVATE *psf) } ; psf->container_close = rf64_close ; + psf->command = rf64_command ; switch (subformat) { case SF_FORMAT_PCM_U8 : @@ -132,68 +145,162 @@ rf64_open (SF_PRIVATE *psf) /*------------------------------------------------------------------------------ */ +enum +{ HAVE_ds64 = 0x01, + HAVE_fmt = 0x02, + HAVE_bext = 0x04, + HAVE_data = 0x08, + HAVE_cart = 0x10 +} ; + +#define HAVE_CHUNK(CHUNK) ((parsestage & CHUNK) != 0) static int -rf64_read_header (SF_PRIVATE *psf) -{ WAV_PRIVATE *wpriv ; - sf_count_t riff_size, data_size ; - unsigned int size32 ; - int marker, marks [2], error, done = 0 ; +rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) +{ WAV_PRIVATE *wpriv ; + WAV_FMT *wav_fmt ; + sf_count_t riff_size = 0, frame_count = 0, ds64_datalength = 0 ; + uint32_t marks [2], size32, parsestage = 0 ; + int marker, error, done = 0, format = 0 ; if ((wpriv = psf->container_data) == NULL) return SFE_INTERNAL ; + wav_fmt = &wpriv->wav_fmt ; /* Set position to start of file to begin reading header. */ psf_binheader_readf (psf, "pmmm", 0, &marker, marks, marks + 1) ; - if (marker != RF64_MARKER || marks [0] != FFFF_MARKER || marks [1] != WAVE_MARKER) + if (marker != RF64_MARKER || marks [1] != WAVE_MARKER) return SFE_RF64_NOT_RF64 ; - psf_log_printf (psf, "%M\n %M\n", RF64_MARKER, WAVE_MARKER) ; + if (marks [0] == FFFF_MARKER) + psf_log_printf (psf, "%M\n %M\n", RF64_MARKER, WAVE_MARKER) ; + else + psf_log_printf (psf, "%M : 0x%x (should be 0xFFFFFFFF)\n %M\n", RF64_MARKER, WAVE_MARKER) ; - while (! done) + while (NOT (done)) { psf_binheader_readf (psf, "em4", &marker, &size32) ; switch (marker) { case ds64_MARKER : + { unsigned int table_len, bytesread ; + + /* Read ds64 sizes (3 8-byte words). */ + bytesread = psf_binheader_readf (psf, "888", &riff_size, &ds64_datalength, &frame_count) ; + + /* Read table length. */ + bytesread += psf_binheader_readf (psf, "4", &table_len) ; + /* Skip table for now. (this was "table_len + 4", why?) */ + bytesread += psf_binheader_readf (psf, "j", table_len) ; + + if (size32 == bytesread) + psf_log_printf (psf, "%M : %u\n", marker, size32) ; + else if (size32 >= bytesread + 4) + { unsigned int next ; + psf_binheader_readf (psf, "m", &next) ; + if (next == fmt_MARKER) + { psf_log_printf (psf, "%M : %u (should be %u)\n", marker, size32, bytesread) ; + psf_binheader_readf (psf, "j", -4) ; + } + else + { psf_log_printf (psf, "%M : %u\n", marker, size32) ; + psf_binheader_readf (psf, "j", size32 - bytesread - 4) ; + } ; + } ; + + if (psf->filelength != riff_size + 8) + psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ; + else + psf_log_printf (psf, " Riff size : %D\n", riff_size) ; + + psf_log_printf (psf, " Data size : %D\n", ds64_datalength) ; + + psf_log_printf (psf, " Frames : %D\n", frame_count) ; + psf_log_printf (psf, " Table length : %u\n", table_len) ; + + } ; + parsestage |= HAVE_ds64 ; + break ; + + case fmt_MARKER: psf_log_printf (psf, "%M : %u\n", marker, size32) ; - - psf_binheader_readf (psf, "888", &riff_size, &data_size, &psf->sf.frames) ; - psf_log_printf (psf, " Riff size : %D\n Data size : %D\n Frames : %D\n", - riff_size, data_size, psf->sf.frames) ; - - psf_binheader_readf (psf, "4", &size32) ; - psf_log_printf (psf, " Table len : %u\n", size32) ; - - psf_binheader_readf (psf, "jm4", size32 + 4, &marker, &size32) ; - psf_log_printf (psf, "%M : %u\n", marker, size32) ; - if ((error = wav_w64_read_fmt_chunk (psf, size32)) != 0) return error ; - psf->sf.format = SF_FORMAT_RF64 | (psf->sf.format & SF_FORMAT_SUBMASK) ; + format = wav_fmt->format ; + parsestage |= HAVE_fmt ; + break ; + + case bext_MARKER : + if ((error = wav_read_bext_chunk (psf, size32)) != 0) + return error ; + parsestage |= HAVE_bext ; + break ; + + case cart_MARKER : + if ((error = wav_read_cart_chunk (psf, size32)) != 0) + return error ; + parsestage |= HAVE_cart ; break ; case data_MARKER : - psf_log_printf (psf, "%M : %x\n", marker, size32) ; - psf->dataoffset = psf->headindex ; - done = SF_TRUE ; - break ; + /* see wav for more sophisticated parsing -> implement state machine with parsestage */ + + if (HAVE_CHUNK (HAVE_ds64)) + { if (size32 == 0xffffffff) + psf_log_printf (psf, "%M : 0x%x\n", marker, size32) ; + else + psf_log_printf (psf, "%M : 0x%x (should be 0xffffffff\n", marker, size32) ; + psf->datalength = ds64_datalength ; + } + else + { if (size32 == 0xffffffff) + { psf_log_printf (psf, "%M : 0x%x\n", marker, size32) ; + psf_log_printf (psf, " *** Data length not specified no 'ds64' chunk.\n") ; + } + else + { psf_log_printf (psf, "%M : 0x%x\n**** Weird, RF64 file without a 'ds64' chunk and no valid 'data' size.\n", marker, size32) ; + psf->datalength = size32 ; + } ; + } ; + + psf->dataoffset = psf_ftell (psf) ; + + if (psf->dataoffset > 0) + { if (size32 == 0 && riff_size == 8 && psf->filelength > 44) + { psf_log_printf (psf, " *** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ; + psf->datalength = psf->filelength - psf->dataoffset ; + } ; + + /* Only set dataend if there really is data at the end. */ + if (psf->datalength + psf->dataoffset < psf->filelength) + psf->dataend = psf->datalength + psf->dataoffset ; + + if (NOT (psf->sf.seekable) || psf->dataoffset < 0) + break ; + + /* Seek past data and continue reading header. */ + psf_fseek (psf, psf->datalength, SEEK_CUR) ; + + if (psf_ftell (psf) != psf->datalength + psf->dataoffset) + psf_log_printf (psf, " *** psf_fseek past end error ***\n") ; + break ; + } ; + break ; default : if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF) && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF)) - { psf_binheader_readf (psf, "4", &size32) ; - psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, size32) ; + { psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, size32) ; if (size32 < 8) done = SF_TRUE ; psf_binheader_readf (psf, "j", size32) ; break ; } ; if (psf_ftell (psf) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", size32 - 4) ; + { psf_log_printf (psf, " Unknown chunk marker at position 0x%x. Resynching.\n", size32 - 4) ; psf_binheader_readf (psf, "j", -3) ; break ; } ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 4) ; + psf_log_printf (psf, "*** Unknown chunk marker (0x%X) at position 0x%X. Exiting parser.\n", marker, psf_ftell (psf) - 4) ; done = SF_TRUE ; break ; } ; /* switch (marker) */ @@ -204,6 +311,99 @@ rf64_read_header (SF_PRIVATE *psf) } ; } ; + if (psf->dataoffset <= 0) + return SFE_WAV_NO_DATA ; + + /* WAVs can be little or big endian */ + psf->endian = psf->rwf_endian ; + + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + + if (psf->is_pipe == 0) + { /* + ** Check for 'wvpk' at the start of the DATA section. Not able to + ** handle this. + */ + psf_binheader_readf (psf, "4", &marker) ; + if (marker == wvpk_MARKER || marker == OggS_MARKER) + return SFE_WAV_WVPK_DATA ; + } ; + + /* Seek to start of DATA section. */ + psf_fseek (psf, psf->dataoffset, SEEK_SET) ; + + if (psf->blockwidth) + { if (psf->filelength - psf->dataoffset < psf->datalength) + psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; + else + psf->sf.frames = psf->datalength / psf->blockwidth ; + } ; + + if (frame_count != psf->sf.frames) + psf_log_printf (psf, "*** Calculated frame count %d does not match value from 'ds64' chunk of %d.\n", psf->sf.frames, frame_count) ; + + switch (format) + { + case WAVE_FORMAT_EXTENSIBLE : + + /* with WAVE_FORMAT_EXTENSIBLE the psf->sf.format field is already set. We just have to set the major to rf64 */ + psf->sf.format = (psf->sf.format & ~SF_FORMAT_TYPEMASK) | SF_FORMAT_RF64 ; + + if (psf->sf.format == (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM)) + { *blockalign = wav_fmt->msadpcm.blockalign ; + *framesperblock = wav_fmt->msadpcm.samplesperblock ; + } ; + break ; + + case WAVE_FORMAT_PCM : + psf->sf.format = SF_FORMAT_RF64 | u_bitwidth_to_subformat (psf->bytewidth * 8) ; + break ; + + case WAVE_FORMAT_MULAW : + case IBM_FORMAT_MULAW : + psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_ULAW) ; + break ; + + case WAVE_FORMAT_ALAW : + case IBM_FORMAT_ALAW : + psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_ALAW) ; + break ; + + case WAVE_FORMAT_MS_ADPCM : + psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_MS_ADPCM) ; + *blockalign = wav_fmt->msadpcm.blockalign ; + *framesperblock = wav_fmt->msadpcm.samplesperblock ; + break ; + + case WAVE_FORMAT_IMA_ADPCM : + psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_IMA_ADPCM) ; + *blockalign = wav_fmt->ima.blockalign ; + *framesperblock = wav_fmt->ima.samplesperblock ; + break ; + + case WAVE_FORMAT_GSM610 : + psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_GSM610) ; + break ; + + case WAVE_FORMAT_IEEE_FLOAT : + psf->sf.format = SF_FORMAT_RF64 ; + psf->sf.format |= (psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT ; + break ; + + case WAVE_FORMAT_G721_ADPCM : + psf->sf.format = SF_FORMAT_RF64 | SF_FORMAT_G721_32 ; + break ; + + default : return SFE_UNIMPLEMENTED ; + } ; + + if (wpriv->fmt_is_broken) + wav_w64_analyze (psf) ; + + /* Only set the format endian-ness if its non-standard big-endian. */ + if (psf->endian == SF_ENDIAN_BIG) + psf->sf.format |= SF_ENDIAN_BIG ; + return 0 ; } /* rf64_read_header */ @@ -242,9 +442,9 @@ static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT = static int -wavex_write_fmt_chunk (SF_PRIVATE *psf) +rf64_write_fmt_chunk (SF_PRIVATE *psf) { WAV_PRIVATE *wpriv ; - int subformat, fmt_size, add_fact_chunk = 0 ; + int subformat, fmt_size ; if ((wpriv = psf->container_data) == NULL) return SFE_INTERNAL ; @@ -281,6 +481,8 @@ wavex_write_fmt_chunk (SF_PRIVATE *psf) */ if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE) psf_binheader_writef (psf, "4", 0) ; + else if (wpriv->wavex_channelmask != 0) + psf_binheader_writef (psf, "4", wpriv->wavex_channelmask) ; else { /* ** Ok some liberty is taken here to use the most commonly used channel masks @@ -345,22 +547,11 @@ wavex_write_fmt_chunk (SF_PRIVATE *psf) wavex_write_guid (psf, &MSGUID_SUBTYPE_ALAW) ; break ; -#if 0 - /* This is dead code due to return in previous switch statement. */ - case SF_FORMAT_MS_ADPCM : /* todo, GUID exists */ - wavex_write_guid (psf, &MSGUID_SUBTYPE_MS_ADPCM) ; - break ; - return SFE_UNIMPLEMENTED ; -#endif - default : return SFE_UNIMPLEMENTED ; } ; - if (add_fact_chunk) - psf_binheader_writef (psf, "tm48", fact_MARKER, 4, psf->sf.frames) ; - return 0 ; -} /* wavex_write_fmt_chunk */ +} /* rf64_write_fmt_chunk */ static int @@ -375,7 +566,6 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) if (calc_length) { psf->filelength = psf_get_filelen (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; if (psf->dataend) @@ -392,7 +582,8 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "em4m", RF64_MARKER, 0xffffffff, WAVE_MARKER) ; - psf_binheader_writef (psf, "m488844", ds64_MARKER, 32, psf->filelength, psf->datalength, psf->sf.frames, 0, 0x005c0064) ; + /* Currently no table. */ + psf_binheader_writef (psf, "m48884", ds64_MARKER, 28, psf->filelength - 8, psf->datalength, psf->sf.frames, 0) ; /* WAVE and 'fmt ' markers. */ psf_binheader_writef (psf, "m", fmt_MARKER) ; @@ -406,7 +597,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) case SF_FORMAT_WAVEX : case SF_FORMAT_RF64 : - if ((error = wavex_write_fmt_chunk (psf)) != 0) + if ((error = rf64_write_fmt_chunk (psf)) != 0) return error ; break ; @@ -414,9 +605,14 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) return SFE_UNIMPLEMENTED ; } ; + if (psf->broadcast_16k != NULL) + wav_write_bext_chunk (psf) ; + + if (psf->cart_16k != NULL) + wav_write_cart_chunk (psf) ; #if 0 /* The LIST/INFO chunk. */ - if (psf->str_flags & SF_STR_LOCATE_START) + if (psf->strings.flags & SF_STR_LOCATE_START) wav_write_strings (psf, SF_STR_LOCATE_START) ; if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) @@ -426,8 +622,8 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; - if (psf->broadcast_info != NULL) - wav_write_bext_chunk (psf) ; +// if (psf->broadcast_info != NULL) +// wav_write_bext_chunk (psf) ; if (psf->instrument != NULL) { int tmp ; @@ -446,7 +642,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) { int type ; type = psf->instrument->loops [tmp].mode ; - type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; + type = (type == SF_LOOP_FORWARD ? 0 : type == SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; psf_binheader_writef (psf, "44", tmp, type) ; psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ; @@ -475,7 +671,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) psf->dataoffset = psf->headindex ; - if (! has_data) + if (NOT (has_data)) psf_fseek (psf, psf->dataoffset, SEEK_SET) ; else if (current > 0) psf_fseek (psf, current, SEEK_SET) ; @@ -486,7 +682,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length) static int rf64_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { // rf64_write_tailer (psf) ; psf->write_header (psf, SF_TRUE) ; @@ -494,3 +690,37 @@ rf64_close (SF_PRIVATE *psf) return 0 ; } /* rf64_close */ + +static int +rf64_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) +{ WAV_PRIVATE *wpriv ; + + if ((wpriv = psf->container_data) == NULL) + return SFE_INTERNAL ; + + switch (command) + { case SFC_WAVEX_SET_AMBISONIC : + if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAVEX) + { if (datasize == SF_AMBISONIC_NONE) + wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; + else if (datasize == SF_AMBISONIC_B_FORMAT) + wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ; + else + return 0 ; + } ; + return wpriv->wavex_ambisonic ; + + case SFC_WAVEX_GET_AMBISONIC : + return wpriv->wavex_ambisonic ; + + case SFC_SET_CHANNEL_MAP_INFO : + wpriv->wavex_channelmask = wavex_gen_channel_mask (psf->channel_map, psf->sf.channels) ; + return (wpriv->wavex_channelmask != 0) ; + + default : + break ; + } ; + + return 0 ; +} /* rf64_command */ + diff --git a/libs/libsndfile/src/rx2.c b/libs/libsndfile/src/rx2.c index 429ac88133..0a730480e7 100644 --- a/libs/libsndfile/src/rx2.c +++ b/libs/libsndfile/src/rx2.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -80,10 +80,9 @@ rx2_open (SF_PRIVATE *psf) "Additional/PencilTool", "Disabled" } ; + BUF_UNION ubuf ; int error, marker, length, glob_offset, slce_count, frames ; - int sdat_length = 0, slce_total = 0 ; - int n_channels ; @@ -119,14 +118,14 @@ rx2_open (SF_PRIVATE *psf) /* Get name length */ length = 0 ; psf_binheader_readf (psf, "1", &length) ; - if (length >= SIGNED_SIZEOF (psf->u.cbuf)) + if (length >= SIGNED_SIZEOF (ubuf.cbuf)) { psf_log_printf (psf, " Text : %d *** Error : Too sf_count_t!\n") ; return -1001 ; } - memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ; - psf_binheader_readf (psf, "b", psf->u.cbuf, length) ; - psf_log_printf (psf, " Text : \"%s\"\n", psf->u.cbuf) ; + memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; + psf_binheader_readf (psf, "b", ubuf.cbuf, length) ; + psf_log_printf (psf, " Text : \"%s\"\n", ubuf.cbuf) ; /* Jump to GLOB offset position. */ if (glob_offset & 1) @@ -253,7 +252,7 @@ rx2_open (SF_PRIVATE *psf) break ; } ; - puts (psf->logbuffer) ; + puts (psf->parselog.buf) ; puts ("-----------------------------------") ; printf ("SDAT length : %d\n", sdat_length) ; @@ -270,7 +269,7 @@ rx2_open (SF_PRIVATE *psf) puts (" ") ; - psf->logbuffer [0] = 0 ; + psf->parselog.buf [0] = 0 ; /* OK, have the header although not too sure what it all means. */ @@ -306,7 +305,7 @@ rx2_open (SF_PRIVATE *psf) static int rx2_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* Now we know for certain the length of the file we can re-write ** correct values for the FORM, 8SVX and BODY chunks. */ diff --git a/libs/libsndfile/src/sd2.c b/libs/libsndfile/src/sd2.c index 1089340cbf..6be150cd57 100644 --- a/libs/libsndfile/src/sd2.c +++ b/libs/libsndfile/src/sd2.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2013 Erik de Castro Lopo ** Copyright (C) 2004 Paavo Jumppanen ** ** This program is free software; you can redistribute it and/or modify @@ -104,12 +104,12 @@ sd2_open (SF_PRIVATE *psf) /* SD2 is always big endian. */ psf->endian = SF_ENDIAN_BIG ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->rsrclength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->rsrclength > 0)) { psf_use_rsrc (psf, SF_TRUE) ; valid = psf_file_valid (psf) ; psf_use_rsrc (psf, SF_FALSE) ; if (! valid) - { psf_log_printf (psf, "sd2_open : psf->rsrcdes < 0\n") ; + { psf_log_printf (psf, "sd2_open : psf->rsrc.filedes < 0\n") ; return SFE_SD2_BAD_RSRC ; } ; @@ -128,8 +128,9 @@ sd2_open (SF_PRIVATE *psf) psf->dataoffset = 0 ; /* Only open and write the resource in RDWR mode is its current length is zero. */ - if (psf->mode == SFM_WRITE || (psf->mode == SFM_RDWR && psf->rsrclength == 0)) - { psf_open_rsrc (psf, psf->mode) ; + if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->rsrclength == 0)) + { psf->rsrc.mode = psf->file.mode ; + psf_open_rsrc (psf) ; error = sd2_write_rsrc_fork (psf, SF_FALSE) ; @@ -148,6 +149,7 @@ sd2_open (SF_PRIVATE *psf) { case SF_FORMAT_PCM_S8 : /* 8-bit linear PCM. */ case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ case SF_FORMAT_PCM_24 : /* 24-bit linear PCM */ + case SF_FORMAT_PCM_32 : /* 32-bit linear PCM */ error = pcm_init (psf) ; break ; @@ -172,7 +174,7 @@ error_cleanup: static int sd2_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { /* Now we know for certain the audio_length of the file we can re-write ** correct values for the FORM, 8SVX and BODY chunks. */ @@ -222,7 +224,7 @@ write_marker (unsigned char * data, int offset, int value) } /* write_marker */ static void -write_str (unsigned char * data, int offset, char * buffer, int buffer_len) +write_str (unsigned char * data, int offset, const char * buffer, int buffer_len) { memcpy (data + offset, buffer, buffer_len) ; } /* write_str */ @@ -281,8 +283,8 @@ sd2_write_rsrc_fork (SF_PRIVATE *psf, int UNUSED (calc_length)) write_int (rsrc.rsrc_data, 4, rsrc.map_offset) ; write_int (rsrc.rsrc_data, 8, rsrc.data_length) ; - write_char (rsrc.rsrc_data, 0x30, strlen (psf->filename)) ; - write_str (rsrc.rsrc_data, 0x31, psf->filename, strlen (psf->filename)) ; + write_char (rsrc.rsrc_data, 0x30, strlen (psf->file.name.c)) ; + write_str (rsrc.rsrc_data, 0x31, psf->file.name.c, strlen (psf->file.name.c)) ; write_short (rsrc.rsrc_data, 0x50, 0) ; write_marker (rsrc.rsrc_data, 0x52, Sd2f_MARKER) ; @@ -369,44 +371,61 @@ sd2_write_rsrc_fork (SF_PRIVATE *psf, int UNUSED (calc_length)) */ static inline int -read_char (const unsigned char * data, int offset) -{ return data [offset] ; -} /* read_char */ +read_rsrc_char (const SD2_RSRC *prsrc, int offset) +{ const unsigned char * data = prsrc->rsrc_data ; + if (offset < 0 || offset >= prsrc->rsrc_len) + return 0 ; + return data [offset] ; +} /* read_rsrc_char */ static inline int -read_short (const unsigned char * data, int offset) -{ return (data [offset] << 8) + data [offset + 1] ; -} /* read_short */ +read_rsrc_short (const SD2_RSRC *prsrc, int offset) +{ const unsigned char * data = prsrc->rsrc_data ; + if (offset < 0 || offset + 1 >= prsrc->rsrc_len) + return 0 ; + return (data [offset] << 8) + data [offset + 1] ; +} /* read_rsrc_short */ static inline int -read_int (const unsigned char * data, int offset) -{ return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ; -} /* read_int */ +read_rsrc_int (const SD2_RSRC *prsrc, int offset) +{ const unsigned char * data = prsrc->rsrc_data ; + if (offset < 0 || offset + 3 >= prsrc->rsrc_len) + return 0 ; + return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ; +} /* read_rsrc_int */ static inline int -read_marker (const unsigned char * data, int offset) -{ +read_rsrc_marker (const SD2_RSRC *prsrc, int offset) +{ const unsigned char * data = prsrc->rsrc_data ; + + if (offset < 0 || offset + 3 >= prsrc->rsrc_len) + return 0 ; + if (CPU_IS_BIG_ENDIAN) return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ; - else if (CPU_IS_LITTLE_ENDIAN) + if (CPU_IS_LITTLE_ENDIAN) return data [offset] + (data [offset + 1] << 8) + (data [offset + 2] << 16) + (data [offset + 3] << 24) ; - else - return 0x666 ; -} /* read_marker */ + + return 0 ; +} /* read_rsrc_marker */ static void -read_str (const unsigned char * data, int offset, char * buffer, int buffer_len) -{ int k ; +read_rsrc_str (const SD2_RSRC *prsrc, int offset, char * buffer, int buffer_len) +{ const unsigned char * data = prsrc->rsrc_data ; + int k ; memset (buffer, 0, buffer_len) ; + if (offset < 0 || offset + buffer_len >= prsrc->rsrc_len) + return ; + for (k = 0 ; k < buffer_len - 1 ; k++) - { if (isprint (data [offset + k]) == 0) + { if (psf_isprint (data [offset + k]) == 0) return ; buffer [k] = data [offset + k] ; } ; return ; -} /* read_str */ +} /* read_rsrc_str */ static int sd2_parse_rsrc_fork (SF_PRIVATE *psf) @@ -433,17 +452,17 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) /* Reset the header storage because we have changed to the rsrcdes. */ psf->headindex = psf->headend = rsrc.rsrc_len ; - rsrc.data_offset = read_int (rsrc.rsrc_data, 0) ; - rsrc.map_offset = read_int (rsrc.rsrc_data, 4) ; - rsrc.data_length = read_int (rsrc.rsrc_data, 8) ; - rsrc.map_length = read_int (rsrc.rsrc_data, 12) ; + rsrc.data_offset = read_rsrc_int (&rsrc, 0) ; + rsrc.map_offset = read_rsrc_int (&rsrc, 4) ; + rsrc.data_length = read_rsrc_int (&rsrc, 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 12) ; if (rsrc.data_offset == 0x51607 && rsrc.map_offset == 0x20000) { psf_log_printf (psf, "Trying offset of 0x52 bytes.\n") ; - rsrc.data_offset = read_int (rsrc.rsrc_data, 0x52 + 0) + 0x52 ; - rsrc.map_offset = read_int (rsrc.rsrc_data, 0x52 + 4) + 0x52 ; - rsrc.data_length = read_int (rsrc.rsrc_data, 0x52 + 8) ; - rsrc.map_length = read_int (rsrc.rsrc_data, 0x52 + 12) ; + rsrc.data_offset = read_rsrc_int (&rsrc, 0x52 + 0) + 0x52 ; + rsrc.map_offset = read_rsrc_int (&rsrc, 0x52 + 4) + 0x52 ; + rsrc.data_length = read_rsrc_int (&rsrc, 0x52 + 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 0x52 + 12) ; } ; psf_log_printf (psf, " data offset : 0x%04X\n map offset : 0x%04X\n" @@ -486,7 +505,7 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) goto parse_rsrc_fork_cleanup ; } ; - rsrc.string_offset = rsrc.map_offset + read_short (rsrc.rsrc_data, rsrc.map_offset + 26) ; + rsrc.string_offset = rsrc.map_offset + read_rsrc_short (&rsrc, rsrc.map_offset + 26) ; if (rsrc.string_offset > rsrc.rsrc_len) { psf_log_printf (psf, "Bad string offset (%d).\n", rsrc.string_offset) ; error = SFE_SD2_BAD_RSRC ; @@ -495,7 +514,7 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) rsrc.type_offset = rsrc.map_offset + 30 ; - rsrc.type_count = read_short (rsrc.rsrc_data, rsrc.map_offset + 28) + 1 ; + rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ; if (rsrc.type_count < 1) { psf_log_printf (psf, "Bad type count.\n") ; error = SFE_SD2_BAD_RSRC ; @@ -511,11 +530,11 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) rsrc.str_index = -1 ; for (k = 0 ; k < rsrc.type_count ; k ++) - { marker = read_marker (rsrc.rsrc_data, rsrc.type_offset + k * 8) ; + { marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; if (marker == STR_MARKER) { rsrc.str_index = k ; - rsrc.str_count = read_short (rsrc.rsrc_data, rsrc.type_offset + k * 8 + 4) + 1 ; + rsrc.str_count = read_rsrc_short (&rsrc, rsrc.type_offset + k * 8 + 4) + 1 ; error = parse_str_rsrc (psf, &rsrc) ; goto parse_rsrc_fork_cleanup ; } ; @@ -547,26 +566,26 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc) for (k = 0 ; data_offset + data_len < rsrc->rsrc_len ; k++) { int slen ; - slen = read_char (rsrc->rsrc_data, str_offset) ; - read_str (rsrc->rsrc_data, str_offset + 1, name, SF_MIN (SIGNED_SIZEOF (name), slen + 1)) ; + slen = read_rsrc_char (rsrc, str_offset) ; + read_rsrc_str (rsrc, str_offset + 1, name, SF_MIN (SIGNED_SIZEOF (name), slen + 1)) ; str_offset += slen + 1 ; - rsrc_id = read_short (rsrc->rsrc_data, rsrc->item_offset + k * 12) ; + rsrc_id = read_rsrc_short (rsrc, rsrc->item_offset + k * 12) ; - data_offset = rsrc->data_offset + read_int (rsrc->rsrc_data, rsrc->item_offset + k * 12 + 4) ; + data_offset = rsrc->data_offset + read_rsrc_int (rsrc, rsrc->item_offset + k * 12 + 4) ; if (data_offset < 0 || data_offset > rsrc->rsrc_len) { psf_log_printf (psf, "Exiting parser on data offset of %d.\n", data_offset) ; break ; } ; - data_len = read_int (rsrc->rsrc_data, data_offset) ; + data_len = read_rsrc_int (rsrc, data_offset) ; if (data_len < 0 || data_len > rsrc->rsrc_len) { psf_log_printf (psf, "Exiting parser on data length of %d.\n", data_len) ; break ; } ; - slen = read_char (rsrc->rsrc_data, data_offset + 4) ; - read_str (rsrc->rsrc_data, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ; + slen = read_rsrc_char (rsrc, data_offset + 4) ; + read_rsrc_str (rsrc, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ; psf_log_printf (psf, " 0x%04x %4d %4d %3d '%s'\n", data_offset, rsrc_id, data_len, slen, value) ; @@ -619,6 +638,10 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc) psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_24 ; break ; + case 4 : + psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_32 ; + break ; + default : psf_log_printf (psf, "Bad sample size (%d)\n", rsrc->sample_size) ; return SFE_SD2_BAD_SAMPLE_SIZE ; diff --git a/libs/libsndfile/src/sds.c b/libs/libsndfile/src/sds.c index 2c2c9fc44d..7dd1d9d27e 100644 --- a/libs/libsndfile/src/sds.c +++ b/libs/libsndfile/src/sds.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -56,6 +56,7 @@ typedef struct tag_SDS_PRIVATE int read_samples [SDS_BLOCK_SIZE / 2] ; /* Maximum samples per block */ int write_block, write_count ; + int total_written ; unsigned char write_data [SDS_BLOCK_SIZE] ; int write_samples [SDS_BLOCK_SIZE / 2] ; /* Maximum samples per block */ } SDS_PRIVATE ; @@ -82,6 +83,7 @@ static sf_count_t sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len static sf_count_t sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; static sf_count_t sds_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; +static int sds_byterate (SF_PRIVATE * psf) ; static int sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; static int sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; @@ -111,7 +113,7 @@ sds_open (SF_PRIVATE *psf) return SFE_MALLOC_FAILED ; psf->codec_data = psds ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = sds_read_header (psf, psds))) return error ; } ; @@ -119,7 +121,7 @@ sds_open (SF_PRIVATE *psf) if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SDS) return SFE_BAD_OPEN_FORMAT ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (sds_write_header (psf, SF_FALSE)) return psf->error ; @@ -131,8 +133,9 @@ sds_open (SF_PRIVATE *psf) if ((error = sds_init (psf, psds)) != 0) return error ; - psf->seek = sds_seek ; psf->container_close = sds_close ; + psf->seek = sds_seek ; + psf->byterate = sds_byterate ; psf->blockwidth = 0 ; @@ -145,7 +148,7 @@ sds_open (SF_PRIVATE *psf) static int sds_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { SDS_PRIVATE *psds ; if ((psds = (SDS_PRIVATE *) psf->codec_data) == NULL) @@ -186,7 +189,7 @@ sds_init (SF_PRIVATE *psf, SDS_PRIVATE *psds) psds->samplesperblock = SDS_AUDIO_BYTES_PER_BLOCK / 4 ; } ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { psf->read_short = sds_read_s ; psf->read_int = sds_read_i ; psf->read_float = sds_read_f ; @@ -196,7 +199,7 @@ sds_init (SF_PRIVATE *psf, SDS_PRIVATE *psds) psds->reader (psf, psds) ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { psf->write_short = sds_write_s ; psf->write_int = sds_write_i ; psf->write_float = sds_write_f ; @@ -219,26 +222,47 @@ sds_read_header (SF_PRIVATE *psf, SDS_PRIVATE *psds) if (marker != 0xF07E || byte != 0x01) return SFE_SDS_NOT_SDS ; - psf_log_printf (psf, "Midi Sample Dump Standard (.sds)\nF07E\n Midi Channel : %d\n", channel) ; - - bytesread += psf_binheader_readf (psf, "e213", &sample_no, &bitwidth, &samp_period) ; - + bytesread += psf_binheader_readf (psf, "e2", &sample_no) ; sample_no = SDS_3BYTE_TO_INT_DECODE (sample_no) ; + + psf_log_printf (psf, "Midi Sample Dump Standard (.sds)\nF07E\n" + " Midi Channel : %d\n Sample Number : %d\n", + channel, sample_no) ; + + bytesread += psf_binheader_readf (psf, "e13", &bitwidth, &samp_period) ; + samp_period = SDS_3BYTE_TO_INT_DECODE (samp_period) ; psds->bitwidth = bitwidth ; - psf->sf.samplerate = 1000000000 / samp_period ; + if (psds->bitwidth > 1) + psf_log_printf (psf, " Bit Width : %d\n", psds->bitwidth) ; + else + { psf_log_printf (psf, " Bit Width : %d (should be > 1)\n", psds->bitwidth) ; + return SFE_SDS_BAD_BIT_WIDTH ; + } ; - psf_log_printf (psf, " Sample Number : %d\n" - " Bit Width : %d\n" + if (samp_period > 0) + { psf->sf.samplerate = 1000000000 / samp_period ; + + psf_log_printf (psf, " Sample Period : %d\n" " Sample Rate : %d\n", - sample_no, psds->bitwidth, psf->sf.samplerate) ; + samp_period, psf->sf.samplerate) ; + } + else + { psf->sf.samplerate = 16000 ; + + psf_log_printf (psf, " Sample Period : %d (should be > 0)\n" + " Sample Rate : %d (guessed)\n", + samp_period, psf->sf.samplerate) ; + } ; bytesread += psf_binheader_readf (psf, "e3331", &data_length, &sustain_loop_start, &sustain_loop_end, &loop_type) ; data_length = SDS_3BYTE_TO_INT_DECODE (data_length) ; + psf->sf.frames = psds->frames = data_length ; + sustain_loop_start = SDS_3BYTE_TO_INT_DECODE (sustain_loop_start) ; sustain_loop_end = SDS_3BYTE_TO_INT_DECODE (sustain_loop_end) ; @@ -251,13 +275,6 @@ sds_read_header (SF_PRIVATE *psf, SDS_PRIVATE *psds) psf->dataoffset = SDS_DATA_OFFSET ; psf->datalength = psf->filelength - psf->dataoffset ; - if (data_length != psf->filelength - psf->dataoffset) - { psf_log_printf (psf, " Datalength : %d (truncated data??? %d)\n", data_length, psf->filelength - psf->dataoffset) ; - data_length = psf->filelength - psf->dataoffset ; - } - else - psf_log_printf (psf, " Datalength : %d\n", data_length) ; - bytesread += psf_binheader_readf (psf, "1", &byte) ; if (byte != 0xF7) psf_log_printf (psf, "bad end : %X\n", byte & 0xFF) ; @@ -281,9 +298,6 @@ sds_read_header (SF_PRIVATE *psf, SDS_PRIVATE *psds) psf_log_printf (psf, "Frames : %d\n", blockcount * psds->samplesperblock) ; - psf->sf.frames = blockcount * psds->samplesperblock ; - psds->frames = blockcount * psds->samplesperblock ; - /* Always Mono */ psf->sf.channels = 1 ; psf->sf.sections = 1 ; @@ -337,7 +351,7 @@ sds_write_header (SF_PRIVATE *psf, int calc_length) current = psf_ftell (psf) ; if (calc_length) - psf->sf.frames = psds->total_blocks * psds->samplesperblock + psds->write_count ; + psf->sf.frames = psds->total_written ; if (psds->write_count > 0) { int current_count = psds->write_count ; @@ -378,9 +392,9 @@ sds_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "e213", 0, psds->bitwidth, samp_period) ; - data_length = SDS_INT_TO_3BYTE_ENCODE (psds->total_blocks * SDS_BLOCK_SIZE) ; + data_length = SDS_INT_TO_3BYTE_ENCODE (psds->total_written) ; sustain_loop_start = SDS_INT_TO_3BYTE_ENCODE (0) ; - sustain_loop_end = SDS_INT_TO_3BYTE_ENCODE (psf->sf.frames) ; + sustain_loop_end = SDS_INT_TO_3BYTE_ENCODE (0) ; psf_binheader_writef (psf, "e33311", data_length, sustain_loop_start, sustain_loop_end, loop_type, 0xF7) ; @@ -429,7 +443,7 @@ sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) { printf ("Error 1 : %02X\n", checksum & 0xFF) ; } - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->read_data [k] ; checksum &= 0x7F ; @@ -473,7 +487,7 @@ sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) { printf ("Error 1 : %02X\n", checksum & 0xFF) ; } - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->read_data [k] ; checksum &= 0x7F ; @@ -517,7 +531,7 @@ sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) { printf ("Error 1 : %02X\n", checksum & 0xFF) ; } - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->read_data [k] ; checksum &= 0x7F ; @@ -538,7 +552,8 @@ sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) static sf_count_t sds_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -547,8 +562,8 @@ sds_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) return 0 ; psds = (SDS_PRIVATE*) psf->codec_data ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = sds_read (psf, psds, iptr, readcount) ; @@ -577,7 +592,8 @@ sds_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t sds_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -592,8 +608,8 @@ sds_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) else normfact = 1.0 / (1 << psds->bitwidth) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = sds_read (psf, psds, iptr, readcount) ; @@ -608,7 +624,8 @@ sds_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t sds_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -623,8 +640,8 @@ sds_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) else normfact = 1.0 / (1 << psds->bitwidth) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; count = sds_read (psf, psds, iptr, readcount) ; @@ -737,6 +754,15 @@ sds_seek (SF_PRIVATE *psf, int mode, sf_count_t seek_from_start) return seek_from_start ; } /* sds_seek */ +static int +sds_byterate (SF_PRIVATE * psf) +{ + if (psf->file.mode == SFM_READ) + return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; + + return -1 ; +} /* sds_byterate */ + /*============================================================================== */ @@ -749,7 +775,8 @@ sds_2byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) psds->write_data [0] = 0xF0 ; psds->write_data [1] = 0x7E ; psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = psds->write_block & 0x7F ; /* Packet number */ + psds->write_data [3] = 2 ; + psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ ucptr = psds->write_data + 5 ; for (k = 0 ; k < 120 ; k += 2) @@ -760,7 +787,7 @@ sds_2byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) } ; checksum = psds->write_data [1] ; - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->write_data [k] ; checksum &= 0x7F ; @@ -789,7 +816,8 @@ sds_3byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) psds->write_data [0] = 0xF0 ; psds->write_data [1] = 0x7E ; psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = psds->write_block & 0x7F ; /* Packet number */ + psds->write_data [3] = 2 ; + psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ ucptr = psds->write_data + 5 ; for (k = 0 ; k < 120 ; k += 3) @@ -801,7 +829,7 @@ sds_3byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) } ; checksum = psds->write_data [1] ; - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->write_data [k] ; checksum &= 0x7F ; @@ -830,7 +858,8 @@ sds_4byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) psds->write_data [0] = 0xF0 ; psds->write_data [1] = 0x7E ; psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = psds->write_block & 0x7F ; /* Packet number */ + psds->write_data [3] = 2 ; + psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ ucptr = psds->write_data + 5 ; for (k = 0 ; k < 120 ; k += 4) @@ -843,7 +872,7 @@ sds_4byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) } ; checksum = psds->write_data [1] ; - for (k = 2 ; k < SDS_BLOCK_SIZE - 3 ; k ++) + for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) checksum ^= psds->write_data [k] ; checksum &= 0x7F ; @@ -865,7 +894,8 @@ sds_4byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) static sf_count_t sds_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -873,9 +903,10 @@ sds_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) if (psf->codec_data == NULL) return 0 ; psds = (SDS_PRIVATE*) psf->codec_data ; + psds->total_written += len ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -896,6 +927,7 @@ sds_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) if (psf->codec_data == NULL) return 0 ; psds = (SDS_PRIVATE*) psf->codec_data ; + psds->total_written += len ; total = sds_write (psf, psds, ptr, len) ; @@ -904,7 +936,8 @@ sds_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -913,14 +946,15 @@ sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) if (psf->codec_data == NULL) return 0 ; psds = (SDS_PRIVATE*) psf->codec_data ; + psds->total_written += len ; if (psf->norm_float == SF_TRUE) normfact = 1.0 * 0x80000000 ; else normfact = 1.0 * (1 << psds->bitwidth) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) @@ -935,7 +969,8 @@ sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; +{ BUF_UNION ubuf ; + SDS_PRIVATE *psds ; int *iptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -944,14 +979,15 @@ sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) if (psf->codec_data == NULL) return 0 ; psds = (SDS_PRIVATE*) psf->codec_data ; + psds->total_written += len ; if (psf->norm_double == SF_TRUE) normfact = 1.0 * 0x80000000 ; else normfact = 1.0 * (1 << psds->bitwidth) ; - iptr = psf->u.ibuf ; - bufferlen = ARRAY_LEN (psf->u.ibuf) ; + iptr = ubuf.ibuf ; + bufferlen = ARRAY_LEN (ubuf.ibuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : len ; for (k = 0 ; k < writecount ; k++) diff --git a/libs/libsndfile/src/sf_unistd.h b/libs/libsndfile/src/sf_unistd.h index 1d71f62604..9fca68eff2 100644 --- a/libs/libsndfile/src/sf_unistd.h +++ b/libs/libsndfile/src/sf_unistd.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -34,15 +34,17 @@ #define S_IXUSR 0000100 /* execute/search permission, owner */ #endif -#define S_IRWXG 0000070 /* rwx, group */ -#define S_IRGRP 0000040 /* read permission, group */ -#define S_IWGRP 0000020 /* write permission, grougroup */ -#define S_IXGRP 0000010 /* execute/search permission, group */ +/* Windows doesn't have group permissions so set all these to zero. */ +#define S_IRWXG 0 /* rwx, group */ +#define S_IRGRP 0 /* read permission, group */ +#define S_IWGRP 0 /* write permission, grougroup */ +#define S_IXGRP 0 /* execute/search permission, group */ -#define S_IRWXO 0000007 /* rwx, other */ -#define S_IROTH 0000004 /* read permission, other */ -#define S_IWOTH 0000002 /* write permission, other */ -#define S_IXOTH 0000001 /* execute/search permission, other */ +/* Windows doesn't have others permissions so set all these to zero. */ +#define S_IRWXO 0 /* rwx, other */ +#define S_IROTH 0 /* read permission, other */ +#define S_IWOTH 0 /* write permission, other */ +#define S_IXOTH 0 /* execute/search permission, other */ #ifndef S_ISFIFO #define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) diff --git a/libs/libsndfile/src/sfconfig.h b/libs/libsndfile/src/sfconfig.h index 1884b09a41..b9b2dbda0d 100644 --- a/libs/libsndfile/src/sfconfig.h +++ b/libs/libsndfile/src/sfconfig.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -53,6 +53,10 @@ #define HAVE_ENDIAN_H 0 #endif +#ifndef HAVE_FSTAT64 +#define HAVE_FSTAT64 0 +#endif + #ifndef HAVE_FSYNC #define HAVE_FSYNC 0 #endif @@ -73,14 +77,6 @@ #define HAVE_MMAP 0 #endif -#ifndef HAVE_PREAD -#define HAVE_PREAD 0 -#endif - -#ifndef HAVE_PWRITE -#define HAVE_PWRITE 0 -#endif - #ifndef HAVE_SETLOCALE #define HAVE_SETLOCALE 0 #endif @@ -93,9 +89,27 @@ #define HAVE_STDINT_H 0 #endif +#ifndef HAVE_SYS_WAIT_H +#define HAVE_SYS_WAIT_H 0 +#endif + #ifndef HAVE_UNISTD_H #define HAVE_UNISTD_H 0 #endif +#ifndef HAVE_PIPE +#define HAVE_PIPE 0 #endif +#ifndef HAVE_WAITPID +#define HAVE_WAITPID 0 +#endif + +#ifndef HAVE_X86INTRIN_H +#define HAVE_X86INTRIN_H 0 +#endif + +#define CPU_IS_X86 (defined __i486__ || defined __i586__ || defined __i686__ || defined __x86_64__) +#define CPU_IS_X86_64 (defined __x86_64__) + +#endif diff --git a/libs/libsndfile/src/sfendian.h b/libs/libsndfile/src/sfendian.h index 2c8a908c58..044fa3a77f 100644 --- a/libs/libsndfile/src/sfendian.h +++ b/libs/libsndfile/src/sfendian.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -21,38 +21,72 @@ #include "sfconfig.h" -#if HAVE_STDINT_H #include -#elif HAVE_INTTYPES_H +#ifndef WIN32 #include #endif -#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8)) -/* Good, we have int64_t. */ -#elif (defined (SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)) -typedef long long int64_t ; -#elif (defined (SIZEOF_LONG) && (SIZEOF_LONG == 8)) -typedef long int64_t ; -#elif (defined (WIN32) || defined (_WIN32)) -typedef __int64 int64_t ; -#else -#error "No 64 bit integer type." + +#if COMPILER_IS_GCC && CPU_IS_X86 + +static inline int16_t +ENDSWAP_16 (int16_t x) +{ int16_t y ; + __asm__ ("rorw $8, %w0" : "=r" (y) : "0" (x) : "cc") ; + return y ; +} /* ENDSWAP_16 */ + +static inline int32_t +ENDSWAP_32 (int32_t x) +{ int32_t y ; + __asm__ ("bswap %0" : "=r" (y) : "0" (x)) ; + return y ; +} /* ENDSWAP_32 */ + +#if CPU_IS_X86_64 + +static inline int64_t +ENDSWAP_64X (int64_t x) +{ int64_t y ; + __asm__ ("bswap %q0" : "=r" (y) : "0" (x)) ; + return y ; +} /* ENDSWAP_64X */ + +#define ENDSWAP_64 ENDSWAP_64X + #endif -#if HAVE_BYTESWAP_H - +#elif HAVE_BYTESWAP_H /* Linux, any CPU */ #include -#define ENDSWAP_SHORT(x) ((short) bswap_16 (x)) -#define ENDSWAP_INT(x) ((int) bswap_32 (x)) +#define ENDSWAP_16(x) (bswap_16 (x)) +#define ENDSWAP_32(x) (bswap_32 (x)) +#define ENDSWAP_64(x) (bswap_64 (x)) #else -#define ENDSWAP_SHORT(x) ((((x) >> 8) & 0xFF) + (((x) & 0xFF) << 8)) -#define ENDSWAP_INT(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + (((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24)) +#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) + (((x) & 0xFF) << 8)) +#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + (((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24)) #endif +#ifndef ENDSWAP_64 +static inline uint64_t +ENDSWAP_64 (uint64_t x) +{ union + { uint32_t parts [2] ; + uint64_t whole ; + } u ; + uint32_t temp ; + + u.whole = x ; + temp = u.parts [0] ; + u.parts [0] = ENDSWAP_32 (u.parts [1]) ; + u.parts [1] = ENDSWAP_32 (temp) ; + return u.whole ; +} +#endif + /* ** Many file types (ie WAV, AIFF) use sets of four consecutive bytes as a ** marker indicating different sections of the file. @@ -61,9 +95,9 @@ typedef __int64 int64_t ; */ #if (CPU_IS_LITTLE_ENDIAN == 1) - #define MAKE_MARKER(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) + #define MAKE_MARKER(a, b, c, d) ((uint32_t) ((a) | ((b) << 8) | ((c) << 16) | (((uint32_t) (d)) << 24))) #elif (CPU_IS_BIG_ENDIAN == 1) - #define MAKE_MARKER(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) + #define MAKE_MARKER(a, b, c, d) ((uint32_t) ((((uint32_t) (a)) << 24) | ((b) << 16) | ((c) << 8) | (d))) #else #error "Target CPU endian-ness unknown. May need to hand edit src/sfconfig.h" #endif @@ -76,34 +110,102 @@ typedef __int64 int64_t ; */ #if (CPU_IS_LITTLE_ENDIAN == 1) - #define LES2H_SHORT(x) (x) - #define LEI2H_INT(x) (x) + #define LE2H_16(x) (x) + #define LE2H_32(x) (x) - #define BES2H_SHORT(x) ENDSWAP_SHORT (x) - #define BEI2H_INT(x) ENDSWAP_INT (x) + #define BE2H_16(x) ENDSWAP_16 (x) + #define BE2H_32(x) ENDSWAP_32 (x) + #define BE2H_64(x) ENDSWAP_64 (x) - #define H2BE_SHORT(x) ENDSWAP_SHORT (x) - #define H2BE_INT(x) ENDSWAP_INT (x) + #define H2BE_16(x) ENDSWAP_16 (x) + #define H2BE_32(x) ENDSWAP_32 (x) #elif (CPU_IS_BIG_ENDIAN == 1) - #define LES2H_SHORT(x) ENDSWAP_SHORT (x) - #define LEI2H_INT(x) ENDSWAP_INT (x) + #define LE2H_16(x) ENDSWAP_16 (x) + #define LE2H_32(x) ENDSWAP_32 (x) - #define BES2H_SHORT(x) (x) - #define BEI2H_INT(x) (x) + #define BE2H_16(x) (x) + #define BE2H_32(x) (x) + #define BE2H_64(x) (x) - #define H2LE_SHORT(x) ENDSWAP_SHORT (x) - #define H2LE_INT(x) ENDSWAP_INT (x) + #define H2BE_16(x) (x) + #define H2BE_32(x) (x) + + #define H2LE_16(x) ENDSWAP_16 (x) + #define H2LE_32(x) ENDSWAP_32 (x) #else #error "Target CPU endian-ness unknown. May need to hand edit src/sfconfig.h" #endif -#define LET2H_SHORT_PTR(x) ((x) [1] + ((x) [2] << 8)) -#define LET2H_INT_PTR(x) (((x) [0] << 8) + ((x) [1] << 16) + ((x) [2] << 24)) +#define LET2H_16_PTR(x) ((x) [1] + ((x) [2] << 8)) +#define LET2H_32_PTR(x) (((x) [0] << 8) + ((x) [1] << 16) + ((x) [2] << 24)) -#define BET2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1]) -#define BET2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8)) +#define BET2H_16_PTR(x) (((x) [0] << 8) + (x) [1]) +#define BET2H_32_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8)) + +static inline void +psf_put_be64 (uint8_t *ptr, int offset, int64_t value) +{ + ptr [offset] = value >> 56 ; + ptr [offset + 1] = value >> 48 ; + ptr [offset + 2] = value >> 40 ; + ptr [offset + 3] = value >> 32 ; + ptr [offset + 4] = value >> 24 ; + ptr [offset + 5] = value >> 16 ; + ptr [offset + 6] = value >> 8 ; + ptr [offset + 7] = value ; +} /* psf_put_be64 */ + +static inline void +psf_put_be32 (uint8_t *ptr, int offset, int32_t value) +{ + ptr [offset] = value >> 24 ; + ptr [offset + 1] = value >> 16 ; + ptr [offset + 2] = value >> 8 ; + ptr [offset + 3] = value ; +} /* psf_put_be32 */ + +static inline void +psf_put_be16 (uint8_t *ptr, int offset, int16_t value) +{ + ptr [offset] = value >> 8 ; + ptr [offset + 1] = value ; +} /* psf_put_be16 */ + +static inline int64_t +psf_get_be64 (uint8_t *ptr, int offset) +{ int64_t value ; + + value = ptr [offset] << 24 ; + value += ptr [offset + 1] << 16 ; + value += ptr [offset + 2] << 8 ; + value += ptr [offset + 3] ; + + value <<= 32 ; + + value += ptr [offset + 4] << 24 ; + value += ptr [offset + 5] << 16 ; + value += ptr [offset + 6] << 8 ; + value += ptr [offset + 7] ; + return value ; +} /* psf_get_be64 */ + +static inline int32_t +psf_get_be32 (uint8_t *ptr, int offset) +{ int32_t value ; + + value = ptr [offset] << 24 ; + value += ptr [offset + 1] << 16 ; + value += ptr [offset + 2] << 8 ; + value += ptr [offset + 3] ; + return value ; +} /* psf_get_be32 */ + +static inline int16_t +psf_get_be16 (uint8_t *ptr, int offset) +{ return (ptr [offset] << 8) + ptr [offset + 1] ; +} /* psf_get_be16 */ /*----------------------------------------------------------------------------------------------- ** Generic functions for performing endian swapping on integer arrays. @@ -115,7 +217,7 @@ endswap_short_array (short *ptr, int len) while (--len >= 0) { temp = ptr [len] ; - ptr [len] = ENDSWAP_SHORT (temp) ; + ptr [len] = ENDSWAP_16 (temp) ; } ; } /* endswap_short_array */ @@ -123,7 +225,7 @@ static inline void endswap_short_copy (short *dest, const short *src, int len) { while (--len >= 0) - { dest [len] = ENDSWAP_SHORT (src [len]) ; + { dest [len] = ENDSWAP_16 (src [len]) ; } ; } /* endswap_short_copy */ @@ -133,7 +235,7 @@ endswap_int_array (int *ptr, int len) while (--len >= 0) { temp = ptr [len] ; - ptr [len] = ENDSWAP_INT (temp) ; + ptr [len] = ENDSWAP_32 (temp) ; } ; } /* endswap_int_array */ @@ -141,22 +243,20 @@ static inline void endswap_int_copy (int *dest, const int *src, int len) { while (--len >= 0) - { dest [len] = ENDSWAP_INT (src [len]) ; + { dest [len] = ENDSWAP_32 (src [len]) ; } ; } /* endswap_int_copy */ /*======================================================================================== */ -#if (HAVE_BYTESWAP_H && defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8)) - static inline void endswap_int64_t_array (int64_t *ptr, int len) { int64_t value ; while (--len >= 0) { value = ptr [len] ; - ptr [len] = bswap_64 (value) ; + ptr [len] = ENDSWAP_64 (value) ; } ; } /* endswap_int64_t_array */ @@ -166,78 +266,20 @@ endswap_int64_t_copy (int64_t *dest, const int64_t *src, int len) while (--len >= 0) { value = src [len] ; - dest [len] = bswap_64 (value) ; + dest [len] = ENDSWAP_64 (value) ; } ; } /* endswap_int64_t_copy */ -#else - -static inline void -endswap_int64_t_array (int64_t *ptr, int len) -{ unsigned char *ucptr, temp ; - - ucptr = (unsigned char *) ptr ; - ucptr += 8 * len ; - while (--len >= 0) - { ucptr -= 8 ; - - temp = ucptr [0] ; - ucptr [0] = ucptr [7] ; - ucptr [7] = temp ; - - temp = ucptr [1] ; - ucptr [1] = ucptr [6] ; - ucptr [6] = temp ; - - temp = ucptr [2] ; - ucptr [2] = ucptr [5] ; - ucptr [5] = temp ; - - temp = ucptr [3] ; - ucptr [3] = ucptr [4] ; - ucptr [4] = temp ; - } ; -} /* endswap_int64_t_array */ - -static inline void -endswap_int64_t_copy (int64_t *dest, const int64_t *src, int len) -{ const unsigned char *psrc ; - unsigned char *pdest ; - - if (dest == src) - { endswap_int64_t_array (dest, len) ; - return ; - } ; - - psrc = ((const unsigned char *) src) + 8 * len ; - pdest = ((unsigned char *) dest) + 8 * len ; - while (--len >= 0) - { psrc -= 8 ; - pdest -= 8 ; - - pdest [0] = psrc [7] ; - pdest [2] = psrc [5] ; - pdest [4] = psrc [3] ; - pdest [6] = psrc [1] ; - pdest [7] = psrc [0] ; - pdest [1] = psrc [6] ; - pdest [3] = psrc [4] ; - pdest [5] = psrc [2] ; - } ; -} /* endswap_int64_t_copy */ - -#endif - /* A couple of wrapper functions. */ static inline void endswap_float_array (float *ptr, int len) -{ endswap_int_array ((void *) ptr, len) ; +{ endswap_int_array ((int *) ptr, len) ; } /* endswap_float_array */ static inline void endswap_double_array (double *ptr, int len) -{ endswap_int64_t_array ((void *) ptr, len) ; +{ endswap_int64_t_array ((int64_t *) ptr, len) ; } /* endswap_double_array */ static inline void diff --git a/libs/libsndfile/src/sndfile.c b/libs/libsndfile/src/sndfile.c index 13a641b3b8..cfe75ac4d9 100644 --- a/libs/libsndfile/src/sndfile.c +++ b/libs/libsndfile/src/sndfile.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -21,6 +21,7 @@ #include #include #include +#include #include "sndfile.h" #include "sfendian.h" @@ -57,14 +58,14 @@ ErrorStruct SndfileErrors [] = { /* Public error values and their associated strings. */ { SF_ERR_NO_ERROR , "No Error." }, - { SF_ERR_UNRECOGNISED_FORMAT , "File opened for read. Format not recognised." }, + { SF_ERR_UNRECOGNISED_FORMAT , "Format not recognised." }, { SF_ERR_SYSTEM , "System error." /* Often replaced. */ }, { SF_ERR_MALFORMED_FILE , "Supported file format but file is malformed." }, { SF_ERR_UNSUPPORTED_ENCODING , "Supported file format but unsupported encoding." }, /* Private error values and their associated strings. */ { SFE_ZERO_MAJOR_FORMAT , "Error : major format is 0." }, - { SFE_ZERO_MINOR_FORMAT , "Error : major format is 0." }, + { SFE_ZERO_MINOR_FORMAT , "Error : minor format is 0." }, { SFE_BAD_FILE , "File does not exist or is not a regular file (possibly a pipe?)." }, { SFE_BAD_FILE_READ , "File exists but no data could be read." }, { SFE_OPEN_FAILED , "Could not open file." }, @@ -74,6 +75,7 @@ ErrorStruct SndfileErrors [] = { SFE_BAD_FILE_PTR , "Bad FILE pointer." }, { SFE_BAD_INT_PTR , "Internal error, Bad pointer." }, { SFE_BAD_STAT_SIZE , "Error : software was misconfigured at compile time (sizeof statbuf.st_size)." }, + { SFE_NO_TEMP_DIR , "Error : Could not file temp dir." }, { SFE_MALLOC_FAILED , "Internal malloc () failed." }, { SFE_UNIMPLEMENTED , "File contains data in an unimplemented format." }, @@ -89,8 +91,12 @@ ErrorStruct SndfileErrors [] = { SFE_NO_EMBEDDED_RDWR , "Error : cannot open embedded file read/write." }, { SFE_NO_PIPE_WRITE , "Error : this file format does not support pipe write." }, { SFE_BAD_VIRTUAL_IO , "Error : bad pointer on SF_VIRTUAL_IO struct." }, - { SFE_BAD_BROADCAST_INFO_SIZE, "Error : badd SF_BROADCAST_INFO_SIZE." }, - + { SFE_BAD_BROADCAST_INFO_SIZE + , "Error : bad coding_history_size in SF_BROADCAST_INFO struct." }, + { SFE_BAD_BROADCAST_INFO_TOO_BIG + , "Error : SF_BROADCAST_INFO struct too large." }, + { SFE_BAD_CART_INFO_SIZE , "Error: SF_CART_INFO struct too large." }, + { SFE_BAD_CART_INFO_TOO_BIG , "Error: bag tag_text_size in SF_CART_INFO struct." }, { SFE_INTERLEAVE_MODE , "Attempt to write to file with non-interleaved data." }, { SFE_INTERLEAVE_SEEK , "Bad karma in seek during interleave read operation." }, { SFE_INTERLEAVE_READ , "Bad karma in read during interleave read operation." }, @@ -108,7 +114,7 @@ ErrorStruct SndfileErrors [] = { SFE_SEEK_FAILED , "Error : parameters OK, but psf_seek() failed." }, { SFE_BAD_OPEN_MODE , "Error : bad mode parameter for file open." }, - { SFE_OPEN_PIPE_RDWR , "Error : attempt toopen a pipe in read/write mode." }, + { SFE_OPEN_PIPE_RDWR , "Error : attempt to open a pipe in read/write mode." }, { SFE_RDWR_POSITION , "Error on RDWR position (cryptic)." }, { SFE_RDWR_BAD_HEADER , "Error : Cannot open file in read/write mode due to string data in header." }, { SFE_CMD_HAS_DATA , "Error : Command fails because file already has audio data." }, @@ -161,8 +167,7 @@ ErrorStruct SndfileErrors [] = { SFE_AU_EMBED_BAD_LEN , "Embedded AU file with unknown length." }, { SFE_RAW_READ_BAD_SPEC , "Error while opening RAW file for read. Must specify format and channels.\n" - "Possibly trying to open unsupported format." - }, + "Possibly trying to open unsupported format." }, { SFE_RAW_BAD_BITWIDTH , "Error. RAW file bitwidth must be a multiple of 8." }, { SFE_RAW_BAD_FORMAT , "Error. Bad format field in SF_INFO struct when openning a RAW file for read." }, @@ -170,6 +175,7 @@ ErrorStruct SndfileErrors [] = { SFE_PAF_VERSION , "Error in PAF file, bad version." }, { SFE_PAF_UNKNOWN_FORMAT , "Error in PAF file, unknown format." }, { SFE_PAF_SHORT_HEADER , "Error in PAF file. File shorter than minimal header." }, + { SFE_PAF_BAD_CHANNELS , "Error in PAF file. Bad channel count." }, { SFE_SVX_NO_FORM , "Error in 8SVX / 16SV file, no 'FORM' marker." }, { SFE_SVX_NO_BODY , "Error in 8SVX / 16SV file, no 'BODY' marker." }, @@ -237,7 +243,7 @@ ErrorStruct SndfileErrors [] = { SFE_FLAC_INIT_DECODER , "Error : problem while initialization of the flac decoder." }, { SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." }, { SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." }, - { SFE_FLAC_UNKOWN_ERROR , "Error : unkown error in flac decoder." }, + { SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." }, { SFE_WVE_NOT_WVE , "Error : not a WVE file." }, { SFE_WVE_NO_PIPE , "Error : not able to operate on WVE files over a pipe." }, @@ -248,6 +254,13 @@ ErrorStruct SndfileErrors [] = { SFE_VORBIS_ENCODER_BUG , "Error : Sample rate chosen is known to trigger a Vorbis encoder bug on this CPU." }, { SFE_RF64_NOT_RF64 , "Error : Not an RF64 file." }, + { SFE_ALAC_FAIL_TMPFILE , "Error : Failed to open tmp file for ALAC encoding." }, + + { SFE_BAD_CHUNK_PTR , "Error : Bad SF_CHUNK_INFO pointer." }, + { SFE_UNKNOWN_CHUNK , "Error : Unknown chunk marker." }, + { SFE_BAD_CHUNK_FORMAT , "Error : Reading/writing chunks from this file format is not supported." }, + { SFE_BAD_CHUNK_MARKER , "Error : Bad chunk marker." }, + { SFE_BAD_CHUNK_DATA_PTR , "Error : Bad data pointer in SF_CHUNK_INFO struct." }, { SFE_MAX_ERROR , "Maximum error number." }, { SFE_MAX_ERROR + 1 , NULL } @@ -263,22 +276,21 @@ static int validate_psf (SF_PRIVATE *psf) ; static void save_header_info (SF_PRIVATE *psf) ; static void copy_filename (SF_PRIVATE *psf, const char *path) ; static int psf_close (SF_PRIVATE *psf) ; -static SNDFILE * psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) ; -static int try_resource_fork (SF_PRIVATE * psf, int mode) ; +static int try_resource_fork (SF_PRIVATE * psf) ; /*------------------------------------------------------------------------------ ** Private (static) variables. */ -static int sf_errno = 0 ; -static char sf_logbuffer [SF_BUFFER_LEN] = { 0 } ; +int sf_errno = 0 ; +static char sf_parselog [SF_BUFFER_LEN] = { 0 } ; static char sf_syserr [SF_SYSERR_LEN] = { 0 } ; /*------------------------------------------------------------------------------ */ -#define VALIDATE_SNDFILE_AND_ASSIGN_PSF(a,b,c) \ +#define VALIDATE_SNDFILE_AND_ASSIGN_PSF(a, b, c) \ { if ((a) == NULL) \ { sf_errno = SFE_BAD_SNDFILE_PTR ; \ return 0 ; \ @@ -304,24 +316,27 @@ SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) { SF_PRIVATE *psf ; + /* Ultimate sanity check. */ + assert (sizeof (sf_count_t) == 8) ; + if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL) { sf_errno = SFE_MALLOC_FAILED ; return NULL ; } ; - memset (psf, 0, sizeof (SF_PRIVATE)) ; psf_init_files (psf) ; psf_log_printf (psf, "File : %s\n", path) ; copy_filename (psf, path) ; + psf->file.mode = mode ; if (strcmp (path, "-") == 0) - psf->error = psf_set_stdio (psf, mode) ; + psf->error = psf_set_stdio (psf) ; else - psf->error = psf_fopen (psf, path, mode) ; + psf->error = psf_fopen (psf) ; - return psf_open_file (psf, mode, sfinfo) ; + return psf_open_file (psf, sfinfo) ; } /* sf_open */ SNDFILE* @@ -339,15 +354,17 @@ sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) } ; psf_init_files (psf) ; + copy_filename (psf, "") ; + psf->file.mode = mode ; psf_set_file (psf, fd) ; psf->is_pipe = psf_is_pipe (psf) ; psf->fileoffset = psf_ftell (psf) ; if (! close_desc) - psf->do_not_close_descriptor = SF_TRUE ; + psf->file.do_not_close_descriptor = SF_TRUE ; - return psf_open_file (psf, mode, sfinfo) ; + return psf_open_file (psf, sfinfo) ; } /* sf_open_fd */ SNDFILE* @@ -357,19 +374,19 @@ sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user /* Make sure we have a valid set ot virtual pointers. */ if (sfvirtual->get_filelen == NULL || sfvirtual->seek == NULL || sfvirtual->tell == NULL) { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ; + snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ; return NULL ; } ; if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL) { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ; + snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ; return NULL ; } ; if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL) { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ; + snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ; return NULL ; } ; @@ -384,9 +401,9 @@ sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user psf->vio = *sfvirtual ; psf->vio_user_data = user_data ; - psf->mode = mode ; + psf->file.mode = mode ; - return psf_open_file (psf, mode, sfinfo) ; + return psf_open_file (psf, sfinfo) ; } /* sf_open_virtual */ int @@ -537,7 +554,7 @@ sf_format_check (const SF_INFO *info) ** Return 0 on failure, 1 ons success. */ - if (info->channels < 1 || info->channels > 256) + if (info->channels < 1 || info->channels > SF_MAX_CHANNELS) return 0 ; if (info->samplerate < 0) @@ -545,7 +562,6 @@ sf_format_check (const SF_INFO *info) switch (SF_CONTAINER (info->format)) { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : /* WAV now allows both endian, RIFF or RIFX (little or big respectively) */ if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) return 1 ; @@ -563,12 +579,25 @@ sf_format_check (const SF_INFO *info) return 1 ; break ; + case SF_FORMAT_WAVEX : + if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) + return 0 ; + if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) + return 1 ; + if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) + return 1 ; + if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) + return 1 ; + if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) + return 1 ; + break ; + case SF_FORMAT_AIFF : /* AIFF does allow both endian-nesses for PCM data.*/ if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) return 1 ; - /* Other encodings. Check for endian-ness. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) + /* For other encodings reject any endian-ness setting. */ + if (endian != 0) return 0 ; if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_S8) return 1 ; @@ -609,6 +638,10 @@ sf_format_check (const SF_INFO *info) return 1 ; if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) return 1 ; + if (subformat == SF_FORMAT_ALAC_16 || subformat == SF_FORMAT_ALAC_20) + return 1 ; + if (subformat == SF_FORMAT_ALAC_24 || subformat == SF_FORMAT_ALAC_32) + return 1 ; if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) return 1 ; break ; @@ -632,23 +665,19 @@ sf_format_check (const SF_INFO *info) break ; case SF_FORMAT_PAF : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) + if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) return 1 ; break ; case SF_FORMAT_SVX : - /* SVX currently does not support more than one channel for write. - ** Read will allow more than one channel but only allow one here. - */ - if (info->channels != 1) + /* SVX only supports writing mono SVX files. */ + if (info->channels > 1) return 0 ; /* Always big endian. */ if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) return 0 ; - if ((subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) && info->channels == 1) + if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) return 1 ; break ; @@ -662,7 +691,7 @@ sf_format_check (const SF_INFO *info) break ; case SF_FORMAT_IRCAM : - if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) + if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_32) return 1 ; if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW || subformat == SF_FORMAT_FLOAT) return 1 ; @@ -756,6 +785,8 @@ sf_format_check (const SF_INFO *info) /* FLAC can't do more than 8 channels. */ if (info->channels > 8) return 0 ; + if (endian != SF_ENDIAN_FILE) + return 0 ; if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) return 1 ; break ; @@ -764,7 +795,7 @@ sf_format_check (const SF_INFO *info) /* SD2 is strictly big endian. */ if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) return 0 ; - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) + if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) return 1 ; break ; @@ -779,6 +810,8 @@ sf_format_check (const SF_INFO *info) break ; case SF_FORMAT_OGG : + if (endian != SF_ENDIAN_FILE) + return 0 ; if (subformat == SF_FORMAT_VORBIS) return 1 ; break ; @@ -811,12 +844,27 @@ sf_format_check (const SF_INFO *info) return 0 ; } /* sf_format_check */ +/*------------------------------------------------------------------------------ +*/ + +const char * +sf_version_string (void) +{ +#if ENABLE_EXPERIMENTAL_CODE + return PACKAGE_NAME "-" PACKAGE_VERSION "-exp" ; +#else + return PACKAGE_NAME "-" PACKAGE_VERSION ; +#endif +} + + /*------------------------------------------------------------------------------ */ int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) { SF_PRIVATE *psf = (SF_PRIVATE *) sndfile ; + double quality ; int old_value ; /* This set of commands do not need the sndfile parameter. */ @@ -827,10 +875,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) psf->error = SFE_BAD_COMMAND_PARAM ; return SFE_BAD_COMMAND_PARAM ; } ; - if (ENABLE_EXPERIMENTAL_CODE) - snprintf (data, datasize, "%s-%s-exp", PACKAGE_NAME, PACKAGE_VERSION) ; - else - snprintf (data, datasize, "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ; + snprintf (data, datasize, "%s", sf_version_string ()) ; return strlen (data) ; case SFC_GET_SIMPLE_FORMAT_COUNT : @@ -874,8 +919,8 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) if (sndfile == NULL && command == SFC_GET_LOG_INFO) { if (data == NULL) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - snprintf (data, datasize, "%s", sf_logbuffer) ; + return (sf_errno = SFE_BAD_COMMAND_PARAM) ; + snprintf (data, datasize, "%s", sf_parselog) ; return strlen (data) ; } ; @@ -921,8 +966,16 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) { int format = SF_CONTAINER (psf->sf.format) ; /* Only WAV and AIFF support the PEAK chunk. */ - if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX && format != SF_FORMAT_AIFF) - return SF_FALSE ; + switch (format) + { case SF_FORMAT_AIFF : + case SF_FORMAT_CAF : + case SF_FORMAT_WAV : + case SF_FORMAT_WAVEX : + break ; + + default : + return SF_FALSE ; + } ; format = SF_CODEC (psf->sf.format) ; @@ -932,7 +985,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) } ; /* Can only do this is in SFM_WRITE mode. */ - if (psf->mode != SFM_WRITE && psf->mode != SFM_RDWR) + if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) return SF_FALSE ; /* If data has already been written this must fail. */ if (psf->have_written) @@ -960,7 +1013,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) case SFC_GET_LOG_INFO : if (data == NULL) return SFE_BAD_COMMAND_PARAM ; - snprintf (data, datasize, "%s", psf->logbuffer) ; + snprintf (data, datasize, "%s", psf->parselog.buf) ; break ; case SFC_CALC_SIGNAL_MAX : @@ -1022,7 +1075,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO)) return (psf->error = SFE_BAD_COMMAND_PARAM) ; memcpy (&psf->write_dither, data, sizeof (psf->write_dither)) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) dither_init (psf, SFM_WRITE) ; break ; @@ -1030,15 +1083,20 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO)) return (psf->error = SFE_BAD_COMMAND_PARAM) ; memcpy (&psf->read_dither, data, sizeof (psf->read_dither)) ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) dither_init (psf, SFM_READ) ; break ; case SFC_FILE_TRUNCATE : - if (psf->mode != SFM_WRITE && psf->mode != SFM_RDWR) + if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) return SF_TRUE ; if (datasize != sizeof (sf_count_t)) return SF_TRUE ; + if (data == NULL || datasize != sizeof (sf_count_t)) + { psf->error = SFE_BAD_COMMAND_PARAM ; + return SF_FALSE ; + } + else { sf_count_t position ; position = *((sf_count_t*) data) ; @@ -1105,29 +1163,22 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) case SFC_SET_BROADCAST_INFO : { int format = SF_CONTAINER (psf->sf.format) ; - /* Only WAV supports the BEXT (Broadcast) chunk. */ - if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX) + /* Only WAV and RF64 supports the BEXT (Broadcast) chunk. */ + if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX && format != SF_FORMAT_RF64) return SF_FALSE ; } ; /* Only makes sense in SFM_WRITE or SFM_RDWR mode. */ - if ((psf->mode != SFM_WRITE) && (psf->mode != SFM_RDWR)) + if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR)) return SF_FALSE ; /* If data has already been written this must fail. */ - if (psf->broadcast_var == NULL && psf->have_written) + if (psf->broadcast_16k == NULL && psf->have_written) { psf->error = SFE_CMD_HAS_DATA ; return SF_FALSE ; } ; -#if 0 - if (psf->broadcast_info == NULL) - psf->broadcast_info = broadcast_info_alloc () ; - - broadcast_info_copy (psf->broadcast_info, data) ; - broadcast_add_coding_history (psf->broadcast_info, psf->sf.channels, psf->sf.samplerate, psf->sf.format) ; -#else - broadcast_var_set (psf, data, datasize) ; -#endif + if (NOT (broadcast_var_set (psf, data, datasize))) + return SF_FALSE ; if (psf->write_header) psf->write_header (psf, SF_TRUE) ; @@ -1138,13 +1189,35 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) { psf->error = SFE_BAD_COMMAND_PARAM ; return SF_FALSE ; } ; -#if 0 - if (psf->broadcast_info == NULL) - return SF_FALSE ; - return broadcast_info_copy (data, psf->broadcast_info) ; -#else return broadcast_var_get (psf, data, datasize) ; -#endif + + case SFC_SET_CART_INFO : + { int format = SF_CONTAINER (psf->sf.format) ; + /* Only WAV and RF64 support cart chunk format */ + if (format != SF_FORMAT_WAV && format != SF_FORMAT_RF64) + return SF_FALSE ; + } ; + + /* Only makes sense in SFM_WRITE or SFM_RDWR mode */ + if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR)) + return SF_FALSE ; + /* If data has already been written this must fail. */ + if (psf->cart_16k == NULL && psf->have_written) + { psf->error = SFE_CMD_HAS_DATA ; + return SF_FALSE ; + } ; + if (NOT (cart_var_set (psf, data, datasize))) + return SF_FALSE ; + if (psf->write_header) + psf->write_header (psf, SF_TRUE) ; + return SF_TRUE ; + + case SFC_GET_CART_INFO : + if (data == NULL) + { psf->error = SFE_BAD_COMMAND_PARAM ; + return SF_FALSE ; + } ; + return cart_var_get (psf, data, datasize) ; case SFC_GET_INSTRUMENT : if (datasize != sizeof (SF_INSTRUMENT) || data == NULL) @@ -1177,6 +1250,63 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize) case SFC_RAW_DATA_NEEDS_ENDSWAP : return psf->data_endswap ; + case SFC_GET_CHANNEL_MAP_INFO : + if (psf->channel_map == NULL) + return SF_FALSE ; + + if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels) + { psf->error = SFE_BAD_COMMAND_PARAM ; + return SF_FALSE ; + } ; + + memcpy (data, psf->channel_map, datasize) ; + return SF_TRUE ; + + case SFC_SET_CHANNEL_MAP_INFO : + if (psf->have_written) + { psf->error = SFE_CMD_HAS_DATA ; + return SF_FALSE ; + } ; + if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels) + { psf->error = SFE_BAD_COMMAND_PARAM ; + return SF_FALSE ; + } ; + + { int *iptr ; + + for (iptr = data ; iptr < (int*) data + psf->sf.channels ; iptr++) + { if (*iptr <= SF_CHANNEL_MAP_INVALID || *iptr >= SF_CHANNEL_MAP_MAX) + { psf->error = SFE_BAD_COMMAND_PARAM ; + return SF_FALSE ; + } ; + } ; + } ; + + free (psf->channel_map) ; + if ((psf->channel_map = malloc (datasize)) == NULL) + { psf->error = SFE_MALLOC_FAILED ; + return SF_FALSE ; + } ; + + memcpy (psf->channel_map, data, datasize) ; + + /* + ** Pass the command down to the container's command handler. + ** Don't pass user data, use validated psf->channel_map data instead. + */ + if (psf->command) + return psf->command (psf, command, NULL, 0) ; + return SF_FALSE ; + + case SFC_SET_VBR_ENCODING_QUALITY : + if (data == NULL || datasize != sizeof (double)) + return SF_FALSE ; + + quality = *((double *) data) ; + quality = 1.0 - SF_MAX (0.0, SF_MIN (1.0, quality)) ; + return sf_command (sndfile, SFC_SET_COMPRESSION_LEVEL, &quality, sizeof (quality)) ; + + default : /* Must be a file specific command. Pass it on. */ if (psf->command) @@ -1207,8 +1337,8 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence) /* If the whence parameter has a mode ORed in, check to see that ** it makes sense. */ - if (((whence & SFM_MASK) == SFM_WRITE && psf->mode == SFM_READ) || - ((whence & SFM_MASK) == SFM_READ && psf->mode == SFM_WRITE)) + if (((whence & SFM_MASK) == SFM_WRITE && psf->file.mode == SFM_READ) || + ((whence & SFM_MASK) == SFM_READ && psf->file.mode == SFM_WRITE)) { psf->error = SFE_WRONG_SEEK ; return PSF_SEEK_ERROR ; } ; @@ -1228,14 +1358,14 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence) /* The SEEK_CUR is a little more tricky. */ case SEEK_CUR : if (offset == 0) - { if (psf->mode == SFM_READ) + { if (psf->file.mode == SFM_READ) return psf->read_current ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) return psf->write_current ; } ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) seek_from_start = psf->read_current + offset ; - else if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + else if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) seek_from_start = psf->write_current + offset ; else psf->error = SFE_AMBIGUOUS_SEEK ; @@ -1268,7 +1398,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence) if (psf->error) return PSF_SEEK_ERROR ; - if (psf->mode == SFM_RDWR || psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_RDWR || psf->file.mode == SFM_WRITE) { if (seek_from_start < 0) { psf->error = SFE_BAD_SEEK ; return PSF_SEEK_ERROR ; @@ -1280,7 +1410,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence) } ; if (psf->seek) - { int new_mode = (whence & SFM_MASK) ? (whence & SFM_MASK) : psf->mode ; + { int new_mode = (whence & SFM_MASK) ? (whence & SFM_MASK) : psf->file.mode ; retval = psf->seek (psf, new_mode, seek_from_start) ; @@ -1331,6 +1461,50 @@ sf_set_string (SNDFILE *sndfile, int str_type, const char* str) return psf_set_string (psf, str_type, str) ; } /* sf_get_string */ +/*------------------------------------------------------------------------------ +*/ + +int +sf_current_byterate (SNDFILE *sndfile) +{ SF_PRIVATE *psf ; + + if ((psf = (SF_PRIVATE*) sndfile) == NULL) + return -1 ; + if (psf->Magick != SNDFILE_MAGICK) + return -1 ; + + /* This should cover all PCM and floating point formats. */ + if (psf->bytewidth) + return psf->sf.samplerate * psf->sf.channels * psf->bytewidth ; + + if (psf->byterate) + return psf->byterate (psf) ; + + switch (SF_CODEC (psf->sf.format)) + { case SF_FORMAT_IMA_ADPCM : + case SF_FORMAT_MS_ADPCM : + case SF_FORMAT_VOX_ADPCM : + return (psf->sf.samplerate * psf->sf.channels) / 2 ; + + case SF_FORMAT_GSM610 : + return (psf->sf.samplerate * psf->sf.channels * 13000) / 8000 ; + + case SF_FORMAT_G721_32 : /* 32kbs G721 ADPCM encoding. */ + return (psf->sf.samplerate * psf->sf.channels) / 2 ; + + case SF_FORMAT_G723_24 : /* 24kbs G723 ADPCM encoding. */ + return (psf->sf.samplerate * psf->sf.channels * 3) / 8 ; + + case SF_FORMAT_G723_40 : /* 40kbs G723 ADPCM encoding. */ + return (psf->sf.samplerate * psf->sf.channels * 5) / 8 ; + + default : + break ; + } ; + + return -1 ; +} /* sf_current_byterate */ + /*============================================================================== */ @@ -1345,12 +1519,12 @@ sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ; blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; - if (bytes < 0 || psf->read_current >= psf->datalength) + if (bytes < 0 || psf->read_current >= psf->sf.frames) { psf_memset (ptr, 0, bytes) ; return 0 ; } ; @@ -1360,6 +1534,10 @@ sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) return 0 ; } ; + if (psf->last_op != SFM_READ) + if (psf->seek (psf, SFM_READ, psf->read_current) < 0) + return 0 ; + count = psf_fread (ptr, 1, bytes, psf) ; if (psf->read_current + count / blockwidth <= psf->sf.frames) @@ -1386,7 +1564,7 @@ sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1433,7 +1611,7 @@ sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1478,7 +1656,7 @@ sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1525,7 +1703,7 @@ sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1570,7 +1748,7 @@ sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1617,7 +1795,7 @@ sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1662,7 +1840,7 @@ sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1709,7 +1887,7 @@ sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->error = SFE_NOT_READMODE ; return 0 ; } ; @@ -1758,7 +1936,7 @@ sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t len) bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ; blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1768,6 +1946,10 @@ sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t len) return 0 ; } ; + if (psf->last_op != SFM_WRITE) + if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) + return 0 ; + if (psf->have_written == SF_FALSE && psf->write_header != NULL) psf->write_header (psf, SF_FALSE) ; psf->have_written = SF_TRUE ; @@ -1776,11 +1958,16 @@ sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t len) psf->write_current += count / blockwidth ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + + if (psf->auto_header && psf->write_header != NULL) + psf->write_header (psf, SF_TRUE) ; + return count ; } /* sf_write_raw */ @@ -1794,7 +1981,7 @@ sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1823,12 +2010,14 @@ sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t len) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count ; } /* sf_write_short */ @@ -1839,7 +2028,7 @@ sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1863,12 +2052,14 @@ sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count / psf->sf.channels ; } /* sf_writef_short */ @@ -1882,7 +2073,7 @@ sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1911,12 +2102,14 @@ sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t len) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count ; } /* sf_write_int */ @@ -1927,7 +2120,7 @@ sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1951,12 +2144,14 @@ sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count / psf->sf.channels ; } /* sf_writef_int */ @@ -1970,7 +2165,7 @@ sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -1999,12 +2194,14 @@ sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t len) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count ; } /* sf_write_float */ @@ -2015,7 +2212,7 @@ sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -2039,12 +2236,14 @@ sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count / psf->sf.channels ; } /* sf_writef_float */ @@ -2058,7 +2257,7 @@ sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t len) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -2087,12 +2286,14 @@ sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t len) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count ; } /* sf_write_double */ @@ -2103,7 +2304,7 @@ sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf->error = SFE_NOT_WRITEMODE ; return 0 ; } ; @@ -2127,12 +2328,14 @@ sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) psf->last_op = SFM_WRITE ; + if (psf->write_current > psf->sf.frames) + { psf->sf.frames = psf->write_current ; + psf->dataend = 0 ; + } ; + if (psf->auto_header && psf->write_header != NULL) psf->write_header (psf, SF_TRUE) ; - if (psf->write_current > psf->sf.frames) - psf->sf.frames = psf->write_current ; - return count / psf->sf.channels ; } /* sf_writef_double */ @@ -2141,13 +2344,18 @@ sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) */ static int -try_resource_fork (SF_PRIVATE * psf, int mode) -{ - if (psf_open_rsrc (psf, mode) != 0) +try_resource_fork (SF_PRIVATE * psf) +{ int old_error = psf->error ; + + /* Set READ mode now, to see if resource fork exists. */ + psf->rsrc.mode = SFM_READ ; + if (psf_open_rsrc (psf) != 0) + { psf->error = old_error ; return 0 ; + } ; /* More checking here. */ - psf_log_printf (psf, "Resource fork : %s\n", psf->rsrcpath) ; + psf_log_printf (psf, "Resource fork : %s\n", psf->rsrc.path.c) ; return SF_FORMAT_SD2 ; } /* try_resource_fork */ @@ -2158,14 +2366,14 @@ format_from_extension (SF_PRIVATE *psf) char buffer [16] ; int format = 0 ; - if ((cptr = strrchr (psf->filename, '.')) == NULL) + if ((cptr = strrchr (psf->file.name.c, '.')) == NULL) return 0 ; cptr ++ ; if (strlen (cptr) > sizeof (buffer) - 1) return 0 ; - strncpy (buffer, cptr, sizeof (buffer)) ; + psf_strlcpy (buffer, sizeof (buffer), cptr) ; buffer [sizeof (buffer) - 1] = 0 ; /* Convert everything in the buffer to lower case. */ @@ -2213,7 +2421,7 @@ format_from_extension (SF_PRIVATE *psf) static int guess_file_type (SF_PRIVATE *psf) -{ int buffer [3], format ; +{ uint32_t buffer [3], format ; if (psf_binheader_readf (psf, "b", &buffer, SIGNED_SIZEOF (buffer)) != SIGNED_SIZEOF (buffer)) { psf->error = SFE_BAD_FILE_READ ; @@ -2299,30 +2507,38 @@ guess_file_type (SF_PRIVATE *psf) return 0 /*-SF_FORMAT_WMA-*/ ; /* HMM (Hidden Markov Model) Tool Kit. */ - if (2 * BEI2H_INT (buffer [0]) + 12 == psf->filelength && buffer [2] == MAKE_MARKER (0, 2, 0, 0)) + if (2 * BE2H_32 (buffer [0]) + 12 == psf->filelength && buffer [2] == MAKE_MARKER (0, 2, 0, 0)) return SF_FORMAT_HTK ; if (buffer [0] == MAKE_MARKER ('f', 'L', 'a', 'C')) return SF_FORMAT_FLAC ; - /* Turtle Beach SMP 16-bit */ - if (buffer [0] == MAKE_MARKER ('S', 'O', 'U', 'N') && buffer [1] == MAKE_MARKER ('D', ' ', 'S', 'A')) - return 0 ; - - if (buffer [0] == MAKE_MARKER ('S', 'Y', '8', '0') || buffer [0] == MAKE_MARKER ('S', 'Y', '8', '5')) - return 0 ; - - if (buffer [0] == MAKE_MARKER ('a', 'j', 'k', 'g')) - return 0 /*-SF_FORMAT_SHN-*/ ; - if (buffer [0] == MAKE_MARKER ('2', 'B', 'I', 'T')) return SF_FORMAT_AVR ; if (buffer [0] == MAKE_MARKER ('R', 'F', '6', '4') && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E')) return SF_FORMAT_RF64 ; - /* This must be the second last one. */ - if (psf->filelength > 0 && (format = try_resource_fork (psf, SFM_READ)) != 0) + if (buffer [0] == MAKE_MARKER ('I', 'D', '3', 3)) + { psf_log_printf (psf, "Found 'ID3' marker.\n") ; + if (id3_skip (psf)) + return guess_file_type (psf) ; + return 0 ; + } ; + + /* Turtle Beach SMP 16-bit */ + if (buffer [0] == MAKE_MARKER ('S', 'O', 'U', 'N') && buffer [1] == MAKE_MARKER ('D', ' ', 'S', 'A')) + return 0 ; + + /* Yamaha sampler format. */ + if (buffer [0] == MAKE_MARKER ('S', 'Y', '8', '0') || buffer [0] == MAKE_MARKER ('S', 'Y', '8', '5')) + return 0 ; + + if (buffer [0] == MAKE_MARKER ('a', 'j', 'k', 'g')) + return 0 /*-SF_FORMAT_SHN-*/ ; + + /* This must be the last one. */ + if (psf->filelength > 0 && (format = try_resource_fork (psf)) != 0) return format ; return 0 ; @@ -2367,7 +2583,7 @@ validate_psf (SF_PRIVATE *psf) static void save_header_info (SF_PRIVATE *psf) -{ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ; +{ snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ; } /* save_header_info */ static void @@ -2375,20 +2591,20 @@ copy_filename (SF_PRIVATE *psf, const char *path) { const char *ccptr ; char *cptr ; - snprintf (psf->filepath, sizeof (psf->filepath), "%s", path) ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", path) ; if ((ccptr = strrchr (path, '/')) || (ccptr = strrchr (path, '\\'))) ccptr ++ ; else ccptr = path ; - snprintf (psf->filename, sizeof (psf->filename), "%s", ccptr) ; + snprintf (psf->file.name.c, sizeof (psf->file.name.c), "%s", ccptr) ; /* Now grab the directory. */ - snprintf (psf->directory, sizeof (psf->directory), "%s", path) ; - if ((cptr = strrchr (psf->directory, '/')) || (cptr = strrchr (psf->directory, '\\'))) + snprintf (psf->file.dir.c, sizeof (psf->file.dir.c), "%s", path) ; + if ((cptr = strrchr (psf->file.dir.c, '/')) || (cptr = strrchr (psf->file.dir.c, '\\'))) cptr [1] = 0 ; else - psf->directory [0] = 0 ; + psf->file.dir.c [0] = 0 ; return ; } /* copy_filename */ @@ -2398,47 +2614,41 @@ copy_filename (SF_PRIVATE *psf, const char *path) static int psf_close (SF_PRIVATE *psf) -{ int error = 0 ; +{ uint32_t k ; + int error = 0 ; if (psf->codec_close) - error = psf->codec_close (psf) ; + { error = psf->codec_close (psf) ; + /* To prevent it being called in psf->container_close(). */ + psf->codec_close = NULL ; + } ; + if (psf->container_close) error = psf->container_close (psf) ; error = psf_fclose (psf) ; psf_close_rsrc (psf) ; - if (psf->container_data) - free (psf->container_data) ; + /* For an ISO C compliant implementation it is ok to free a NULL pointer. */ + free (psf->container_data) ; + free (psf->codec_data) ; + free (psf->interleave) ; + free (psf->dither) ; + free (psf->peak_info) ; + free (psf->broadcast_16k) ; + free (psf->loop_info) ; + free (psf->instrument) ; + free (psf->channel_map) ; + free (psf->format_desc) ; + free (psf->strings.storage) ; - if (psf->codec_data) - free (psf->codec_data) ; - - if (psf->interleave) - free (psf->interleave) ; - - if (psf->dither) - free (psf->dither) ; - - if (psf->peak_info) - free (psf->peak_info) ; - - if (psf->broadcast_var) - free (psf->broadcast_var) ; - - if (psf->loop_info) - free (psf->loop_info) ; - - if (psf->instrument) - free (psf->instrument) ; - - if (psf->channel_map) - free (psf->channel_map) ; - - if (psf->format_desc) - { psf->format_desc [0] = 0 ; - free (psf->format_desc) ; - } ; + if (psf->wchunks.chunks) + for (k = 0 ; k < psf->wchunks.used ; k++) + free (psf->wchunks.chunks [k].data) ; + free (psf->rchunks.chunks) ; + free (psf->wchunks.chunks) ; + free (psf->iterator) ; + free (psf->cart_16k) ; memset (psf, 0, sizeof (SF_PRIVATE)) ; free (psf) ; @@ -2446,19 +2656,19 @@ psf_close (SF_PRIVATE *psf) return error ; } /* psf_close */ -static SNDFILE * -psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) +SNDFILE * +psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo) { int error, format ; sf_errno = error = 0 ; - sf_logbuffer [0] = 0 ; + sf_parselog [0] = 0 ; if (psf->error) { error = psf->error ; goto error_exit ; } ; - if (mode != SFM_READ && mode != SFM_WRITE && mode != SFM_RDWR) + if (psf->file.mode != SFM_READ && psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) { error = SFE_BAD_OPEN_MODE ; goto error_exit ; } ; @@ -2473,7 +2683,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) sfinfo->sections = 0 ; sfinfo->seekable = 0 ; - if (mode == SFM_READ) + if (psf->file.mode == SFM_READ) { if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_RAW) { if (sf_format_check (sfinfo) == 0) { error = SFE_RAW_BAD_FORMAT ; @@ -2484,12 +2694,11 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) memset (sfinfo, 0, sizeof (SF_INFO)) ; } ; - memcpy (&(psf->sf), sfinfo, sizeof (SF_INFO)) ; + memcpy (&psf->sf, sfinfo, sizeof (SF_INFO)) ; psf->Magick = SNDFILE_MAGICK ; psf->norm_float = SF_TRUE ; psf->norm_double = SF_TRUE ; - psf->mode = mode ; psf->dataoffset = -1 ; psf->datalength = -1 ; psf->read_current = -1 ; @@ -2519,7 +2728,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) } ; if (psf->fileoffset > 0) - { switch (psf->mode) + { switch (psf->file.mode) { case SFM_READ : if (psf->filelength < 44) { psf_log_printf (psf, "Short filelength: %D (fileoffset: %D)\n", psf->filelength, psf->fileoffset) ; @@ -2547,7 +2756,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) else psf_log_printf (psf, "Length : %D\n", psf->filelength) ; - if (mode == SFM_WRITE || (mode == SFM_RDWR && psf->filelength == 0)) + if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->filelength == 0)) { /* If the file is being opened for write or RDWR and the file is currently ** empty, then the SF_INFO struct must contain valid data. */ @@ -2555,12 +2764,12 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) { error = SFE_ZERO_MAJOR_FORMAT ; goto error_exit ; } ; - if ((SF_CONTAINER (psf->sf.format)) == 0) + if ((SF_CODEC (psf->sf.format)) == 0) { error = SFE_ZERO_MINOR_FORMAT ; goto error_exit ; } ; - if (sf_format_check (&(psf->sf)) == 0) + if (sf_format_check (&psf->sf) == 0) { error = SFE_BAD_OPEN_FORMAT ; goto error_exit ; } ; @@ -2574,7 +2783,7 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) } ; /* Prevent unnecessary seeks */ - psf->last_op = psf->mode ; + psf->last_op = psf->file.mode ; /* Set bytewidth if known. */ switch (SF_CODEC (psf->sf.format)) @@ -2728,23 +2937,34 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) /* For now, check whether embedding is supported. */ format = SF_CONTAINER (psf->sf.format) ; - if (psf->fileoffset > 0 && - (format != SF_FORMAT_WAV) && (format != SF_FORMAT_WAVEX) && - (format != SF_FORMAT_AIFF) && (format != SF_FORMAT_AU) - ) - { error = SFE_NO_EMBED_SUPPORT ; - goto error_exit ; + if (psf->fileoffset > 0) + { switch (format) + { case SF_FORMAT_WAV : + case SF_FORMAT_WAVEX : + case SF_FORMAT_AIFF : + case SF_FORMAT_AU : + /* Actual embedded files. */ + break ; + + case SF_FORMAT_FLAC : + /* Flac with an ID3v2 header? */ + break ; + + default : + error = SFE_NO_EMBED_SUPPORT ; + goto error_exit ; + } ; } ; if (psf->fileoffset > 0) psf_log_printf (psf, "Embedded file length : %D\n", psf->filelength) ; - if (mode == SFM_RDWR && sf_format_check (&(psf->sf)) == 0) + if (psf->file.mode == SFM_RDWR && sf_format_check (&psf->sf) == 0) { error = SFE_BAD_MODE_RW ; goto error_exit ; } ; - if (validate_sfinfo (&(psf->sf)) == 0) + if (validate_sfinfo (&psf->sf) == 0) { psf_log_SF_INFO (psf) ; save_header_info (psf) ; error = SFE_BAD_SF_INFO ; @@ -2759,14 +2979,12 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) psf->read_current = 0 ; psf->write_current = 0 ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) { psf->write_current = psf->sf.frames ; psf->have_written = psf->sf.frames > 0 ? SF_TRUE : SF_FALSE ; } ; - memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ; - - memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ; + memcpy (sfinfo, &psf->sf, sizeof (SF_INFO)) ; return (SNDFILE *) psf ; @@ -2775,7 +2993,7 @@ error_exit : if (error == SFE_SYSTEM) snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ; - snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ; + snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ; switch (error) { case SF_ERR_SYSTEM : @@ -2787,7 +3005,7 @@ error_exit : break ; default : - if (psf->mode == SFM_READ) + if (psf->file.mode == SFM_READ) { psf_log_printf (psf, "Parse error : %s\n", sf_error_number (error)) ; error = SF_ERR_MALFORMED_FILE ; } ; @@ -2797,3 +3015,79 @@ error_exit : return NULL ; } /* psf_open_file */ +/*============================================================================== +** Chunk getting and setting. +*/ + +int +sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) +{ SF_PRIVATE *psf ; + + VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; + + if (chunk_info == NULL || chunk_info->data == NULL) + return SFE_BAD_CHUNK_PTR ; + + if (psf->set_chunk) + return psf->set_chunk (psf, chunk_info) ; + + return SFE_BAD_CHUNK_FORMAT ; +} /* sf_set_chunk */ + +SF_CHUNK_ITERATOR * +sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) +{ SF_PRIVATE *psf ; + + VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; + + if (chunk_info) + return psf_get_chunk_iterator (psf, chunk_info->id) ; + + return psf_get_chunk_iterator (psf, NULL) ; +} /* sf_get_chunk_iterator */ + +SF_CHUNK_ITERATOR * +sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) +{ SF_PRIVATE *psf ; + SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; + + VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; + + if (psf->next_chunk_iterator) + return psf->next_chunk_iterator (psf, iterator) ; + + return NULL ; +} /* sf_get_chunk_iterator_next */ + +int +sf_get_chunk_size (const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ SF_PRIVATE *psf ; + SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; + + VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; + + if (chunk_info == NULL) + return SFE_BAD_CHUNK_PTR ; + + if (psf->get_chunk_size) + return psf->get_chunk_size (psf, iterator, chunk_info) ; + + return SFE_BAD_CHUNK_FORMAT ; + return 0 ; +} /* sf_get_chunk_size */ + +int +sf_get_chunk_data (const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ SF_PRIVATE *psf ; + SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; + + VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; + + if (chunk_info == NULL || chunk_info->data == NULL) + return SFE_BAD_CHUNK_PTR ; + + if (psf->get_chunk_data) + return psf->get_chunk_data (psf, iterator, chunk_info) ; + + return SFE_BAD_CHUNK_FORMAT ; +} /* sf_get_chunk_data */ diff --git a/libs/libsndfile/src/sndfile.h.in b/libs/libsndfile/src/sndfile.h.in index 0682740da6..b1e32d7f21 100644 --- a/libs/libsndfile/src/sndfile.h.in +++ b/libs/libsndfile/src/sndfile.h.in @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -30,6 +30,7 @@ #define SNDFILE_1 #include +#include #include #ifdef __cplusplus @@ -105,6 +106,11 @@ enum SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ + SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */ + SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */ + SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */ + SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */ + /* Endian-ness options. */ SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ @@ -192,6 +198,11 @@ enum SFC_WAVEX_GET_AMBISONIC = 0x1201, SFC_SET_VBR_ENCODING_QUALITY = 0x1300, + SFC_SET_COMPRESSION_LEVEL = 0x1301, + + /* Cart Chunk support */ + SFC_SET_CART_INFO = 0x1400, + SFC_GET_CART_INFO = 0x1401, /* Following commands for testing only. */ SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, @@ -199,7 +210,7 @@ enum /* ** SFC_SET_ADD_* values are deprecated and will disappear at some ** time in the future. They are guaranteed to be here up to and - ** including version 1.0.8 to avoid breakage of existng software. + ** including version 1.0.8 to avoid breakage of existing software. ** They currently do nothing and will continue to do nothing. */ SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, @@ -221,7 +232,9 @@ enum SF_STR_COMMENT = 0x05, SF_STR_DATE = 0x06, SF_STR_ALBUM = 0x07, - SF_STR_LICENSE = 0x08 + SF_STR_LICENSE = 0x08, + SF_STR_TRACKNUMBER = 0x09, + SF_STR_GENRE = 0x10 } ; /* @@ -230,7 +243,7 @@ enum */ #define SF_STR_FIRST SF_STR_TITLE -#define SF_STR_LAST SF_STR_LICENSE +#define SF_STR_LAST SF_STR_GENRE enum { /* True and false */ @@ -267,27 +280,34 @@ enum enum { SF_CHANNEL_MAP_INVALID = 0, SF_CHANNEL_MAP_MONO = 1, - SF_CHANNEL_MAP_LEFT, - SF_CHANNEL_MAP_RIGHT, - SF_CHANNEL_MAP_CENTER, + SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */ + SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */ + SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */ SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_RIGHT, SF_CHANNEL_MAP_FRONT_CENTER, - SF_CHANNEL_MAP_REAR_CENTER, - SF_CHANNEL_MAP_REAR_LEFT, - SF_CHANNEL_MAP_REAR_RIGHT, - SF_CHANNEL_MAP_LFE, - SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, - SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, - SF_CHANNEL_MAP_SIDE_LEFT, - SF_CHANNEL_MAP_SIDE_RIGHT, - SF_CHANNEL_MAP_TOP_CENTER, - SF_CHANNEL_MAP_TOP_FRONT_LEFT, - SF_CHANNEL_MAP_TOP_FRONT_RIGHT, - SF_CHANNEL_MAP_TOP_FRONT_CENTER, - SF_CHANNEL_MAP_TOP_REAR_LEFT, - SF_CHANNEL_MAP_TOP_REAR_RIGHT, - SF_CHANNEL_MAP_TOP_REAR_CENTER + SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */ + SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */ + SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */ + SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */ + SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */ + SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */ + SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */ + SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */ + SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */ + SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */ + SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */ + SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */ + SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */ + SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */ + SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */ + + SF_CHANNEL_MAP_AMBISONIC_B_W, + SF_CHANNEL_MAP_AMBISONIC_B_X, + SF_CHANNEL_MAP_AMBISONIC_B_Y, + SF_CHANNEL_MAP_AMBISONIC_B_Z, + + SF_CHANNEL_MAP_MAX } ; @@ -296,13 +316,14 @@ enum typedef struct SNDFILE_tag SNDFILE ; /* The following typedef is system specific and is defined when libsndfile is -** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t -** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same -** header file to be compiler by both GCC and the microsoft compiler. +** compiled. sf_count_t will be a 64 bit value when the underlying OS allows +** 64 bit file offsets. +** On windows, we need to allow the same header file to be compiler by both GCC +** and the Microsoft compiler. */ -#ifdef _MSCVER -typedef __int64_t sf_count_t ; +#if (defined (_MSCVER) || defined (_MSC_VER)) +typedef __int64 sf_count_t ; #define SF_COUNT_MAX 0x7fffffffffffffffi64 #else typedef @TYPEOF_SF_COUNT_T@ sf_count_t ; @@ -310,9 +331,9 @@ typedef @TYPEOF_SF_COUNT_T@ sf_count_t ; #endif -/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. +/* A pointer to a SF_INFO structure is passed to sf_open () and filled in. ** On write, the SF_INFO structure is filled in by the user and passed into -** sf_open_write (). +** sf_open (). */ struct SF_INFO @@ -396,9 +417,9 @@ typedef struct struct { int mode ; - unsigned int start ; - unsigned int end ; - unsigned int count ; + uint32_t start ; + uint32_t end ; + uint32_t count ; } loops [16] ; /* make variable in a sensible way */ } SF_INSTRUMENT ; @@ -416,7 +437,7 @@ typedef struct /* a full bar of 7/8 is 7 beats */ float bpm ; /* suggestion, as it can be calculated using other fields:*/ - /* file's lenght, file's sampleRate and our time_sig_den*/ + /* file's length, file's sampleRate and our time_sig_den*/ /* -> bpms are always the amount of _quarter notes_ per minute */ int root_key ; /* MIDI note, or -1 for None */ @@ -429,23 +450,56 @@ typedef struct */ #define SF_BROADCAST_INFO_VAR(coding_hist_size) \ struct \ - { char description [256] ; \ - char originator [32] ; \ - char originator_reference [32] ; \ - char origination_date [10] ; \ - char origination_time [8] ; \ - unsigned int time_reference_low ; \ - unsigned int time_reference_high ; \ - short version ; \ - char umid [64] ; \ - char reserved [190] ; \ - unsigned int coding_history_size ; \ - char coding_history [coding_hist_size] ; \ + { char description [256] ; \ + char originator [32] ; \ + char originator_reference [32] ; \ + char origination_date [10] ; \ + char origination_time [8] ; \ + uint32_t time_reference_low ; \ + uint32_t time_reference_high ; \ + short version ; \ + char umid [64] ; \ + char reserved [190] ; \ + uint32_t coding_history_size ; \ + char coding_history [coding_hist_size] ; \ } /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; +struct SF_CART_TIMER +{ char usage[4] ; + int32_t value ; +} ; + +typedef struct SF_CART_TIMER SF_CART_TIMER ; + +#define SF_CART_INFO_VAR(p_tag_text_size) \ + struct \ + { char version [4] ; \ + char title [64] ; \ + char artist [64] ; \ + char cut_id [64] ; \ + char client_id [64] ; \ + char category [64] ; \ + char classification [64] ; \ + char out_cue [64] ; \ + char start_date [10] ; \ + char start_time [8] ; \ + char end_date [10] ; \ + char end_time [8] ; \ + char producer_app_id [64] ; \ + char producer_app_version [64] ; \ + char user_def [64] ; \ + int32_t level_reference ; \ + SF_CART_TIMER post_timers [8] ; \ + char reserved [276] ; \ + char url [1024] ; \ + uint32_t tag_text_size ; \ + char tag_text[p_tag_text_size] ; \ + } + +typedef SF_CART_INFO_VAR (256) SF_CART_INFO ; /* Virtual I/O functionality. */ @@ -465,6 +519,7 @@ struct SF_VIRTUAL_IO typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; + /* Open the specified file for read, write or both. On error, this will ** return a NULL pointer. To find the error number, pass a NULL SNDFILE ** to sf_strerror (). @@ -473,9 +528,10 @@ typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; + /* Use the existing file descriptor to create a SNDFILE object. If close_desc ** is TRUE, the file descriptor will be closed when sf_close() is called. If -** it is FALSE, the descritor will not be closed. +** it is FALSE, the descriptor will not be closed. ** When passed a descriptor like this, the library will assume that the start ** of file header is at the current file offset. This allows sound files within ** larger container files to be read and/or written. @@ -489,18 +545,21 @@ SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; + /* sf_error () returns a error number which can be translated to a text ** string using sf_error_number(). */ int sf_error (SNDFILE *sndfile) ; + /* sf_strerror () returns to the caller a pointer to the current error message for ** the given SNDFILE. */ const char* sf_strerror (SNDFILE *sndfile) ; + /* sf_error_number () allows the retrieval of the error string for each internal ** error number. ** @@ -508,8 +567,9 @@ const char* sf_strerror (SNDFILE *sndfile) ; const char* sf_error_number (int errnum) ; + /* The following two error functions are deprecated but they will remain in the -** library for the forseeable future. The function sf_strerror() should be used +** library for the foreseeable future. The function sf_strerror() should be used ** in their place. */ @@ -521,10 +581,12 @@ int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; + /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ int sf_format_check (const SF_INFO *info) ; + /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as ** stdio.h function fseek (). @@ -537,8 +599,15 @@ int sf_format_check (const SF_INFO *info) ; ** On error all of these functions return -1. */ +enum +{ SF_SEEK_SET = SEEK_SET, + SF_SEEK_CUR = SEEK_CUR, + SF_SEEK_END = SEEK_END +} ; + sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; + /* Functions for retrieving and setting string data within sound files. ** Not all file types support this features; AIFF and WAV do. For both ** functions, the str_type parameter must be one of the SF_STR_* values @@ -551,12 +620,31 @@ int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; const char* sf_get_string (SNDFILE *sndfile, int str_type) ; + +/* Return the library version string. */ + +const char * sf_version_string (void) ; + +/* Return the current byterate at this point in the file. The byte rate in this +** case is the number of bytes per second of audio data. For instance, for a +** stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate +** would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec. +** For some file formats the returned value will be accurate and exact, for some +** it will be a close approximation, for some it will be the average bitrate for +** the whole file and for some it will be a time varying value that was accurate +** when the file was most recently read or written. +** To get the bitrate, multiple this value by 8. +** Returns -1 for unknown. +*/ +int sf_current_byterate (SNDFILE *sndfile) ; + /* Functions for reading/writing the waveform data of a sound file. */ sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; + /* Functions for reading and writing the data chunk in terms of frames. ** The number of items actually read/written = frames * number of channels. ** sf_xxxx_raw read/writes the raw data bytes from/to the file @@ -579,6 +667,7 @@ sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frame sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; + /* Functions for reading and writing the data chunk in terms of items. ** Otherwise similar to above. ** All of these read/write function return number of items read/written. @@ -596,6 +685,7 @@ sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; + /* Close the SNDFILE and clean up all memory allocations associated with this ** file. ** Returns 0 on success, or an error number. @@ -603,6 +693,7 @@ sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t item int sf_close (SNDFILE *sndfile) ; + /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file ** to force the writing of data to disk. If the file is opened SFM_READ ** no action is taken. @@ -610,8 +701,124 @@ int sf_close (SNDFILE *sndfile) ; void sf_write_sync (SNDFILE *sndfile) ; + + +/* The function sf_wchar_open() is Windows Only! +** Open a file passing in a Windows Unicode filename. Otherwise, this is +** the same as sf_open(). +** +** In order for this to work, you need to do the following: +** +** #include +** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 +** #including +*/ + +#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES) +SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; +#endif + + + + +/* Getting and setting of chunks from within a sound file. +** +** These functions allow the getting and setting of chunks within a sound file +** (for those formats which allow it). +** +** These functions fail safely. Specifically, they will not allow you to overwrite +** existing chunks or add extra versions of format specific reserved chunks but +** should allow you to retrieve any and all chunks (may not be implemented for +** all chunks or all file formats). +*/ + +struct SF_CHUNK_INFO +{ char id [64] ; /* The chunk identifier. */ + unsigned id_size ; /* The size of the chunk identifier. */ + unsigned datalen ; /* The size of that data. */ + void *data ; /* Pointer to the data. */ +} ; + +typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ; + +/* Set the specified chunk info (must be done before any audio data is written +** to the file). This will fail for format specific reserved chunks. +** The chunk_info->data pointer must be valid until the file is closed. +** Returns SF_ERR_NO_ERROR on success or non-zero on failure. +*/ +int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* +** An opaque structure to an iterator over the all chunks of a given id +*/ +typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ; + +/* Get an iterator for all chunks matching chunk_info. +** The iterator will point to the first chunk matching chunk_info. +** Chunks are matching, if (chunk_info->id) matches the first +** (chunk_info->id_size) bytes of a chunk found in the SNDFILE* handle. +** If chunk_info is NULL, an iterator to all chunks in the SNDFILE* handle +** is returned. +** The values of chunk_info->datalen and chunk_info->data are ignored. +** If no matching chunks are found in the sndfile, NULL is returned. +** The returned iterator will stay valid until one of the following occurs: +** a) The sndfile is closed. +** b) A new chunk is added using sf_set_chunk(). +** c) Another chunk iterator function is called on the same SNDFILE* handle +** that causes the iterator to be modified. +** The memory for the iterator belongs to the SNDFILE* handle and is freed when +** sf_close() is called. +*/ +SF_CHUNK_ITERATOR * +sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* Iterate through chunks by incrementing the iterator. +** Increments the iterator and returns a handle to the new one. +** After this call, iterator will no longer be valid, and you must use the +** newly returned handle from now on. +** The returned handle can be used to access the next chunk matching +** the criteria as defined in sf_get_chunk_iterator(). +** If iterator points to the last chunk, this will free all resources +** associated with iterator and return NULL. +** The returned iterator will stay valid until sf_get_chunk_iterator_next +** is called again, the sndfile is closed or a new chunk us added. +*/ +SF_CHUNK_ITERATOR * +sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ; + + +/* Get the size of the specified chunk. +** If the specified chunk exists, the size will be returned in the +** datalen field of the SF_CHUNK_INFO struct. +** Additionally, the id of the chunk will be copied to the id +** field of the SF_CHUNK_INFO struct and it's id_size field will +** be updated accordingly. +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + +/* Get the specified chunk data. +** If the specified chunk exists, up to chunk_info->datalen bytes of +** the chunk data will be copied into the chunk_info->data buffer +** (allocated by the caller) and the chunk_info->datalen field +** updated to reflect the size of the data. The id and id_size +** field will be updated according to the retrieved chunk +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* SNDFILE_H */ + diff --git a/libs/libsndfile/src/sndfile.hh b/libs/libsndfile/src/sndfile.hh index e84054b557..0a0c62d7f6 100644 --- a/libs/libsndfile/src/sndfile.hh +++ b/libs/libsndfile/src/sndfile.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2007 Erik de Castro Lopo +** Copyright (C) 2005-2012 Erik de Castro Lopo ** ** All rights reserved. ** @@ -77,6 +77,16 @@ class SndfileHandle int format = 0, int channels = 0, int samplerate = 0) ; SndfileHandle (std::string const & path, int mode = SFM_READ, int format = 0, int channels = 0, int samplerate = 0) ; + SndfileHandle (int fd, bool close_desc, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + +#ifdef ENABLE_SNDFILE_WINDOWS_PROTOTYPES + SndfileHandle (LPCWSTR wpath, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; +#endif + ~SndfileHandle (void) ; SndfileHandle (const SndfileHandle &orig) ; @@ -132,6 +142,11 @@ class SndfileHandle sf_count_t readRaw (void *ptr, sf_count_t bytes) ; sf_count_t writeRaw (const void *ptr, sf_count_t bytes) ; + /**< Raw access to the handle. SndfileHandle keeps ownership. */ + SNDFILE * rawHandle (void) ; + + /**< Take ownership of handle, if reference count is 1. */ + SNDFILE * takeOwnership (void) ; } ; /*============================================================================== @@ -191,6 +206,53 @@ SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int c return ; } /* SndfileHandle std::string constructor */ +inline +SndfileHandle::SndfileHandle (int fd, bool close_desc, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + if (fd < 0) + return ; + + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open_fd (fd, mode, &p->sfinfo, close_desc) ; + } ; + + return ; +} /* SndfileHandle fd constructor */ + +inline +SndfileHandle::SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open_virtual (&sfvirtual, mode, &p->sfinfo, user_data) ; + } ; + + return ; +} /* SndfileHandle std::string constructor */ + inline SndfileHandle::~SndfileHandle (void) { if (p != NULL && --p->ref == 0) @@ -249,7 +311,7 @@ SndfileHandle::getString (int str_type) const { return sf_get_string (p->sf, str_type) ; } inline int -SndfileHandle::formatCheck(int fmt, int chans, int srate) +SndfileHandle::formatCheck (int fmt, int chans, int srate) { SF_INFO sfinfo ; @@ -337,6 +399,48 @@ inline sf_count_t SndfileHandle::writeRaw (const void *ptr, sf_count_t bytes) { return sf_write_raw (p->sf, ptr, bytes) ; } +inline SNDFILE * +SndfileHandle::rawHandle (void) +{ return (p ? p->sf : NULL) ; } + +inline SNDFILE * +SndfileHandle::takeOwnership (void) +{ + if (p == NULL || (p->ref != 1)) + return NULL ; + + SNDFILE * sf = p->sf ; + p->sf = NULL ; + delete p ; + p = NULL ; + return sf ; +} + +#ifdef ENABLE_SNDFILE_WINDOWS_PROTOTYPES + +inline +SndfileHandle::SndfileHandle (LPCWSTR wpath, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_wchar_open (wpath, mode, &p->sfinfo) ; + } ; + + return ; +} /* SndfileHandle const wchar_t * constructor */ + +#endif #endif /* SNDFILE_HH */ diff --git a/libs/libsndfile/src/strings.c b/libs/libsndfile/src/strings.c index c6c4c10386..c587e9b736 100644 --- a/libs/libsndfile/src/strings.c +++ b/libs/libsndfile/src/strings.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -32,9 +32,9 @@ static void hexdump (void *data, int len) ; int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) -{ static char lsf_name [] = PACKAGE "-" VERSION ; - static char bracket_name [] = " (" PACKAGE "-" VERSION ")" ; - int k, str_len, len_remaining, str_flags, str_type_replace = 0 ; +{ char new_str [128] ; + size_t str_len ; + int k, str_flags ; if (str == NULL) return SFE_STR_BAD_STRING ; @@ -42,10 +42,10 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) str_len = strlen (str) ; /* A few extra checks for write mode. */ - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) - { if ((psf->str_flags & SF_STR_ALLOW_START) == 0) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) + { if ((psf->strings.flags & SF_STR_ALLOW_START) == 0) return SFE_STR_NO_SUPPORT ; - if (psf->have_written && (psf->str_flags & SF_STR_ALLOW_END) == 0) + if (psf->have_written && (psf->strings.flags & SF_STR_ALLOW_END) == 0) return SFE_STR_NO_SUPPORT ; /* Only allow zero length strings for software. */ if (str_type != SF_STR_SOFTWARE && str_len == 0) @@ -55,17 +55,17 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) /* Find the next free slot in table. */ for (k = 0 ; k < SF_MAX_STRINGS ; k++) { /* If we find a matching entry clear it. */ - if (psf->strings [k].type == str_type) - psf->strings [k].type = -1 ; + if (psf->strings.data [k].type == str_type) + psf->strings.data [k].type = -1 ; - if (psf->strings [k].type == 0) + if (psf->strings.data [k].type == 0) break ; } ; /* Determine flags */ str_flags = SF_STR_LOCATE_START ; - if (psf->mode == SFM_RDWR || psf->have_written || str_type_replace) - { if ((psf->str_flags & SF_STR_ALLOW_END) == 0) + if (psf->file.mode == SFM_RDWR || psf->have_written) + { if ((psf->strings.flags & SF_STR_ALLOW_END) == 0) return SFE_STR_NO_ADD_END ; str_flags = SF_STR_LOCATE_END ; } ; @@ -74,54 +74,40 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) if (k >= SF_MAX_STRINGS) return SFE_STR_MAX_COUNT ; - if (k == 0 && psf->str_end != NULL) - { psf_log_printf (psf, "SFE_STR_WEIRD : k == 0 && psf->str_end != NULL\n") ; + if (k == 0 && psf->strings.storage_used != 0) + { psf_log_printf (psf, "SFE_STR_WEIRD : k == 0 && psf->strings.storage_used != 0\n") ; return SFE_STR_WEIRD ; } ; - if (k != 0 && psf->str_end == NULL) - { psf_log_printf (psf, "SFE_STR_WEIRD : k != 0 && psf->str_end == NULL\n") ; + if (k != 0 && psf->strings.storage_used == 0) + { psf_log_printf (psf, "SFE_STR_WEIRD : k != 0 && psf->strings.storage_used == 0\n") ; return SFE_STR_WEIRD ; } ; /* Special case for the first string. */ if (k == 0) - psf->str_end = psf->str_storage ; - - len_remaining = SIGNED_SIZEOF (psf->str_storage) - (psf->str_end - psf->str_storage) ; - - if (len_remaining < str_len + 2) - return SFE_STR_MAX_DATA ; + psf->strings.storage_used = 0 ; switch (str_type) { case SF_STR_SOFTWARE : /* In write mode, want to append libsndfile-version to string. */ - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) - { psf->strings [k].type = str_type ; - psf->strings [k].str = psf->str_end ; - psf->strings [k].flags = str_flags ; - - memcpy (psf->str_end, str, str_len + 1) ; - psf->str_end += str_len ; - - /* - ** If the supplied string does not already contain a - ** libsndfile-X.Y.Z component, then add it. - */ - if (strstr (str, PACKAGE) == NULL && len_remaining > (int) (strlen (bracket_name) + str_len + 2)) - { if (strlen (str) == 0) - strncat (psf->str_end, lsf_name, len_remaining) ; + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) + { if (strstr (str, PACKAGE) == NULL) + { /* + ** If the supplied string does not already contain a + ** libsndfile-X.Y.Z component, then add it. + */ + if (strlen (str) == 0) + snprintf (new_str, sizeof (new_str), "%s-%s", PACKAGE, VERSION) ; else - strncat (psf->str_end, bracket_name, len_remaining) ; - psf->str_end += strlen (psf->str_end) ; - } ; + snprintf (new_str, sizeof (new_str), "%s (%s-%s)", str, PACKAGE, VERSION) ; + } + else + snprintf (new_str, sizeof (new_str), "%s", str) ; - /* Plus one to catch string terminator. */ - psf->str_end += 1 ; - break ; + str = new_str ; } ; - - /* Fall though if not write mode. */ + break ; case SF_STR_TITLE : case SF_STR_COPYRIGHT : @@ -130,13 +116,8 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) case SF_STR_DATE : case SF_STR_ALBUM : case SF_STR_LICENSE : - psf->strings [k].type = str_type ; - psf->strings [k].str = psf->str_end ; - psf->strings [k].flags = str_flags ; - - /* Plus one to catch string terminator. */ - memcpy (psf->str_end, str, str_len + 1) ; - psf->str_end += str_len + 1 ; + case SF_STR_TRACKNUMBER : + case SF_STR_GENRE : break ; default : @@ -144,16 +125,39 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) return SFE_STR_BAD_TYPE ; } ; - psf->str_flags |= str_flags ; + /* Plus one to catch string terminator. */ + str_len = strlen (str) + 1 ; + + if (psf->strings.storage_used + str_len + 1 > psf->strings.storage_len) + { char * temp = psf->strings.storage ; + size_t newlen = 2 * psf->strings.storage_len + str_len + 1 ; + + newlen = newlen < 256 ? 256 : newlen ; + + if ((psf->strings.storage = realloc (temp, newlen)) == NULL) + { psf->strings.storage = temp ; + return SFE_MALLOC_FAILED ; + } ; + + psf->strings.storage_len = newlen ; + } ; + + psf->strings.data [k].type = str_type ; + psf->strings.data [k].offset = psf->strings.storage_used ; + psf->strings.data [k].flags = str_flags ; + + memcpy (psf->strings.storage + psf->strings.storage_used, str, str_len) ; + psf->strings.storage_used += str_len ; + + psf->strings.flags |= str_flags ; #if STRINGS_DEBUG - psf_log_printf (psf, "str_storage : %X\n", (int) psf->str_storage) ; - psf_log_printf (psf, "str_end : %X\n", (int) psf->str_end) ; - psf_log_printf (psf, "sizeof (str_storage) : %d\n", SIGNED_SIZEOF (psf->str_storage)) ; - psf_log_printf (psf, "used : %d\n", (int ) (psf->str_end - psf->str_storage)) ; - psf_log_printf (psf, "remaining : %d\n", SIGNED_SIZEOF (psf->str_storage) - (psf->str_end - psf->str_storage)) ; + psf_log_printf (psf, "str_storage : %p\n", psf->strings.storage) ; + psf_log_printf (psf, "storage_used : %u\n", psf->strings.storage_used) ; + psf_log_printf (psf, "used : %d\n", psf->strings.storage_used) ; + psf_log_printf (psf, "remaining : %d\n", psf->strings.storage_len - psf->strings.storage_used ; - hexdump (psf->str_storage, 300) ; + hexdump (psf->strings.storage, 300) ; #endif return 0 ; @@ -161,7 +165,7 @@ psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) int psf_set_string (SF_PRIVATE *psf, int str_type, const char *str) -{ if (psf->mode == SFM_READ) +{ if (psf->file.mode == SFM_READ) return SFE_STR_NOT_WRITE ; return psf_store_string (psf, str_type, str) ; @@ -172,8 +176,8 @@ psf_get_string (SF_PRIVATE *psf, int str_type) { int k ; for (k = 0 ; k < SF_MAX_STRINGS ; k++) - if (str_type == psf->strings [k].type) - return psf->strings [k].str ; + if (str_type == psf->strings.data [k].type) + return psf->strings.storage + psf->strings.data [k].offset ; return NULL ; } /* psf_get_string */ @@ -183,7 +187,7 @@ psf_location_string_count (const SF_PRIVATE * psf, int location) { int k, count = 0 ; for (k = 0 ; k < SF_MAX_STRINGS ; k++) - if (psf->strings [k].type > 0 && psf->strings [k].flags & location) + if (psf->strings.data [k].type > 0 && psf->strings.data [k].flags & location) count ++ ; return count ; @@ -208,7 +212,7 @@ hexdump (void *data, int len) printf ("%02X ", ptr [k] & 0xFF) ; printf (" ") ; for (k = 0 ; k < 16 ; k++) - printf ("%c", isprint (ptr [k]) ? ptr [k] : '.') ; + printf ("%c", psf_isprint (ptr [k]) ? ptr [k] : '.') ; puts ("") ; ptr += 16 ; len -= 16 ; diff --git a/libs/libsndfile/src/svx.c b/libs/libsndfile/src/svx.c index 70dbdd6689..b611f760af 100644 --- a/libs/libsndfile/src/svx.c +++ b/libs/libsndfile/src/svx.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -82,7 +82,7 @@ int svx_open (SF_PRIVATE *psf) { int error ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = svx_read_header (psf))) return error ; @@ -95,7 +95,7 @@ svx_open (SF_PRIVATE *psf) psf_fseek (psf, psf->dataoffset, SEEK_SET) ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -140,7 +140,7 @@ svx_read_header (SF_PRIVATE *psf) memset (&vhdr, 0, sizeof (vhdr)) ; psf_binheader_readf (psf, "p", 0) ; - /* Set default number of channels. Currently can't handle stereo SVX files. */ + /* Set default number of channels. Modify later if necessary */ psf->sf.channels = 1 ; psf->sf.format = SF_FORMAT_SVX ; @@ -252,12 +252,12 @@ svx_read_header (SF_PRIVATE *psf) psf_log_printf (psf, " %M : %d\n", marker, dword) ; - if (strlen (psf->filename) != dword) - { if (dword > sizeof (psf->filename) - 1) + if (strlen (psf->file.name.c) != dword) + { if (dword > sizeof (psf->file.name.c) - 1) return SFE_SVX_BAD_NAME_LENGTH ; - psf_binheader_readf (psf, "b", psf->filename, dword) ; - psf->filename [dword] = 0 ; + psf_binheader_readf (psf, "b", psf->file.name.c, dword) ; + psf->file.name.c [dword] = 0 ; } else psf_binheader_readf (psf, "j", dword) ; @@ -283,9 +283,15 @@ svx_read_header (SF_PRIVATE *psf) psf_log_printf (psf, " %M : %d\n", marker, dword) ; bytecount += psf_binheader_readf (psf, "E4", &channels) ; - psf->sf.channels = channels ; - psf_log_printf (psf, " Channels : %d\n", channels) ; + if (channels == 2 || channels == 4) + psf_log_printf (psf, " Channels : %d => mono\n", channels) ; + else if (channels == 6) + { psf->sf.channels = 2 ; + psf_log_printf (psf, " Channels : %d => stereo\n", channels) ; + } + else + psf_log_printf (psf, " Channels : %d *** assuming mono\n", channels) ; psf_binheader_readf (psf, "j", dword - bytecount) ; break ; @@ -304,8 +310,8 @@ svx_read_header (SF_PRIVATE *psf) break ; default : - if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF) - && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF)) + if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) + && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) { psf_binheader_readf (psf, "E4", &dword) ; psf_log_printf (psf, "%M : %d (unknown marker)\n", marker, dword) ; @@ -342,7 +348,7 @@ svx_read_header (SF_PRIVATE *psf) static int svx_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) svx_write_header (psf, SF_TRUE) ; return 0 ; @@ -385,8 +391,11 @@ svx_write_header (SF_PRIVATE *psf, int calc_length) /* VHDR : volume */ psf_binheader_writef (psf, "E4", (psf->bytewidth == 1) ? 0xFF : 0xFFFF) ; + if (psf->sf.channels == 2) + psf_binheader_writef (psf, "Em44", CHAN_MARKER, 4, 6) ; + /* Filename and annotation strings. */ - psf_binheader_writef (psf, "Emsms", NAME_MARKER, psf->filename, ANNO_MARKER, annotation) ; + psf_binheader_writef (psf, "Emsms", NAME_MARKER, psf->file.name.c, ANNO_MARKER, annotation) ; /* BODY marker and size. */ psf_binheader_writef (psf, "Etm8", BODY_MARKER, (psf->datalength < 0) ? diff --git a/libs/libsndfile/src/test_audio_detect.c b/libs/libsndfile/src/test_audio_detect.c index 63257cc15c..9706249eae 100644 --- a/libs/libsndfile/src/test_audio_detect.c +++ b/libs/libsndfile/src/test_audio_detect.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007-2009 Erik de Castro Lopo +** Copyright (C) 2007-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -88,8 +88,7 @@ test_audio_detect (void) ad.endianness = SF_ENDIAN_LITTLE ; ad.channels = 1 ; if (audio_detect (&psf, &ad, float_le_mono, sizeof (float_le_mono)) != SF_FORMAT_FLOAT) - { if (errors == 0) puts ("\nFailed tests :\n") ; - puts (" float_le_mono") ; + { puts (" float_le_mono") ; errors ++ ; } ; diff --git a/libs/libsndfile/src/test_broadcast_var.c b/libs/libsndfile/src/test_broadcast_var.c new file mode 100644 index 0000000000..dbea943124 --- /dev/null +++ b/libs/libsndfile/src/test_broadcast_var.c @@ -0,0 +1,119 @@ +/* +** Copyright (C) 2010-2012 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include + +#include "common.h" + +#include "test_main.h" + +#define BCAST_MAX 512 + +typedef SF_BROADCAST_INFO_VAR (BCAST_MAX) SF_BROADCAST_INFO_512 ; + +static void +fill_coding_history (SF_BROADCAST_INFO_512 * bi) +{ static const char *lines [] = + { "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.", + "Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.", + "Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.", + "Mauris aliquam,\nlectus interdum\ntincidunt luctus.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "In auctor lorem\nvel est euismod\ncondimentum.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Ut vitae magna\nid dui placerat vehicula\nin id lectus.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.", + "Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl." + } ; + int k ; + + bi->coding_history [0] = 0 ; + + for (k = 0 ; strlen (bi->coding_history) < bi->coding_history_size - 1 ; k ++) + append_snprintf (bi->coding_history, bi->coding_history_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ; + + return ; +} /* fill_coding_listory */ + +static void +test_broadcast_var_set (void) +{ SF_PRIVATE sf_private, *psf ; + int k ; + + psf = &sf_private ; + memset (psf, 0, sizeof (sf_private)) ; + + print_test_name ("Testing broadcast_var_set ") ; + + for (k = 64 ; k < BCAST_MAX ; k++) + { + SF_BROADCAST_INFO_512 bi ; + + memset (&bi, 0, sizeof (bi)) ; + + bi.coding_history_size = k ; + fill_coding_history (&bi) ; + bi.coding_history_size -- ; + + broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ; + } ; + + if (psf->broadcast_16k != NULL) + free (psf->broadcast_16k) ; + + puts ("ok") ; +} /* test_broadcast_var_set */ + +static void +test_broadcast_var_zero (void) +{ SF_PRIVATE sf_private, *psf ; + SF_BROADCAST_INFO_VAR (0) bi ; + + psf = &sf_private ; + memset (psf, 0, sizeof (sf_private)) ; + psf->file.mode = SFM_RDWR ; + + print_test_name ("Testing broadcast_var_zero ") ; + + memset (&bi, 0, sizeof (bi)) ; + + broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ; + + if (psf->broadcast_16k->coding_history_size != 0) + { printf ("\n\nLine %d: coding_history_size %d should be zero.\n\n", __LINE__, psf->broadcast_16k->coding_history_size) ; + exit (1) ; + } ; + + if (psf->broadcast_16k != NULL) + free (psf->broadcast_16k) ; + + puts ("ok") ; +} /* test_broadcast_var_zero */ + +void +test_broadcast_var (void) +{ test_broadcast_var_set () ; + test_broadcast_var_zero () ; +} /* test_broadcast_var */ diff --git a/libs/libsndfile/src/test_cart_var.c b/libs/libsndfile/src/test_cart_var.c new file mode 100644 index 0000000000..532a755876 --- /dev/null +++ b/libs/libsndfile/src/test_cart_var.c @@ -0,0 +1,91 @@ +/* +** Copyright (C) 2010-2013 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include + +#include "common.h" + +#include "test_main.h" + +#define CART_MAX 512 + +typedef SF_CART_INFO_VAR (CART_MAX) SF_CART_INFO_512 ; + +static void +fill_tag_text (SF_CART_INFO_512 * ci) +{ static const char *lines [] = + { "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.", + "Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.", + "Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.", + "Mauris aliquam,\nlectus interdum\ntincidunt luctus.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "In auctor lorem\nvel est euismod\ncondimentum.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Ut vitae magna\nid dui placerat vehicula\nin id lectus.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.", + "\n\n\n\n\n\n\n\n\n\n\n\n", + "Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.", + "Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl." + } ; + int k ; + + ci->tag_text [0] = 0 ; + + for (k = 0 ; strlen (ci->tag_text) < ci->tag_text_size - 1 ; k ++) + append_snprintf (ci->tag_text, ci->tag_text_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ; + + return ; +} /* fill_tag_text */ + +void +test_cart_var (void) +{ SF_PRIVATE sf_private, *psf ; + SF_CART_TIMER timer ; + int k ; + + psf = &sf_private ; + memset (psf, 0, sizeof (sf_private)) ; + + print_test_name ("Testing cart_var_set ") ; + + for (k = 64 ; k < CART_MAX ; k++) + { + SF_CART_INFO_512 ci ; + + memset (&ci, 0, sizeof (ci)) ; + + memset (&timer, 0, sizeof (timer)) ; + memcpy (ci.post_timers, &timer, sizeof (timer)) ; + + ci.tag_text_size = k ; + fill_tag_text (&ci) ; + ci.tag_text_size -- ; + + cart_var_set (psf, (SF_CART_INFO*) &ci, sizeof (ci)) ; + } ; + + if (psf->cart_16k != NULL) + free (psf->cart_16k) ; + + puts ("ok") ; +} /* test_cart_var */ diff --git a/libs/libsndfile/src/test_conversions.c b/libs/libsndfile/src/test_conversions.c index dc9ee7293f..7e8c2edee0 100644 --- a/libs/libsndfile/src/test_conversions.c +++ b/libs/libsndfile/src/test_conversions.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2006-2009 Erik de Castro Lopo +** Copyright (C) 2006-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -34,7 +33,7 @@ ** This is a bit rough, but it is the nicest way to do it. */ -#define cmp_test(line,ival,tval,str) \ +#define cmp_test(line, ival, tval, str) \ if (ival != tval) \ { printf (str, line, ival, tval) ; \ exit (1) ; \ @@ -62,7 +61,10 @@ conversion_test (char endian) psf = &sf_private ; memset (psf, 0, sizeof (sf_private)) ; - if (psf_fopen (psf, filename, SFM_WRITE) != 0) + psf->file.mode = SFM_WRITE ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ; + + if (psf_fopen (psf) != 0) { printf ("\n\nError : failed to open file '%s' for write.\n\n", filename) ; exit (1) ; } ; @@ -72,7 +74,11 @@ conversion_test (char endian) psf_fclose (psf) ; memset (psf, 0, sizeof (sf_private)) ; - if (psf_fopen (psf, filename, SFM_READ) != 0) + + psf->file.mode = SFM_READ ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ; + + if (psf_fopen (psf) != 0) { printf ("\n\nError : failed to open file '%s' for read.\n\n", filename) ; exit (1) ; } ; diff --git a/libs/libsndfile/src/test_endswap.c b/libs/libsndfile/src/test_endswap.c index ccf9fcfc17..4931650c87 100644 --- a/libs/libsndfile/src/test_endswap.c +++ b/libs/libsndfile/src/test_endswap.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by diff --git a/libs/libsndfile/src/test_endswap.def b/libs/libsndfile/src/test_endswap.def index c817322c99..9516e4d67c 100644 --- a/libs/libsndfile/src/test_endswap.def +++ b/libs/libsndfile/src/test_endswap.def @@ -18,3 +18,23 @@ int_type = { format = FMT_INT64 ; } ; +int_size = { + name = 16 ; + typename = int16_t ; + value = 0x4142 ; + strval = "AB" ; + } ; + +int_size = { + name = 32 ; + typename = int32_t ; + value = 0x30313233 ; + strval = "0123" ; + } ; + +int_size = { + name = 64 ; + typename = int64_t ; + value = 0x3031323334353637 ; + strval = "01234567" ; + } ; diff --git a/libs/libsndfile/src/test_endswap.tpl b/libs/libsndfile/src/test_endswap.tpl index 70ea721b33..89b7d1473a 100644 --- a/libs/libsndfile/src/test_endswap.tpl +++ b/libs/libsndfile/src/test_endswap.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 2002-2005 Erik de Castro Lopo +** Copyright (C) 2002-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -105,6 +105,34 @@ test_endswap_[+ (get "name") +] (void) [+ ENDFOR int_type +] +[+ FOR int_size +] +static void +test_psf_put_be[+ (get "name") +] (void) +{ const char *test = "[+ (get "strval") +]" ; + uint8_t array [32] ; + int k ; + + printf (" %-40s : ", __func__) ; + fflush (stdout) ; + + for (k = 0 ; k < 10 ; k++) + { memset (array, 0, sizeof (array)) ; + + psf_put_be[+ (get "name") +] (array, k, [+ (get "value") +]) ; + if (memcmp (array + k, test, sizeof ([+ (get "typename") +])) != 0) + { printf ("\n\nLine %d : Put failed at index %d.\n", __LINE__, k) ; + exit (1) ; + } ; + if (psf_get_be[+ (get "name") +] (array, k) != [+ (get "value") +]) + { printf ("\n\nLine %d : Get failed at index %d.\n", __LINE__, k) ; + exit (1) ; + } ; + } ; + + puts ("ok") ; +} /* test_psf_put_be[+ (get "name") +] */ +[+ ENDFOR int_size ++] void test_endswap (void) @@ -113,5 +141,11 @@ test_endswap (void) +] test_endswap_[+ (get "name") +] () ; [+ ENDFOR int_type +] + +[+ FOR int_size ++] test_psf_put_be[+ (get "name") +] () ; +[+ ENDFOR int_endsize ++] + } /* test_endswap */ diff --git a/libs/libsndfile/src/test_file_io.c b/libs/libsndfile/src/test_file_io.c index 9108f2a768..08fccebd21 100644 --- a/libs/libsndfile/src/test_file_io.c +++ b/libs/libsndfile/src/test_file_io.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -27,6 +27,7 @@ #include #include +#include #include "common.h" @@ -68,10 +69,11 @@ file_open_test (const char *filename) exit (1) ; } ; - snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ; + psf->file.mode = SFM_READ ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ; /* Test that open for read fails if the file doesn't exist. */ - error = psf_fopen (psf, psf->filename, SFM_READ) ; + error = psf_fopen (psf) ; if (error == 0) { printf ("\n\nLine %d: psf_fopen() should have failed.\n\n", __LINE__) ; exit (1) ; @@ -81,26 +83,26 @@ file_open_test (const char *filename) psf->error = SFE_NO_ERROR ; /* Test file open in write mode. */ - psf->mode = SFM_WRITE ; + psf->file.mode = SFM_WRITE ; test_open_or_die (psf, __LINE__) ; test_close_or_die (psf, __LINE__) ; - unlink (psf->filename) ; + unlink (psf->file.path.c) ; /* Test file open in read/write mode for a non-existant file. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; test_open_or_die (psf, __LINE__) ; test_close_or_die (psf, __LINE__) ; /* Test file open in read/write mode for an existing file. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; test_open_or_die (psf, __LINE__) ; test_close_or_die (psf, __LINE__) ; - unlink (psf->filename) ; + unlink (psf->file.path.c) ; puts ("ok") ; } /* file_open_test */ @@ -121,17 +123,17 @@ file_read_write_test (const char *filename) memset (&sf_data, 0, sizeof (sf_data)) ; psf = &sf_data ; - snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ; /* Test file open in write mode. */ - psf->mode = SFM_WRITE ; + psf->file.mode = SFM_WRITE ; test_open_or_die (psf, __LINE__) ; make_data (data_out, ARRAY_LEN (data_out), 1) ; test_write_or_die (psf, data_out, sizeof (data_out [0]), ARRAY_LEN (data_out), sizeof (data_out), __LINE__) ; if ((retval = psf_get_filelen (psf)) != sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct (%ld should be %d).\n\n", __LINE__, (long) retval, (int) sizeof (data_out)) ; + { printf ("\n\nLine %d: file length after write is not correct (%" PRId64 " should be %zd).\n\n", __LINE__, retval, sizeof (data_out)) ; if (retval == 0) printf ("An fsync() may be necessary before fstat() in psf_get_filelen().\n\n") ; exit (1) ; @@ -141,7 +143,7 @@ file_read_write_test (const char *filename) test_write_or_die (psf, data_out, ARRAY_LEN (data_out), sizeof (data_out [0]), 2 * sizeof (data_out), __LINE__) ; if ((retval = psf_get_filelen (psf)) != 2 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 2 * ((int) sizeof (data_out))) ; + { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 2 * sizeof (data_out)) ; exit (1) ; } ; @@ -156,7 +158,7 @@ file_read_write_test (const char *filename) print_test_name ("Testing file read") ; /* Test file open in write mode. */ - psf->mode = SFM_READ ; + psf->file.mode = SFM_READ ; test_open_or_die (psf, __LINE__) ; make_data (data_out, ARRAY_LEN (data_out), 1) ; @@ -180,7 +182,7 @@ file_read_write_test (const char *filename) print_test_name ("Testing file seek") ; /* Test file open in read/write mode. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; test_open_or_die (psf, __LINE__) ; test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ; @@ -218,12 +220,12 @@ file_read_write_test (const char *filename) print_test_name ("Testing file offset") ; /* Test file open in read/write mode. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; psf->fileoffset = sizeof (data_out [0]) * ARRAY_LEN (data_out) ; test_open_or_die (psf, __LINE__) ; if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 3 * ((int) sizeof (data_out))) ; + { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ; exit (1) ; } ; @@ -234,12 +236,12 @@ file_read_write_test (const char *filename) /* final test with psf->fileoffset == 0. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; psf->fileoffset = 0 ; test_open_or_die (psf, __LINE__) ; if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 3 * ((int) sizeof (data_out))) ; + { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ; exit (1) ; } ; @@ -277,20 +279,20 @@ file_truncate_test (const char *filename) memset (buffer, 0xEE, sizeof (buffer)) ; psf = &sf_data ; - snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ; + snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ; /* ** Open the file write mode, write 0xEE data and then extend the file ** using truncate (the extended data should be 0x00). */ - psf->mode = SFM_WRITE ; + psf->file.mode = SFM_WRITE ; test_open_or_die (psf, __LINE__) ; test_write_or_die (psf, buffer, sizeof (buffer) / 2, 1, sizeof (buffer) / 2, __LINE__) ; psf_ftruncate (psf, sizeof (buffer)) ; test_close_or_die (psf, __LINE__) ; /* Open the file in read mode and check the data. */ - psf->mode = SFM_READ ; + psf->file.mode = SFM_READ ; test_open_or_die (psf, __LINE__) ; test_read_or_die (psf, buffer, sizeof (buffer), 1, sizeof (buffer), __LINE__) ; test_close_or_die (psf, __LINE__) ; @@ -308,13 +310,13 @@ file_truncate_test (const char *filename) } ; /* Open the file in read/write and shorten the file using truncate. */ - psf->mode = SFM_RDWR ; + psf->file.mode = SFM_RDWR ; test_open_or_die (psf, __LINE__) ; psf_ftruncate (psf, sizeof (buffer) / 4) ; test_close_or_die (psf, __LINE__) ; /* Check the file length. */ - psf->mode = SFM_READ ; + psf->file.mode = SFM_READ ; test_open_or_die (psf, __LINE__) ; test_seek_or_die (psf, 0, SEEK_END, SIGNED_SIZEOF (buffer) / 4, __LINE__) ; test_close_or_die (psf, __LINE__) ; @@ -331,7 +333,7 @@ test_open_or_die (SF_PRIVATE *psf, int linenum) { int error ; /* Test that open for read fails if the file doesn't exist. */ - error = psf_fopen (psf, psf->filename, psf->mode) ; + error = psf_fopen (psf) ; if (error) { printf ("\n\nLine %d: psf_fopen() failed : %s\n\n", linenum, strerror (errno)) ; exit (1) ; @@ -344,7 +346,7 @@ test_close_or_die (SF_PRIVATE *psf, int linenum) { psf_fclose (psf) ; if (psf_file_valid (psf)) - { printf ("\n\nLine %d: psf->filedes should not be valid.\n\n", linenum) ; + { printf ("\n\nLine %d: psf->file.filedes should not be valid.\n\n", linenum) ; exit (1) ; } ; @@ -356,12 +358,12 @@ test_write_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t ite retval = psf_fwrite (data, bytes, items, psf) ; if (retval != items) - { printf ("\n\nLine %d: psf_write() returned %ld (should be %ld)\n\n", linenum, (long) retval, (long) items) ; + { printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ; exit (1) ; } ; if ((retval = psf_ftell (psf)) != new_position) - { printf ("\n\nLine %d: file length after write is not correct. (%ld should be %ld)\n\n", linenum, (long) retval, (long) new_position) ; + { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ; exit (1) ; } ; @@ -374,12 +376,12 @@ test_read_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t item retval = psf_fread (data, bytes, items, psf) ; if (retval != items) - { printf ("\n\nLine %d: psf_write() returned %ld (should be %ld)\n\n", linenum, (long) retval, (long) items) ; + { printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ; exit (1) ; } ; if ((retval = psf_ftell (psf)) != new_position) - { printf ("\n\nLine %d: file length after write is not correct. (%ld should be %ld)\n\n", linenum, (long) retval, (long) new_position) ; + { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ; exit (1) ; } ; @@ -393,8 +395,8 @@ test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf_count_t new retval = psf_fseek (psf, offset, whence) ; if (retval != new_position) - { printf ("\n\nLine %d: psf_fseek() failed. New position is %ld (should be %ld).\n\n", - linenum, (long) retval, (long) new_position) ; + { printf ("\n\nLine %d: psf_fseek() failed. New position is %" PRId64 " (should be %" PRId64 ").\n\n", + linenum, retval, new_position) ; exit (1) ; } ; diff --git a/libs/libsndfile/src/test_float.c b/libs/libsndfile/src/test_float.c index 5d47747b59..07879896e5 100644 --- a/libs/libsndfile/src/test_float.c +++ b/libs/libsndfile/src/test_float.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2006-2009 Erik de Castro Lopo +** Copyright (C) 2006-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -48,7 +48,7 @@ test_float_convert (void) test = float32_le_read (bytes) ; if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ; + { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; exit (1) ; } ; @@ -85,7 +85,7 @@ test_double_convert (void) test = double64_le_read (bytes) ; if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ; + { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; exit (1) ; } ; diff --git a/libs/libsndfile/src/test_ima_oki_adpcm.c b/libs/libsndfile/src/test_ima_oki_adpcm.c index 40754994ca..6c937d1173 100644 --- a/libs/libsndfile/src/test_ima_oki_adpcm.c +++ b/libs/libsndfile/src/test_ima_oki_adpcm.c @@ -1,6 +1,6 @@ /* +** Copyright (C) 2007-2011 Erik de Castro Lopo ** Copyright (c) 2007 -** Copyright (C) 2007-2009 Erik de Castro Lopo ** ** This library is free software; you can redistribute it and/or modify it ** under the terms of the GNU Lesser General Public License as published by @@ -17,6 +17,8 @@ ** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. */ +#include "sfconfig.h" + #include #include "test_main.h" @@ -71,7 +73,7 @@ test_oki_adpcm (void) print_test_name ("Testing ima/oki decoder") ; ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - for (i = 0 ; i < ARRAY_LEN (test_pcm) - 1 ; i += j) + for (i = 0 ; i < ARRAY_LEN (test_pcm) - 1 ; i += 2) { code = adpcm_encode (&adpcm, test_pcm [i]) ; code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ; if (code != test_codes [i / 2]) diff --git a/libs/libsndfile/src/test_log_printf.c b/libs/libsndfile/src/test_log_printf.c index 3b3f485c83..e1806a1484 100644 --- a/libs/libsndfile/src/test_log_printf.c +++ b/libs/libsndfile/src/test_log_printf.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -28,39 +28,39 @@ #include "test_main.h" -#define CMP_0_ARGS(line,err,fmt) \ - { psf->logindex = 0 ; \ +#define CMP_0_ARGS(line, err, fmt) \ + { psf->parselog.indx = 0 ; \ snprintf (buffer, sizeof (buffer), (fmt)) ; \ psf_log_printf (psf, (fmt)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \ + err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ } -#define CMP_2_ARGS(line,err,fmt,a) \ - { psf->logindex = 0 ; \ +#define CMP_2_ARGS(line, err, fmt, a) \ + { psf->parselog.indx = 0 ; \ snprintf (buffer, sizeof (buffer), (fmt), (a), (a)) ; \ psf_log_printf (psf, (fmt), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \ + err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ } -#define CMP_4_ARGS(line,err,fmt,a) \ - { psf->logindex = 0 ; \ +#define CMP_4_ARGS(line, err, fmt, a) \ + { psf->parselog.indx = 0 ; \ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \ psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \ + err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ } -#define CMP_5_ARGS(line,err,fmt,a) \ - { psf->logindex = 0 ; \ +#define CMP_5_ARGS(line, err, fmt, a) \ + { psf->parselog.indx = 0 ; \ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \ psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \ + err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ } -#define CMP_6_ARGS(line,err,fmt,a) \ - { psf->logindex = 0 ; \ +#define CMP_6_ARGS(line, err, fmt, a) \ + { psf->parselog.indx = 0 ; \ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \ psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \ + err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ } static int diff --git a/libs/libsndfile/src/test_main.c b/libs/libsndfile/src/test_main.c index e46d6c106d..f51f7c9ee6 100644 --- a/libs/libsndfile/src/test_main.c +++ b/libs/libsndfile/src/test_main.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -40,6 +40,10 @@ main (void) test_audio_detect () ; test_ima_oki_adpcm () ; + test_psf_strlcpy_crlf () ; + test_broadcast_var () ; + test_cart_var () ; + return 0 ; } /* main */ diff --git a/libs/libsndfile/src/test_main.h b/libs/libsndfile/src/test_main.h index 2d0dcd79b5..6b2f28f4cd 100644 --- a/libs/libsndfile/src/test_main.h +++ b/libs/libsndfile/src/test_main.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -34,3 +34,8 @@ void test_double_convert (void) ; void test_audio_detect (void) ; void test_ima_oki_adpcm (void) ; + +void test_psf_strlcpy_crlf (void) ; +void test_broadcast_var (void) ; + +void test_cart_var (void) ; diff --git a/libs/libsndfile/src/test_strncpy_crlf.c b/libs/libsndfile/src/test_strncpy_crlf.c new file mode 100644 index 0000000000..774ced1083 --- /dev/null +++ b/libs/libsndfile/src/test_strncpy_crlf.c @@ -0,0 +1,56 @@ +/* +** Copyright (C) 2010-2012 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include + +#include "common.h" + +#include "test_main.h" + +void +test_psf_strlcpy_crlf (void) +{ const char *src = "a\nb\nc\n" ; + char *dest ; + int dest_len ; + + print_test_name ("Testing psf_strlcpy_crlf") ; + + for (dest_len = 3 ; dest_len < 30 ; dest_len++) + { dest = calloc (1, dest_len + 1) ; + if (dest == NULL) + { printf ("\n\nLine %d: calloc failed!\n\n", __LINE__) ; + exit (1) ; + } ; + + dest [dest_len] = '\xea' ; + + psf_strlcpy_crlf (dest, src, dest_len, sizeof (*src)) ; + + if (dest [dest_len] != '\xea') + { printf ("\n\nLine %d: buffer overrun for dest_len == %d\n\n", __LINE__, dest_len) ; + exit (1) ; + } ; + + free (dest) ; + } ; + + puts ("ok") ; +} /* test_psf_strlcpy_crlf */ diff --git a/libs/libsndfile/src/txw.c b/libs/libsndfile/src/txw.c index edc9751674..16525dfe29 100644 --- a/libs/libsndfile/src/txw.c +++ b/libs/libsndfile/src/txw.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -51,8 +51,8 @@ txw_open (SF_PRIVATE *psf) #define TXW_DATA_OFFSET 32 -#define TXW_LOOPED 0x49 -#define TXW_NO_LOOP 0xC9 +#define TXW_LOOPED 0x49 +#define TXW_NO_LOOP 0xC9 /*------------------------------------------------------------------------------ ** Private static functions. @@ -100,7 +100,7 @@ int txw_open (SF_PRIVATE *psf) { int error ; - if (psf->mode != SFM_READ) + if (psf->file.mode != SFM_READ) return SFE_UNIMPLEMENTED ; if ((error = txw_read_header (psf))) @@ -124,14 +124,15 @@ txw_open (SF_PRIVATE *psf) static int txw_read_header (SF_PRIVATE *psf) -{ TXW_HEADER txwh ; +{ BUF_UNION ubuf ; + TXW_HEADER txwh ; const char *strptr ; memset (&txwh, 0, sizeof (txwh)) ; - memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ; - psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, 16) ; + memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; + psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, 16) ; - if (memcmp (psf->u.cbuf, "LM8953\0\0\0\0\0\0\0\0\0\0", 16) != 0) + if (memcmp (ubuf.cbuf, "LM8953\0\0\0\0\0\0\0\0\0\0", 16) != 0) return ERROR_666 ; psf_log_printf (psf, "Read only : Yamaha TX-16 Sampler (.txw)\nLM8953\n") ; @@ -235,18 +236,19 @@ txw_read_header (SF_PRIVATE *psf) static sf_count_t txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ unsigned char *ucptr ; +{ BUF_UNION ubuf ; + unsigned char *ucptr ; short sample ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.cbuf) / 3 ; + bufferlen = sizeof (ubuf.cbuf) / 3 ; bufferlen -= (bufferlen & 1) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (psf->u.cbuf, 3, readcount, psf) ; + count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - ucptr = psf->u.ucbuf ; + ucptr = ubuf.ucbuf ; for (k = 0 ; k < readcount ; k += 2) { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; ptr [total + k] = sample ; @@ -264,18 +266,19 @@ txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ unsigned char *ucptr ; +{ BUF_UNION ubuf ; + unsigned char *ucptr ; short sample ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; - bufferlen = sizeof (psf->u.cbuf) / 3 ; + bufferlen = sizeof (ubuf.cbuf) / 3 ; bufferlen -= (bufferlen & 1) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (psf->u.cbuf, 3, readcount, psf) ; + count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - ucptr = psf->u.ucbuf ; + ucptr = ubuf.ucbuf ; for (k = 0 ; k < readcount ; k += 2) { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; ptr [total + k] = sample << 16 ; @@ -293,7 +296,8 @@ txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ unsigned char *ucptr ; +{ BUF_UNION ubuf ; + unsigned char *ucptr ; short sample ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -304,13 +308,13 @@ txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) else normfact = 1.0 / 0x10 ; - bufferlen = sizeof (psf->u.cbuf) / 3 ; + bufferlen = sizeof (ubuf.cbuf) / 3 ; bufferlen -= (bufferlen & 1) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (psf->u.cbuf, 3, readcount, psf) ; + count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - ucptr = psf->u.ucbuf ; + ucptr = ubuf.ucbuf ; for (k = 0 ; k < readcount ; k += 2) { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; ptr [total + k] = normfact * sample ; @@ -328,7 +332,8 @@ txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ unsigned char *ucptr ; +{ BUF_UNION ubuf ; + unsigned char *ucptr ; short sample ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -339,13 +344,13 @@ txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) else normfact = 1.0 / 0x10 ; - bufferlen = sizeof (psf->u.cbuf) / 3 ; + bufferlen = sizeof (ubuf.cbuf) / 3 ; bufferlen -= (bufferlen & 1) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (psf->u.cbuf, 3, readcount, psf) ; + count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - ucptr = psf->u.ucbuf ; + ucptr = ubuf.ucbuf ; for (k = 0 ; k < readcount ; k += 2) { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; ptr [total + k] = normfact * sample ; diff --git a/libs/libsndfile/src/ulaw.c b/libs/libsndfile/src/ulaw.c index 638903bb04..ded46e929c 100644 --- a/libs/libsndfile/src/ulaw.c +++ b/libs/libsndfile/src/ulaw.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -36,14 +36,14 @@ static sf_count_t ulaw_write_d2ulaw (SF_PRIVATE *psf, const double *ptr, sf_coun int ulaw_init (SF_PRIVATE *psf) { - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { psf->read_short = ulaw_read_ulaw2s ; psf->read_int = ulaw_read_ulaw2i ; psf->read_float = ulaw_read_ulaw2f ; psf->read_double = ulaw_read_ulaw2d ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { psf->write_short = ulaw_write_s2ulaw ; psf->write_int = ulaw_write_i2ulaw ; psf->write_float = ulaw_write_f2ulaw ; @@ -59,7 +59,7 @@ ulaw_init (SF_PRIVATE *psf) else psf->datalength = 0 ; - psf->sf.frames = psf->datalength / psf->blockwidth ; + psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; return 0 ; } /* ulaw_init */ @@ -787,7 +787,7 @@ unsigned char ulaw_encode [8193] = 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00 + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 } ; static inline void @@ -859,16 +859,17 @@ d2ulaw_array (const double *ptr, int count, unsigned char *buffer, double normfa static sf_count_t ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - ulaw2s_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + ulaw2s_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -880,16 +881,17 @@ ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - ulaw2i_array (psf->u.ucbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + ulaw2i_array (ubuf.ucbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -901,19 +903,20 @@ ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - ulaw2f_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + ulaw2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -925,18 +928,19 @@ ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen, readcount ; +{ BUF_UNION ubuf ; + int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.ucbuf, 1, bufferlen, psf) ; - ulaw2d_array (psf->u.ucbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; + ulaw2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -951,16 +955,17 @@ ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t ulaw_write_s2ulaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2ulaw_array (ptr + total, bufferlen, psf->u.ucbuf) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + s2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -972,16 +977,17 @@ ulaw_write_s2ulaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t ulaw_write_i2ulaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2ulaw_array (ptr + total, bufferlen, psf->u.ucbuf) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + i2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -993,20 +999,21 @@ ulaw_write_i2ulaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t ulaw_write_f2ulaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; float normfact ; /* Factor in a divide by 4. */ normfact = (psf->norm_float == SF_TRUE) ? (0.25 * 0x7FFF) : 0.25 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2ulaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + f2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1018,20 +1025,21 @@ ulaw_write_f2ulaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t ulaw_write_d2ulaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ int bufferlen, writecount ; +{ BUF_UNION ubuf ; + int bufferlen, writecount ; sf_count_t total = 0 ; double normfact ; /* Factor in a divide by 4. */ normfact = (psf->norm_double) ? (0.25 * 0x7FFF) : 0.25 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2ulaw_array (ptr + total, bufferlen, psf->u.ucbuf, normfact) ; - writecount = psf_fwrite (psf->u.ucbuf, 1, bufferlen, psf) ; + d2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; + writecount = psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; diff --git a/libs/libsndfile/src/version-metadata.rc.in b/libs/libsndfile/src/version-metadata.rc.in new file mode 100644 index 0000000000..ed79b22ad1 --- /dev/null +++ b/libs/libsndfile/src/version-metadata.rc.in @@ -0,0 +1,32 @@ +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +1 VERSIONINFO + FILEVERSION @WIN_RC_VERSION@,0 + PRODUCTVERSION @WIN_RC_VERSION@,0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN + FILEFLAGSMASK 0x00000000 + FILEFLAGS 0x00000000 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904e4" + { + VALUE "FileDescription", "A library for reading and writing audio files." + VALUE "FileVersion", "@CLEAN_VERSION@.0\0" + VALUE "Full Version", "@PACKAGE_VERSION@" + VALUE "InternalName", "libsndfile" + VALUE "LegalCopyright", "Copyright (C) 1999-2012, Licensed LGPL" + VALUE "OriginalFilename", "libsndfile-1.dll" + VALUE "ProductName", "libsndfile-1 DLL" + VALUE "ProductVersion", "@CLEAN_VERSION@.0\0" + VALUE "Language", "Language Neutral" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04E4 + } +} diff --git a/libs/libsndfile/src/voc.c b/libs/libsndfile/src/voc.c index c7380c3880..d13b03311b 100644 --- a/libs/libsndfile/src/voc.c +++ b/libs/libsndfile/src/voc.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -107,14 +107,14 @@ voc_open (SF_PRIVATE *psf) if (psf->is_pipe) return SFE_VOC_NO_PIPE ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = voc_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_VOC) return SFE_BAD_OPEN_FORMAT ; @@ -199,7 +199,7 @@ voc_read_header (SF_PRIVATE *psf) psf->endian = SF_ENDIAN_LITTLE ; while (1) - { int size ; + { unsigned size ; short count ; block_type = 0 ; @@ -211,9 +211,14 @@ voc_read_header (SF_PRIVATE *psf) psf_log_printf (psf, " ASCII : %d\n", size) ; - offset += psf_binheader_readf (psf, "b", psf->header, size) ; - psf->header [size] = 0 ; - psf_log_printf (psf, " text : %s\n", psf->header) ; + if (size < sizeof (psf->header) - 1) + { offset += psf_binheader_readf (psf, "b", psf->header, size) ; + psf->header [size] = 0 ; + psf_log_printf (psf, " text : %s\n", psf->header) ; + continue ; + } + + offset += psf_binheader_readf (psf, "j", size) ; continue ; case VOC_REPEAT : @@ -523,11 +528,11 @@ voc_write_header (SF_PRIVATE *psf, int calc_length) static int voc_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { /* Now we know for certain the length of the file we can re-write ** correct values for the FORM, 8SVX and BODY chunks. */ - unsigned byte = VOC_TERMINATOR ; + unsigned char byte = VOC_TERMINATOR ; psf_fseek (psf, 0, SEEK_END) ; diff --git a/libs/libsndfile/src/vox_adpcm.c b/libs/libsndfile/src/vox_adpcm.c index 64ebd4d0dd..9abd42b0d7 100644 --- a/libs/libsndfile/src/vox_adpcm.c +++ b/libs/libsndfile/src/vox_adpcm.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -71,10 +71,10 @@ int vox_adpcm_init (SF_PRIVATE *psf) { IMA_OKI_ADPCM *pvox = NULL ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; - if (psf->mode == SFM_WRITE && psf->sf.channels != 1) + if (psf->file.mode == SFM_WRITE && psf->sf.channels != 1) return SFE_CHANNEL_COUNT ; if ((pvox = malloc (sizeof (IMA_OKI_ADPCM))) == NULL) @@ -83,7 +83,7 @@ vox_adpcm_init (SF_PRIVATE *psf) psf->codec_data = (void*) pvox ; memset (pvox, 0, sizeof (IMA_OKI_ADPCM)) ; - if (psf->mode == SFM_WRITE) + if (psf->file.mode == SFM_WRITE) { psf->write_short = vox_write_s ; psf->write_int = vox_write_i ; psf->write_float = vox_write_f ; @@ -174,6 +174,7 @@ vox_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -182,8 +183,8 @@ vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) return 0 ; pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = vox_read_block (psf, pvox, sptr, readcount) ; @@ -201,6 +202,7 @@ vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -212,8 +214,8 @@ vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = vox_read_block (psf, pvox, sptr, readcount) ; @@ -231,6 +233,7 @@ vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t vox_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, readcount, count ; sf_count_t total = 0 ; @@ -242,8 +245,8 @@ vox_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { readcount = (len >= bufferlen) ? bufferlen : (int) len ; count = vox_read_block (psf, pvox, sptr, readcount) ; @@ -308,6 +311,7 @@ vox_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -316,8 +320,8 @@ vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return 0 ; pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) @@ -335,6 +339,7 @@ vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -346,8 +351,8 @@ vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) @@ -365,6 +370,7 @@ vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { IMA_OKI_ADPCM *pvox ; + BUF_UNION ubuf ; short *sptr ; int k, bufferlen, writecount, count ; sf_count_t total = 0 ; @@ -376,8 +382,8 @@ vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - sptr = psf->u.sbuf ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + sptr = ubuf.sbuf ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { writecount = (len >= bufferlen) ? bufferlen : (int) len ; for (k = 0 ; k < writecount ; k++) diff --git a/libs/libsndfile/src/w64.c b/libs/libsndfile/src/w64.c index 6e9abefa6a..2dbc962e13 100644 --- a/libs/libsndfile/src/w64.c +++ b/libs/libsndfile/src/w64.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -37,13 +37,13 @@ ** header. */ -#define MAKE_HASH16(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc,xd,xe,xf) \ +#define MAKE_HASH16(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf) \ ( (x0) ^ ((x1) << 1) ^ ((x2) << 2) ^ ((x3) << 3) ^ \ ((x4) << 4) ^ ((x5) << 5) ^ ((x6) << 6) ^ ((x7) << 7) ^ \ ((x8) << 8) ^ ((x9) << 9) ^ ((xa) << 10) ^ ((xb) << 11) ^ \ ((xc) << 12) ^ ((xd) << 13) ^ ((xe) << 14) ^ ((xf) << 15) ) -#define MAKE_MARKER16(name,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc,xd,xe,xf) \ +#define MAKE_MARKER16(name, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf) \ static unsigned char name [16] = { (x0), (x1), (x2), (x3), (x4), (x5), \ (x6), (x7), (x8), (x9), (xa), (xb), (xc), (xd), (xe), (xf) } @@ -129,7 +129,7 @@ w64_open (SF_PRIVATE *psf) return SFE_MALLOC_FAILED ; psf->container_data = wpriv ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR &&psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR &&psf->filelength > 0)) { if ((error = w64_read_header (psf, &blockalign, &framesperblock))) return error ; } ; @@ -139,7 +139,7 @@ w64_open (SF_PRIVATE *psf) subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -631,7 +631,7 @@ w64_write_header (SF_PRIVATE *psf, int calc_length) static int w64_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) w64_write_header (psf, SF_TRUE) ; return 0 ; diff --git a/libs/libsndfile/src/wav.c b/libs/libsndfile/src/wav.c index 1e69018664..6e616b70ff 100644 --- a/libs/libsndfile/src/wav.c +++ b/libs/libsndfile/src/wav.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** Copyright (C) 2004-2005 David Viens ** ** This program is free software; you can redistribute it and/or modify @@ -24,6 +24,9 @@ #include #include #include +#ifdef HAVE_INTTYPES_H +#include +#endif #include "sndfile.h" #include "sfendian.h" @@ -34,60 +37,76 @@ * Macros to handle big/little endian issues. */ -#define RIFF_MARKER (MAKE_MARKER ('R', 'I', 'F', 'F')) -#define RIFX_MARKER (MAKE_MARKER ('R', 'I', 'F', 'X')) -#define WAVE_MARKER (MAKE_MARKER ('W', 'A', 'V', 'E')) -#define fmt_MARKER (MAKE_MARKER ('f', 'm', 't', ' ')) -#define data_MARKER (MAKE_MARKER ('d', 'a', 't', 'a')) -#define fact_MARKER (MAKE_MARKER ('f', 'a', 'c', 't')) -#define PEAK_MARKER (MAKE_MARKER ('P', 'E', 'A', 'K')) +#define RIFF_MARKER (MAKE_MARKER ('R', 'I', 'F', 'F')) +#define RIFX_MARKER (MAKE_MARKER ('R', 'I', 'F', 'X')) +#define WAVE_MARKER (MAKE_MARKER ('W', 'A', 'V', 'E')) +#define fmt_MARKER (MAKE_MARKER ('f', 'm', 't', ' ')) +#define data_MARKER (MAKE_MARKER ('d', 'a', 't', 'a')) +#define fact_MARKER (MAKE_MARKER ('f', 'a', 'c', 't')) +#define PEAK_MARKER (MAKE_MARKER ('P', 'E', 'A', 'K')) -#define cue_MARKER (MAKE_MARKER ('c', 'u', 'e', ' ')) -#define LIST_MARKER (MAKE_MARKER ('L', 'I', 'S', 'T')) -#define slnt_MARKER (MAKE_MARKER ('s', 'l', 'n', 't')) -#define wavl_MARKER (MAKE_MARKER ('w', 'a', 'v', 'l')) -#define INFO_MARKER (MAKE_MARKER ('I', 'N', 'F', 'O')) -#define plst_MARKER (MAKE_MARKER ('p', 'l', 's', 't')) -#define adtl_MARKER (MAKE_MARKER ('a', 'd', 't', 'l')) -#define labl_MARKER (MAKE_MARKER ('l', 'a', 'b', 'l')) -#define ltxt_MARKER (MAKE_MARKER ('l', 't', 'x', 't')) -#define note_MARKER (MAKE_MARKER ('n', 'o', 't', 'e')) -#define smpl_MARKER (MAKE_MARKER ('s', 'm', 'p', 'l')) -#define bext_MARKER (MAKE_MARKER ('b', 'e', 'x', 't')) -#define iXML_MARKER (MAKE_MARKER ('i', 'X', 'M', 'L')) -#define levl_MARKER (MAKE_MARKER ('l', 'e', 'v', 'l')) -#define MEXT_MARKER (MAKE_MARKER ('M', 'E', 'X', 'T')) -#define DISP_MARKER (MAKE_MARKER ('D', 'I', 'S', 'P')) -#define acid_MARKER (MAKE_MARKER ('a', 'c', 'i', 'd')) -#define strc_MARKER (MAKE_MARKER ('s', 't', 'r', 'c')) -#define PAD_MARKER (MAKE_MARKER ('P', 'A', 'D', ' ')) -#define afsp_MARKER (MAKE_MARKER ('a', 'f', 's', 'p')) -#define clm_MARKER (MAKE_MARKER ('c', 'l', 'm', ' ')) -#define elmo_MARKER (MAKE_MARKER ('e', 'l', 'm', 'o')) -#define cart_MARKER (MAKE_MARKER ('c', 'a', 'r', 't')) +#define cue_MARKER (MAKE_MARKER ('c', 'u', 'e', ' ')) +#define LIST_MARKER (MAKE_MARKER ('L', 'I', 'S', 'T')) +#define slnt_MARKER (MAKE_MARKER ('s', 'l', 'n', 't')) +#define wavl_MARKER (MAKE_MARKER ('w', 'a', 'v', 'l')) +#define INFO_MARKER (MAKE_MARKER ('I', 'N', 'F', 'O')) +#define plst_MARKER (MAKE_MARKER ('p', 'l', 's', 't')) +#define adtl_MARKER (MAKE_MARKER ('a', 'd', 't', 'l')) +#define labl_MARKER (MAKE_MARKER ('l', 'a', 'b', 'l')) +#define ltxt_MARKER (MAKE_MARKER ('l', 't', 'x', 't')) +#define note_MARKER (MAKE_MARKER ('n', 'o', 't', 'e')) +#define smpl_MARKER (MAKE_MARKER ('s', 'm', 'p', 'l')) +#define bext_MARKER (MAKE_MARKER ('b', 'e', 'x', 't')) +#define iXML_MARKER (MAKE_MARKER ('i', 'X', 'M', 'L')) +#define levl_MARKER (MAKE_MARKER ('l', 'e', 'v', 'l')) +#define MEXT_MARKER (MAKE_MARKER ('M', 'E', 'X', 'T')) +#define DISP_MARKER (MAKE_MARKER ('D', 'I', 'S', 'P')) +#define acid_MARKER (MAKE_MARKER ('a', 'c', 'i', 'd')) +#define strc_MARKER (MAKE_MARKER ('s', 't', 'r', 'c')) +#define PAD_MARKER (MAKE_MARKER ('P', 'A', 'D', ' ')) +#define afsp_MARKER (MAKE_MARKER ('a', 'f', 's', 'p')) +#define clm_MARKER (MAKE_MARKER ('c', 'l', 'm', ' ')) +#define elmo_MARKER (MAKE_MARKER ('e', 'l', 'm', 'o')) +#define cart_MARKER (MAKE_MARKER ('c', 'a', 'r', 't')) +#define FLLR_MARKER (MAKE_MARKER ('F', 'L', 'L', 'R')) -#define exif_MARKER (MAKE_MARKER ('e', 'x', 'i', 'f')) -#define ever_MARKER (MAKE_MARKER ('e', 'v', 'e', 'r')) -#define etim_MARKER (MAKE_MARKER ('e', 't', 'i', 'm')) -#define ecor_MARKER (MAKE_MARKER ('e', 'c', 'o', 'r')) -#define emdl_MARKER (MAKE_MARKER ('e', 'm', 'd', 'l')) -#define emnt_MARKER (MAKE_MARKER ('e', 'm', 'n', 't')) -#define erel_MARKER (MAKE_MARKER ('e', 'r', 'e', 'l')) -#define eucm_MARKER (MAKE_MARKER ('e', 'u', 'c', 'm')) +#define exif_MARKER (MAKE_MARKER ('e', 'x', 'i', 'f')) +#define ever_MARKER (MAKE_MARKER ('e', 'v', 'e', 'r')) +#define etim_MARKER (MAKE_MARKER ('e', 't', 'i', 'm')) +#define ecor_MARKER (MAKE_MARKER ('e', 'c', 'o', 'r')) +#define emdl_MARKER (MAKE_MARKER ('e', 'm', 'd', 'l')) +#define emnt_MARKER (MAKE_MARKER ('e', 'm', 'n', 't')) +#define erel_MARKER (MAKE_MARKER ('e', 'r', 'e', 'l')) +#define eucm_MARKER (MAKE_MARKER ('e', 'u', 'c', 'm')) +#define olym_MARKER (MAKE_MARKER ('o', 'l', 'y', 'm')) +#define minf_MARKER (MAKE_MARKER ('m', 'i', 'n', 'f')) +#define elm1_MARKER (MAKE_MARKER ('e', 'l', 'm', '1')) +#define regn_MARKER (MAKE_MARKER ('r', 'e', 'g', 'n')) +#define ovwf_MARKER (MAKE_MARKER ('o', 'v', 'w', 'f')) +#define umid_MARKER (MAKE_MARKER ('u', 'm', 'i', 'd')) +#define SyLp_MARKER (MAKE_MARKER ('S', 'y', 'L', 'p')) +#define Cr8r_MARKER (MAKE_MARKER ('C', 'r', '8', 'r')) +#define JUNK_MARKER (MAKE_MARKER ('J', 'U', 'N', 'K')) +#define PMX_MARKER (MAKE_MARKER ('_', 'P', 'M', 'X')) +#define inst_MARKER (MAKE_MARKER ('i', 'n', 's', 't')) +#define AFAn_MARKER (MAKE_MARKER ('A', 'F', 'A', 'n')) -#define ISFT_MARKER (MAKE_MARKER ('I', 'S', 'F', 'T')) -#define ICRD_MARKER (MAKE_MARKER ('I', 'C', 'R', 'D')) -#define ICOP_MARKER (MAKE_MARKER ('I', 'C', 'O', 'P')) -#define IARL_MARKER (MAKE_MARKER ('I', 'A', 'R', 'L')) -#define IART_MARKER (MAKE_MARKER ('I', 'A', 'R', 'T')) -#define INAM_MARKER (MAKE_MARKER ('I', 'N', 'A', 'M')) -#define IENG_MARKER (MAKE_MARKER ('I', 'E', 'N', 'G')) -#define IART_MARKER (MAKE_MARKER ('I', 'A', 'R', 'T')) -#define ICOP_MARKER (MAKE_MARKER ('I', 'C', 'O', 'P')) -#define IPRD_MARKER (MAKE_MARKER ('I', 'P', 'R', 'D')) -#define ISRC_MARKER (MAKE_MARKER ('I', 'S', 'R', 'C')) -#define ISBJ_MARKER (MAKE_MARKER ('I', 'S', 'B', 'J')) -#define ICMT_MARKER (MAKE_MARKER ('I', 'C', 'M', 'T')) + +#define ISFT_MARKER (MAKE_MARKER ('I', 'S', 'F', 'T')) +#define ICRD_MARKER (MAKE_MARKER ('I', 'C', 'R', 'D')) +#define ICOP_MARKER (MAKE_MARKER ('I', 'C', 'O', 'P')) +#define IARL_MARKER (MAKE_MARKER ('I', 'A', 'R', 'L')) +#define IART_MARKER (MAKE_MARKER ('I', 'A', 'R', 'T')) +#define INAM_MARKER (MAKE_MARKER ('I', 'N', 'A', 'M')) +#define IENG_MARKER (MAKE_MARKER ('I', 'E', 'N', 'G')) +#define IGNR_MARKER (MAKE_MARKER ('I', 'G', 'N', 'R')) +#define ICOP_MARKER (MAKE_MARKER ('I', 'C', 'O', 'P')) +#define IPRD_MARKER (MAKE_MARKER ('I', 'P', 'R', 'D')) +#define ISRC_MARKER (MAKE_MARKER ('I', 'S', 'R', 'C')) +#define ISBJ_MARKER (MAKE_MARKER ('I', 'S', 'B', 'J')) +#define ICMT_MARKER (MAKE_MARKER ('I', 'C', 'M', 'T')) +#define IAUT_MARKER (MAKE_MARKER ('I', 'A', 'U', 'T')) +#define ITRK_MARKER (MAKE_MARKER ('I', 'T', 'R', 'K')) /* Weird WAVPACK marker which can show up at the start of the DATA section. */ #define wvpk_MARKER (MAKE_MARKER ('w', 'v', 'p', 'k')) @@ -97,6 +116,10 @@ #define WAV_BEXT_MIN_CHUNK_SIZE 602 #define WAV_BEXT_MAX_CHUNK_SIZE (10 * 1024) +#define WAV_CART_MIN_CHUNK_SIZE 2048 +#define WAV_CART_MAX_CHUNK_SIZE 0xffffffff + + enum { HAVE_RIFF = 0x01, HAVE_WAVE = 0x02, @@ -155,27 +178,30 @@ static const EXT_SUBFORMAT MSGUID_SUBTYPE_PVOCEX = ** Private static functions. */ -static int wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; -static int wav_write_header (SF_PRIVATE *psf, int calc_length) ; +static int wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; +static int wav_write_header (SF_PRIVATE *psf, int calc_length) ; static int wav_write_tailer (SF_PRIVATE *psf) ; static void wav_write_strings (SF_PRIVATE *psf, int location) ; static int wav_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; static int wav_close (SF_PRIVATE *psf) ; -static int wav_subchunk_parse (SF_PRIVATE *psf, int chunk) ; -static int exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length) ; -static int wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) ; -static int wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) ; -static int wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunklen) ; -static int wav_write_bext_chunk (SF_PRIVATE *psf) ; +static int wav_subchunk_parse (SF_PRIVATE *psf, int chunk, uint32_t length) ; +static int exif_subchunk_parse (SF_PRIVATE *psf, uint32_t length) ; +static int wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen) ; +static int wav_read_acid_chunk (SF_PRIVATE *psf, uint32_t chunklen) ; + +static int wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; +static SF_CHUNK_ITERATOR * wav_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; +static int wav_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; +static int wav_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; /*------------------------------------------------------------------------------ ** Public function. */ int -wav_open (SF_PRIVATE *psf) +wav_open (SF_PRIVATE *psf) { WAV_PRIVATE * wpriv ; int format, subformat, error, blockalign = 0, framesperblock = 0 ; @@ -184,16 +210,20 @@ wav_open (SF_PRIVATE *psf) psf->container_data = wpriv ; wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - psf->str_flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; + psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = wav_read_header (psf, &blockalign, &framesperblock))) return error ; + + psf->next_chunk_iterator = wav_next_chunk_iterator ; + psf->get_chunk_size = wav_get_chunk_size ; + psf->get_chunk_data = wav_get_chunk_data ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if (psf->is_pipe) return SFE_NO_PIPE_WRITE ; @@ -212,7 +242,7 @@ wav_open (SF_PRIVATE *psf) else if (psf->endian != SF_ENDIAN_BIG) psf->endian = SF_ENDIAN_LITTLE ; - if (psf->mode != SFM_RDWR || psf->filelength < 44) + if (psf->file.mode != SFM_RDWR || psf->filelength < 44) { psf->filelength = 0 ; psf->datalength = 0 ; psf->dataoffset = 0 ; @@ -227,13 +257,14 @@ wav_open (SF_PRIVATE *psf) /* By default, add the peak chunk to floating point files. Default behaviour ** can be switched off using sf_command (SFC_SET_PEAK_CHUNK, SF_FALSE). */ - if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) + if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) return SFE_MALLOC_FAILED ; psf->peak_info->peak_loc = SF_PEAK_START ; } ; - psf->write_header = wav_write_header ; + psf->write_header = wav_write_header ; + psf->set_chunk = wav_set_chunk ; } ; psf->container_close = wav_close ; @@ -284,7 +315,7 @@ wav_open (SF_PRIVATE *psf) default : return SFE_UNIMPLEMENTED ; } ; - if (psf->mode == SFM_WRITE || (psf->mode == SFM_RDWR && psf->filelength == 0)) + if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->filelength == 0)) return psf->write_header (psf, SF_FALSE) ; return error ; @@ -295,13 +326,13 @@ wav_open (SF_PRIVATE *psf) */ static int -wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) +wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) { WAV_PRIVATE *wpriv ; WAV_FMT *wav_fmt ; FACT_CHUNK fact_chunk ; - unsigned dword = 0, marker, RIFFsize, done = 0 ; + uint32_t marker, chunk_size = 0, RIFFsize = 0, done = 0, uk ; int parsestage = 0, error, format = 0 ; - char *cptr ; + char buffer [256] ; if (psf->filelength > SF_PLATFORM_S64 (0xffffffff)) psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ; @@ -311,10 +342,26 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) wav_fmt = &wpriv->wav_fmt ; /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "p", 0) ; + psf_binheader_readf (psf, "pmj", 0, &marker, -4) ; + psf->headindex = 0 ; + + /* RIFX signifies big-endian format for all header and data to prevent + ** lots of code copying here, we'll set the psf->rwf_endian flag once here, + ** and never specify endian-ness for all other header ops/ + */ + psf->rwf_endian = (marker == RIFF_MARKER) ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ; while (! done) - { psf_binheader_readf (psf, "m", &marker) ; + { size_t jump = chunk_size & 1 ; + + marker = chunk_size = 0 ; + psf_binheader_readf (psf, "jm4", jump, &marker, &chunk_size) ; + if (marker == 0) + { psf_log_printf (psf, "Have 0 marker.\n") ; + break ; + } ; + + psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; switch (marker) { case RIFF_MARKER : @@ -324,16 +371,7 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) parsestage |= HAVE_RIFF ; - /* RIFX signifies big-endian format for all header and data - ** to prevent lots of code copying here, we'll set the psf->rwf_endian - ** flag once here, and never specify endian-ness for all other header ops - */ - if (marker == RIFF_MARKER) - psf->rwf_endian = SF_ENDIAN_LITTLE ; - else - psf->rwf_endian = SF_ENDIAN_BIG ; - - psf_binheader_readf (psf, "4", &RIFFsize) ; + RIFFsize = chunk_size ; if (psf->fileoffset > 0 && psf->filelength > RIFFsize + 8) { /* Set file length. */ @@ -343,13 +381,13 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) else psf_log_printf (psf, "RIFX : %u\n", RIFFsize) ; } - else if (psf->filelength < RIFFsize + 2 * SIGNED_SIZEOF (dword)) + else if (psf->filelength < RIFFsize + 2 * SIGNED_SIZEOF (marker)) { if (marker == RIFF_MARKER) - psf_log_printf (psf, "RIFF : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (dword)) ; + psf_log_printf (psf, "RIFF : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (marker)) ; else - psf_log_printf (psf, "RIFX : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (dword)) ; + psf_log_printf (psf, "RIFX : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (marker)) ; - RIFFsize = dword ; + RIFFsize = psf->filelength - 2 * SIGNED_SIZEOF (RIFFsize) ; } else { if (marker == RIFF_MARKER) @@ -357,14 +395,13 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) else psf_log_printf (psf, "RIFX : %u\n", RIFFsize) ; } ; - break ; - case WAVE_MARKER : - if ((parsestage & HAVE_RIFF) != HAVE_RIFF) + psf_binheader_readf (psf, "m", &marker) ; + if (marker != WAVE_MARKER) return SFE_WAV_NO_WAVE ; parsestage |= HAVE_WAVE ; - psf_log_printf (psf, "WAVE\n") ; + chunk_size = 0 ; break ; case fmt_MARKER : @@ -377,10 +414,9 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) parsestage |= HAVE_fmt ; - psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "fmt : %d\n", dword) ; + psf_log_printf (psf, "fmt : %d\n", chunk_size) ; - if ((error = wav_w64_read_fmt_chunk (psf, dword))) + if ((error = wav_w64_read_fmt_chunk (psf, chunk_size))) return error ; format = wav_fmt->format ; @@ -390,18 +426,16 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) return SFE_WAV_NO_DATA ; - if (psf->mode == SFM_RDWR && (parsestage & HAVE_other) != 0) + if (psf->file.mode == SFM_RDWR && (parsestage & HAVE_other) != 0) return SFE_RDWR_BAD_HEADER ; parsestage |= HAVE_data ; - psf_binheader_readf (psf, "4", &dword) ; - - psf->datalength = dword ; + psf->datalength = chunk_size ; psf->dataoffset = psf_ftell (psf) ; if (psf->dataoffset > 0) - { if (dword == 0 && RIFFsize == 8 && psf->filelength > 44) + { if (chunk_size == 0 && RIFFsize == 8 && psf->filelength > 44) { psf_log_printf (psf, "*** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ; psf->datalength = psf->filelength - psf->dataoffset ; } ; @@ -417,10 +451,8 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) if (psf->datalength + psf->dataoffset < psf->filelength) psf->dataend = psf->datalength + psf->dataoffset ; - if (format == WAVE_FORMAT_MS_ADPCM && psf->datalength % 2) - { psf->datalength ++ ; - psf_log_printf (psf, "*** Data length odd. Increasing it by 1.\n") ; - } ; + psf->datalength += chunk_size & 1 ; + chunk_size = 0 ; } ; if (! psf->sf.seekable || psf->dataoffset < 0) @@ -430,7 +462,7 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) psf_fseek (psf, psf->datalength, SEEK_CUR) ; if (psf_ftell (psf) != psf->datalength + psf->dataoffset) - psf_log_printf (psf, "*** psf_fseek past end error ***\n", dword, psf->dataoffset + psf->datalength) ; + psf_log_printf (psf, "*** psf_fseek past end error ***\n") ; break ; case fact_MARKER : @@ -442,15 +474,15 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) if ((parsestage & HAVE_fmt) != HAVE_fmt) psf_log_printf (psf, "*** Should have 'fmt ' chunk before 'fact'\n") ; - psf_binheader_readf (psf, "44", &dword, & (fact_chunk.frames)) ; + psf_binheader_readf (psf, "4", & (fact_chunk.frames)) ; - if (dword > SIGNED_SIZEOF (fact_chunk)) - psf_binheader_readf (psf, "j", (int) (dword - SIGNED_SIZEOF (fact_chunk))) ; + if (chunk_size > SIGNED_SIZEOF (fact_chunk)) + psf_binheader_readf (psf, "j", (int) (chunk_size - SIGNED_SIZEOF (fact_chunk))) ; - if (dword) - psf_log_printf (psf, "%M : %d\n", marker, dword) ; + if (chunk_size) + psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ; else - psf_log_printf (psf, "%M : %d (should not be zero)\n", marker, dword) ; + psf_log_printf (psf, "%M : %d (should not be zero)\n", marker, chunk_size) ; psf_log_printf (psf, " frames : %d\n", fact_chunk.frames) ; break ; @@ -461,11 +493,9 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) parsestage |= HAVE_PEAK ; - psf_binheader_readf (psf, "4", &dword) ; - - psf_log_printf (psf, "%M : %d\n", marker, dword) ; - if (dword != WAV_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", dword) ; + psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ; + if (chunk_size != WAV_PEAK_CHUNK_SIZE (psf->sf.channels)) + { psf_binheader_readf (psf, "j", chunk_size) ; psf_log_printf (psf, "*** File PEAK chunk size doesn't fit with number of channels (%d).\n", psf->sf.channels) ; return SFE_WAV_BAD_PEAK ; } ; @@ -484,18 +514,18 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) psf_log_printf (psf, " time stamp : %d\n", psf->peak_info->timestamp) ; psf_log_printf (psf, " Ch Position Value\n") ; - cptr = psf->u.cbuf ; - for (dword = 0 ; dword < (unsigned) psf->sf.channels ; dword++) + for (uk = 0 ; uk < (uint32_t) psf->sf.channels ; uk++) { float value ; - unsigned int position ; - psf_binheader_readf (psf, "f4", &value, &position) ; - psf->peak_info->peaks [dword].value = value ; - psf->peak_info->peaks [dword].position = position ; + uint32_t position ; - snprintf (cptr, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", - dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ; - cptr [sizeof (psf->u.cbuf) - 1] = 0 ; - psf_log_printf (psf, cptr) ; + psf_binheader_readf (psf, "f4", &value, &position) ; + psf->peak_info->peaks [uk].value = value ; + psf->peak_info->peaks [uk].position = position ; + + snprintf (buffer, sizeof (buffer), " %2d %-12" PRId64 " %g\n", + uk, psf->peak_info->peaks [uk].position, psf->peak_info->peaks [uk].value) ; + buffer [sizeof (buffer) - 1] = 0 ; + psf_log_printf (psf, "%s", buffer) ; } ; psf->peak_info->peak_loc = ((parsestage & HAVE_data) == 0) ? SF_PEAK_START : SF_PEAK_END ; @@ -504,12 +534,11 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) case cue_MARKER : parsestage |= HAVE_other ; - { unsigned bytesread, cue_count ; + { uint32_t bytesread, cue_count ; int id, position, chunk_id, chunk_start, block_start, offset ; - bytesread = psf_binheader_readf (psf, "44", &dword, &cue_count) ; - bytesread -= 4 ; /* Remove bytes for first dword. */ - psf_log_printf (psf, "%M : %u\n", marker, dword) ; + bytesread = psf_binheader_readf (psf, "4", &cue_count) ; + psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; if (cue_count > 10) { psf_log_printf (psf, " Count : %d (skipping)\n", cue_count) ; @@ -522,17 +551,17 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) while (cue_count) { bytesread += psf_binheader_readf (psf, "444444", &id, &position, &chunk_id, &chunk_start, &block_start, &offset) ; - psf_log_printf (psf, " Cue ID : %2d" - " Pos : %5u Chunk : %M" - " Chk Start : %d Blk Start : %d" - " Offset : %5d\n", + psf_log_printf (psf, " Cue ID : %2d" + " Pos : %5u Chunk : %M" + " Chk Start : %d Blk Start : %d" + " Offset : %5d\n", id, position, chunk_id, chunk_start, block_start, offset) ; cue_count -- ; } ; - if (bytesread != dword) - { psf_log_printf (psf, "**** Chunk size weirdness (%d != %d)\n", dword, bytesread) ; - psf_binheader_readf (psf, "j", dword - bytesread) ; + if (bytesread != chunk_size) + { psf_log_printf (psf, "**** Chunk size weirdness (%d != %d)\n", chunk_size, bytesread) ; + psf_binheader_readf (psf, "j", chunk_size - bytesread) ; } ; } ; break ; @@ -540,20 +569,18 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) case smpl_MARKER : parsestage |= HAVE_other ; - psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "smpl : %u\n", dword) ; + psf_log_printf (psf, "smpl : %u\n", chunk_size) ; - if ((error = wav_read_smpl_chunk (psf, dword))) + if ((error = wav_read_smpl_chunk (psf, chunk_size))) return error ; break ; case acid_MARKER : parsestage |= HAVE_other ; - psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "acid : %u\n", dword) ; + psf_log_printf (psf, "acid : %u\n", chunk_size) ; - if ((error = wav_read_acid_chunk (psf, dword))) + if ((error = wav_read_acid_chunk (psf, chunk_size))) return error ; break ; @@ -561,7 +588,7 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) case LIST_MARKER : parsestage |= HAVE_other ; - if ((error = wav_subchunk_parse (psf, marker)) != 0) + if ((error = wav_subchunk_parse (psf, marker, chunk_size)) != 0) return error ; break ; @@ -570,8 +597,7 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) The 'bext' chunk can actually be updated, so don't need to set this. parsestage |= HAVE_other ; */ - psf_binheader_readf (psf, "4", &dword) ; - if ((error = wav_read_bext_chunk (psf, dword))) + if ((error = wav_read_bext_chunk (psf, chunk_size))) return error ; break ; @@ -580,10 +606,13 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) We can eat into a 'PAD ' chunk if we need to. parsestage |= HAVE_other ; */ - psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "%M : %u\n", marker, dword) ; - dword += (dword & 1) ; - psf_binheader_readf (psf, "j", dword) ; + psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size) ; + break ; + + case cart_MARKER: + if ((error = wav_read_cart_chunk (psf, chunk_size))) + return error ; break ; case iXML_MARKER : /* See http://en.wikipedia.org/wiki/IXML */ @@ -591,42 +620,49 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) case afsp_MARKER : case clm_MARKER : case elmo_MARKER : - case cart_MARKER : case levl_MARKER : case plst_MARKER : + case minf_MARKER : + case elm1_MARKER : + case regn_MARKER : + case ovwf_MARKER : + case inst_MARKER : + case AFAn_MARKER : + case umid_MARKER : + case SyLp_MARKER : + case Cr8r_MARKER : + case JUNK_MARKER : + case PMX_MARKER : case DISP_MARKER : case MEXT_MARKER : - parsestage |= HAVE_other ; - - psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "%M : %u\n", marker, dword) ; - dword += (dword & 1) ; - psf_binheader_readf (psf, "j", dword) ; + case FLLR_MARKER : + psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size) ; break ; default : - parsestage |= HAVE_other ; - if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF) - && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF)) - { psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, dword) ; - psf_binheader_readf (psf, "j", dword) ; + if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) + && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) + { psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, chunk_size) ; + psf_binheader_readf (psf, "j", chunk_size) ; break ; } ; if (psf_ftell (psf) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", dword - 4) ; + { psf_log_printf (psf, " Unknown chunk marker at position %D. Resynching.\n", psf_ftell (psf) - 8) ; psf_binheader_readf (psf, "j", -3) ; + /* File is too messed up so we prevent editing in RDWR mode here. */ + parsestage |= HAVE_other ; break ; } ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 4) ; + psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 8) ; done = SF_TRUE ; break ; - } ; /* switch (dword) */ + } ; /* switch (marker) */ if (! psf->sf.seekable && (parsestage & HAVE_data)) break ; - if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (dword)) + if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (chunk_size)) { psf_log_printf (psf, "End\n") ; break ; } ; @@ -756,27 +792,27 @@ wav_write_fmt_chunk (SF_PRIVATE *psf) break ; case SF_FORMAT_ULAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ; + fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 ; /* fmt : format, channels, samplerate */ psf_binheader_writef (psf, "4224", fmt_size, WAVE_FORMAT_MULAW, psf->sf.channels, psf->sf.samplerate) ; /* fmt : bytespersec */ psf_binheader_writef (psf, "4", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", psf->bytewidth * psf->sf.channels, 8) ; + /* fmt : blockalign, bitwidth, extrabytes */ + psf_binheader_writef (psf, "222", psf->bytewidth * psf->sf.channels, 8, 0) ; add_fact_chunk = SF_TRUE ; break ; case SF_FORMAT_ALAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ; + fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 ; /* fmt : format, channels, samplerate */ psf_binheader_writef (psf, "4224", fmt_size, WAVE_FORMAT_ALAW, psf->sf.channels, psf->sf.samplerate) ; /* fmt : bytespersec */ psf_binheader_writef (psf, "4", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", psf->bytewidth * psf->sf.channels, 8) ; + /* fmt : blockalign, bitwidth, extrabytes */ + psf_binheader_writef (psf, "222", psf->bytewidth * psf->sf.channels, 8, 0) ; add_fact_chunk = SF_TRUE ; break ; @@ -918,6 +954,8 @@ wavex_write_fmt_chunk (SF_PRIVATE *psf) */ if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE) psf_binheader_writef (psf, "4", 0) ; + else if (wpriv->wavex_channelmask != 0) + psf_binheader_writef (psf, "4", wpriv->wavex_channelmask) ; else { /* ** Ok some liberty is taken here to use the most commonly used channel masks @@ -1007,6 +1045,7 @@ wavex_write_fmt_chunk (SF_PRIVATE *psf) static int wav_write_header (SF_PRIVATE *psf, int calc_length) { sf_count_t current ; + uint32_t uk ; int k, error, has_data = SF_FALSE ; current = psf_ftell (psf) ; @@ -1021,9 +1060,8 @@ wav_write_header (SF_PRIVATE *psf, int calc_length) if (psf->dataend) psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; + else if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) + psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; } ; /* Reset the current header length to zero. */ @@ -1064,7 +1102,7 @@ wav_write_header (SF_PRIVATE *psf, int calc_length) } ; /* The LIST/INFO chunk. */ - if (psf->str_flags & SF_STR_LOCATE_START) + if (psf->strings.flags & SF_STR_LOCATE_START) wav_write_strings (psf, SF_STR_LOCATE_START) ; if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) @@ -1074,9 +1112,12 @@ wav_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; - if (psf->broadcast_var != NULL) + if (psf->broadcast_16k != NULL) wav_write_bext_chunk (psf) ; + if (psf->cart_16k != NULL) + wav_write_cart_chunk (psf) ; + if (psf->instrument != NULL) { int tmp ; double dtune = (double) (0x40000000) / 25.0 ; @@ -1085,7 +1126,7 @@ wav_write_header (SF_PRIVATE *psf, int calc_length) psf_binheader_writef (psf, "44", 0, 0) ; /* Manufacturer zero is everyone */ tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */ psf_binheader_writef (psf, "44", tmp, psf->instrument->basenote) ; - tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ; + tmp = (uint32_t) (psf->instrument->detune * dtune + 0.5) ; psf_binheader_writef (psf, "4", tmp) ; psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */ psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ; @@ -1094,14 +1135,18 @@ wav_write_header (SF_PRIVATE *psf, int calc_length) { int type ; type = psf->instrument->loops [tmp].mode ; - type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; + type = (type == SF_LOOP_FORWARD ? 0 : type == SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; psf_binheader_writef (psf, "44", tmp, type) ; - psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ; + psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end - 1) ; psf_binheader_writef (psf, "44", 0, psf->instrument->loops [tmp].count) ; } ; } ; + /* Write custom headers. */ + for (uk = 0 ; uk < psf->wchunks.used ; uk++) + psf_binheader_writef (psf, "m4b", (int) psf->wchunks.chunks [uk].mark32, psf->wchunks.chunks [uk].len, psf->wchunks.chunks [uk].data, make_size_t (psf->wchunks.chunks [uk].len)) ; + if (psf->headindex + 16 < psf->dataoffset) { /* Add PAD data if necessary. */ k = psf->dataoffset - (psf->headindex + 16) ; @@ -1137,6 +1182,11 @@ wav_write_tailer (SF_PRIVATE *psf) psf->header [0] = 0 ; psf->headindex = 0 ; + if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) + { psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; + psf->dataend = psf->dataoffset + psf->datalength ; + } ; + if (psf->dataend > 0) psf_fseek (psf, psf->dataend, SEEK_SET) ; else @@ -1150,7 +1200,7 @@ wav_write_tailer (SF_PRIVATE *psf) psf_binheader_writef (psf, "f4", psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ; } ; - if (psf->str_flags & SF_STR_LOCATE_END) + if (psf->strings.flags & SF_STR_LOCATE_END) wav_write_strings (psf, SF_STR_LOCATE_END) ; /* Write the tailer. */ @@ -1172,34 +1222,46 @@ wav_write_strings (SF_PRIVATE *psf, int location) psf_binheader_writef (psf, "m4m", LIST_MARKER, 0xBADBAD, INFO_MARKER) ; for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings [k].type == 0) + { if (psf->strings.data [k].type == 0) break ; - if (psf->strings [k].type < 0 || psf->strings [k].flags != location) + if (psf->strings.data [k].type < 0 || psf->strings.data [k].flags != location) continue ; - switch (psf->strings [k].type) + switch (psf->strings.data [k].type) { case SF_STR_SOFTWARE : - psf_binheader_writef (psf, "ms", ISFT_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", ISFT_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_TITLE : - psf_binheader_writef (psf, "ms", INAM_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", INAM_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_COPYRIGHT : - psf_binheader_writef (psf, "ms", ICOP_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", ICOP_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_ARTIST : - psf_binheader_writef (psf, "ms", IART_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", IART_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_COMMENT : - psf_binheader_writef (psf, "ms", ICMT_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", ICMT_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; case SF_STR_DATE : - psf_binheader_writef (psf, "ms", ICRD_MARKER, psf->strings [k].str) ; + psf_binheader_writef (psf, "ms", ICRD_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; + break ; + + case SF_STR_GENRE : + psf_binheader_writef (psf, "ms", IGNR_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; + break ; + + case SF_STR_ALBUM : + psf_binheader_writef (psf, "ms", IPRD_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; + break ; + + case SF_STR_TRACKNUMBER : + psf_binheader_writef (psf, "ms", ITRK_MARKER, psf->strings.storage + psf->strings.data [k].offset) ; break ; default : @@ -1217,10 +1279,10 @@ wav_write_strings (SF_PRIVATE *psf, int location) static int wav_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { wav_write_tailer (psf) ; - if (psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_RDWR) { sf_count_t current = psf_ftell (psf) ; /* @@ -1262,6 +1324,10 @@ wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) case SFC_WAVEX_GET_AMBISONIC : return wpriv->wavex_ambisonic ; + case SFC_SET_CHANNEL_MAP_INFO : + wpriv->wavex_channelmask = wavex_gen_channel_mask (psf->channel_map, psf->sf.channels) ; + return (wpriv->wavex_channelmask != 0) ; + default : break ; } ; @@ -1270,45 +1336,50 @@ wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) } /* wav_command */ static int -wav_subchunk_parse (SF_PRIVATE *psf, int chunk) +wav_subchunk_parse (SF_PRIVATE *psf, int chunk, uint32_t chunk_length) { sf_count_t current_pos ; - char *cptr ; - unsigned dword, bytesread, length ; + char buffer [512] ; + uint32_t dword, bytesread ; - current_pos = psf_fseek (psf, 0, SEEK_CUR) ; + current_pos = psf_fseek (psf, 0, SEEK_CUR) - 4 ; - bytesread = psf_binheader_readf (psf, "4", &length) ; + bytesread = sizeof (chunk_length) ; - if (length <= 8) + if (chunk_length <= 8) { /* This case is for broken files generated by PEAK. */ - psf_log_printf (psf, "%M : %d (weird length)\n", chunk, length) ; - psf_binheader_readf (psf, "mj", &chunk, length - 4) ; + psf_log_printf (psf, "%M : %d (weird length)\n", chunk, chunk_length) ; + psf_binheader_readf (psf, "mj", &chunk, chunk_length - 4) ; psf_log_printf (psf, " %M\n", chunk) ; return 0 ; } ; - if (psf->headindex + length > SIGNED_SIZEOF (psf->header)) - { psf_log_printf (psf, "%M : %d (too long)\n", chunk, length) ; - psf_binheader_readf (psf, "j", length) ; + if (psf->headindex + chunk_length > SIGNED_SIZEOF (psf->header)) + { psf_log_printf (psf, "%M : %d (too long)\n", chunk, chunk_length) ; + psf_binheader_readf (psf, "j", chunk_length) ; return 0 ; } ; - if (current_pos + length > psf->filelength) - { psf_log_printf (psf, "%M : %d (should be %d)\n", chunk, length, (int) (psf->filelength - current_pos)) ; - length = psf->filelength - current_pos ; + if (current_pos + chunk_length > psf->filelength) + { psf_log_printf (psf, "%M : %d (should be %d)\n", chunk, chunk_length, (int) (psf->filelength - current_pos)) ; + chunk_length = psf->filelength - current_pos ; } else - psf_log_printf (psf, "%M : %d\n", chunk, length) ; + psf_log_printf (psf, "%M : %d\n", chunk, chunk_length) ; - while (bytesread < length) + while (bytesread < chunk_length) { bytesread += psf_binheader_readf (psf, "m", &chunk) ; switch (chunk) { case adtl_MARKER : case INFO_MARKER : - /* These markers don't contain anything. */ + /* These markers don't contain anything, not even a chunk lebgth. */ psf_log_printf (psf, " %M\n", chunk) ; - break ; + continue ; + + case exif_MARKER : + psf_log_printf (psf, " %M\n", chunk) ; + bytesread += exif_subchunk_parse (psf, chunk_length - bytesread) ; + continue ; case data_MARKER : psf_log_printf (psf, " %M inside a LIST block??? Backing out.\n", chunk) ; @@ -1316,31 +1387,47 @@ wav_subchunk_parse (SF_PRIVATE *psf, int chunk) psf_binheader_readf (psf, "j", -4) ; return 0 ; - case ISFT_MARKER : + case 0 : + /* + ** Four zero bytes where a marker was expected. Assume this means + ** the rest of the chunk is garbage. + */ + psf_log_printf (psf, " *** Found weird-ass zero marker. Jumping to end of chunk.\n") ; + if (bytesread < chunk_length) + bytesread += psf_binheader_readf (psf, "j", chunk_length - bytesread + 4) ; + psf_log_printf (psf, " *** Offset is now : 0x%X\n", psf_fseek (psf, 0, SEEK_CUR)) ; + return 0 ; + + default : + break ; + } ; + + switch (chunk) + { case ISFT_MARKER : case ICOP_MARKER : case IARL_MARKER : case IART_MARKER : case ICMT_MARKER : case ICRD_MARKER : case IENG_MARKER : - + case IGNR_MARKER : case INAM_MARKER : case IPRD_MARKER : case ISBJ_MARKER : case ISRC_MARKER : + case IAUT_MARKER : + case ITRK_MARKER : bytesread += psf_binheader_readf (psf, "4", &dword) ; dword += (dword & 1) ; - if (dword >= SIGNED_SIZEOF (psf->u.cbuf)) + if (dword >= SIGNED_SIZEOF (buffer)) { psf_log_printf (psf, " *** %M : %d (too big)\n", chunk, dword) ; psf_binheader_readf (psf, "j", dword) ; break ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword) ; - bytesread += dword ; - cptr [dword] = 0 ; - psf_log_printf (psf, " %M : %s\n", chunk, cptr) ; + bytesread += psf_binheader_readf (psf, "b", buffer, dword) ; + buffer [dword] = 0 ; + psf_log_printf (psf, " %M : %s\n", chunk, buffer) ; break ; case labl_MARKER : @@ -1349,17 +1436,15 @@ wav_subchunk_parse (SF_PRIVATE *psf, int chunk) bytesread += psf_binheader_readf (psf, "44", &dword, &mark_id) ; dword -= 4 ; dword += (dword & 1) ; - if (dword < 1 || dword >= SIGNED_SIZEOF (psf->u.cbuf)) + if (dword < 1 || dword >= SIGNED_SIZEOF (buffer)) { psf_log_printf (psf, " *** %M : %d (too big)\n", chunk, dword) ; psf_binheader_readf (psf, "j", dword) ; break ; } ; - cptr = psf->u.cbuf ; - psf_binheader_readf (psf, "b", cptr, dword) ; - bytesread += dword ; - cptr [dword] = 0 ; - psf_log_printf (psf, " %M : %d : %s\n", chunk, mark_id, cptr) ; + bytesread += psf_binheader_readf (psf, "b", buffer, dword) ; + buffer [dword] = 0 ; + psf_log_printf (psf, " %M : %d : %s\n", chunk, mark_id, buffer) ; } ; break ; @@ -1369,73 +1454,70 @@ wav_subchunk_parse (SF_PRIVATE *psf, int chunk) case note_MARKER : bytesread += psf_binheader_readf (psf, "4", &dword) ; dword += (dword & 1) ; - psf_binheader_readf (psf, "j", dword) ; - bytesread += dword ; + bytesread += psf_binheader_readf (psf, "j", dword) ; psf_log_printf (psf, " %M : %d\n", chunk, dword) ; break ; - case exif_MARKER : - psf_log_printf (psf, " %M\n", chunk) ; - bytesread += exif_subchunk_parse (psf, length - bytesread) ; - break ; - - case 0 : - /* - ** Four zero bytes where a marker was expected. Assume this means - ** the rest of the chunk is garbage. - */ - psf_log_printf (psf, " *** Found weird-ass zero marker. Jumping to end of chunk.\n") ; - if (bytesread < length) - bytesread += psf_binheader_readf (psf, "j", length - bytesread + 4) ; - psf_log_printf (psf, " *** Offset is now : 0x%X\n", psf_fseek (psf, 0, SEEK_CUR)) ; - return 0 ; - default : - psf_binheader_readf (psf, "4", &dword) ; - bytesread += sizeof (dword) ; + bytesread += psf_binheader_readf (psf, "4", &dword) ; dword += (dword & 1) ; - psf_binheader_readf (psf, "j", dword) ; - bytesread += dword ; psf_log_printf (psf, " *** %M : %d\n", chunk, dword) ; - if (dword > length) + if (bytesread + dword > chunk_length) + { bytesread += psf_binheader_readf (psf, "j", chunk_length - bytesread + 4) ; + continue ; + } + else + bytesread += psf_binheader_readf (psf, "j", dword) ; + + if (dword >= chunk_length) return 0 ; break ; } ; switch (chunk) { case ISFT_MARKER : - psf_store_string (psf, SF_STR_SOFTWARE, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_SOFTWARE, buffer) ; break ; case ICOP_MARKER : - psf_store_string (psf, SF_STR_COPYRIGHT, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_COPYRIGHT, buffer) ; break ; case INAM_MARKER : - psf_store_string (psf, SF_STR_TITLE, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_TITLE, buffer) ; break ; case IART_MARKER : - psf_store_string (psf, SF_STR_ARTIST, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_ARTIST, buffer) ; break ; case ICMT_MARKER : - psf_store_string (psf, SF_STR_COMMENT, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_COMMENT, buffer) ; break ; case ICRD_MARKER : - psf_store_string (psf, SF_STR_DATE, psf->u.cbuf) ; + psf_store_string (psf, SF_STR_DATE, buffer) ; + break ; + case IGNR_MARKER : + psf_store_string (psf, SF_STR_GENRE, buffer) ; + break ; + case IPRD_MARKER : + psf_store_string (psf, SF_STR_ALBUM, buffer) ; + break ; + case ITRK_MARKER : + psf_store_string (psf, SF_STR_TRACKNUMBER, buffer) ; break ; } ; } ; current_pos = psf_fseek (psf, 0, SEEK_CUR) - current_pos ; - if (current_pos - 4 != length) - psf_log_printf (psf, "**** Bad chunk length %d sbould be %D\n", length, current_pos - 4) ; + if (current_pos - 4 != chunk_length) + psf_log_printf (psf, "**** Bad chunk length %d sbould be %D\n", chunk_length, current_pos - 4) ; return 0 ; } /* wav_subchunk_parse */ static int -wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) -{ unsigned int bytesread = 0, dword, sampler_data, loop_count ; - unsigned int note, start, end, type = -1, count ; +wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen) +{ char buffer [512] ; + uint32_t bytesread = 0, dword, sampler_data, loop_count ; + uint32_t note, start, end, type = -1, count ; int j, k ; chunklen += (chunklen & 1) ; @@ -1454,9 +1536,9 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) bytesread += psf_binheader_readf (psf, "4", &dword) ; if (dword != 0) - { snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", - (1.0 * 0x80000000) / ((unsigned int) dword)) ; - psf_log_printf (psf, " Pitch Fract. : %s\n", psf->u.cbuf) ; + { snprintf (buffer, sizeof (buffer), "%f", + (1.0 * 0x80000000) / ((uint32_t) dword)) ; + psf_log_printf (psf, " Pitch Fract. : %s\n", buffer) ; } else psf_log_printf (psf, " Pitch Fract. : 0\n") ; @@ -1465,9 +1547,9 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) psf_log_printf (psf, " SMPTE Format : %u\n", dword) ; bytesread += psf_binheader_readf (psf, "4", &dword) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%02d:%02d:%02d %02d", - (dword >> 24) & 0x7F, (dword >> 16) & 0x7F, (dword >> 8) & 0x7F, dword & 0x7F) ; - psf_log_printf (psf, " SMPTE Offset : %s\n", psf->u.cbuf) ; + snprintf (buffer, sizeof (buffer), "%02d:%02d:%02d %02d", + (dword >> 24) & 0x7F, (dword >> 16) & 0x7F, (dword >> 8) & 0x7F, dword & 0x7F) ; + psf_log_printf (psf, " SMPTE Offset : %s\n", buffer) ; bytesread += psf_binheader_readf (psf, "4", &loop_count) ; psf_log_printf (psf, " Loop Count : %u\n", loop_count) ; @@ -1503,7 +1585,7 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) if (j < ARRAY_LEN (psf->instrument->loops)) { psf->instrument->loops [j].start = start ; - psf->instrument->loops [j].end = end ; + psf->instrument->loops [j].end = end + 1 ; psf->instrument->loops [j].count = count ; switch (type) @@ -1593,8 +1675,9 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) */ static int -wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) -{ unsigned int bytesread = 0 ; +wav_read_acid_chunk (SF_PRIVATE *psf, uint32_t chunklen) +{ char buffer [512] ; + uint32_t bytesread = 0 ; int beats, flags ; short rootnote, q1, meter_denom, meter_numer ; float q2, tempo ; @@ -1603,7 +1686,7 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) bytesread += psf_binheader_readf (psf, "422f", &flags, &rootnote, &q1, &q2) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", q2) ; + snprintf (buffer, sizeof (buffer), "%f", q2) ; psf_log_printf (psf, " Flags : 0x%04x (%s,%s,%s,%s,%s)\n", flags, (flags & 0x01) ? "OneShot" : "Loop", @@ -1613,12 +1696,12 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) (flags & 0x10) ? "??On" : "??Off") ; psf_log_printf (psf, " Root note : 0x%x\n ???? : 0x%04x\n ???? : %s\n", - rootnote, q1, psf->u.cbuf) ; + rootnote, q1, buffer) ; bytesread += psf_binheader_readf (psf, "422f", &beats, &meter_denom, &meter_numer, &tempo) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", tempo) ; + snprintf (buffer, sizeof (buffer), "%f", tempo) ; psf_log_printf (psf, " Beats : %d\n Meter : %d/%d\n Tempo : %s\n", - beats, meter_numer, meter_denom, psf->u.cbuf) ; + beats, meter_numer, meter_denom, buffer) ; psf_binheader_readf (psf, "j", chunklen - bytesread) ; @@ -1635,11 +1718,11 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) return 0 ; } /* wav_read_acid_chunk */ -static int -wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize) +int +wav_read_bext_chunk (SF_PRIVATE *psf, uint32_t chunksize) { - SF_BROADCAST_INFO* b ; - unsigned int bytes = 0 ; + SF_BROADCAST_INFO_16K * b ; + uint32_t bytes = 0 ; if (chunksize < WAV_BEXT_MIN_CHUNK_SIZE) { psf_log_printf (psf, "bext : %u (should be >= %d)\n", chunksize, WAV_BEXT_MIN_CHUNK_SIZE) ; @@ -1653,14 +1736,20 @@ wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize) return 0 ; } ; + if (chunksize >= sizeof (SF_BROADCAST_INFO_16K)) + { psf_log_printf (psf, "bext : %u too big to be handled\n", chunksize) ; + psf_binheader_readf (psf, "j", chunksize) ; + return 0 ; + } ; + psf_log_printf (psf, "bext : %u\n", chunksize) ; - if ((psf->broadcast_var = broadcast_var_alloc (chunksize + 128)) == NULL) + if ((psf->broadcast_16k = broadcast_var_alloc ()) == NULL) { psf->error = SFE_MALLOC_FAILED ; return psf->error ; } ; - b = & psf->broadcast_var->binfo ; + b = psf->broadcast_16k ; bytes += psf_binheader_readf (psf, "b", b->description, sizeof (b->description)) ; bytes += psf_binheader_readf (psf, "b", b->originator, sizeof (b->originator)) ; @@ -1685,14 +1774,14 @@ wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize) return 0 ; } /* wav_read_bext_chunk */ -static int +int wav_write_bext_chunk (SF_PRIVATE *psf) -{ SF_BROADCAST_INFO *b ; +{ SF_BROADCAST_INFO_16K *b ; - if (psf->broadcast_var == NULL) + if (psf->broadcast_16k == NULL) return -1 ; - b = & psf->broadcast_var->binfo ; + b = psf->broadcast_16k ; psf_binheader_writef (psf, "m4", bext_MARKER, WAV_BEXT_MIN_CHUNK_SIZE + b->coding_history_size) ; @@ -1716,6 +1805,112 @@ wav_write_bext_chunk (SF_PRIVATE *psf) return 0 ; } /* wav_write_bext_chunk */ +int +wav_read_cart_chunk (SF_PRIVATE *psf, uint32_t chunksize) +{ SF_CART_INFO_16K *c ; + uint32_t bytes = 0 ; + int k ; + + if (chunksize < WAV_CART_MIN_CHUNK_SIZE) + { psf_log_printf (psf, "cart : %u (should be >= %d)\n", chunksize, WAV_CART_MIN_CHUNK_SIZE) ; + psf_binheader_readf (psf, "j", chunksize) ; + return 0 ; + } ; + if (chunksize > WAV_CART_MAX_CHUNK_SIZE) + { psf_log_printf (psf, "cart : %u (should be < %d)\n", chunksize, WAV_CART_MAX_CHUNK_SIZE) ; + psf_binheader_readf (psf, "j", chunksize) ; + return 0 ; + } ; + + if (chunksize >= sizeof (SF_CART_INFO_16K)) + { psf_log_printf (psf, "cart : %u too big to be handled\n", chunksize) ; + psf_binheader_readf (psf, "j", chunksize) ; + return 0 ; + } ; + + psf_log_printf (psf, "cart : %u\n", chunksize) ; + + if ((psf->cart_16k = cart_var_alloc ()) == NULL) + { psf->error = SFE_MALLOC_FAILED ; + return psf->error ; + } ; + + c = psf->cart_16k ; + bytes += psf_binheader_readf (psf, "b", c->version, sizeof (c->version)) ; + bytes += psf_binheader_readf (psf, "b", c->title, sizeof (c->title)) ; + bytes += psf_binheader_readf (psf, "b", c->artist, sizeof (c->artist)) ; + bytes += psf_binheader_readf (psf, "b", c->cut_id, sizeof (c->cut_id)) ; + bytes += psf_binheader_readf (psf, "b", c->client_id, sizeof (c->client_id)) ; + bytes += psf_binheader_readf (psf, "b", c->category, sizeof (c->category)) ; + bytes += psf_binheader_readf (psf, "b", c->classification, sizeof (c->classification)) ; + bytes += psf_binheader_readf (psf, "b", c->out_cue, sizeof (c->out_cue)) ; + bytes += psf_binheader_readf (psf, "b", c->start_date, sizeof (c->start_date)) ; + bytes += psf_binheader_readf (psf, "b", c->start_time, sizeof (c->start_time)) ; + bytes += psf_binheader_readf (psf, "b", c->end_date, sizeof (c->end_date)) ; + bytes += psf_binheader_readf (psf, "b", c->end_time, sizeof (c->end_time)) ; + bytes += psf_binheader_readf (psf, "b", c->producer_app_id, sizeof (c->producer_app_id)) ; + bytes += psf_binheader_readf (psf, "b", c->producer_app_version, sizeof (c->producer_app_version)) ; + bytes += psf_binheader_readf (psf, "b", c->user_def, sizeof (c->user_def)) ; + bytes += psf_binheader_readf (psf, "e4", &c->level_reference, sizeof (c->level_reference)) ; + + for (k = 0 ; k < ARRAY_LEN (c->post_timers) ; k++) + bytes += psf_binheader_readf (psf, "b4", &c->post_timers [k].usage, make_size_t (4), &c->post_timers [k].value) ; + + bytes += psf_binheader_readf (psf, "b", c->reserved, sizeof (c->reserved)) ; + bytes += psf_binheader_readf (psf, "b", c->url, sizeof (c->url)) ; + + if (chunksize > WAV_CART_MIN_CHUNK_SIZE) + { /* File has tag text. */ + c->tag_text_size = chunksize - WAV_CART_MIN_CHUNK_SIZE ; + bytes += psf_binheader_readf (psf, "b", c->tag_text, make_size_t (c->tag_text_size)) ; + } ; + + return 0 ; +} /* wav_read_cart_chunk */ + +int +wav_write_cart_chunk (SF_PRIVATE *psf) +{ SF_CART_INFO_16K *c ; + int k ; + + if (psf->cart_16k == NULL) + return -1 ; + + c = psf->cart_16k ; + psf_binheader_writef (psf, "m4", cart_MARKER, WAV_CART_MIN_CHUNK_SIZE + c->tag_text_size) ; + /* + ** Note that it is very important the the field widths of the SF_CART_INFO + ** struct match those for the cart chunk fields. + */ + psf_binheader_writef (psf, "b", c->version, sizeof (c->version)) ; + psf_binheader_writef (psf, "b", c->title, sizeof (c->title)) ; + psf_binheader_writef (psf, "b", c->artist, sizeof (c->artist)) ; + psf_binheader_writef (psf, "b", c->cut_id, sizeof (c->cut_id)) ; + psf_binheader_writef (psf, "b", c->client_id, sizeof (c->client_id)) ; + psf_binheader_writef (psf, "b", c->category, sizeof (c->category)) ; + psf_binheader_writef (psf, "b", c->classification, sizeof (c->classification)) ; + psf_binheader_writef (psf, "b", c->out_cue, sizeof (c->out_cue)) ; + psf_binheader_writef (psf, "b", c->start_date, sizeof (c->start_date)) ; + psf_binheader_writef (psf, "b", c->start_time, sizeof (c->start_time)) ; + psf_binheader_writef (psf, "b", c->end_date, sizeof (c->end_date)) ; + psf_binheader_writef (psf, "b", c->end_time, sizeof (c->end_time)) ; + psf_binheader_writef (psf, "b", c->producer_app_id, sizeof (c->producer_app_id)) ; + psf_binheader_writef (psf, "b", c->producer_app_version, sizeof (c->producer_app_version)) ; + psf_binheader_writef (psf, "b", c->user_def, sizeof (c->user_def)) ; + psf_binheader_writef (psf, "4", c->level_reference, sizeof (c->level_reference)) ; + + for (k = 0 ; k < ARRAY_LEN (c->post_timers) ; k++) + psf_binheader_writef (psf, "b4", c->post_timers [k].usage, make_size_t (4), c->post_timers [k].value) ; + + psf_binheader_writef (psf, "z", sizeof (c->reserved)) ; // just write zeros, we don't have any other use for it + psf_binheader_writef (psf, "b", c->url, sizeof (c->url)) ; + + if (c->tag_text_size > 0) + psf_binheader_writef (psf, "b", c->tag_text, make_size_t (c->tag_text_size)) ; + + return 0 ; +} /* wav_write_cart_chunk */ + static int exif_fill_and_sink (SF_PRIVATE *psf, char* buf, size_t bufsz, size_t toread) { @@ -1739,8 +1934,8 @@ exif_fill_and_sink (SF_PRIVATE *psf, char* buf, size_t bufsz, size_t toread) ** (Exif Audio File Specification) http://www.exif.org/Exif2-2.PDF */ static int -exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length) -{ unsigned marker, dword, vmajor = -1, vminor = -1, bytesread = 0 ; +exif_subchunk_parse (SF_PRIVATE *psf, uint32_t length) +{ uint32_t marker, dword, vmajor = -1, vminor = -1, bytesread = 0 ; char buf [4096] ; while (bytesread < length) @@ -1759,13 +1954,20 @@ exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length) psf_log_printf (psf, " EXIF Version : %u.%02u\n", vmajor, vminor) ; break ; + case olym_MARKER : + bytesread += psf_binheader_readf (psf, "4", &dword) ; + psf_log_printf (psf, "%M : %u\n", marker, dword) ; + dword += (dword & 1) ; + bytesread += psf_binheader_readf (psf, "j", dword) ; + break ; + case emnt_MARKER : /* design information: null-terminated string */ case emdl_MARKER : /* model name ; null-terminated string */ case ecor_MARKER : /* manufacturer: null-terminated string */ case etim_MARKER : /* creation time: null-terminated string in the format "hour:minute:second.subsecond" */ case erel_MARKER : /* relation info: null-terminated string (filename) */ case eucm_MARKER : /* user comment: 4-byte size follows, then possibly unicode data */ - psf_binheader_readf (psf, "4", &dword) ; + bytesread += psf_binheader_readf (psf, "4", &dword) ; bytesread += sizeof (dword) ; dword += (dword & 1) ; @@ -1798,3 +2000,49 @@ exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length) return bytesread ; } /* exif_subchunk_parse */ +/*============================================================================== +*/ + +static int +wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) +{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; +} /* wav_set_chunk */ + +static SF_CHUNK_ITERATOR * +wav_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) +{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; +} /* wav_next_chunk_iterator */ + +static int +wav_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ int indx ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + chunk_info->datalen = psf->rchunks.chunks [indx].len ; + + return SFE_NO_ERROR ; +} /* wav_get_chunk_size */ + +static int +wav_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) +{ int indx ; + sf_count_t pos ; + + if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) + return SFE_UNKNOWN_CHUNK ; + + if (chunk_info->data == NULL) + return SFE_BAD_CHUNK_DATA_PTR ; + + chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; + memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; + + pos = psf_ftell (psf) ; + psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; + psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; + psf_fseek (psf, pos, SEEK_SET) ; + + return SFE_NO_ERROR ; +} /* wav_get_chunk_data */ diff --git a/libs/libsndfile/src/wav_w64.c b/libs/libsndfile/src/wav_w64.c index 4f540339a4..cf0d3ef2b1 100644 --- a/libs/libsndfile/src/wav_w64.c +++ b/libs/libsndfile/src/wav_w64.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** Copyright (C) 2004-2005 David Viens ** ** This program is free software; you can redistribute it and/or modify @@ -72,6 +72,32 @@ static const EXT_SUBFORMAT MSGUID_SUBTYPE_PVOCEX = } ; #endif +/* This stores which bit in dwChannelMask maps to which channel */ +static const struct chanmap_s +{ int id ; + const char * name ; +} channel_mask_bits [] = +{ /* WAVEFORMATEXTENSIBLE doesn't distuingish FRONT_LEFT from LEFT */ + { SF_CHANNEL_MAP_LEFT, "L" }, + { SF_CHANNEL_MAP_RIGHT, "R" }, + { SF_CHANNEL_MAP_CENTER, "C" }, + { SF_CHANNEL_MAP_LFE, "LFE" }, + { SF_CHANNEL_MAP_REAR_LEFT, "Ls" }, + { SF_CHANNEL_MAP_REAR_RIGHT, "Rs" }, + { SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, "Lc" }, + { SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, "Rc" }, + { SF_CHANNEL_MAP_REAR_CENTER, "Cs" }, + { SF_CHANNEL_MAP_SIDE_LEFT, "Sl" }, + { SF_CHANNEL_MAP_SIDE_RIGHT, "Sr" }, + { SF_CHANNEL_MAP_TOP_CENTER, "Tc" }, + { SF_CHANNEL_MAP_TOP_FRONT_LEFT, "Tfl" }, + { SF_CHANNEL_MAP_TOP_FRONT_CENTER, "Tfc" }, + { SF_CHANNEL_MAP_TOP_FRONT_RIGHT, "Tfr" }, + { SF_CHANNEL_MAP_TOP_REAR_LEFT, "Trl" }, + { SF_CHANNEL_MAP_TOP_REAR_CENTER, "Trc" }, + { SF_CHANNEL_MAP_TOP_REAR_RIGHT, "Trr" }, +} ; + /*------------------------------------------------------------------------------ * Private static functions. */ @@ -109,12 +135,15 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) psf_log_printf (psf, " Format : 0x%X => %s\n", wav_fmt->format, wav_w64_format_str (wav_fmt->format)) ; psf_log_printf (psf, " Channels : %d\n", wav_fmt->min.channels) ; psf_log_printf (psf, " Sample Rate : %d\n", wav_fmt->min.samplerate) ; - psf_log_printf (psf, " Block Align : %d\n", wav_fmt->min.blockalign) ; - if (wav_fmt->min.blockalign == 0) - { psf_log_printf (psf, "*** Error : wav_fmt->min.blockalign should not be zero.\n") ; - return SFE_INTERNAL ; - } ; + if (wav_fmt->format == WAVE_FORMAT_PCM && wav_fmt->min.blockalign == 0 + && wav_fmt->min.bitwidth > 0 && wav_fmt->min.channels > 0) + { wav_fmt->min.blockalign = wav_fmt->min.bitwidth / 8 + (wav_fmt->min.bitwidth % 8 > 0 ? 1 : 0) ; + wav_fmt->min.blockalign *= wav_fmt->min.channels ; + psf_log_printf (psf, " Block Align : 0 (should be %d)\n", wav_fmt->min.blockalign) ; + } + else + psf_log_printf (psf, " Block Align : %d\n", wav_fmt->min.blockalign) ; if (wav_fmt->format == WAVE_FORMAT_PCM && wav_fmt->min.bitwidth == 24 && wav_fmt->min.blockalign == 4 * wav_fmt->min.channels) @@ -195,7 +224,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) else psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->ima.bytespersec) ; - psf->bytewidth = 2 ; psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->ima.extrabytes) ; psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->ima.samplesperblock) ; break ; @@ -218,8 +246,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) else psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ; - - psf->bytewidth = 2 ; psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->msadpcm.extrabytes) ; psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->msadpcm.samplesperblock) ; if (wav_fmt->msadpcm.numcoeffs > ARRAY_LEN (wav_fmt->msadpcm.coeffs)) @@ -231,10 +257,12 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) psf_log_printf (psf, " Index Coeffs1 Coeffs2\n") ; for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++) - { bytesread += - psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ; - snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ; - psf_log_printf (psf, psf->u.cbuf) ; + { char buffer [128] ; + + bytesread += + psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ; + snprintf (buffer, sizeof (buffer), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ; + psf_log_printf (psf, buffer) ; } ; break ; @@ -254,7 +282,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) else psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->gsm610.bytespersec) ; - psf->bytewidth = 2 ; psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->gsm610.extrabytes) ; psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->gsm610.samplesperblock) ; break ; @@ -270,11 +297,51 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) &(wav_fmt->ext.channelmask)) ; psf_log_printf (psf, " Valid Bits : %d\n", wav_fmt->ext.validbits) ; - psf_log_printf (psf, " Channel Mask : 0x%X\n", wav_fmt->ext.channelmask) ; - bytesread += - psf_binheader_readf (psf, "422", &(wav_fmt->ext.esf.esf_field1), &(wav_fmt->ext.esf.esf_field2), - &(wav_fmt->ext.esf.esf_field3)) ; + if (wav_fmt->ext.channelmask == 0) + psf_log_printf (psf, " Channel Mask : 0x0 (should not be zero)\n") ; + else + { char buffer [512] ; + unsigned bit ; + + wpriv->wavex_channelmask = wav_fmt->ext.channelmask ; + + /* It's probably wise to ignore the channel mask if it is all zero */ + free (psf->channel_map) ; + + if ((psf->channel_map = calloc (psf->sf.channels, sizeof (psf->channel_map [0]))) == NULL) + return SFE_MALLOC_FAILED ; + + /* Terminate the buffer we're going to append_snprintf into. */ + buffer [0] = 0 ; + + for (bit = k = 0 ; bit < ARRAY_LEN (channel_mask_bits) ; bit++) + { + if (wav_fmt->ext.channelmask & (1 << bit)) + { if (k > psf->sf.channels) + { psf_log_printf (psf, "*** More channel map bits than there are channels.\n") ; + break ; + } ; + + psf->channel_map [k++] = channel_mask_bits [bit].id ; + append_snprintf (buffer, sizeof (buffer), "%s, ", channel_mask_bits [bit].name) ; + } ; + } ; + + /* Remove trailing ", ". */ + bit = strlen (buffer) ; + buffer [--bit] = 0 ; + buffer [--bit] = 0 ; + + if (k != psf->sf.channels) + { psf_log_printf (psf, " Channel Mask : 0x%X\n", wav_fmt->ext.channelmask) ; + psf_log_printf (psf, "*** Less channel map bits than there are channels.\n") ; + } + else + psf_log_printf (psf, " Channel Mask : 0x%X (%s)\n", wav_fmt->ext.channelmask, buffer) ; + } ; + + bytesread += psf_binheader_readf (psf, "422", &(wav_fmt->ext.esf.esf_field1), &(wav_fmt->ext.esf.esf_field2), &(wav_fmt->ext.esf.esf_field3)) ; /* compare the esf_fields with each known GUID? and print? */ psf_log_printf (psf, " Subformat\n") ; @@ -368,9 +435,38 @@ wavex_write_guid (SF_PRIVATE *psf, const EXT_SUBFORMAT * subformat) subformat->esf_field4, make_size_t (8)) ; } /* wavex_write_guid */ + +int +wavex_gen_channel_mask (const int *chan_map, int channels) +{ int chan, mask = 0, bit = -1, last_bit = -1 ; + + if (chan_map == NULL) + return 0 ; + + for (chan = 0 ; chan < channels ; chan ++) + { int k ; + + for (k = bit + 1 ; k < ARRAY_LEN (channel_mask_bits) ; k++) + if (chan_map [chan] == channel_mask_bits [k].id) + { bit = k ; + break ; + } ; + + /* Check for bad sequence. */ + if (bit <= last_bit) + return 0 ; + + mask += 1 << bit ; + last_bit = bit ; + } ; + + return mask ; +} /* wavex_gen_channel_mask */ + void wav_w64_analyze (SF_PRIVATE *psf) -{ AUDIO_DETECT ad ; +{ unsigned char buffer [4096] ; + AUDIO_DETECT ad ; int format = 0 ; if (psf->is_pipe) @@ -387,8 +483,8 @@ wav_w64_analyze (SF_PRIVATE *psf) psf_fseek (psf, 3 * 4 * 50, SEEK_SET) ; - while (psf_fread (psf->u.ucbuf, 1, 4096, psf) == 4096) - { format = audio_detect (psf, &ad, psf->u.ucbuf, 4096) ; + while (psf_fread (buffer, 1, sizeof (buffer), psf) == sizeof (buffer)) + { format = audio_detect (psf, &ad, buffer, sizeof (buffer)) ; if (format != 0) break ; } ; diff --git a/libs/libsndfile/src/wav_w64.h b/libs/libsndfile/src/wav_w64.h index bcc86e8e62..7e180801a6 100644 --- a/libs/libsndfile/src/wav_w64.h +++ b/libs/libsndfile/src/wav_w64.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -28,9 +28,9 @@ enum { - /* keep sorted for wav_w64_format_str() */ + /* keep sorted for wav_w64_format_str() */ WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */ - WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */ + WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */ WAVE_FORMAT_MS_ADPCM = 0x0002, /* Microsoft ADPCM */ WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* Micrososft 32 bit float format */ WAVE_FORMAT_VSELP = 0x0004, /* Compaq Computer Corporation */ @@ -259,6 +259,7 @@ typedef struct typedef struct { /* For ambisonic commands */ int wavex_ambisonic ; + unsigned wavex_channelmask ; /* Set to true when 'fmt ' chunk is ambiguous.*/ int fmt_is_broken ; @@ -285,6 +286,13 @@ char const* wav_w64_format_str (int k) ; int wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) ; void wavex_write_guid (SF_PRIVATE *psf, const EXT_SUBFORMAT * subformat) ; void wav_w64_analyze (SF_PRIVATE *psf) ; +int wavex_gen_channel_mask (const int *chan_map, int channels) ; + +int wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize) ; +int wav_write_bext_chunk (SF_PRIVATE *psf) ; + +int wav_read_cart_chunk (SF_PRIVATE *psf, unsigned int chunksize) ; +int wav_write_cart_chunk (SF_PRIVATE *psf) ; #endif diff --git a/libs/libsndfile/src/windows.c b/libs/libsndfile/src/windows.c new file mode 100644 index 0000000000..387afddafe --- /dev/null +++ b/libs/libsndfile/src/windows.c @@ -0,0 +1,93 @@ +/* +** Copyright (C) 2009-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +** This needs to be a separate file so that we don't have to include +** elsewhere (too many symbol clashes). +*/ + + +#include "sfconfig.h" + +#if OS_IS_WIN32 +#include + +#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 +#include "sndfile.h" +#include "common.h" + +extern int sf_errno ; + +static void copy_filename (SF_PRIVATE * psf, LPCWSTR wpath) ; + +SNDFILE* +sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) +{ SF_PRIVATE *psf ; + char utf8name [512] ; + + if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL) + { sf_errno = SFE_MALLOC_FAILED ; + return NULL ; + } ; + + memset (psf, 0, sizeof (SF_PRIVATE)) ; + psf_init_files (psf) ; + + if (WideCharToMultiByte (CP_UTF8, 0, wpath, -1, utf8name, sizeof (utf8name), NULL, NULL) == 0) + psf->file.path.wc [0] = 0 ; + + psf_log_printf (psf, "File : '%s' (utf-8 converted from ucs-2)\n", utf8name) ; + + copy_filename (psf, wpath) ; + psf->file.use_wchar = SF_TRUE ; + psf->file.mode = mode ; + + psf->error = psf_fopen (psf) ; + + return psf_open_file (psf, sfinfo) ; +} /* sf_wchar_open */ + + +static void +copy_filename (SF_PRIVATE *psf, LPCWSTR wpath) +{ const wchar_t *cwcptr ; + wchar_t *wcptr ; + + wcsncpy (psf->file.path.wc, wpath, ARRAY_LEN (psf->file.path.wc)) ; + psf->file.path.wc [ARRAY_LEN (psf->file.path.wc) - 1] = 0 ; + if ((cwcptr = wcsrchr (wpath, '/')) || (cwcptr = wcsrchr (wpath, '\\'))) + cwcptr ++ ; + else + cwcptr = wpath ; + + wcsncpy (psf->file.name.wc, cwcptr, ARRAY_LEN (psf->file.name.wc)) ; + psf->file.name.wc [ARRAY_LEN (psf->file.name.wc) - 1] = 0 ; + + /* Now grab the directory. */ + wcsncpy (psf->file.dir.wc, wpath, ARRAY_LEN (psf->file.dir.wc)) ; + psf->file.dir.wc [ARRAY_LEN (psf->file.dir.wc) - 1] = 0 ; + + if ((wcptr = wcsrchr (psf->file.dir.wc, '/')) || (wcptr = wcsrchr (psf->file.dir.wc, '\\'))) + wcptr [1] = 0 ; + else + psf->file.dir.wc [0] = 0 ; + + return ; +} /* copy_filename */ + +#endif diff --git a/libs/libsndfile/src/wve.c b/libs/libsndfile/src/wve.c index d539347c0f..c13e7ab9b7 100644 --- a/libs/libsndfile/src/wve.c +++ b/libs/libsndfile/src/wve.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** Copyright (C) 2007 Reuben Thomas ** ** This program is free software; you can redistribute it and/or modify @@ -58,12 +58,12 @@ wve_open (SF_PRIVATE *psf) if (psf->is_pipe) return SFE_WVE_NO_PIPE ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = wve_read_header (psf))) return error ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE) return SFE_BAD_OPEN_FORMAT ; @@ -198,7 +198,7 @@ wve_write_header (SF_PRIVATE *psf, int calc_length) static int wve_close (SF_PRIVATE *psf) { - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { /* Now we know for certain the length of the file we can re-write ** the header. */ diff --git a/libs/libsndfile/src/xi.c b/libs/libsndfile/src/xi.c index d1de796578..fc442d1c3a 100644 --- a/libs/libsndfile/src/xi.c +++ b/libs/libsndfile/src/xi.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -75,14 +75,14 @@ xi_open (SF_PRIVATE *psf) psf->codec_data = pxi ; - if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0)) + if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) { if ((error = xi_read_header (psf))) return error ; } ; subformat = SF_CODEC (psf->sf.format) ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_XI) return SFE_BAD_OPEN_FORMAT ; @@ -163,7 +163,7 @@ dpcm_init (SF_PRIVATE *psf) psf->blockwidth = psf->bytewidth * psf->sf.channels ; - if (psf->mode == SFM_READ || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) { switch (psf->bytewidth) { case 1 : psf->read_short = dpcm_read_dsc2s ; @@ -183,7 +183,7 @@ dpcm_init (SF_PRIVATE *psf) } ; } ; - if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR) + if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) { switch (psf->bytewidth) { case 1 : psf->write_short = dpcm_write_s2dsc ; @@ -216,7 +216,8 @@ dpcm_init (SF_PRIVATE *psf) static sf_count_t dpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int total, bufferlen, len ; if ((pxi = psf->codec_data) == NULL) @@ -248,18 +249,18 @@ dpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DPCM_16) { total = offset ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (total > 0) { len = (total > bufferlen) ? bufferlen : total ; - total -= dpcm_read_dles2s (psf, psf->u.sbuf, len) ; + total -= dpcm_read_dles2s (psf, ubuf.sbuf, len) ; } ; } else { total = offset ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (total > 0) { len = (total > bufferlen) ? bufferlen : total ; - total -= dpcm_read_dsc2s (psf, psf->u.sbuf, len) ; + total -= dpcm_read_dsc2s (psf, ubuf.sbuf, len) ; } ; } ; @@ -351,11 +352,19 @@ xi_read_header (SF_PRIVATE *psf) return SFE_XI_BAD_HEADER ; buffer [22] = 0 ; + for (k = 21 ; k >= 0 && buffer [k] == ' ' ; k --) + buffer [k] = 0 ; + psf_log_printf (psf, "Extended Instrument : %s\n", buffer) ; + psf_store_string (psf, SF_STR_TITLE, buffer) ; psf_binheader_readf (psf, "be2", buffer, 20, &version) ; buffer [19] = 0 ; + for (k = 18 ; k >= 0 && buffer [k] == ' ' ; k --) + buffer [k] = 0 ; + psf_log_printf (psf, "Software : %s\nVersion : %d.%02d\n", buffer, version / 256, version % 256) ; + psf_store_string (psf, SF_STR_SOFTWARE, buffer) ; /* Jump note numbers (96), volume envelope (48), pan envelope (48), ** volume points (1), pan points (1) @@ -387,6 +396,7 @@ xi_read_header (SF_PRIVATE *psf) if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) return SFE_MALLOC_FAILED ; + psf->instrument->basenote = 0 ; /* Log all data for each sample. */ for (k = 0 ; k < sample_count ; k++) { psf_binheader_readf (psf, "e444", &(sample_sizes [k]), &loop_begin, &loop_end) ; @@ -417,6 +427,14 @@ xi_read_header (SF_PRIVATE *psf) psf_log_printf (psf, " pan : %u\n note : %d\n namelen : %d\n", buffer [3] & 0xFF, buffer [4], buffer [5]) ; + psf->instrument->basenote = buffer [4] ; + if (buffer [2] & 1) + { psf->instrument->loop_count = 1 ; + psf->instrument->loops [0].mode = (buffer [2] & 2) ? SF_LOOP_ALTERNATING : SF_LOOP_FORWARD ; + psf->instrument->loops [0].start = loop_begin ; + psf->instrument->loops [0].end = loop_end ; + } ; + if (k != 0) continue ; @@ -469,7 +487,6 @@ xi_read_header (SF_PRIVATE *psf) if (! psf->sf.frames && psf->blockwidth) psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - psf->instrument->basenote = 0 ; psf->instrument->gain = 1 ; psf->instrument->velocity_lo = psf->instrument->key_lo = 0 ; psf->instrument->velocity_hi = psf->instrument->key_hi = 127 ; @@ -492,20 +509,21 @@ static void dles2d_array (XI_PRIVATE *pxi, short *src, int count, double *dest, static sf_count_t dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2s_array (pxi, psf->u.scbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + dsc2s_array (pxi, ubuf.scbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -517,20 +535,21 @@ dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2i_array (pxi, psf->u.scbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + dsc2i_array (pxi, ubuf.scbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -542,7 +561,8 @@ dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; @@ -552,13 +572,13 @@ dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2f_array (pxi, psf->u.scbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + dsc2f_array (pxi, ubuf.scbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -570,7 +590,8 @@ dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; @@ -580,13 +601,13 @@ dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2d_array (pxi, psf->u.scbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; + dsc2d_array (pxi, ubuf.scbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -601,20 +622,21 @@ dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - dles2s_array (pxi, psf->u.sbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + dles2s_array (pxi, ubuf.sbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -626,20 +648,21 @@ dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) static sf_count_t dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - dles2i_array (pxi, psf->u.sbuf, readcount, ptr + total) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + dles2i_array (pxi, ubuf.sbuf, readcount, ptr + total) ; total += readcount ; if (readcount < bufferlen) break ; @@ -651,7 +674,8 @@ dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) static sf_count_t dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; float normfact ; @@ -661,13 +685,13 @@ dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - dles2f_array (pxi, psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + dles2f_array (pxi, ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -679,7 +703,8 @@ dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) static sf_count_t dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, readcount ; sf_count_t total = 0 ; double normfact ; @@ -689,13 +714,13 @@ dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - readcount = psf_fread (psf->u.sbuf, sizeof (short), bufferlen, psf) ; - dles2d_array (pxi, psf->u.sbuf, readcount, ptr + total, normfact) ; + readcount = psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; + dles2d_array (pxi, ubuf.sbuf, readcount, ptr + total, normfact) ; total += readcount ; if (readcount < bufferlen) break ; @@ -721,20 +746,21 @@ static void d2dles_array (XI_PRIVATE *pxi, const double *src, short *dest, int c static sf_count_t dpcm_write_s2dsc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2dsc_array (pxi, ptr + total, psf->u.scbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + s2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -746,20 +772,21 @@ dpcm_write_s2dsc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t dpcm_write_i2dsc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2dsc_array (pxi, ptr + total, psf->u.scbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + i2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -771,7 +798,8 @@ dpcm_write_i2dsc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t dpcm_write_f2dsc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; float normfact ; @@ -781,13 +809,13 @@ dpcm_write_f2dsc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7F) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2dsc_array (pxi, ptr + total, psf->u.scbuf, bufferlen, normfact) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + f2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen, normfact) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -799,7 +827,8 @@ dpcm_write_f2dsc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t dpcm_write_d2dsc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; double normfact ; @@ -809,13 +838,13 @@ dpcm_write_d2dsc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7F) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.ucbuf) ; + bufferlen = ARRAY_LEN (ubuf.ucbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2dsc_array (pxi, ptr + total, psf->u.scbuf, bufferlen, normfact) ; - writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ; + d2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen, normfact) ; + writecount = psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -828,20 +857,21 @@ dpcm_write_d2dsc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) static sf_count_t dpcm_write_s2dles (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - s2dles_array (pxi, ptr + total, psf->u.sbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + s2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -853,20 +883,21 @@ dpcm_write_s2dles (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t dpcm_write_i2dles (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; if ((pxi = psf->codec_data) == NULL) return 0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - i2dles_array (pxi, ptr + total, psf->u.sbuf, bufferlen) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + i2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -878,7 +909,8 @@ dpcm_write_i2dles (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t dpcm_write_f2dles (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; float normfact ; @@ -888,13 +920,13 @@ dpcm_write_f2dles (SF_PRIVATE *psf, const float *ptr, sf_count_t len) normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - f2dles_array (pxi, ptr + total, psf->u.sbuf, bufferlen, normfact) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + f2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen, normfact) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -906,7 +938,8 @@ dpcm_write_f2dles (SF_PRIVATE *psf, const float *ptr, sf_count_t len) static sf_count_t dpcm_write_d2dles (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ XI_PRIVATE *pxi ; +{ BUF_UNION ubuf ; + XI_PRIVATE *pxi ; int bufferlen, writecount ; sf_count_t total = 0 ; double normfact ; @@ -916,13 +949,13 @@ dpcm_write_d2dles (SF_PRIVATE *psf, const double *ptr, sf_count_t len) normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - bufferlen = ARRAY_LEN (psf->u.sbuf) ; + bufferlen = ARRAY_LEN (ubuf.sbuf) ; while (len > 0) { if (len < bufferlen) bufferlen = (int) len ; - d2dles_array (pxi, ptr + total, psf->u.sbuf, bufferlen, normfact) ; - writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ; + d2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen, normfact) ; + writecount = psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; total += writecount ; if (writecount < bufferlen) break ; @@ -1074,7 +1107,7 @@ dles2s_array (XI_PRIVATE *pxi, short *src, int count, short *dest) last_val = pxi->last_16 ; for (k = 0 ; k < count ; k++) - { last_val += LES2H_SHORT (src [k]) ; + { last_val += LE2H_16 (src [k]) ; dest [k] = last_val ; } ; @@ -1089,7 +1122,7 @@ dles2i_array (XI_PRIVATE *pxi, short *src, int count, int *dest) last_val = pxi->last_16 ; for (k = 0 ; k < count ; k++) - { last_val += LES2H_SHORT (src [k]) ; + { last_val += LE2H_16 (src [k]) ; dest [k] = last_val << 16 ; } ; @@ -1104,7 +1137,7 @@ dles2f_array (XI_PRIVATE *pxi, short *src, int count, float *dest, float normfac last_val = pxi->last_16 ; for (k = 0 ; k < count ; k++) - { last_val += LES2H_SHORT (src [k]) ; + { last_val += LE2H_16 (src [k]) ; dest [k] = last_val * normfact ; } ; @@ -1119,7 +1152,7 @@ dles2d_array (XI_PRIVATE *pxi, short *src, int count, double *dest, double normf last_val = pxi->last_16 ; for (k = 0 ; k < count ; k++) - { last_val += LES2H_SHORT (src [k]) ; + { last_val += LE2H_16 (src [k]) ; dest [k] = last_val * normfact ; } ; @@ -1138,7 +1171,7 @@ s2dles_array (XI_PRIVATE *pxi, const short *src, short *dest, int count) for (k = 0 ; k < count ; k++) { diff = src [k] - last_val ; - dest [k] = LES2H_SHORT (diff) ; + dest [k] = LE2H_16 (diff) ; last_val = src [k] ; } ; @@ -1154,7 +1187,7 @@ i2dles_array (XI_PRIVATE *pxi, const int *src, short *dest, int count) for (k = 0 ; k < count ; k++) { diff = (src [k] >> 16) - last_val ; - dest [k] = LES2H_SHORT (diff) ; + dest [k] = LE2H_16 (diff) ; last_val = src [k] >> 16 ; } ; @@ -1171,7 +1204,7 @@ f2dles_array (XI_PRIVATE *pxi, const float *src, short *dest, int count, float n for (k = 0 ; k < count ; k++) { current = lrintf (src [k] * normfact) ; diff = current - last_val ; - dest [k] = LES2H_SHORT (diff) ; + dest [k] = LE2H_16 (diff) ; last_val = current ; } ; @@ -1188,7 +1221,7 @@ d2dles_array (XI_PRIVATE *pxi, const double *src, short *dest, int count, double for (k = 0 ; k < count ; k++) { current = lrint (src [k] * normfact) ; diff = current - last_val ; - dest [k] = LES2H_SHORT (diff) ; + dest [k] = LE2H_16 (diff) ; last_val = current ; } ; diff --git a/libs/libsndfile/tests/Makefile.am b/libs/libsndfile/tests/Makefile.am index 59264e9888..089046bb81 100644 --- a/libs/libsndfile/tests/Makefile.am +++ b/libs/libsndfile/tests/Makefile.am @@ -6,16 +6,17 @@ else CPP_TEST = cpp_test endif -INCLUDES = -I$(top_srcdir)/src +AM_CPPFLAGS = -I$(top_srcdir)/src -noinst_PROGRAMS = sfversion floating_point_test write_read_test \ +check_PROGRAMS = sfversion floating_point_test write_read_test \ lossy_comp_test error_test ulaw_test alaw_test dwvw_test \ peak_chunk_test command_test stdin_test stdout_test stdio_test \ pcm_test headerless_test pipe_test benchmark header_test misc_test \ - raw_test string_test multi_file_test dither_test \ + raw_test string_test multi_file_test dither_test chunk_test \ scale_clip_test win32_test fix_this aiff_rw_test virtual_io_test \ - locale_test largefile_test win32_ordinal_test ogg_test vorbis_test \ - checksum_test external_libs_test $(CPP_TEST) + locale_test largefile_test win32_ordinal_test ogg_test compression_size_test \ + checksum_test external_libs_test rdwr_test format_check_test $(CPP_TEST) \ + channel_test noinst_HEADERS = dft_cmp.h utils.h generate.h @@ -25,11 +26,38 @@ autogen_sources = write_read_test.tpl write_read_test.def \ utils.tpl utils.def \ scale_clip_test.tpl scale_clip_test.def \ pipe_test.tpl pipe_test.def \ + rdwr_test.tpl rdwr_test.def \ floating_point_test.tpl floating_point_test.def \ benchmark.tpl benchmark.def EXTRA_DIST = $(autogen_sources) +CLEANFILES = *~ *.exe + +#=============================================================================== +# If we're cross compiling from Linux to Windows and running the test suite +# under Wine, we need a symbolic link to the generated libsndfile DLL. + +if LINUX_MINGW_CROSS_TEST + +$(check_PROGRAMS) : libsndfile-1.dll + +libsndfile-1.dll : + ln -s $(top_builddir)/src/.libs/$@ $@ + +clean-local : + -rm -f libsndfile-1.dll + +endif + +#=============================================================================== + +check: test_wrapper.sh + sh test_wrapper.sh + +# Need this target to force building of test programs. +checkprograms : $(check_PROGRAMS) + #=============================================================================== sfversion_SOURCES = sfversion.c @@ -101,6 +129,9 @@ string_test_LDADD = $(top_builddir)/src/libsndfile.la dither_test_SOURCES = dither_test.c utils.c dither_test_LDADD = $(top_builddir)/src/libsndfile.la +chunk_test_SOURCES = chunk_test.c utils.c +chunk_test_LDADD = $(top_builddir)/src/libsndfile.la + multi_file_test_SOURCES = multi_file_test.c utils.c multi_file_test_LDADD = $(top_builddir)/src/libsndfile.la @@ -110,11 +141,15 @@ virtual_io_test_LDADD = $(top_builddir)/src/libsndfile.la ogg_test_SOURCES = ogg_test.c utils.c ogg_test_LDADD = $(top_builddir)/src/libsndfile.la -vorbis_test_SOURCES = vorbis_test.c utils.c -vorbis_test_LDADD = $(top_builddir)/src/libsndfile.la +compression_size_test_SOURCES = compression_size_test.c utils.c +compression_size_test_LDADD = $(top_builddir)/src/libsndfile.la + +rdwr_test_SOURCES = rdwr_test.c utils.c +rdwr_test_LDADD = $(top_builddir)/src/libsndfile.la win32_test_SOURCES = win32_test.c -win32_test_LDADD = +# Link lib here so that generating the testsuite tarball works correctly. +win32_test_LDADD = $(top_builddir)/src/libsndfile.la win32_ordinal_test_SOURCES = win32_ordinal_test.c utils.c win32_ordinal_test_LDADD = $(top_builddir)/src/libsndfile.la @@ -122,6 +157,12 @@ win32_ordinal_test_LDADD = $(top_builddir)/src/libsndfile.la external_libs_test_SOURCES = external_libs_test.c utils.c external_libs_test_LDADD = $(top_builddir)/src/libsndfile.la +format_check_test_SOURCES = format_check_test.c utils.c +format_check_test_LDADD = $(top_builddir)/src/libsndfile.la + +channel_test_SOURCES = channel_test.c utils.c +channel_test_LDADD = $(top_builddir)/src/libsndfile.la + cpp_test_SOURCES = cpp_test.cc utils.c cpp_test_LDADD = $(top_builddir)/src/libsndfile.la @@ -145,51 +186,33 @@ scale_clip_test_LDADD = $(top_builddir)/src/libsndfile.la #=============================================================================== write_read_test.c: write_read_test.def write_read_test.tpl - autogen --writable write_read_test.def + cd $(srcdir) && autogen --writable write_read_test.def && cd $(abs_builddir) pcm_test.c: pcm_test.def pcm_test.tpl - autogen --writable pcm_test.def + cd $(srcdir) && autogen --writable pcm_test.def && cd $(abs_builddir) header_test.c: header_test.def header_test.tpl - autogen --writable header_test.def + cd $(srcdir) && autogen --writable header_test.def && cd $(abs_builddir) utils.c utils.h : utils.def utils.tpl - autogen --writable utils.def + cd $(srcdir) && autogen --writable utils.def && cd $(abs_builddir) scale_clip_test.c: scale_clip_test.def scale_clip_test.tpl - autogen --writable scale_clip_test.def + cd $(srcdir) && autogen --writable scale_clip_test.def && cd $(abs_builddir) pipe_test.c: pipe_test.def pipe_test.tpl - autogen --writable pipe_test.def + cd $(srcdir) && autogen --writable pipe_test.def && cd $(abs_builddir) + +rdwr_test.c: rdwr_test.def rdwr_test.tpl + cd $(srcdir) && autogen --writable rdwr_test.def && cd $(abs_builddir) floating_point_test.c: floating_point_test.def floating_point_test.tpl - autogen --writable floating_point_test.def + cd $(srcdir) && autogen --writable floating_point_test.def && cd $(abs_builddir) benchmark.c: benchmark.def benchmark.tpl - autogen --writable benchmark.def + cd $(srcdir) && autogen --writable benchmark.def && cd $(abs_builddir) genfiles : write_read_test.c pcm_test.c header_test.c utils.c \ - scale_clip_test.c pipe_test.c floating_point_test.c benchmark.c + scale_clip_test.c pipe_test.c floating_point_test.c rdwr_test.c \ + benchmark.c -#=============================================================================== -# If we're cross compiling from Linux to Windows and running the test suite -# under Wine, we need a symbolic link to the generated libsndfile DLL. - -if LINUX_MINGW_CROSS_TEST - -$(noinst_PROGRAMS) : libsndfile-1.dll - -libsndfile-1.dll : - ln -s $(top_builddir)/src/.libs/$@ $@ - -clean-local : - -rm -f libsndfile-1.dll - -endif - -#=============================================================================== - -check: $(noinst_PROGRAMS) test_wrapper.sh - sh test_wrapper.sh - - diff --git a/libs/libsndfile/tests/aiff_rw_test.c b/libs/libsndfile/tests/aiff_rw_test.c index 92f8222403..43d34dbc8f 100644 --- a/libs/libsndfile/tests/aiff_rw_test.c +++ b/libs/libsndfile/tests/aiff_rw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -17,15 +17,17 @@ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include "utils.h" +#include + +#include "utils.h" static unsigned char aifc_data [] = @@ -152,8 +154,8 @@ rw_test (const char *filename) } ; if (sfinfo_rd.frames != sfinfo_rw.frames) - { printf ("\n\nLine %d : frame count mismatch (rd %ld != rw %ld).\n\n", __LINE__, - SF_COUNT_TO_LONG (sfinfo_rd.frames), SF_COUNT_TO_LONG (sfinfo_rw.frames)) ; + { printf ("\n\nLine %d : frame count mismatch (rd %" PRId64 " != rw %" PRId64 ").\n\n", __LINE__, + sfinfo_rd.frames, sfinfo_rw.frames) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/alaw_test.c b/libs/libsndfile/tests/alaw_test.c index 4bbb518a1a..6d71ffed98 100644 --- a/libs/libsndfile/tests/alaw_test.c +++ b/libs/libsndfile/tests/alaw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include #include +#include #if HAVE_UNISTD_H #include @@ -44,12 +45,11 @@ main (void) const char *filename ; int k ; + print_test_name ("alaw_test", "encoder") ; + filename = "test.raw" ; - sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW ; - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; + sf_info_setup (&sfinfo, SF_FORMAT_RAW | SF_FORMAT_ALAW, 44100, 1) ; if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) { printf ("sf_open_write failed with error : ") ; @@ -94,8 +94,9 @@ main (void) sf_close (file) ; - printf (" alaw_test : encoder ... ok\n") ; + puts ("ok") ; + print_test_name ("alaw_test", "decoder") ; /* Now generate a file containing all possible 8 bit encoded ** sample values and write it to disk as alaw encoded.frames. */ @@ -139,7 +140,7 @@ main (void) sf_close (file) ; - printf (" alaw_test : decoder ... ok\n") ; + puts ("ok") ; unlink (filename) ; @@ -188,48 +189,48 @@ unsigned char alaw_encode (int sample) 7, 7, 7, 7, 7, 7, 7, 7 } ; - int sign, exponent, mantissa ; - unsigned char Alawbyte ; + int sign, exponent, mantissa ; + unsigned char Alawbyte ; - /* Get the sample into sign-magnitude. */ - sign = ((~sample) >> 8) & 0x80 ; /* set aside the sign */ - if (sign == 0) + /* Get the sample into sign-magnitude. */ + sign = ((~sample) >> 8) & 0x80 ; /* set aside the sign */ + if (sign == 0) sample = -sample ; /* get magnitude */ - if (sample > ACLIP) + if (sample > ACLIP) sample = ACLIP ; /* clip the magnitude */ - /* Convert from 16 bit linear to ulaw. */ - if (sample >= 256) + /* Convert from 16 bit linear to ulaw. */ + if (sample >= 256) { exponent = exp_lut [(sample >> 8) & 0x7F] ; - mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F ; + mantissa = (sample >> (exponent + 3)) & 0x0F ; Alawbyte = ((exponent << 4) | mantissa) ; } - else + else Alawbyte = (sample >> 4) ; Alawbyte ^= (sign ^ 0x55) ; - return Alawbyte ; + return Alawbyte ; } /* alaw_encode */ static int alaw_decode (unsigned int Alawbyte) { static int exp_lut [8] = { 0, 264, 528, 1056, 2112, 4224, 8448, 16896 } ; - int sign, exponent, mantissa, sample ; + int sign, exponent, mantissa, sample ; - Alawbyte ^= 0x55 ; - sign = (Alawbyte & 0x80) ; - Alawbyte &= 0x7f ; /* get magnitude */ - if (Alawbyte >= 16) - { exponent = (Alawbyte >> 4 ) & 0x07 ; + Alawbyte ^= 0x55 ; + sign = (Alawbyte & 0x80) ; + Alawbyte &= 0x7f ; /* get magnitude */ + if (Alawbyte >= 16) + { exponent = (Alawbyte >> 4) & 0x07 ; mantissa = Alawbyte & 0x0F ; - sample = exp_lut [exponent] + (mantissa << ( exponent + 3 )) ; + sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ; } - else + else sample = (Alawbyte << 4) + 8 ; - if (sign == 0) + if (sign == 0) sample = -sample ; - return sample ; + return sample ; } /* alaw_decode */ diff --git a/libs/libsndfile/tests/benchmark-0.0.28 b/libs/libsndfile/tests/benchmark-0.0.28 new file mode 100644 index 0000000000..2d2b06f9bc --- /dev/null +++ b/libs/libsndfile/tests/benchmark-0.0.28 @@ -0,0 +1,40 @@ +erikd@coltrane > tests/benchmark +Benchmarking libsndfile-0.0.28 +------------------------------ +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 30660117 samples per sec + Raw read PCM_16 : 62788982 samples per sec + +Native endian I/O : + Write short to PCM_16 : 83.37% of raw write + Read short from PCM_16 : 83.17% of raw read + Write int to PCM_24 : 30.78% of raw write + Read int from PCM_24 : 32.96% of raw read + Write int to PCM_32 : 42.05% of raw write + Read int from PCM_32 : 41.11% of raw read + Write float to PCM_16 : 17.75% of raw write + Read float from PCM_16 : 43.27% of raw read + Write float to PCM_24 : 15.30% of raw write + Read float from PCM_24 : 28.09% of raw read + Write float to PCM_32 : 14.55% of raw write + Read float from PCM_32 : 34.65% of raw read + Write float to FLOAT : 28.98% of raw write + Read float from FLOAT : 56.71% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 43.39% of raw write + Read short from PCM_16 : 49.12% of raw read + Write int to PCM_24 : 29.65% of raw write + Read int from PCM_24 : 33.66% of raw read + Write int to PCM_32 : 19.62% of raw write + Read int from PCM_32 : 21.97% of raw read + Write float to PCM_16 : 17.63% of raw write + Read float from PCM_16 : 31.43% of raw read + Write float to PCM_24 : 14.91% of raw write + Read float from PCM_24 : 27.99% of raw read + Write float to PCM_32 : 13.69% of raw write + Read float from PCM_32 : 22.23% of raw read + Write float to FLOAT : 19.25% of raw write + Read float from FLOAT : 25.66% of raw read + diff --git a/libs/libsndfile/tests/benchmark-1.0.0 b/libs/libsndfile/tests/benchmark-1.0.0 new file mode 100644 index 0000000000..2922836419 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.0 @@ -0,0 +1,35 @@ +Benchmarking libsndfile-1.0.0 +----------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 31084269 samples per sec + Raw read PCM_16 : 63597065 samples per sec + +Native endian I/O : + Write short to PCM_16 : 83.19% of raw write + Read short from PCM_16 : 82.93% of raw read + Write int to PCM_24 : 31.12% of raw write + Read int from PCM_24 : 37.90% of raw read + Write float to PCM_16 : 37.00% of raw write + Read float from PCM_16 : 45.53% of raw read + Write float to PCM_24 : 29.08% of raw write + Read float from PCM_24 : 28.48% of raw read + Write float to PCM_32 : 22.08% of raw write + Read float from PCM_32 : 31.21% of raw read + Write float to FLOAT : 28.70% of raw write + Read float from FLOAT : 56.32% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 22.08% of raw write + Read short from PCM_16 : 23.20% of raw read + Write int to PCM_24 : 30.96% of raw write + Read int from PCM_24 : 37.76% of raw read + Write float to PCM_16 : 35.82% of raw write + Read float from PCM_16 : 22.61% of raw read + Write float to PCM_24 : 27.70% of raw write + Read float from PCM_24 : 28.37% of raw read + Write float to PCM_32 : 20.77% of raw write + Read float from PCM_32 : 23.46% of raw read + Write float to FLOAT : 15.03% of raw write + Read float from FLOAT : 15.43% of raw read + diff --git a/libs/libsndfile/tests/benchmark-1.0.0rc2 b/libs/libsndfile/tests/benchmark-1.0.0rc2 new file mode 100644 index 0000000000..770224672f --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.0rc2 @@ -0,0 +1,31 @@ +Benchmarking libsndfile-1.0.0rc2 +-------------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 31638069 samples per sec + Raw read PCM_16 : 62788982 samples per sec + +Native endian I/O : + Write short to PCM_16 : 82.37% of raw write + Read short from PCM_16 : 82.17% of raw read + Write int to PCM_24 : 30.80% of raw write + Read int from PCM_24 : 37.95% of raw read + Write float to PCM_16 : 36.22% of raw write + Read float from PCM_16 : 23.32% of raw read + Write float to PCM_24 : 28.41% of raw write + Read float from PCM_24 : 28.41% of raw read + Write float to FLOAT : 28.41% of raw write + Read float from FLOAT : 57.50% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 21.73% of raw write + Read short from PCM_16 : 23.37% of raw read + Write int to PCM_24 : 31.02% of raw write + Read int from PCM_24 : 38.24% of raw read + Write float to PCM_16 : 35.51% of raw write + Read float from PCM_16 : 19.16% of raw read + Write float to PCM_24 : 27.37% of raw write + Read float from PCM_24 : 28.74% of raw read + Write float to FLOAT : 15.11% of raw write + Read float from FLOAT : 15.60% of raw read + diff --git a/libs/libsndfile/tests/benchmark-1.0.18pre16-hendrix b/libs/libsndfile/tests/benchmark-1.0.18pre16-hendrix new file mode 100644 index 0000000000..951bc56d25 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.18pre16-hendrix @@ -0,0 +1,38 @@ +Benchmarking libsndfile-1.0.18pre15 +----------------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 103189885 samples per sec + Raw read PCM_16 : 660854036 samples per sec + +Native endian I/O : + Write short to PCM_16 : 95.08% of raw write + Read short from PCM_16 : 96.39% of raw read + Write int to PCM_24 : 54.55% of raw write + Read int from PCM_24 : 28.50% of raw read + Write int to PCM_32 : 46.97% of raw write + Read int from PCM_32 : 39.98% of raw read + Write float to PCM_16 : 60.85% of raw write + Read float from PCM_16 : 27.79% of raw read + Write float to PCM_24 : 46.23% of raw write + Read float from PCM_24 : 22.62% of raw read + Write float to PCM_32 : 35.38% of raw write + Read float from PCM_32 : 24.18% of raw read + Write float to FLOAT : 47.73% of raw write + Read float from FLOAT : 40.62% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 79.98% of raw write + Read short from PCM_16 : 49.27% of raw read + Write int to PCM_24 : 53.80% of raw write + Read int from PCM_24 : 28.50% of raw read + Write int to PCM_32 : 41.68% of raw write + Read int from PCM_32 : 25.89% of raw read + Write float to PCM_16 : 61.03% of raw write + Read float from PCM_16 : 27.74% of raw read + Write float to PCM_24 : 45.10% of raw write + Read float from PCM_24 : 22.43% of raw read + Write float to PCM_32 : 35.24% of raw write + Read float from PCM_32 : 22.37% of raw read + Write float to FLOAT : 42.01% of raw write + Read float from FLOAT : 28.98% of raw read diff --git a/libs/libsndfile/tests/benchmark-1.0.18pre16-mingus b/libs/libsndfile/tests/benchmark-1.0.18pre16-mingus new file mode 100644 index 0000000000..fa0584e149 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.18pre16-mingus @@ -0,0 +1,38 @@ +Benchmarking libsndfile-1.0.18pre15 +----------------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 178237074 samples per sec + Raw read PCM_16 : 368885269 samples per sec + +Native endian I/O : + Write short to PCM_16 : 98.84% of raw write + Read short from PCM_16 : 147.10% of raw read + Write int to PCM_24 : 33.74% of raw write + Read int from PCM_24 : 30.82% of raw read + Write int to PCM_32 : 48.34% of raw write + Read int from PCM_32 : 62.43% of raw read + Write float to PCM_16 : 41.86% of raw write + Read float from PCM_16 : 36.73% of raw read + Write float to PCM_24 : 28.38% of raw write + Read float from PCM_24 : 19.50% of raw read + Write float to PCM_32 : 23.68% of raw write + Read float from PCM_32 : 28.76% of raw read + Write float to FLOAT : 47.21% of raw write + Read float from FLOAT : 60.85% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 54.94% of raw write + Read short from PCM_16 : 59.03% of raw read + Write int to PCM_24 : 33.40% of raw write + Read int from PCM_24 : 31.98% of raw read + Write int to PCM_32 : 30.89% of raw write + Read int from PCM_32 : 33.68% of raw read + Write float to PCM_16 : 41.61% of raw write + Read float from PCM_16 : 26.76% of raw read + Write float to PCM_24 : 25.75% of raw write + Read float from PCM_24 : 19.84% of raw read + Write float to PCM_32 : 21.29% of raw write + Read float from PCM_32 : 21.78% of raw read + Write float to FLOAT : 30.82% of raw write + Read float from FLOAT : 35.04% of raw read diff --git a/libs/libsndfile/tests/benchmark-1.0.6pre10-coltrane b/libs/libsndfile/tests/benchmark-1.0.6pre10-coltrane new file mode 100644 index 0000000000..12f71a8a78 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.6pre10-coltrane @@ -0,0 +1,39 @@ +Benchmarking libsndfile-1.0.6pre10 +---------------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 28845961 samples per sec + Raw read PCM_16 : 63471874 samples per sec + +Native endian I/O : + Write short to PCM_16 : 86.21% of raw write + Read short from PCM_16 : 82.60% of raw read + Write int to PCM_24 : 34.89% of raw write + Read int from PCM_24 : 37.26% of raw read + Write int to PCM_32 : 43.36% of raw write + Read int from PCM_32 : 41.30% of raw read + Write float to PCM_16 : 43.02% of raw write + Read float from PCM_16 : 43.99% of raw read + Write float to PCM_24 : 32.72% of raw write + Read float from PCM_24 : 28.21% of raw read + Write float to PCM_32 : 25.92% of raw write + Read float from PCM_32 : 30.98% of raw read + Write float to FLOAT : 46.65% of raw write + Read float from FLOAT : 56.66% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 54.53% of raw write + Read short from PCM_16 : 56.32% of raw read + Write int to PCM_24 : 35.28% of raw write + Read int from PCM_24 : 37.33% of raw read + Write int to PCM_32 : 26.21% of raw write + Read int from PCM_32 : 23.51% of raw read + Write float to PCM_16 : 41.39% of raw write + Read float from PCM_16 : 23.56% of raw read + Write float to PCM_24 : 30.86% of raw write + Read float from PCM_24 : 28.27% of raw read + Write float to PCM_32 : 23.83% of raw write + Read float from PCM_32 : 20.54% of raw read + Write float to FLOAT : 27.26% of raw write + Read float from FLOAT : 29.04% of raw read + diff --git a/libs/libsndfile/tests/benchmark-1.0.6pre10-miles b/libs/libsndfile/tests/benchmark-1.0.6pre10-miles new file mode 100644 index 0000000000..fffdb84630 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-1.0.6pre10-miles @@ -0,0 +1,39 @@ +Benchmarking libsndfile-1.0.6pre10 +---------------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 40092612 samples per sec + Raw read PCM_16 : 42382563 samples per sec + +Native endian I/O : + Write short to PCM_16 : 61.90% of raw write + Read short from PCM_16 : 100.20% of raw read + Write int to PCM_24 : 28.69% of raw write + Read int from PCM_24 : 33.62% of raw read + Write int to PCM_32 : 31.14% of raw write + Read int from PCM_32 : 51.04% of raw read + Write float to PCM_16 : 25.57% of raw write + Read float from PCM_16 : 28.17% of raw read + Write float to PCM_24 : 23.59% of raw write + Read float from PCM_24 : 24.14% of raw read + Write float to PCM_32 : 18.00% of raw write + Read float from PCM_32 : 22.59% of raw read + Write float to FLOAT : 31.32% of raw write + Read float from FLOAT : 51.54% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 42.81% of raw write + Read short from PCM_16 : 54.58% of raw read + Write int to PCM_24 : 29.28% of raw write + Read int from PCM_24 : 33.43% of raw read + Write int to PCM_32 : 22.21% of raw write + Read int from PCM_32 : 27.24% of raw read + Write float to PCM_16 : 25.76% of raw write + Read float from PCM_16 : 26.84% of raw read + Write float to PCM_24 : 23.71% of raw write + Read float from PCM_24 : 24.10% of raw read + Write float to PCM_32 : 18.47% of raw write + Read float from PCM_32 : 21.45% of raw read + Write float to FLOAT : 22.46% of raw write + Read float from FLOAT : 29.72% of raw read + diff --git a/libs/libsndfile/tests/benchmark-latest-coltrane b/libs/libsndfile/tests/benchmark-latest-coltrane new file mode 100644 index 0000000000..97ce29a8a9 --- /dev/null +++ b/libs/libsndfile/tests/benchmark-latest-coltrane @@ -0,0 +1,75 @@ +erikd@coltrane > cat tests/benchmark-0.0.28 +Benchmarking libsndfile-0.0.28 +------------------------------ +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 31022959 samples per sec + Raw read PCM_16 : 63471874 samples per sec + +Native endian I/O : + Write short to PCM_16 : 83.19% of raw write + Read short from PCM_16 : 82.28% of raw read + Write int to PCM_24 : 30.81% of raw write + Read int from PCM_24 : 32.92% of raw read + Write float to PCM_16 : 17.70% of raw write + Read float from PCM_16 : 43.64% of raw read + Write float to PCM_24 : 15.09% of raw write + Read float from PCM_24 : 27.79% of raw read + Write float to PCM_32 : 14.32% of raw write + Read float from PCM_32 : 34.42% of raw read + Write float to FLOAT : 28.64% of raw write + Read float from FLOAT : 56.77% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 44.04% of raw write + Read short from PCM_16 : 49.46% of raw read + Write int to PCM_24 : 28.92% of raw write + Read int from PCM_24 : 33.10% of raw read + Write float to PCM_16 : 17.30% of raw write + Read float from PCM_16 : 31.46% of raw read + Write float to PCM_24 : 14.62% of raw write + Read float from PCM_24 : 27.64% of raw read + Write float to PCM_32 : 13.65% of raw write + Read float from PCM_32 : 22.41% of raw read + Write float to FLOAT : 19.13% of raw write + Read float from FLOAT : 26.21% of raw read + +erikd@coltrane > tests/benchmark +Benchmarking libsndfile-1.0.0 +----------------------------- +Each test takes a little over 5 seconds. + + Raw write PCM_16 : 29884416 samples per sec + Raw read PCM_16 : 63347175 samples per sec + +Native endian I/O : + Write short to PCM_16 : 88.24% of raw write + Read short from PCM_16 : 82.76% of raw read + Write int to PCM_24 : 34.95% of raw write + Read int from PCM_24 : 37.17% of raw read + Write int to PCM_32 : 43.86% of raw write + Read int from PCM_32 : 41.22% of raw read + Write float to PCM_16 : 42.07% of raw write + Read float from PCM_16 : 44.25% of raw read + Write float to PCM_24 : 32.43% of raw write + Read float from PCM_24 : 28.93% of raw read + Write float to PCM_32 : 25.60% of raw write + Read float from PCM_32 : 31.10% of raw read + Write float to FLOAT : 45.55% of raw write + Read float from FLOAT : 57.41% of raw read + +Endian swapped I/O : + Write short to PCM_16 : 43.46% of raw write + Read short from PCM_16 : 43.99% of raw read + Write int to PCM_24 : 35.09% of raw write + Read int from PCM_24 : 37.34% of raw read + Write int to PCM_32 : 24.05% of raw write + Read int from PCM_32 : 19.74% of raw read + Write float to PCM_16 : 40.25% of raw write + Read float from PCM_16 : 32.15% of raw read + Write float to PCM_24 : 31.02% of raw write + Read float from PCM_24 : 28.82% of raw read + Write float to PCM_32 : 23.54% of raw write + Read float from PCM_32 : 23.65% of raw read + Write float to FLOAT : 24.87% of raw write + Read float from FLOAT : 20.28% of raw read diff --git a/libs/libsndfile/tests/benchmark.c b/libs/libsndfile/tests/benchmark.c index 21f62efce6..f33bfee43b 100644 --- a/libs/libsndfile/tests/benchmark.c +++ b/libs/libsndfile/tests/benchmark.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/benchmark.def b/libs/libsndfile/tests/benchmark.def index f2db29ae24..382bf3b1a6 100644 --- a/libs/libsndfile/tests/benchmark.def +++ b/libs/libsndfile/tests/benchmark.def @@ -1,16 +1,16 @@ autogen definitions benchmark.tpl; -data_type = { +data_type = { type_name = short ; multiplier = "32700.0" ; }; -data_type = { +data_type = { type_name = int ; - multiplier = "32700.0 * (1<<16)" ; + multiplier = "32700.0 * (1 << 16)" ; }; -data_type = { +data_type = { type_name = float ; multiplier = "1.0" ; }; diff --git a/libs/libsndfile/tests/benchmark.tpl b/libs/libsndfile/tests/benchmark.tpl index e1a6f3ccfd..14b22e2e22 100644 --- a/libs/libsndfile/tests/benchmark.tpl +++ b/libs/libsndfile/tests/benchmark.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ #define WRITE_PERMS (S_IRUSR | S_IWUSR | S_IRGRP) #endif -#define BUFFER_SIZE (1<<18) +#define BUFFER_SIZE (1 << 18) #define BLOCK_COUNT (30) #define TEST_DURATION (5) /* 5 Seconds. */ diff --git a/libs/libsndfile/tests/channel_test.c b/libs/libsndfile/tests/channel_test.c new file mode 100644 index 0000000000..8a69734389 --- /dev/null +++ b/libs/libsndfile/tests/channel_test.c @@ -0,0 +1,134 @@ +/* +** Copyright (C) 2001-2012 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include + +#include + +#include "utils.h" + +#define BUFFER_LEN (1 << 10) +#define LOG_BUFFER_SIZE 1024 + +static void channel_test (void) ; +static double max_diff (const float *a, const float *b, int len) ; + +int +main (void) // int argc, char *argv []) +{ channel_test () ; + return 0 ; +} /* main */ + +/*============================================================================================ +** Here are the test functions. +*/ + +static void +channel_test (void) +{ static float float_data [1024] ; + static float read_float [1024] ; + static int read_int [1024] ; + static short read_short [1024] ; + unsigned int ch, k ; + + gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9) ; + + for (ch = 1 ; ch <= 8 ; ch++) + { SNDFILE *file ; + SF_INFO wsfinfo, rsfinfo ; + sf_count_t wframes = ARRAY_LEN (float_data) / ch ; + double maxdiff ; + char filename [256] ; + + snprintf (filename, sizeof (filename), "chan_%d.wav", ch) ; + print_test_name (__func__, filename) ; + + sf_info_setup (&wsfinfo, SF_FORMAT_WAV | SF_FORMAT_FLOAT, 48000, ch) ; + sf_info_clear (&rsfinfo) ; + + /* Write the test file. */ + file = test_open_file_or_die (filename, SFM_WRITE, &wsfinfo, SF_FALSE, __LINE__) ; + test_writef_float_or_die (file, 0, float_data, wframes, __LINE__) ; + sf_close (file) ; + + /* Read it as float and test. */ + file = test_open_file_or_die (filename, SFM_READ, &rsfinfo, SF_FALSE, __LINE__) ; + exit_if_true (rsfinfo.frames == 0, + "\n\nLine %d : Frames in file %" PRId64 ".\n\n", __LINE__, rsfinfo.frames) ; + exit_if_true (wframes != rsfinfo.frames, + "\n\nLine %d : Wrote %" PRId64 ", read %" PRId64 " frames.\n\n", __LINE__, wframes, rsfinfo.frames) ; + + sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; + + test_readf_float_or_die (file, 0, read_float, rsfinfo.frames, __LINE__) ; + compare_float_or_die (float_data, read_float, ch * rsfinfo.frames, __LINE__) ; + + /* Read it as short and test. */ + test_seek_or_die (file, 0, SEEK_SET, 0, ch, __LINE__) ; + test_readf_short_or_die (file, 0, read_short, rsfinfo.frames, __LINE__) ; + + for (k = 0 ; k < ARRAY_LEN (read_float) ; k++) + read_float [k] = read_short [k] * (0.9 / 0x8000) ; + + maxdiff = max_diff (float_data, read_float, ch * rsfinfo.frames) ; + exit_if_true (maxdiff > 0.5, "\n\nLine %d : Max diff is %f\n\n", __LINE__, maxdiff) ; + + /* Read it as int and test. */ + test_seek_or_die (file, 0, SEEK_SET, 0, ch, __LINE__) ; + test_readf_int_or_die (file, 0, read_int, rsfinfo.frames, __LINE__) ; + + for (k = 0 ; k < ARRAY_LEN (read_float) ; k++) + read_float [k] = read_int [k] * (0.9 / 0x80000000) ; + + maxdiff = max_diff (float_data, read_float, ch * rsfinfo.frames) ; + exit_if_true (maxdiff > 0.5, "\n\nLine %d : Max diff is %f\n\n", __LINE__, maxdiff) ; + + sf_close (file) ; + unlink (filename) ; + printf ("ok\n") ; + } ; + + return ; +} /* channel_test */ + +static double +max_diff (const float *a, const float *b, int len) +{ double mdiff = 0.0, diff ; + int k ; + + for (k = 0 ; k < len ; k++) + { diff = fabs (a [k] - b [k]) ; + mdiff = diff > mdiff ? diff : mdiff ; + // printf ("%4d: % f % f % f % f\n", k, a [k], b [k], diff, mdiff) ; + } ; + + return mdiff ; +} /* max_diff */ diff --git a/libs/libsndfile/tests/checksum_test.c b/libs/libsndfile/tests/checksum_test.c index 52007e3a32..544da93408 100644 --- a/libs/libsndfile/tests/checksum_test.c +++ b/libs/libsndfile/tests/checksum_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/chunk_test.c b/libs/libsndfile/tests/chunk_test.c new file mode 100644 index 0000000000..5a036b1e07 --- /dev/null +++ b/libs/libsndfile/tests/chunk_test.c @@ -0,0 +1,293 @@ +/* +** Copyright (C) 2003-2012 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include + +#include "utils.h" + +#define BUFFER_LEN (1 << 10) +#define LOG_BUFFER_SIZE 1024 + +static void chunk_test (const char *filename, int format) ; + +static void +chunk_test_helper (const char *filename, int format, const char * testdata) ; + +int +main (int argc, char *argv []) +{ int do_all = 0 ; + int test_count = 0 ; + + if (argc != 2) + { printf ("Usage : %s \n", argv [0]) ; + printf (" Where is one of the following:\n") ; + printf (" wav - test adding chunks to WAV files\n") ; + printf (" aiff - test adding chunks to AIFF files\n") ; + printf (" all - perform all tests\n") ; + exit (1) ; + } ; + + do_all = ! strcmp (argv [1], "all") ; + + if (do_all || ! strcmp (argv [1], "wav")) + { chunk_test ("chunks_pcm16.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; + chunk_test ("chunks_pcm16.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; + chunk_test ("chunks_pcm16.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; + test_count++ ; + } ; + + if (do_all || ! strcmp (argv [1], "aiff")) + { chunk_test ("chunks_pcm16.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; + test_count++ ; + } ; + + if (do_all || ! strcmp (argv [1], "caf")) + { chunk_test ("chunks_pcm16.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; + chunk_test ("chunks_alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_16) ; + test_count++ ; + } ; + + if (test_count == 0) + { printf ("Mono : ************************************\n") ; + printf ("Mono : * No '%s' test defined.\n", argv [1]) ; + printf ("Mono : ************************************\n") ; + return 1 ; + } ; + + return 0 ; +} /* main */ + + +/*============================================================================================ +** Here are the test functions. +*/ + +static void +chunk_test_helper (const char *filename, int format, const char * testdata) +{ SNDFILE *file ; + SF_INFO sfinfo ; + SF_CHUNK_INFO chunk_info ; + SF_CHUNK_ITERATOR * iterator ; + uint32_t length_before ; + int err, allow_fd ; + + switch (format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_ALAC_16 : + allow_fd = SF_FALSE ; + break ; + default : + allow_fd = SF_TRUE ; + break ; + } ; + + sfinfo.samplerate = 44100 ; + sfinfo.channels = 1 ; + sfinfo.frames = 0 ; + sfinfo.format = format ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; + + /* Set up the chunk to write. */ + memset (&chunk_info, 0, sizeof (chunk_info)) ; + snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; + chunk_info.id_size = 4 ; + chunk_info.data = strdup (testdata) ; + chunk_info.datalen = strlen (chunk_info.data) ; + + length_before = chunk_info.datalen ; + + err = sf_set_chunk (file, &chunk_info) ; + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_set_chunk returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) + ) ; + + memset (chunk_info.data, 0, chunk_info.datalen) ; + free (chunk_info.data) ; + + sf_close (file) ; + + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; + + memset (&chunk_info, 0, sizeof (chunk_info)) ; + snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; + chunk_info.id_size = 4 ; + + iterator = sf_get_chunk_iterator (file, &chunk_info) ; + err = sf_get_chunk_size (iterator, &chunk_info) ; + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_get_chunk_size returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) + ) ; + + exit_if_true ( + length_before > chunk_info.datalen || chunk_info.datalen - length_before > 4, + "\n\nLine %d : testdata '%s' : Bad chunk length %u (previous length %u)\n\n", __LINE__, testdata, chunk_info.datalen, length_before + ) ; + + chunk_info.data = malloc (chunk_info.datalen) ; + err = sf_get_chunk_data (iterator, &chunk_info) ; + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_get_chunk_size returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) + ) ; + + exit_if_true ( + memcmp (testdata, chunk_info.data, length_before), + "\n\nLine %d : Data compare failed.\n %s\n %s\n\n", __LINE__, testdata, (char*) chunk_info.data + ) ; + + free (chunk_info.data) ; + + sf_close (file) ; + unlink (filename) ; +} /* chunk_test_helper */ + +static void +multichunk_test_helper (const char *filename, int format, const char * testdata [], size_t testdata_len) +{ SNDFILE *file ; + SF_INFO sfinfo ; + SF_CHUNK_INFO chunk_info ; + SF_CHUNK_ITERATOR * iterator ; + uint32_t length_before [testdata_len] ; + int err, allow_fd ; + size_t i ; + + sfinfo.samplerate = 44100 ; + sfinfo.channels = 1 ; + sfinfo.frames = 0 ; + sfinfo.format = format ; + + switch (format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_ALAC_16 : + allow_fd = SF_FALSE ; + break ; + default : + allow_fd = SF_TRUE ; + break ; + } ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; + + /* Set up the chunk to write. */ + for (i = 0 ; i < testdata_len ; i++) + { memset (&chunk_info, 0, sizeof (chunk_info)) ; + snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; + chunk_info.id_size = 4 ; + + chunk_info.data = strdup (testdata [i]) ; + chunk_info.datalen = strlen (chunk_info.data) ; + + length_before [i] = chunk_info.datalen ; + + err = sf_set_chunk (file, &chunk_info) ; + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_set_chunk returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) + ) ; + + memset (chunk_info.data, 0, chunk_info.datalen) ; + free (chunk_info.data) ; + } + + sf_close (file) ; + + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; + + memset (&chunk_info, 0, sizeof (chunk_info)) ; + snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; + chunk_info.id_size = 4 ; + + iterator = sf_get_chunk_iterator (file, &chunk_info) ; + + i = 0 ; + while (iterator) + { memset (&chunk_info, 0, sizeof (chunk_info)) ; + err = sf_get_chunk_size (iterator, &chunk_info) ; + exit_if_true ( + i > testdata_len, + "\n\nLine %d : iterated to chunk #%d, but only %d chunks have been written\n\n", __LINE__, (int) i, (int) testdata_len + ) ; + + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_get_chunk_size returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) + ) ; + + exit_if_true ( + length_before [i] > chunk_info.datalen || chunk_info.datalen - length_before [i] > 4, + "\n\nLine %d : testdata[%d] '%s' : Bad chunk length %u (previous length %u)\n\n", __LINE__, (int) i, testdata [i], chunk_info.datalen, length_before [i] + ) ; + + chunk_info.data = malloc (chunk_info.datalen) ; + err = sf_get_chunk_data (iterator, &chunk_info) ; + exit_if_true ( + err != SF_ERR_NO_ERROR, + "\n\nLine %d : sf_get_chunk_size returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) + ) ; + + exit_if_true ( + 4 != chunk_info.id_size, + "\n\nLine %d : testdata[%d] : Bad ID length %u (previous length %u)\n\n", __LINE__, (int) i, chunk_info.id_size, 4 + ) ; + exit_if_true ( + memcmp ("Test", chunk_info.id, 4), + "\n\nLine %d : ID compare failed at %d.\n %s\n %s\n\n", __LINE__, (int) i, "Test", (char*) chunk_info.id + ) ; + + exit_if_true ( + memcmp (testdata [i], chunk_info.data, length_before [i]), + "\n\nLine %d : Data compare failed at %d.\n %s\n %s\n\n", __LINE__, (int) i, testdata [i], (char*) chunk_info.data + ) ; + + free (chunk_info.data) ; + iterator = sf_next_chunk_iterator (iterator) ; + i++ ; + } + + sf_close (file) ; + unlink (filename) ; +} /* multichunk_test_helper */ + + +static void +chunk_test (const char *filename, int format) +{ const char* testdata [] = + { "There can be only one.", "", "A", "AB", "ABC", "ABCD", "ABCDE" } ; + uint32_t k ; + + print_test_name (__func__, filename) ; + + for (k = 0 ; k < ARRAY_LEN (testdata) ; k++) + chunk_test_helper (filename, format, testdata [k]) ; + + multichunk_test_helper (filename, format, testdata, ARRAY_LEN (testdata)) ; + + puts ("ok") ; +} /* chunk_test */ diff --git a/libs/libsndfile/tests/command_test.c b/libs/libsndfile/tests/command_test.c index 6940d25684..9e6bfd485b 100644 --- a/libs/libsndfile/tests/command_test.c +++ b/libs/libsndfile/tests/command_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include @@ -33,7 +35,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<10) +#define BUFFER_LEN (1 << 10) #define LOG_BUFFER_SIZE 1024 static void float_norm_test (const char *filename) ; @@ -51,6 +53,10 @@ static void broadcast_rdwr_test (const char *filename, int filetype) ; static void broadcast_coding_history_test (const char *filename) ; static void broadcast_coding_history_size (const char *filename) ; +/* Cart Chunk tests */ +static void cart_test (const char *filename, int filetype) ; +static void cart_rdwr_test (const char *filename, int filetype) ; + /* Force the start of this buffer to be double aligned. Sparc-solaris will ** choke if its not. */ @@ -76,12 +82,13 @@ main (int argc, char *argv []) printf (" chanmap - test set/get of channel map data..\n") ; printf (" bext - test set/get of SF_BROADCAST_INFO.\n") ; printf (" bextch - test set/get of SF_BROADCAST_INFO coding_history.\n") ; + printf (" cart - test set/get of SF_CART_INFO.\n") ; printf (" rawend - test SFC_RAW_NEEDS_ENDSWAP.\n") ; printf (" all - perform all tests\n") ; exit (1) ; } ; - do_all =! strcmp (argv [1], "all") ; + do_all = ! strcmp (argv [1], "all") ; if (do_all || strcmp (argv [1], "ver") == 0) { char buffer [128] ; @@ -141,6 +148,17 @@ main (int argc, char *argv []) broadcast_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; broadcast_rdwr_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; + + broadcast_test ("broadcast.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; + broadcast_rdwr_test ("broadcast.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; + test_count ++ ; + } ; + + if (do_all || strcmp (argv [1], "cart") == 0) + { cart_test ("cart.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; + cart_rdwr_test ("cart.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; + cart_test ("cart.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; + cart_rdwr_test ("cart.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; test_count ++ ; } ; @@ -151,8 +169,10 @@ main (int argc, char *argv []) } ; if (do_all || strcmp (argv [1], "chanmap") == 0) - { channel_map_test ("chanmap.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - channel_map_test ("chanmap.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ; + { channel_map_test ("chanmap.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; + channel_map_test ("chanmap.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; + channel_map_test ("chanmap.aifc" , SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; + channel_map_test ("chanmap.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; test_count ++ ; } ; @@ -236,7 +256,7 @@ float_norm_test (const char *filename) } ; if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_LEN, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; exit (1) ; } ; @@ -352,7 +372,7 @@ double_norm_test (const char *filename) } ; if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_LEN, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; exit (1) ; } ; @@ -541,7 +561,7 @@ calc_peak_test (int filetype, const char *filename) } ; if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_LEN, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; exit (1) ; } ; @@ -588,7 +608,7 @@ calc_peak_test (int filetype, const char *filename) } ; if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_LEN, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; exit (1) ; } ; @@ -694,8 +714,8 @@ instrument_test (const char *filename, int filetype) } } ; SF_INSTRUMENT read_inst ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; print_test_name ("instrument_test", filename) ; @@ -800,7 +820,6 @@ static void current_sf_info_test (const char *filename) { SNDFILE *outfile, *infile ; SF_INFO outinfo, ininfo ; - sf_count_t last_count ; print_test_name ("current_sf_info_test", filename) ; @@ -820,23 +839,21 @@ current_sf_info_test (const char *filename) sf_command (outfile, SFC_GET_CURRENT_SF_INFO, &outinfo, sizeof (outinfo)) ; exit_if_true (outinfo.frames != BUFFER_LEN, - "\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__, - SF_COUNT_TO_LONG (outinfo.frames), BUFFER_LEN + "\n\nLine %d : Initial sfinfo.frames (%" PRId64 ") should be %d.\n\n", __LINE__, + outinfo.frames, BUFFER_LEN ) ; /* Read file making sure no channel map exists. */ memset (&ininfo, 0, sizeof (ininfo)) ; infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ; - last_count = ininfo.frames ; - test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ; sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ; exit_if_true (ininfo.frames != BUFFER_LEN, - "\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__, - SF_COUNT_TO_LONG (ininfo.frames), BUFFER_LEN + "\n\nLine %d : Initial sfinfo.frames (%" PRId64 ") should be %d.\n\n", __LINE__, + ininfo.frames, BUFFER_LEN ) ; sf_close (outfile) ; @@ -849,8 +866,8 @@ current_sf_info_test (const char *filename) static void broadcast_test (const char *filename, int filetype) { static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; int errors = 0 ; print_test_name ("broadcast_test", filename) ; @@ -965,7 +982,7 @@ broadcast_rdwr_test (const char *filename, int filetype) file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; sf_close (file) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; unlink (filename) ; puts ("ok") ; @@ -974,8 +991,8 @@ broadcast_rdwr_test (const char *filename, int filetype) static void check_coding_history_newlines (const char *filename) { static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; unsigned k ; sfinfo.samplerate = 22050 ; @@ -1044,8 +1061,8 @@ check_coding_history_newlines (const char *filename) static void broadcast_coding_history_test (const char *filename) { static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; const char *default_history = "A=PCM,F=22050,W=16,M=mono" ; const char *supplied_history = "A=PCM,F=44100,W=24,M=mono,T=other\r\n" @@ -1093,7 +1110,9 @@ broadcast_coding_history_test (const char *filename) } ; if (bc_read.coding_history_size < strlen (default_history) || memcmp (bc_read.coding_history, default_history, strlen (default_history)) != 0) - { printf ("\n\nLine %d : unexpected coding history '%.*s'.\n\n", __LINE__, bc_read.coding_history_size, bc_read.coding_history) ; + { printf ("\n\n" + "Line %d : unexpected coding history '%.*s',\n" + " should be '%s'\n\n", __LINE__, bc_read.coding_history_size, bc_read.coding_history, default_history) ; exit (1) ; } ; @@ -1146,8 +1165,8 @@ broadcast_coding_history_size (const char *filename) { /* SF_BROADCAST_INFO struct with coding_history field of 1024 bytes. */ static SF_BROADCAST_INFO_VAR (1024) bc_write ; static SF_BROADCAST_INFO_VAR (1024) bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; int k ; print_test_name (__func__, filename) ; @@ -1204,16 +1223,227 @@ broadcast_coding_history_size (const char *filename) puts ("ok") ; } /* broadcast_coding_history_size */ +/*============================================================================== +*/ +static void +cart_test (const char *filename, int filetype) +{ static SF_CART_INFO ca_write, ca_read ; + SNDFILE *file ; + SF_INFO sfinfo ; + int errors = 0 ; + + print_test_name ("cart_test", filename) ; + + sfinfo.samplerate = 11025 ; + sfinfo.format = filetype ; + sfinfo.channels = 1 ; + memset (&ca_write, 0, sizeof (ca_write)) ; + + // example test data + snprintf (ca_write.artist, sizeof (ca_write.artist), "Test artist") ; + snprintf (ca_write.version, sizeof (ca_write.version), "Test version") ; + snprintf (ca_write.cut_id, sizeof (ca_write.cut_id), "Test cut ID") ; + snprintf (ca_write.client_id, sizeof (ca_write.client_id), "Test client ID") ; + snprintf (ca_write.category, sizeof (ca_write.category), "Test category") ; + snprintf (ca_write.classification, sizeof (ca_write.classification), "Test classification") ; + snprintf (ca_write.out_cue, sizeof (ca_write.out_cue), "Test out cue") ; + snprintf (ca_write.start_date, sizeof (ca_write.start_date), "%d/%02d/%02d", 2006, 3, 30) ; + snprintf (ca_write.start_time, sizeof (ca_write.start_time), "%02d:%02d:%02d", 20, 27, 0) ; + snprintf (ca_write.end_date, sizeof (ca_write.end_date), "%d/%02d/%02d", 2006, 3, 30) ; + snprintf (ca_write.end_time, sizeof (ca_write.end_time), "%02d:%02d:%02d", 20, 27, 0) ; + snprintf (ca_write.producer_app_id, sizeof (ca_write.producer_app_id), "Test producer app id") ; + snprintf (ca_write.producer_app_version, sizeof (ca_write.producer_app_version), "Test producer app version") ; + snprintf (ca_write.user_def, sizeof (ca_write.user_def), "test user def test test") ; + ca_write.level_reference = 42 ; + snprintf (ca_write.url, sizeof (ca_write.url), "http://www.test.com/test_url") ; + snprintf (ca_write.tag_text, sizeof (ca_write.tag_text), "tag text test! \r\n") ; // must be terminated \r\n to be valid + ca_write.tag_text_size = strlen (ca_write.tag_text) ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; + if (sf_command (file, SFC_SET_CART_INFO, &ca_write, sizeof (ca_write)) == SF_FALSE) + exit (1) ; + + test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; + sf_close (file) ; + + memset (&ca_read, 0, sizeof (ca_read)) ; + + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; + if (sf_command (file, SFC_GET_CART_INFO, &ca_read, sizeof (ca_read)) == SF_FALSE) + { printf ("\n\nLine %d : sf_command (SFC_GET_CART_INFO) failed.\n\n", __LINE__) ; + exit (1) ; + return ; + } ; + check_log_buffer_or_die (file, __LINE__) ; + sf_close (file) ; + + + if (memcmp (ca_write.artist, ca_read.artist, sizeof (ca_write.artist)) != 0) + { printf ("\n\nLine %d : artist mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.artist, ca_read.artist) ; + errors ++ ; + } ; + + if (memcmp (ca_write.version, ca_read.version, sizeof (ca_write.version)) != 0) + { printf ("\n\nLine %d : version mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.version, ca_read.version) ; + errors ++ ; + } ; + + if (memcmp (ca_write.title, ca_read.title, sizeof (ca_write.title)) != 0) + { printf ("\n\nLine %d : title mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.title, ca_read.title) ; + errors ++ ; + } ; + + if (memcmp (ca_write.cut_id, ca_read.cut_id, sizeof (ca_write.cut_id)) != 0) + { printf ("\n\nLine %d : cut_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.cut_id, ca_read.cut_id) ; + errors ++ ; + } ; + + if (memcmp (ca_write.client_id, ca_read.client_id, sizeof (ca_write.client_id)) != 0) + { printf ("\n\nLine %d : client_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.client_id, ca_read.client_id) ; + errors ++ ; + } ; + + if (memcmp (ca_write.category, ca_read.category, sizeof (ca_write.category)) != 0) + { printf ("\n\nLine %d : category mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.category, ca_read.category) ; + errors ++ ; + } ; + + if (memcmp (ca_write.out_cue, ca_read.out_cue, sizeof (ca_write.out_cue)) != 0) + { printf ("\n\nLine %d : out_cue mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.out_cue, ca_read.out_cue) ; + errors ++ ; + } ; + + if (memcmp (ca_write.start_date, ca_read.start_date, sizeof (ca_write.start_date)) != 0) + { printf ("\n\nLine %d : start_date mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.start_date, ca_read.start_date) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.start_time, ca_read.start_time, sizeof (ca_write.start_time)) != 0) + { printf ("\n\nLine %d : start_time mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.start_time, ca_read.start_time) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.end_date, ca_read.end_date, sizeof (ca_write.end_date)) != 0) + { printf ("\n\nLine %d : end_date mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.end_date, ca_read.end_date) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.end_time, ca_read.end_time, sizeof (ca_write.end_time)) != 0) + { printf ("\n\nLine %d : end_time mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.end_time, ca_read.end_time) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.producer_app_id, ca_read.producer_app_id, sizeof (ca_write.producer_app_id)) != 0) + { printf ("\n\nLine %d : producer_app_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.producer_app_id, ca_read.producer_app_id) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.producer_app_version, ca_read.producer_app_version, sizeof (ca_write.producer_app_version)) != 0) + { printf ("\n\nLine %d : producer_app_version mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.producer_app_version, ca_read.producer_app_version) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.user_def, ca_read.user_def, sizeof (ca_write.user_def)) != 0) + { printf ("\n\nLine %d : user_def mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.user_def, ca_read.user_def) ; + errors ++ ; + } ; + + + if (ca_write.level_reference != ca_read.level_reference) + { printf ("\n\nLine %d : level_reference mismatch :\n\twrite : '%d'\n\tread : '%d'\n\n", __LINE__, ca_write.level_reference, ca_read.level_reference) ; + errors ++ ; + } ; + + // TODO: make this more helpful + if (memcmp (ca_write.post_timers, ca_read.post_timers, sizeof (ca_write.post_timers)) != 0) + { printf ("\n\nLine %d : post_timers mismatch :\n'\n\n", __LINE__) ; + errors ++ ; + } ; + + if (memcmp (ca_write.url, ca_read.url, sizeof (ca_write.url)) != 0) + { printf ("\n\nLine %d : url mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.url, ca_read.url) ; + errors ++ ; + } ; + + + if (memcmp (ca_write.tag_text, ca_read.tag_text, (size_t) (ca_read.tag_text_size)) != 0) + { printf ("\n\nLine %d : tag_text mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.tag_text, ca_read.tag_text) ; + errors ++ ; + } ; + + + if (errors) + exit (1) ; + + unlink (filename) ; + puts ("ok") ; +} /* cart_test */ + +static void +cart_rdwr_test (const char *filename, int filetype) +{ SF_CART_INFO cinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; + sf_count_t frames ; + + print_test_name (__func__, filename) ; + + create_short_sndfile (filename, filetype, 2) ; + + memset (&sfinfo, 0, sizeof (sfinfo)) ; + memset (&cinfo, 0, sizeof (cinfo)) ; + + snprintf (cinfo.artist, sizeof (cinfo.artist), "Test artist") ; + snprintf (cinfo.version, sizeof (cinfo.version), "Test version") ; + snprintf (cinfo.cut_id, sizeof (cinfo.cut_id), "Test cut ID") ; + snprintf (cinfo.client_id, sizeof (cinfo.client_id), "Test client ID") ; + snprintf (cinfo.category, sizeof (cinfo.category), "Test category") ; + snprintf (cinfo.classification, sizeof (cinfo.classification), "Test classification") ; + snprintf (cinfo.out_cue, sizeof (cinfo.out_cue), "Test out cue") ; + snprintf (cinfo.start_date, sizeof (cinfo.start_date), "%d/%02d/%02d", 2006, 3, 30) ; + snprintf (cinfo.start_time, sizeof (cinfo.start_time), "%02d:%02d:%02d", 20, 27, 0) ; + snprintf (cinfo.end_date, sizeof (cinfo.end_date), "%d/%02d/%02d", 2006, 3, 30) ; + snprintf (cinfo.end_time, sizeof (cinfo.end_time), "%02d:%02d:%02d", 20, 27, 0) ; + snprintf (cinfo.producer_app_id, sizeof (cinfo.producer_app_id), "Test producer app id") ; + snprintf (cinfo.producer_app_version, sizeof (cinfo.producer_app_version), "Test producer app version") ; + snprintf (cinfo.user_def, sizeof (cinfo.user_def), "test user def test test") ; + cinfo.level_reference = 42 ; + snprintf (cinfo.url, sizeof (cinfo.url), "http://www.test.com/test_url") ; + snprintf (cinfo.tag_text, sizeof (cinfo.tag_text), "tag text test!\r\n") ; + cinfo.tag_text_size = strlen (cinfo.tag_text) ; + + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; + frames = sfinfo.frames ; + if (sf_command (file, SFC_SET_CART_INFO, &cinfo, sizeof (cinfo)) != SF_FALSE) + { printf ("\n\nLine %d : sf_command (SFC_SET_CART_INFO) should have failed but didn't.\n\n", __LINE__) ; + exit (1) ; + } ; + sf_close (file) ; + + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; + sf_close (file) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; + + unlink (filename) ; + puts ("ok") ; +} /* cart_rdwr_test */ + /*============================================================================== */ static void channel_map_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; +{ SNDFILE *file ; + SF_INFO sfinfo ; int channel_map_read [4], channel_map_write [4] = - { SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_CENTER, - SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT + { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, + SF_CHANNEL_MAP_REAR_CENTER } ; print_test_name ("channel_map_test", filename) ; @@ -1223,27 +1453,36 @@ channel_map_test (const char *filename, int filetype) sfinfo.format = filetype ; sfinfo.channels = ARRAY_LEN (channel_map_read) ; - /* Write file without channel map. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; + switch (filetype & SF_FORMAT_TYPEMASK) + { /* WAVEX and RF64 have a default channel map, even if you don't specify one. */ + case SF_FORMAT_WAVEX : + case SF_FORMAT_RF64 : + /* Write file without channel map. */ + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; + test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; + sf_close (file) ; - /* Read file making sure no channel map exists. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - exit_if_true ( - sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) != SF_FALSE, - "\n\nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) should have failed.\n\n", __LINE__ - ) ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; + /* Read file making default channel map exists. */ + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; + exit_if_true ( + sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) == SF_FALSE, + "\n\nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) should not have failed.\n\n", __LINE__ + ) ; + check_log_buffer_or_die (file, __LINE__) ; + sf_close (file) ; + break ; + + default : + break ; + } ; /* Write file with a channel map. */ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; exit_if_true ( sf_command (file, SFC_SET_CHANNEL_MAP_INFO, channel_map_write, sizeof (channel_map_write)) == SF_FALSE, "\n\nLine %d : sf_command (SFC_SET_CHANNEL_MAP_INFO) failed.\n\n", __LINE__ ) ; + test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; sf_close (file) ; /* Read file making sure no channel map exists. */ @@ -1270,8 +1509,8 @@ raw_needs_endswap_test (const char *filename, int filetype) { SF_FORMAT_FLOAT, SF_FORMAT_DOUBLE, SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_PCM_32 } ; - SNDFILE *file ; - SF_INFO sfinfo ; + SNDFILE *file ; + SF_INFO sfinfo ; unsigned k ; int needs_endswap ; diff --git a/libs/libsndfile/tests/compression_size_test.c b/libs/libsndfile/tests/compression_size_test.c new file mode 100644 index 0000000000..ddacf94905 --- /dev/null +++ b/libs/libsndfile/tests/compression_size_test.c @@ -0,0 +1,205 @@ +/* +** Copyright (C) 2007-2012 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include + +#include + +#include + +#include "utils.h" +#include "dft_cmp.h" + +#define SAMPLE_RATE 16000 +#define DATA_LENGTH (SAMPLE_RATE) + +static float data_out [DATA_LENGTH] ; + +static inline float +max_float (float a, float b) +{ return a > b ? a : b ; +} /* max_float */ + +static void +vorbis_test (void) +{ static float float_data [DFT_DATA_LENGTH] ; + const char * filename = "vorbis_test.oga" ; + SNDFILE * file ; + SF_INFO sfinfo ; + float max_abs = 0.0 ; + unsigned k ; + + print_test_name ("vorbis_test", filename) ; + + /* Generate float data. */ + gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 1.0) ; + + /* Set up output file type. */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; + sfinfo.channels = 1 ; + sfinfo.samplerate = SAMPLE_RATE ; + + /* Write the output file. */ + + /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates + ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. + ** See https://trac.xiph.org/ticket/1229 + */ + if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) + { const char * errstr ; + + errstr = sf_strerror (NULL) ; + if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") == NULL) + { printf ("Line %d: sf_open (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; + dump_log_buffer (NULL) ; + exit (1) ; + } ; + + printf ("\n Sample rate -> 32kHz ") ; + sfinfo.samplerate = 32000 ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; + } ; + + test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ; + sf_close (file) ; + + memset (float_data, 0, sizeof (float_data)) ; + + /* Read the file back in again. */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; + test_read_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ; + sf_close (file) ; + + for (k = 0 ; k < ARRAY_LEN (float_data) ; k ++) + max_abs = max_float (max_abs, fabs (float_data [k])) ; + + if (max_abs > 1.021) + { printf ("\n\n Error : max_abs %f should be < 1.021.\n\n", max_abs) ; + exit (1) ; + } ; + + puts ("ok") ; + unlink (filename) ; +} /* vorbis_test */ + +static void +compression_size_test (int format, const char * filename) +{ /* + ** Encode two files, one at quality 0.3 and one at quality 0.5 and then + ** make sure that the quality 0.3 files is the smaller of the two. + */ + char q3_fname [64] ; + char q6_fname [64] ; + char test_name [64] ; + + SNDFILE *q3_file, *q6_file ; + SF_INFO sfinfo ; + int q3_size, q6_size ; + double quality ; + int k ; + + snprintf (q3_fname, sizeof (q3_fname), "q3_%s", filename) ; + snprintf (q6_fname, sizeof (q6_fname), "q6_%s", filename) ; + + snprintf (test_name, sizeof (test_name), "q[36]_%s", filename) ; + print_test_name (__func__, test_name) ; + + memset (&sfinfo, 0, sizeof (sfinfo)) ; + + /* Set up output file type. */ + sfinfo.format = format ; + sfinfo.channels = 1 ; + sfinfo.samplerate = SAMPLE_RATE ; + + /* Write the output file. */ + q3_file = test_open_file_or_die (q3_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; + q6_file = test_open_file_or_die (q6_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; + + quality = 0.3 ; + sf_command (q3_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ; + quality = 0.6 ; + sf_command (q6_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ; + + for (k = 0 ; k < 5 ; k++) + { gen_lowpass_signal_float (data_out, ARRAY_LEN (data_out)) ; + test_write_float_or_die (q3_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ; + test_write_float_or_die (q6_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ; + } ; + + sf_close (q3_file) ; + sf_close (q6_file) ; + + q3_size = file_length (q3_fname) ; + q6_size = file_length (q6_fname) ; + + if (q3_size >= q6_size) + { printf ("\n\nLine %d : q3 size (%d) >= q5 size (%d)\n\n", __LINE__, q3_size, q6_size) ; + exit (1) ; + } ; + + puts ("ok") ; + unlink (q3_fname) ; + unlink (q6_fname) ; +} /* compression_size_test */ + + + +int +main (int argc, char *argv []) +{ int all_tests = 0, tests = 0 ; + + if (argc != 2) + { printf ( + "Usage : %s \n" + " Where is one of:\n" + " vorbis - test Ogg/Vorbis\n" + " flac - test FLAC\n" + " all - perform all tests\n", + argv [0]) ; + exit (0) ; + } ; + + if (! HAVE_EXTERNAL_LIBS) + { puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ; + return 0 ; + } ; + + if (strcmp (argv [1], "all") == 0) + all_tests = 1 ; + + if (all_tests || strcmp (argv [1], "vorbis") == 0) + { vorbis_test () ; + compression_size_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS, "vorbis.oga") ; + tests ++ ; + } ; + + if (all_tests || strcmp (argv [1], "flac") == 0) + { compression_size_test (SF_FORMAT_FLAC | SF_FORMAT_PCM_16, "pcm16.flac") ; + tests ++ ; + } ; + + return 0 ; +} /* main */ diff --git a/libs/libsndfile/tests/cpp_test.cc b/libs/libsndfile/tests/cpp_test.cc index 213b6545a3..364ec86ee2 100644 --- a/libs/libsndfile/tests/cpp_test.cc +++ b/libs/libsndfile/tests/cpp_test.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2006 Erik de Castro Lopo +** Copyright (C) 2006-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -29,6 +29,41 @@ static int ibuffer [100] ; static float fbuffer [100] ; static double dbuffer [100] ; +static void +ceeplusplus_wchar_test (void) +{ +#if 0 + LPCWSTR filename = L"wchar_test.wav" ; + + print_test_name (__func__, "ceeplusplus_wchar_test.wav") ; + + /* Use this scope to make sure the created file is closed. */ + { + SndfileHandle file (filename, SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 44100) ; + + if (file.refCount () != 1) + { printf ("\n\n%s %d : Error : Reference count (%d) should be 1.\n\n", __func__, __LINE__, file.refCount ()) ; + exit (1) ; + } ; + + /* This should check that the file did in fact get created with a + ** wchar_t * filename. + */ + exit_if_true ( + GetFileAttributesW (filename) == INVALID_FILE_ATTRIBUTES, + "\n\nLine %d : GetFileAttributes failed.\n\n", __LINE__ + ) ; + } + + /* Use this because the file was created with CreateFileW. */ + DeleteFileW (filename) ; + + puts ("ok") ; +#endif +} /* ceeplusplus_wchar_test */ + + + static void create_file (const char * filename, int format) { SndfileHandle file ; @@ -124,7 +159,7 @@ read_file (const char * filename, int format) if (file.frames () != ARRAY_LEN (sbuffer) * 4) { printf ("\n\n%s %d : Error : frames %ld should be %lu.\n\n", __func__, __LINE__, - SF_COUNT_TO_LONG (file.frames ()), (long unsigned int) ARRAY_LEN (sbuffer) * 4 / 2) ; + (long) file.frames (), (long) ARRAY_LEN (sbuffer) * 4 / 2) ; exit (1) ; } ; @@ -152,14 +187,14 @@ read_file (const char * filename, int format) count = file.seek (file.frames () - 10, SEEK_SET) ; if (count != file.frames () - 10) { printf ("\n\n%s %d : Error : offset (%ld) should be %ld\n\n", __func__, __LINE__, - SF_COUNT_TO_LONG (count), SF_COUNT_TO_LONG (file.frames () - 10)) ; + (long) count, (long) (file.frames () - 10)) ; exit (1) ; } ; count = file.read (sbuffer, ARRAY_LEN (sbuffer)) ; if (count != 10 * file.channels ()) { printf ("\n\n%s %d : Error : count (%ld) should be %ld\n\n", __func__, __LINE__, - SF_COUNT_TO_LONG (count), SF_COUNT_TO_LONG (10 * file.channels ())) ; + (long) count, (long) (10 * file.channels ())) ; exit (1) ; } ; @@ -190,7 +225,7 @@ ceeplusplus_extra_test (void) error = file.error () ; if (error == 0) - { printf ("\n\n%s %d : error should be zero.\n\n", __func__, __LINE__) ; + { printf ("\n\n%s %d : error should not be zero.\n\n", __func__, __LINE__) ; exit (1) ; } ; @@ -207,6 +242,60 @@ ceeplusplus_extra_test (void) puts ("ok") ; } /* ceeplusplus_extra_test */ + +static void +ceeplusplus_rawhandle_test (const char *filename) +{ + SNDFILE* handle ; + { + SndfileHandle file (filename) ; + handle = file.rawHandle () ; + sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) ; + } +} /* ceeplusplus_rawhandle_test */ + +static void +ceeplusplus_takeOwnership_test (const char *filename) +{ + SNDFILE* handle ; + { + SndfileHandle file (filename) ; + handle = file.takeOwnership () ; + } + + if (sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) <= 0) + { printf ("\n\n%s %d : error when taking ownership of handle.\n\n", __func__, __LINE__) ; + exit (1) ; + } + + if (sf_close (handle) != 0) + { printf ("\n\n%s %d : cannot close file.\n\n", __func__, __LINE__) ; + exit (1) ; + } + + SndfileHandle file (filename) ; + SndfileHandle file2 (file) ; + + if (file2.takeOwnership ()) + { printf ("\n\n%s %d : taking ownership of shared handle is not allowed.\n\n", __func__, __LINE__) ; + exit (1) ; + } +} /* ceeplusplus_takeOwnership_test */ + +static void +ceeplusplus_handle_test (const char *filename, int format) +{ + print_test_name ("ceeplusplus_handle_test", filename) ; + + create_file (filename, format) ; + + if (0) ceeplusplus_rawhandle_test (filename) ; + ceeplusplus_takeOwnership_test (filename) ; + + remove (filename) ; + puts ("ok") ; +} /* ceeplusplus_test */ + int main (void) { @@ -215,6 +304,9 @@ main (void) ceeplusplus_test ("cpp_test.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ; ceeplusplus_extra_test () ; + ceeplusplus_handle_test ("cpp_test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; + + ceeplusplus_wchar_test () ; return 0 ; } /* main */ diff --git a/libs/libsndfile/tests/dft_cmp.c b/libs/libsndfile/tests/dft_cmp.c index ddec0ccd1e..439a53949a 100644 --- a/libs/libsndfile/tests/dft_cmp.c +++ b/libs/libsndfile/tests/dft_cmp.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -123,7 +123,7 @@ dft_magnitude (const double *data, double *spectrum) spectrum [k] = sqrt (real_part * real_part + imag_part * imag_part) ; } ; - spectrum [k] = 0.0 ; + spectrum [DFT_DATA_LENGTH - 1] = 0.0 ; spectrum [0] = spectrum [1] = spectrum [2] = spectrum [3] = spectrum [4] = 0.0 ; diff --git a/libs/libsndfile/tests/dft_cmp.h b/libs/libsndfile/tests/dft_cmp.h index 349e0a066e..3cbdd118e7 100644 --- a/libs/libsndfile/tests/dft_cmp.h +++ b/libs/libsndfile/tests/dft_cmp.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/dither_test.c b/libs/libsndfile/tests/dither_test.c index c5300116ca..e9eef7c136 100644 --- a/libs/libsndfile/tests/dither_test.c +++ b/libs/libsndfile/tests/dither_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<16) +#define BUFFER_LEN (1 << 16) #define LOG_BUFFER_SIZE 1024 static void dither_test (const char *filename, int filetype) ; @@ -52,7 +52,7 @@ main (int argc, char *argv []) exit (1) ; } ; - do_all=!strcmp (argv [1], "all") ; + do_all = ! strcmp (argv [1], "all") ; if (do_all || ! strcmp (argv [1], "wav")) { dither_test ("dither.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ; @@ -134,9 +134,6 @@ dither_test (const char *filename, int filetype) { SNDFILE *file ; SF_INFO sfinfo ; SF_DITHER_INFO dither ; - int frames ; - - filetype = filetype ; print_test_name ("dither_test", filename) ; @@ -145,8 +142,6 @@ dither_test (const char *filename, int filetype) sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; /* Check for old version of the dither API. */ diff --git a/libs/libsndfile/tests/dwvw_test.c b/libs/libsndfile/tests/dwvw_test.c index eeaa85d951..2bd11d18c9 100644 --- a/libs/libsndfile/tests/dwvw_test.c +++ b/libs/libsndfile/tests/dwvw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include #include +#include #include #if HAVE_UNISTD_H @@ -65,15 +66,11 @@ dwvw_test (const char *filename, int format, int bit_width) print_test_name ("dwvw_test", filename) ; - sfinfo.format = format ; - sfinfo.samplerate = 44100 ; - sfinfo.frames = -1 ; /* Unknown! */ - sfinfo.channels = 1 ; + sf_info_setup (&sfinfo, format, 44100, 1) ; file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; /* Generate random.frames. */ - k = 0 ; for (k = 0 ; k < BUFFER_SIZE / 2 ; k++) { value = 0x7FFFFFFF * sin (123.0 / sfinfo.samplerate * 2 * k * M_PI) ; write_buf [k] = bit_mask & lrint (value) ; diff --git a/libs/libsndfile/tests/error_test.c b/libs/libsndfile/tests/error_test.c index e7b47fdb70..4207c0a3cf 100644 --- a/libs/libsndfile/tests/error_test.c +++ b/libs/libsndfile/tests/error_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -26,11 +26,15 @@ #include #endif +#if OS_IS_WIN32 +#include +#endif + #include #include "utils.h" -#define BUFFER_SIZE (1<<15) +#define BUFFER_SIZE (1 << 15) #define SHORT_BUFFER (256) static void @@ -203,8 +207,22 @@ error_close_test (void) fclose (file) ; if (sf_close (sndfile) == 0) - { printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ; + { +#if OS_IS_WIN32 + OSVERSIONINFOEX osvi ; + + memset (&osvi, 0, sizeof (OSVERSIONINFOEX)) ; + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX) ; + + if (GetVersionEx ((OSVERSIONINFO *) &osvi)) + { printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ; + printf ("\nHowever, this is a known bug in version %d.%d of windows so we'll ignore it.\n\n", + (int) osvi.dwMajorVersion, (int) osvi.dwMinorVersion) ; + } ; +#else + printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ; exit (1) ; +#endif } ; unlink (filename) ; diff --git a/libs/libsndfile/tests/external_libs_test.c b/libs/libsndfile/tests/external_libs_test.c index 8d20cbd4f9..86b029078e 100644 --- a/libs/libsndfile/tests/external_libs_test.c +++ b/libs/libsndfile/tests/external_libs_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2009 Erik de Castro Lopo +** Copyright (C) 2008-2011 Erik de Castro Lopo ** ** This program is free software ; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/fix_this.c b/libs/libsndfile/tests/fix_this.c index f108c88f85..4cbb8d43ac 100644 --- a/libs/libsndfile/tests/fix_this.c +++ b/libs/libsndfile/tests/fix_this.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -16,17 +16,18 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include "utils.h" +#include "utils.h" -#define BUFFER_SIZE (1<<14) /* Should be (1<<14) */ +#define BUFFER_SIZE (1 << 14) #define SAMPLE_RATE (11025) #ifndef M_PI @@ -69,8 +70,9 @@ static void lcomp_test_int (const char *str, const char *filename, int filetype, double margin) { SNDFILE *file ; SF_INFO sfinfo ; - int k, m, *orig, *data, sum_abs ; - long datalen, seekpos ; + int k, m, *orig, *data ; + sf_count_t datalen, seekpos ; + int64_t sum_abs ; double scale ; printf ("\nThis is program is not part of the libsndfile test suite.\n\n") ; @@ -102,7 +104,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg } ; if ((k = sf_writef_int (file, orig, datalen)) != datalen) - { printf ("sf_writef_int failed with short write (%ld => %d).\n", datalen, k) ; + { printf ("sf_writef_int failed with short write (%" PRId64 " => %d).\n", datalen, k) ; exit (1) ; } ; sf_close (file) ; @@ -124,12 +126,12 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg } ; if (sfinfo.frames < datalen) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + datalen / 2)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; @@ -141,7 +143,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg check_log_buffer_or_die (file, __LINE__) ; if ((k = sf_readf_int (file, data, datalen)) != datalen) - { printf ("Line %d: short read (%d should be %ld).\n", __LINE__, k, datalen) ; + { printf ("Line %d: short read (%d should be %" PRId64 ").\n", __LINE__, k, datalen) ; exit (1) ; } ; @@ -152,7 +154,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg oct_save_int (orig, data, datalen) ; exit (1) ; } ; - sum_abs = abs (sum_abs + abs (data [k])) ; + sum_abs += abs (data [k]) ; } ; if (sum_abs < 1.0) @@ -161,7 +163,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg } ; if ((k = sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("Line %d: Incorrect read length (%ld should be %d).\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames - datalen), k) ; + { printf ("Line %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, sfinfo.frames - datalen, k) ; exit (1) ; } ; @@ -188,7 +190,9 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg } ; for (m = 0 ; m < 3 ; m++) - { if ((k = sf_readf_int (file, data, 11)) != 11) + { int n ; + + if ((k = sf_readf_int (file, data, 11)) != 11) { printf ("Line %d: Incorrect read length (11 => %d).\n", __LINE__, k) ; exit (1) ; } ; @@ -196,8 +200,8 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg for (k = 0 ; k < 11 ; k++) if (error_function (data [k] / scale, orig [k + m * 11] / scale, margin)) { printf ("Line %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + m * 11, orig [k + m * 11], data [k]) ; - for (m = 0 ; m < 1 ; m++) - printf ("%d ", data [m]) ; + for (n = 0 ; n < 1 ; n++) + printf ("%d ", data [n]) ; printf ("\n") ; exit (1) ; } ; @@ -207,7 +211,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg /* Check seek from start of file. */ if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %ld failed (%d).\n", seekpos, k) ; + { printf ("Seek to start of file + %" PRId64 " failed (%d).\n", seekpos, k) ; exit (1) ; } ; @@ -222,7 +226,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg } ; if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("Line %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %ld)\n", __LINE__, k, seekpos + 1) ; + { printf ("Line %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %" PRId64 ")\n", __LINE__, k, seekpos + 1) ; exit (1) ; } ; @@ -230,7 +234,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; sf_readf_int (file, data, 1) ; if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos) - { printf ("Line %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos], k, seekpos + 1) ; + { printf ("Line %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos], k, seekpos + 1) ; exit (1) ; } ; @@ -239,7 +243,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg k = sf_seek (file, -20, SEEK_CUR) ; sf_readf_int (file, data, 1) ; if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos) - { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", data [0], orig [seekpos], k, seekpos) ; + { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", data [0], orig [seekpos], k, seekpos) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/floating_point_test.c b/libs/libsndfile/tests/floating_point_test.c index 7db65192a5..aaf53866ea 100644 --- a/libs/libsndfile/tests/floating_point_test.c +++ b/libs/libsndfile/tests/floating_point_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/floating_point_test.tpl b/libs/libsndfile/tests/floating_point_test.tpl index 443ec0a34a..4b2d21caab 100644 --- a/libs/libsndfile/tests/floating_point_test.tpl +++ b/libs/libsndfile/tests/floating_point_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -60,7 +61,7 @@ main (int argc, char *argv []) if (argc == 2 && ! strstr (argv [1], "no-exit")) allow_exit = 0 ; -#if ((HAVE_LRINTF == 0) && (HAVE_LRINT_REPLACEMENT == 0)) +#if (HAVE_LRINTF == 0) puts ("*** Cannot run this test on this platform because it lacks lrintf().") ; exit (0) ; #endif @@ -106,6 +107,11 @@ main (int argc, char *argv []) float_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ; float_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -170.0) ; + float_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ; + float_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -181.0) ; + float_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -160.0) ; + float_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -134.0) ; + #if HAVE_EXTERNAL_LIBS float_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ; float_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ; @@ -120,7 +126,7 @@ main (int argc, char *argv []) ** Double tests. */ - double_scaled_test ("double.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -300.0) ; + double_scaled_test ("double.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -205.0) ; /* Test both signed (AIFF) and unsigned (WAV) 8 bit files. */ double_scaled_test ("pcm_s8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_S8, -39.0) ; @@ -158,6 +164,11 @@ main (int argc, char *argv []) double_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ; double_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -180.0) ; + double_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ; + double_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -134.0) ; + double_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -158.0) ; + double_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -186.0) ; + #if HAVE_EXTERNAL_LIBS double_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ; double_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ; @@ -166,7 +177,7 @@ main (int argc, char *argv []) double_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -29.0) ; #endif - double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -300.0) ; + double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -205.0) ; putchar ('\n') ; /* Float int tests. */ @@ -187,6 +198,7 @@ float_scaled_test (const char *filename, int allow_exit, int replace_float, int { SNDFILE *file ; SF_INFO sfinfo ; double snr ; + int byterate ; print_test_name ("float_scaled_test", filename) ; @@ -210,13 +222,16 @@ float_scaled_test (const char *filename, int allow_exit, int replace_float, int sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ; + exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; check_log_buffer_or_die (file, __LINE__) ; test_read_float_or_die (file, 0, float_test, DFT_DATA_LENGTH, __LINE__) ; + byterate = sf_current_byterate (file) ; + exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ; + sf_close (file) ; snr = dft_cmp_float (__LINE__, float_data, float_test, DFT_DATA_LENGTH, target_snr, allow_exit) ; @@ -235,6 +250,7 @@ double_scaled_test (const char *filename, int allow_exit, int replace_float, int { SNDFILE *file ; SF_INFO sfinfo ; double snr ; + int byterate ; print_test_name ("double_scaled_test", filename) ; @@ -258,13 +274,16 @@ double_scaled_test (const char *filename, int allow_exit, int replace_float, int sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ; + exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; check_log_buffer_or_die (file, __LINE__) ; test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ; + byterate = sf_current_byterate (file) ; + exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ; + sf_close (file) ; snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ; @@ -305,7 +324,7 @@ static void file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; if (sfinfo.frames != ARRAY_LEN ([+ (get "float_name") +]_data)) - { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ; + { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/format_check_test.c b/libs/libsndfile/tests/format_check_test.c new file mode 100644 index 0000000000..a371c71ff7 --- /dev/null +++ b/libs/libsndfile/tests/format_check_test.c @@ -0,0 +1,149 @@ +/* +** Copyright (C) 2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include "sndfile.h" +#include "utils.h" + +static void format_error_test (void) ; +static void format_combo_test (void) ; + +int +main (void) +{ + format_error_test () ; + format_combo_test () ; + + return 0 ; +} /* main */ + +/*============================================================================== +*/ + +static void +format_error_test (void) +{ const char *filename = "format-error.wav" ; + SNDFILE *file ; + SF_INFO info ; + + print_test_name (__func__, NULL) ; + + memset (&info, 0, sizeof (info)) ; + info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; + info.channels = 1 ; + info.samplerate = 44100 ; + + info.format = SF_FORMAT_WAV ; + file = sf_open (filename, SFM_WRITE, &info) ; + exit_if_true (file != NULL, "\n\nLine %d : Format should not be valid.\n\n", __LINE__) ; + exit_if_true ( + strstr (sf_strerror (NULL), "minor format") == NULL, + "\n\nLine %d : Error string should reference bad 'minor format'.\n\n", __LINE__ + ) ; + + info.format = SF_FORMAT_PCM_16 ; + file = sf_open (filename, SFM_WRITE, &info) ; + exit_if_true (file != NULL, "\n\nLine %d : Format should not be valid.\n\n", __LINE__) ; + exit_if_true ( + strstr (sf_strerror (NULL), "major format") == NULL, + "\n\nLine %d : Error string should reference bad 'major format'.\n\n", __LINE__ + ) ; + + unlink (filename) ; + puts ("ok") ; +} /* format_error_test */ + +static void +format_combo_test (void) +{ int container_max, codec_max, cont, codec ; + + print_test_name (__func__, NULL) ; + + sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &container_max, sizeof (container_max)) ; + sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &codec_max, sizeof (codec_max)) ; + + for (cont = 0 ; cont < container_max + 10 ; cont ++) + { SF_FORMAT_INFO major_fmt_info ; + + memset (&major_fmt_info, 0, sizeof (major_fmt_info)) ; + major_fmt_info.format = cont ; + (void) sf_command (NULL, SFC_GET_FORMAT_MAJOR, &major_fmt_info, sizeof (major_fmt_info)) ; + + for (codec = 0 ; codec < codec_max + 10 ; codec ++) + { SF_FORMAT_INFO subtype_fmt_info ; + SNDFILE * sndfile ; + SF_INFO info ; + char filename [128] ; + int subtype_is_valid, check_is_valid ; + + memset (&subtype_fmt_info, 0, sizeof (subtype_fmt_info)) ; + subtype_fmt_info.format = codec ; + subtype_is_valid = sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &subtype_fmt_info, sizeof (subtype_fmt_info)) == 0 ; + + sf_info_setup (&info, major_fmt_info.format | subtype_fmt_info.format, 22050, 1) ; + + check_is_valid = sf_format_check (&info) ; + + exit_if_true ( + NOT (subtype_is_valid) && check_is_valid, + "\n\nLine %d : Subtype is not valid but checks ok.\n", + __LINE__ + ) ; + + snprintf (filename, sizeof (filename), "format-check.%s", major_fmt_info.extension) ; + + sndfile = sf_open (filename, SFM_WRITE, &info) ; + + sf_close (sndfile) ; + unlink (filename) ; + + if (major_fmt_info.extension != NULL && strcmp (major_fmt_info.extension, "sd2") == 0) + { snprintf (filename, sizeof (filename), "._format-check.%s", major_fmt_info.extension) ; + unlink (filename) ; + } ; + + exit_if_true ( + sndfile && NOT (check_is_valid), + "\n\nError : Format was not valid but file opened correctly.\n" + " Container : %s\n" + " Codec : %s\n\n", + major_fmt_info.name, subtype_fmt_info.name + ) ; + + exit_if_true ( + NOT (sndfile) && check_is_valid, + "\n\nError : Format was valid but file failed to open.\n" + " Container : %s\n" + " Codec : %s\n\n", + major_fmt_info.name, subtype_fmt_info.name + ) ; + } ; + } ; + + puts ("ok") ; +} /* format_combo_test */ + diff --git a/libs/libsndfile/tests/generate.c b/libs/libsndfile/tests/generate.c index 1dc105c565..653018b0f4 100644 --- a/libs/libsndfile/tests/generate.c +++ b/libs/libsndfile/tests/generate.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007-2009 Erik de Castro Lopo +** Copyright (C) 2007-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include "utils.h" #include "generate.h" -#define SF_MAX(x,y) ((x) > (y) ? (x) : (y)) +#define SF_MAX(x, y) ((x) > (y) ? (x) : (y)) static float crappy_snare (float *output, int len, int offset, float gain, float maxabs) ; @@ -40,7 +40,7 @@ generate_file (const char * filename, int format, int len) maxabs = crappy_snare (output, len, 0, 0.95, maxabs) ; maxabs = crappy_snare (output, len, len / 4, 0.85, maxabs) ; maxabs = crappy_snare (output, len, 2 * len / 4, 0.85, maxabs) ; - maxabs = crappy_snare (output, len, 3 * len / 4, 0.85, maxabs) ; + crappy_snare (output, len, 3 * len / 4, 0.85, maxabs) ; write_mono_file (filename, format, 44100, output, len) ; diff --git a/libs/libsndfile/tests/generate.h b/libs/libsndfile/tests/generate.h index 6de6160fcb..709ea61191 100644 --- a/libs/libsndfile/tests/generate.h +++ b/libs/libsndfile/tests/generate.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007-2009 Erik de Castro Lopo +** Copyright (C) 2007-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/header_test.c b/libs/libsndfile/tests/header_test.c index dee936b3e3..9802fd9e58 100644 --- a/libs/libsndfile/tests/header_test.c +++ b/libs/libsndfile/tests/header_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** This program is free software ; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -244,15 +244,13 @@ static void update_header_sub (const char *filename, int typemajor, int write_mode) { SNDFILE *outfile, *infile ; SF_INFO sfinfo ; - int k, frames ; + int k ; sfinfo.samplerate = 44100 ; sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - outfile = test_open_file_or_die (filename, write_mode, &sfinfo, SF_TRUE, __LINE__) ; for (k = 0 ; k < BUFFER_LEN ; k++) @@ -642,7 +640,7 @@ header_shrink_test (const char *filename, int filetype) static void extra_header_test (const char *filename, int filetype) -{ SNDFILE *outfile ; +{ SNDFILE *outfile, *infile ; SF_INFO sfinfo ; sf_count_t frames ; short buffer [8] ; @@ -660,9 +658,9 @@ extra_header_test (const char *filename, int filetype) frames = ARRAY_LEN (buffer) / sfinfo.channels ; /* Test the file with extra header data. */ - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, 464) ; + outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, 462) ; sf_set_string (outfile, SF_STR_TITLE, filename) ; - test_writef_short_or_die (outfile, k, buffer, frames, 466) ; + test_writef_short_or_die (outfile, k, buffer, frames, 464) ; sf_set_string (outfile, SF_STR_COPYRIGHT, "(c) 1980 Erik") ; sf_close (outfile) ; @@ -676,7 +674,7 @@ extra_header_test (const char *filename, int filetype) ** integration is done. */ - if (sf_open (filename, SFM_RDWR, &sfinfo) != NULL) + if ((infile = sf_open (filename, SFM_RDWR, &sfinfo)) != NULL) { printf ("\n\nError : should not be able to open this file in SFM_RDWR.\n\n") ; exit (1) ; } ; @@ -689,7 +687,7 @@ extra_header_test (const char *filename, int filetype) hexdump_file (filename, 0, 100000) ; /* Open again for read/write. */ - outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, 493) ; + outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, 491) ; /* ** In auto header update mode, seeking to the end of the file with @@ -710,26 +708,26 @@ extra_header_test (const char *filename, int filetype) memset (buffer, 0xA0 + k, sizeof (buffer)) ; - test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, 514) ; - test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, 515) ; + test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, 512) ; + test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, 513) ; /* Open file again and make sure no errors in log buffer. */ if (0) - { infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, 519) ; - check_log_buffer_or_die (infile, 520) ; + { infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, 517) ; + check_log_buffer_or_die (infile, 518) ; sf_close (infile) ; } ; if (sfinfo.frames != k * frames) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", 525, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ; + { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", 523, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ; dump_log_buffer (infile) ; exit (1) ; } ; if ((k & 1) == 0) - test_write_short_or_die (outfile, k, buffer, sfinfo.channels * frames, 531) ; + test_write_short_or_die (outfile, k, buffer, sfinfo.channels * frames, 529) ; else - test_writef_short_or_die (outfile, k, buffer, frames, 533) ; + test_writef_short_or_die (outfile, k, buffer, frames, 531) ; hexdump_file (filename, 0, 100000) ; } ; diff --git a/libs/libsndfile/tests/header_test.tpl b/libs/libsndfile/tests/header_test.tpl index 488e128acb..6545bb498b 100644 --- a/libs/libsndfile/tests/header_test.tpl +++ b/libs/libsndfile/tests/header_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software ; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,9 +22,10 @@ #include #include #include +#include +#include #include -#include #if HAVE_UNISTD_H #include @@ -43,7 +44,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<10) +#define BUFFER_LEN (1 << 10) #define LOG_BUFFER_SIZE 1024 static void update_header_test (const char *filename, int typemajor) ; @@ -77,7 +78,7 @@ main (int argc, char *argv []) exit (1) ; } ; - do_all=!strcmp (argv [1], "all") ; + do_all= !strcmp (argv [1], "all") ; if (do_all || ! strcmp (argv [1], "wav")) { update_header_test ("header.wav", SF_FORMAT_WAV) ; @@ -244,15 +245,13 @@ static void update_header_sub (const char *filename, int typemajor, int write_mode) { SNDFILE *outfile, *infile ; SF_INFO sfinfo ; - int k, frames ; + int k ; sfinfo.samplerate = 44100 ; sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - outfile = test_open_file_or_die (filename, write_mode, &sfinfo, SF_TRUE, __LINE__) ; for (k = 0 ; k < BUFFER_LEN ; k++) @@ -275,7 +274,7 @@ update_header_sub (const char *filename, int typemajor, int write_mode) check_log_buffer_or_die (infile, __LINE__) ; if (sfinfo.frames < BUFFER_LEN || sfinfo.frames > BUFFER_LEN + 50) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), BUFFER_LEN) ; + { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ; dump_log_buffer (infile) ; exit (1) ; } ; @@ -300,7 +299,7 @@ update_header_sub (const char *filename, int typemajor, int write_mode) check_log_buffer_or_die (infile, __LINE__) ; if (sfinfo.frames < 2 * BUFFER_LEN || sfinfo.frames > 2 * BUFFER_LEN + 50) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * BUFFER_LEN) ; + { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 2 * BUFFER_LEN) ; dump_log_buffer (infile) ; exit (1) ; } ; @@ -332,8 +331,8 @@ update_header_test (const char *filename, int typemajor) update_seek_[+ (get "name") +]_test (const char *filename, int filetype) { SNDFILE *outfile, *infile ; SF_INFO sfinfo ; - sf_count_t frames ; - [+ (get "name") +] buffer [8] ; + sf_count_t frames ; + [+ (get "name") +] buffer [8] ; int k ; print_test_name ("update_seek_[+ (get "name") +]_test", filename) ; @@ -356,11 +355,11 @@ update_seek_[+ (get "name") +]_test (const char *filename, int filetype) /* ** In auto header update mode, seeking to the end of the file with - ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END + ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END ** will seek to 0 anyway */ if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0) - { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; + { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; exit (1) ; } ; @@ -377,7 +376,7 @@ update_seek_[+ (get "name") +]_test (const char *filename, int filetype) sf_close (infile) ; if (sfinfo.frames != k * frames) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ; + { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", __LINE__, sfinfo.frames, k + frames) ; dump_log_buffer (infile) ; exit (1) ; } ; @@ -445,8 +444,8 @@ static void extra_header_test (const char *filename, int filetype) { SNDFILE *outfile, *infile ; SF_INFO sfinfo ; - sf_count_t frames ; - short buffer [8] ; + sf_count_t frames ; + short buffer [8] ; int k = 0 ; print_test_name ("extra_header_test", filename) ; @@ -494,11 +493,11 @@ extra_header_test (const char *filename, int filetype) /* ** In auto header update mode, seeking to the end of the file with - ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END + ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END ** will seek to 0 anyway */ if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0) - { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; + { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; exit (1) ; } ; @@ -522,7 +521,7 @@ extra_header_test (const char *filename, int filetype) } ; if (sfinfo.frames != k * frames) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", [+ (tpl-file-line "%2$d") +], SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ; + { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", [+ (tpl-file-line "%2$d") +], sfinfo.frames, k + frames) ; dump_log_buffer (infile) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/headerless_test.c b/libs/libsndfile/tests/headerless_test.c index 4300a1f1a9..6d3e2f2589 100644 --- a/libs/libsndfile/tests/headerless_test.c +++ b/libs/libsndfile/tests/headerless_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -93,7 +94,7 @@ headerless_test (const char * filename, int format, int expected) } ; if (sfinfo.frames < BUFFER_SIZE) - { printf ("Line %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Line %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; exit (1) ; } ; @@ -154,7 +155,7 @@ old_test (void) } ; if (sfinfo.frames < BUFFER_SIZE) - { printf ("Line %d: Incorrect number of.frames in file. (%d => %ld)\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Line %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/largefile_test.c b/libs/libsndfile/tests/largefile_test.c index 73c11ef8cb..328a589a02 100644 --- a/libs/libsndfile/tests/largefile_test.c +++ b/libs/libsndfile/tests/largefile_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2006-2009 Erik de Castro Lopo +** Copyright (C) 2006-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/locale_test.c b/libs/libsndfile/tests/locale_test.c index d8f16ed21f..b67d549c58 100644 --- a/libs/libsndfile/tests/locale_test.c +++ b/libs/libsndfile/tests/locale_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005-2009 Erik de Castro Lopo +** Copyright (C) 2005-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ */ #include "sfconfig.h" -#include "sndfile.h" #include #include @@ -31,41 +30,98 @@ #include #endif +#if OS_IS_WIN32 +#include +#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 +#endif + +#include "sndfile.h" #include "utils.h" -typedef struct -{ const char *locale ; - const char *filename ; - int width ; -} LOCALE_DATA ; - -static void locale_test (const char * locname, const char * filename, int width) ; +static void utf8_test (void) ; +static void wchar_test (void) ; int main (void) -{ LOCALE_DATA ldata [] = - { { "de_DE", "F\303\274\303\237e.au", 7 }, - { "en_AU", "kangaroo.au", 11 }, - { "POSIX", "posix.au", 8 }, - { "pt_PT", "concei\303\247\303\243o.au", 12 }, - -#if OS_IS_WIN32 == 0 - { "ja_JP", "\343\201\212\343\201\257\343\202\210\343\201\206\343\201\224\343\201\226\343\201\204\343\201\276\343\201\231.au", 21 }, - { "vi_VN", "qu\341\273\221c ng\341\273\257.au", 11 }, -#endif - - { NULL, NULL, 0 } - } ; - int k ; - - for (k = 0 ; ldata [k].locale != NULL ; k++) - locale_test (ldata [k].locale, ldata [k].filename, ldata [k].width) ; +{ + utf8_test () ; + wchar_test () ; return 0 ; } /* main */ +/*============================================================================== +*/ + static void -locale_test (const char * locname, const char * filename, int width) +wchar_test (void) +{ +#if OS_IS_WIN32 + SNDFILE * file ; + SF_INFO info ; + LPCWSTR filename = L"test.wav" ; + + print_test_name (__func__, "test.wav") ; + + info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; + info.channels = 1 ; + info.samplerate = 44100 ; + + file = sf_wchar_open (filename, SFM_WRITE, &info) ; + exit_if_true (file == NULL, "\n\nLine %d : sf_wchar_open failed : %s\n\n", __LINE__, sf_strerror (NULL)) ; + sf_close (file) ; + + /* This should check that the file did in fact get created with a + ** wchar_t * filename. + */ + exit_if_true ( + GetFileAttributesW (filename) == INVALID_FILE_ATTRIBUTES, + "\n\nLine %d : GetFileAttributes failed.\n\n", __LINE__ + ) ; + + /* Use this because the file was created with CreateFileW. */ + DeleteFileW (filename) ; + + puts ("ok") ; +#endif +} /* wchar_test */ + +/*============================================================================== +*/ + +typedef struct +{ const char *locale ; + int utf8 ; + const char *filename ; + int width ; +} LOCALE_DATA ; + +static void locale_test (const LOCALE_DATA * locdata) ; + +static void +utf8_test (void) +{ LOCALE_DATA ldata [] = + { { "de_DE", 1, "F\303\274\303\237e.au", 7 }, + { "en_AU", 1, "kangaroo.au", 11 }, + { "POSIX", 0, "posix.au", 8 }, + { "pt_PT", 1, "concei\303\247\303\243o.au", 12 }, + +#if OS_IS_WIN32 == 0 + { "ja_JP", 1, "\343\201\212\343\201\257\343\202\210\343\201\206\343\201\224\343\201\226\343\201\204\343\201\276\343\201\231.au", 21 }, +#endif + + { "vi_VN", 1, "qu\341\273\221c ng\341\273\257.au", 11 }, + { NULL, 0, NULL, 0 } + } ; + int k ; + + for (k = 0 ; ldata [k].locale != NULL ; k++) + locale_test (ldata + k) ; +} /* utf8_test */ + + +static void +locale_test (const LOCALE_DATA * ldata) { #if (HAVE_LOCALE_H == 0 || HAVE_SETLOCALE == 0) locname = filename = NULL ; @@ -75,34 +131,36 @@ locale_test (const char * locname, const char * filename, int width) const short wdata [] = { 1, 2, 3, 4, 5, 6, 7, 8 } ; short rdata [ARRAY_LEN (wdata)] ; const char *old_locale ; + char utf8_locname [32] ; SNDFILE *file ; SF_INFO sfinfo ; - /* Grab the old locale. */ - old_locale = setlocale (LC_ALL, NULL) ; + snprintf (utf8_locname, sizeof (utf8_locname), "%s%s", ldata->locale, ldata->utf8 ? ".UTF-8" : "") ; - if (setlocale (LC_ALL, locname) == NULL) + /* Change the locale saving the old one. */ + if ((old_locale = setlocale (LC_CTYPE, utf8_locname)) == NULL) return ; - printf (" locale_test : %-6s %s%*c : ", locname, filename, 28 - width, ' ') ; + printf (" locale_test %-8s : %s %*c ", ldata->locale, ldata->filename, 24 - ldata->width, ' ') ; fflush (stdout) ; sfinfo.format = SF_FORMAT_AU | SF_FORMAT_PCM_16 ; sfinfo.channels = 1 ; sfinfo.samplerate = 44100 ; - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, 0, __LINE__) ; + file = test_open_file_or_die (ldata->filename, SFM_WRITE, &sfinfo, 0, __LINE__) ; test_write_short_or_die (file, 0, wdata, ARRAY_LEN (wdata), __LINE__) ; sf_close (file) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, 0, __LINE__) ; + file = test_open_file_or_die (ldata->filename, SFM_READ, &sfinfo, 0, __LINE__) ; test_read_short_or_die (file, 0, rdata, ARRAY_LEN (rdata), __LINE__) ; sf_close (file) ; - /* Restore old locale. */ - setlocale (LC_ALL, old_locale) ; + unlink (ldata->filename) ; + + /* Restore old locale. */ + setlocale (LC_CTYPE, old_locale) ; - unlink (filename) ; puts ("ok") ; #endif } /* locale_test */ diff --git a/libs/libsndfile/tests/lossy_comp_test.c b/libs/libsndfile/tests/lossy_comp_test.c index 8947da02cf..5f9f593f8f 100644 --- a/libs/libsndfile/tests/lossy_comp_test.c +++ b/libs/libsndfile/tests/lossy_comp_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ #include #include #include +#include + #if HAVE_UNISTD_H #include @@ -31,14 +33,14 @@ #include "utils.h" -#define BUFFER_SIZE (1<<14) /* Should be (1<<14) */ +#define BUFFER_SIZE (1 << 14) #define SAMPLE_RATE 11025 #ifndef M_PI #define M_PI 3.14159265358979323846264338 #endif -#define LCT_MAX(x,y) ((x) > (y) ? (x) : (y)) +#define LCT_MAX(x, y) ((x) > (y) ? (x) : (y)) static void lcomp_test_short (const char *filename, int filetype, int chan, double margin) ; static void lcomp_test_int (const char *filename, int filetype, int chan, double margin) ; @@ -556,7 +558,7 @@ lcomp_test_short (const char *filename, int filetype, int channels, double margi { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos, half_max_abs ; - long datalen ; + sf_count_t datalen ; short *orig, *data ; print_test_name ("lcomp_test_short", filename) ; @@ -593,12 +595,12 @@ lcomp_test_short (const char *filename, int filetype, int channels, double margi } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too few frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -629,8 +631,8 @@ lcomp_test_short (const char *filename, int filetype, int channels, double margi } ; if ((k = sf_readf_short (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%ld should be %d).\n", __LINE__, - SF_COUNT_TO_LONG (channels * sfinfo.frames - datalen), k) ; + { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, + channels * sfinfo.frames - datalen, k) ; exit (1) ; } ; @@ -742,7 +744,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) { SNDFILE *file ; SF_INFO sfinfo ; int k, m, half_max_abs ; - long datalen, seekpos ; + sf_count_t datalen, seekpos ; double scale, max_val ; int *orig, *data ; @@ -790,12 +792,12 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; @@ -826,8 +828,8 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) } ; if ((k = sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%ld should be %d).\n", __LINE__, - SF_COUNT_TO_LONG (channels * sfinfo.frames - datalen), k) ; + { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, + channels * sfinfo.frames - datalen, k) ; exit (1) ; } ; @@ -872,7 +874,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) /* Check seek from start of file. */ if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %ld failed (%d).\n", seekpos, k) ; + { printf ("Seek to start of file + %" PRId64 " failed (%d).\n", seekpos, k) ; exit (1) ; } ; @@ -884,7 +886,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) } ; if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %ld)\n", __LINE__, k, seekpos + 1) ; + { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %" PRId64 ")\n", __LINE__, k, seekpos + 1) ; exit (1) ; } ; @@ -892,7 +894,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; test_readf_int_or_die (file, 0, data, 1, __LINE__) ; if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; + { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; exit (1) ; } ; @@ -901,7 +903,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) k = sf_seek (file, -20, SEEK_CUR) ; test_readf_int_or_die (file, 0, data, 1, __LINE__) ; if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; + { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; exit (1) ; } ; @@ -939,7 +941,7 @@ lcomp_test_float (const char *filename, int filetype, int channels, double margi { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos ; - long datalen ; + sf_count_t datalen ; float *orig, *data ; double half_max_abs ; @@ -978,12 +980,12 @@ lcomp_test_float (const char *filename, int filetype, int channels, double margi } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; @@ -1020,8 +1022,8 @@ lcomp_test_float (const char *filename, int filetype, int channels, double margi } ; if ((k = sf_readf_float (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%ld should be %d).\n", __LINE__, - SF_COUNT_TO_LONG (channels * sfinfo.frames - datalen), k) ; + { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, + channels * sfinfo.frames - datalen, k) ; exit (1) ; } ; @@ -1133,7 +1135,7 @@ lcomp_test_double (const char *filename, int filetype, int channels, double marg { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos ; - long datalen ; + sf_count_t datalen ; double *orig, *data ; double half_max_abs ; @@ -1172,12 +1174,12 @@ lcomp_test_double (const char *filename, int filetype, int channels, double marg } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; @@ -1214,8 +1216,8 @@ lcomp_test_double (const char *filename, int filetype, int channels, double marg } ; if ((k = sf_readf_double (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%ld should be %d).\n", __LINE__, - SF_COUNT_TO_LONG (channels * sfinfo.frames - datalen), k) ; + { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, + channels * sfinfo.frames - datalen, k) ; exit (1) ; } ; @@ -1328,7 +1330,7 @@ sdlcomp_test_short (const char *filename, int filetype, int channels, double mar { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos, half_max_abs ; - long datalen ; + sf_count_t datalen ; short *orig, *data, *smooth ; channels = 1 ; @@ -1386,12 +1388,12 @@ channels = 1 ; } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -1428,7 +1430,7 @@ channels = 1 ; } ; if ((k = sf_read_short (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %ld).\n", __LINE__, k, SF_COUNT_TO_LONG (sfinfo.frames - datalen)) ; + { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; exit (1) ; } ; @@ -1436,7 +1438,7 @@ channels = 1 ; (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) if (abs (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%ld : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; + { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; exit (1) ; } ; @@ -1456,7 +1458,7 @@ channels = 1 ; for (k = 0 ; k < datalen / 7 ; k++) if (error_function (1.0 * data [k], 1.0 * smooth [k], margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; + { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; for (m = 0 ; m < 10 ; m++) printf ("%d ", data [k]) ; printf ("\n") ; @@ -1503,10 +1505,10 @@ channels = 1 ; /* Check that read past end of file returns number of items. */ sf_seek (file, sfinfo.frames, SEEK_SET) ; - if ((k = sf_read_short (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_short past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; + if ((k = sf_read_short (file, data, datalen)) != 0) + { printf ("\n\nLine %d: Return value from sf_read_short past end of file incorrect (%d).\n", __LINE__, k) ; + exit (1) ; + } ; /* Check seek backward from end. */ @@ -1533,7 +1535,7 @@ sdlcomp_test_int (const char *filename, int filetype, int channels, double margi { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos, half_max_abs ; - long datalen ; + sf_count_t datalen ; int *orig, *data, *smooth ; double scale ; @@ -1594,12 +1596,12 @@ channels = 1 ; } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -1632,7 +1634,7 @@ channels = 1 ; } ; if ((k = sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %ld).\n", __LINE__, k, SF_COUNT_TO_LONG (sfinfo.frames - datalen)) ; + { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; exit (1) ; } ; @@ -1643,7 +1645,7 @@ channels = 1 ; (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_G723_24) for (k = 0 ; k < sfinfo.frames - datalen ; k++) if (abs (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%ld : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; + { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; exit (1) ; } ; @@ -1663,7 +1665,7 @@ channels = 1 ; for (k = 0 ; k < datalen / 7 ; k++) if (error_function (data [k] / scale, smooth [k] / scale, margin)) - { printf ("\nLine %d: Incorrect sample (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; + { printf ("\nLine %d: Incorrect sample (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; for (m = 0 ; m < 10 ; m++) printf ("%d ", data [k]) ; printf ("\n") ; @@ -1710,10 +1712,10 @@ channels = 1 ; /* Check that read past end of file returns number of items. */ sf_seek (file, sfinfo.frames, SEEK_SET) ; - if ((k = sf_readf_int (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; + if ((k = sf_readf_int (file, data, datalen)) != 0) + { printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ; + exit (1) ; + } ; /* Check seek backward from end. */ @@ -1740,7 +1742,7 @@ sdlcomp_test_float (const char *filename, int filetype, int channels, double mar { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos ; - long datalen ; + sf_count_t datalen ; float *orig, *data, *smooth ; double half_max_abs ; @@ -1789,12 +1791,12 @@ printf ("** fix this ** ") ; } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -1832,7 +1834,7 @@ printf ("** fix this ** ") ; } ; if ((k = sf_read_float (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %ld).\n", __LINE__, k, SF_COUNT_TO_LONG (sfinfo.frames - datalen)) ; + { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; exit (1) ; } ; @@ -1840,7 +1842,7 @@ printf ("** fix this ** ") ; (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) if (abs (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%ld : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; + { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; exit (1) ; } ; @@ -1860,7 +1862,7 @@ printf ("** fix this ** ") ; for (k = 0 ; k < datalen / 7 ; k++) if (error_function (data [k], smooth [k], margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ; + { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ; for (m = 0 ; m < 10 ; m++) printf ("%d ", (int) data [k]) ; printf ("\n") ; @@ -1907,10 +1909,10 @@ printf ("** fix this ** ") ; /* Check that read past end of file returns number of items. */ sf_seek (file, sfinfo.frames, SEEK_SET) ; - if ((k = sf_read_float (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_float past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; + if ((k = sf_read_float (file, data, datalen)) != 0) + { printf ("\n\nLine %d: Return value from sf_read_float past end of file incorrect (%d).\n", __LINE__, k) ; + exit (1) ; + } ; /* Check seek backward from end. */ @@ -1937,7 +1939,7 @@ sdlcomp_test_double (const char *filename, int filetype, int channels, double ma { SNDFILE *file ; SF_INFO sfinfo ; int k, m, seekpos ; - long datalen ; + sf_count_t datalen ; double *orig, *data, *smooth, half_max_abs ; channels = 1 ; @@ -1980,12 +1982,12 @@ channels = 1 ; } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -2024,7 +2026,7 @@ channels = 1 ; } ; if ((k = sf_read_double (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %ld).\n", __LINE__, k, SF_COUNT_TO_LONG (sfinfo.frames - datalen)) ; + { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; exit (1) ; } ; @@ -2032,7 +2034,7 @@ channels = 1 ; (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) if (abs (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%ld : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; + { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; exit (1) ; } ; @@ -2052,7 +2054,7 @@ channels = 1 ; for (k = 0 ; k < datalen / 7 ; k++) if (error_function (data [k], smooth [k], margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ; + { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ; for (m = 0 ; m < 10 ; m++) printf ("%d ", (int) data [k]) ; printf ("\n") ; @@ -2099,10 +2101,10 @@ channels = 1 ; /* Check that read past end of file returns number of items. */ sf_seek (file, sfinfo.frames, SEEK_SET) ; - if ((k = sf_read_double (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_double past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; + if ((k = sf_read_double (file, data, datalen)) != 0) + { printf ("\n\nLine %d: Return value from sf_read_double past end of file incorrect (%d).\n", __LINE__, k) ; + exit (1) ; + } ; /* Check seek backward from end. */ @@ -2128,8 +2130,7 @@ static void read_raw_test (const char *filename, int filetype, int channels) { SNDFILE *file ; SF_INFO sfinfo ; - sf_count_t count ; - long datalen ; + sf_count_t count, datalen ; short *orig, *data ; int k ; @@ -2167,12 +2168,12 @@ read_raw_test (const char *filename, int filetype, int channels) } ; if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; exit (1) ; } ; if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ; + { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; exit (1) ; } ; @@ -2185,7 +2186,7 @@ read_raw_test (const char *filename, int filetype, int channels) count = sf_read_raw (file, orig_buffer.c, datalen + 5 * channels) ; if (count != sfinfo.channels * sfinfo.frames) - { printf ("\nLine %d : sf_read_raw returned %ld should be %ld\n", __LINE__, SF_COUNT_TO_LONG (count), sfinfo.channels * SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\nLine %d : sf_read_raw returned %" PRId64 " should be %" PRId64 "\n", __LINE__, count, sfinfo.channels * sfinfo.frames) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/misc_test.c b/libs/libsndfile/tests/misc_test.c index ab66078eca..b95e421dce 100644 --- a/libs/libsndfile/tests/misc_test.c +++ b/libs/libsndfile/tests/misc_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software ; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<10) +#define BUFFER_LEN (1 << 10) #define LOG_BUFFER_SIZE 1024 static void zero_data_test (const char *filename, int format) ; @@ -65,7 +65,7 @@ main (int argc, char *argv []) exit (1) ; } ; - do_all=!strcmp (argv [1], "all") ; + do_all = ! strcmp (argv [1], "all") ; if (do_all || ! strcmp (argv [1], "wav")) { zero_data_test ("zerolen.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; @@ -220,7 +220,6 @@ static void zero_data_test (const char *filename, int format) { SNDFILE *file ; SF_INFO sfinfo ; - int frames ; switch (format & SF_FORMAT_TYPEMASK) { case SF_FORMAT_OGG : @@ -238,8 +237,6 @@ zero_data_test (const char *filename, int format) sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; sf_close (file) ; @@ -261,7 +258,6 @@ filesystem_full_test (int format) struct stat buf ; const char *filename = "/dev/full", *errorstr ; - int frames ; #if (defined (WIN32) || defined (_WIN32)) /* Can't run this test on Win32 so return. */ @@ -288,8 +284,6 @@ filesystem_full_test (int format) sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL) { printf ("\n\nLine %d : Error, file should not have openned.\n", __LINE__ - 1) ; exit (1) ; @@ -321,7 +315,6 @@ permission_test (const char *filename, int typemajor) SNDFILE *file ; SF_INFO sfinfo ; const char *errorstr ; - int frames ; /* Make sure errno is zero before doing anything else. */ errno = 0 ; @@ -360,8 +353,6 @@ permission_test (const char *filename, int typemajor) sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL) { printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ; exit (1) ; diff --git a/libs/libsndfile/tests/multi_file_test.c b/libs/libsndfile/tests/multi_file_test.c index 2e066a2bd4..502d15a6ba 100644 --- a/libs/libsndfile/tests/multi_file_test.c +++ b/libs/libsndfile/tests/multi_file_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #include #include +#include +#include +#include #if HAVE_UNISTD_H #include @@ -30,8 +33,6 @@ #endif #include -#include -#include #include #include @@ -131,15 +132,13 @@ multi_file_test (const char *filename, int *formats, int format_count) SF_INFO sfinfo ; SF_EMBED_FILE_INFO embed_info ; sf_count_t filelen ; - int fd, k, file_count = 0, open_perm ; + int fd, k, file_count = 0 ; print_test_name ("multi_file_test", filename) ; unlink (filename) ; - open_perm = OS_IS_WIN32 ? 0 : S_IRUSR | S_IWUSR | S_IRGRP ; - - if ((fd = open (filename, O_RDWR | O_CREAT, open_perm)) < 0) + if ((fd = open (filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { printf ("\n\nLine %d: open failed : %s\n", __LINE__, strerror (errno)) ; exit (1) ; } ; @@ -155,13 +154,11 @@ multi_file_test (const char *filename, int *formats, int format_count) embed_info.length = 0 ; - for (file_count = 0 ; embed_info.offset + embed_info.length < filelen ; ) + for (file_count = 1 ; embed_info.offset + embed_info.length < filelen ; file_count ++) { - file_count ++ ; - if (verbose) { puts ("\n------------------------------------") ; - printf ("This offset : %ld\n", SF_COUNT_TO_LONG (embed_info.offset + embed_info.length)) ; + printf ("This offset : %" PRId64 "\n", embed_info.offset + embed_info.length) ; } ; if (lseek (fd, embed_info.offset + embed_info.length, SEEK_SET) < 0) @@ -172,7 +169,7 @@ multi_file_test (const char *filename, int *formats, int format_count) memset (&sfinfo, 0, sizeof (sfinfo)) ; if ((sndfile = sf_open_fd (fd, SFM_READ, &sfinfo, SF_FALSE)) == NULL) { printf ("\n\nLine %d: sf_open_fd failed\n", __LINE__) ; - printf ("Embedded file number : %d offset : %ld\n", file_count, SF_COUNT_TO_LONG (embed_info.offset)) ; + printf ("Embedded file number : %d offset : %" PRId64 "\n", file_count, embed_info.offset) ; puts (sf_strerror (sndfile)) ; dump_log_buffer (sndfile) ; exit (1) ; @@ -183,9 +180,11 @@ multi_file_test (const char *filename, int *formats, int format_count) sf_close (sndfile) ; if (verbose) - printf ("\nNext offset : %ld\nNext length : %ld\n", SF_COUNT_TO_LONG (embed_info.offset), SF_COUNT_TO_LONG (embed_info.length)) ; + printf ("\nNext offset : %" PRId64 "\nNext length : %" PRId64 "\n", embed_info.offset, embed_info.length) ; } ; + file_count -- ; + if (file_count != format_count) { printf ("\n\nLine %d: file count (%d) not equal to %d.\n\n", __LINE__, file_count, format_count) ; printf ("Embedded file number : %d\n", file_count) ; diff --git a/libs/libsndfile/tests/ogg_test.c b/libs/libsndfile/tests/ogg_test.c index b3b8327fdc..4b1be031fc 100644 --- a/libs/libsndfile/tests/ogg_test.c +++ b/libs/libsndfile/tests/ogg_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007-2009 Erik de Castro Lopo +** Copyright (C) 2007-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -90,6 +90,9 @@ ogg_short_test (void) test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ; + /* Test seek to end of file. */ + test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; + sf_close (file) ; puts ("ok") ; @@ -266,7 +269,7 @@ ogg_stereo_seek_test (const char * filename, int format) gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ; for (k = 0 ; k < ARRAY_LEN (data) ; k++) { stereo_out [2 * k] = data [k] ; - stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; + stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; } ; memset (&sfinfo, 0, sizeof (sfinfo)) ; diff --git a/libs/libsndfile/tests/pcm_test.c b/libs/libsndfile/tests/pcm_test.c index 88bde01242..86511f65e4 100644 --- a/libs/libsndfile/tests/pcm_test.c +++ b/libs/libsndfile/tests/pcm_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -80,8 +80,6 @@ main (void) pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_FALSE) ; pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_FALSE) ; - puts ("Test IEEE replacement code.") ; - pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_TRUE) ; pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_TRUE) ; @@ -318,7 +316,6 @@ pcm_test_bits_8 (const char *filename, int filetype, uint64_t hash) if (fabs (float_out [k] - float_in [k]) > 1e-10) { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; exit (1) ; - break ; } ; sf_close (file) ; @@ -585,7 +582,6 @@ pcm_test_bits_16 (const char *filename, int filetype, uint64_t hash) if (fabs (float_out [k] - float_in [k]) > 1e-10) { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; exit (1) ; - break ; } ; sf_close (file) ; @@ -852,7 +848,6 @@ pcm_test_bits_24 (const char *filename, int filetype, uint64_t hash) if (fabs (float_out [k] - float_in [k]) > 1e-10) { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; exit (1) ; - break ; } ; sf_close (file) ; @@ -1119,7 +1114,6 @@ pcm_test_bits_32 (const char *filename, int filetype, uint64_t hash) if (fabs (float_out [k] - float_in [k]) > 1e-10) { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; exit (1) ; - break ; } ; sf_close (file) ; @@ -1205,7 +1199,7 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f int sign ; double *data, error ; - print_test_name ("pcm_test_float", filename) ; + print_test_name (replace_float ? "pcm_test_float (replace)" : "pcm_test_float", filename) ; items = BUFFER_SIZE ; @@ -1461,7 +1455,7 @@ pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_ /* This is the best test routine. Other should be brought up to this standard. */ - print_test_name ("pcm_test_double", filename) ; + print_test_name (replace_float ? "pcm_test_double (replace)" : "pcm_test_double", filename) ; items = BUFFER_SIZE ; diff --git a/libs/libsndfile/tests/pcm_test.tpl b/libs/libsndfile/tests/pcm_test.tpl index a84520ee04..459e741d0a 100644 --- a/libs/libsndfile/tests/pcm_test.tpl +++ b/libs/libsndfile/tests/pcm_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -32,7 +33,7 @@ #include "utils.h" -#define BUFFER_SIZE (1<<12) +#define BUFFER_SIZE (1 << 12) static void lrintf_test (void) ; @@ -80,8 +81,6 @@ main (void) pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_FALSE) ; pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_FALSE) ; - puts ("Test IEEE replacement code.") ; - pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_TRUE) ; pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_TRUE) ; @@ -176,7 +175,7 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) } ; if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %ld)\n", __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -238,7 +237,7 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) } ; if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %ld)\n", __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -300,7 +299,7 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) } ; if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %ld)\n", __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -319,7 +318,6 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) if (fabs (float_out [k] - float_in [k]) > 1e-10) { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; exit (1) ; - break ; } ; sf_close (file) ; @@ -364,7 +362,7 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) } ; if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %ld)\n", __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -406,7 +404,7 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f int sign ; double *data, error ; - print_test_name ("pcm_test_float", filename) ; + print_test_name (replace_float ? "pcm_test_float (replace)" : "pcm_test_float", filename) ; items = BUFFER_SIZE ; @@ -454,7 +452,7 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f } ; if (sfinfo.frames != items) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %ld)\n", __FILE__, __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -475,6 +473,9 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f } ; } ; + /* Seek to end of file. */ + test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; + /* Seek to start of file. */ test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; @@ -578,7 +579,7 @@ pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_f } ; if (sfinfo.frames != frames) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %ld)\n", __FILE__, __LINE__, frames, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, frames, sfinfo.frames) ; exit (1) ; } ; @@ -662,7 +663,7 @@ pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_ /* This is the best test routine. Other should be brought up to this standard. */ - print_test_name ("pcm_test_double", filename) ; + print_test_name (replace_float ? "pcm_test_double (replace)" : "pcm_test_double", filename) ; items = BUFFER_SIZE ; @@ -717,7 +718,7 @@ pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_ } ; if (sfinfo.frames != items) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %ld)\n", __FILE__, __LINE__, items, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, items, sfinfo.frames) ; exit (1) ; } ; @@ -851,7 +852,7 @@ pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_ } ; if (sfinfo.frames != frames) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %ld)\n", __FILE__, __LINE__, frames, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, frames, sfinfo.frames) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/peak_chunk_test.c b/libs/libsndfile/tests/peak_chunk_test.c index 9083e4735e..9e5332a1e4 100644 --- a/libs/libsndfile/tests/peak_chunk_test.c +++ b/libs/libsndfile/tests/peak_chunk_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -31,7 +32,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<15) +#define BUFFER_LEN (1 << 15) #define LOG_BUFFER_SIZE 1024 @@ -54,8 +55,9 @@ main (int argc, char *argv []) if (argc != 2) { printf ("Usage : %s \n", argv [0]) ; printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file peak chunk\n") ; printf (" aiff - test AIFF file PEAK chunk\n") ; + printf (" caf - test CAF file PEAK chunk\n") ; + printf (" wav - test WAV file peak chunk\n") ; printf (" all - perform all tests\n") ; exit (1) ; } ; @@ -79,6 +81,13 @@ main (int argc, char *argv []) test_count++ ; } ; + if (do_all || ! strcmp (argv [1], "caf")) + { test_float_peak ("peak_float.caf", SF_FORMAT_CAF | SF_FORMAT_FLOAT) ; + + read_write_peak_test ("rw_peak.caf", SF_FORMAT_CAF | SF_FORMAT_FLOAT) ; + test_count++ ; + } ; + if (test_count == 0) { printf ("Mono : ************************************\n") ; printf ("Mono : * No '%s' test defined.\n", argv [1]) ; @@ -248,7 +257,13 @@ check_logged_peaks (char *buffer) exit (1) ; } ; - if (! (cptr = strstr (buffer, "Channels")) || sscanf (cptr, "Channels : %d", &channel_count) != 1) + channel_count = 0 ; + cptr = strstr (buffer, "Channels") ; + if (cptr && sscanf (cptr, "Channels : %d", &k) == 1) + channel_count = k ; + else if (cptr && sscanf (cptr, "Channels / frame : %d", &k) == 1) + channel_count = k ; + else { printf ("\n\nLine %d: Couldn't find channel count.\n", __LINE__) ; exit (1) ; } ; @@ -291,56 +306,55 @@ check_logged_peaks (char *buffer) static void read_write_peak_test (const char *filename, int filetype) { SNDFILE *file ; - SF_INFO sfinfo ; + SF_INFO sfinfo ; - double small_data [10] ; - double max_peak = 0.0 ; - unsigned k ; + double small_data [10], max_peak = 0.0 ; + unsigned k ; print_test_name (__func__, filename) ; - for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) - small_data [k] = 0.1 ; + for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) + small_data [k] = 0.1 ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 2 ; - sfinfo.format = filetype ; - sfinfo.frames = 0 ; + sfinfo.samplerate = 44100 ; + sfinfo.channels = 2 ; + sfinfo.format = filetype ; + sfinfo.frames = 0 ; /* Open the file, add peak chunk and write samples with value 0.1. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; + sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ; - sf_close (file) ; + sf_close (file) ; - /* Open the fiel RDWR, write sample valied 1.25. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; + /* Open the fiel RDWR, write sample valied 1.25. */ + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) - small_data [k] = 1.0 ; + for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) + small_data [k] = 1.0 ; test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ; - sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ; + sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ; - sf_close (file) ; + sf_close (file) ; - exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ; + exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ; - /* Open the file and test the values written to the PEAK chunk. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; + /* Open the file and test the values written to the PEAK chunk. */ + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; exit_if_true (sfinfo.channels * sfinfo.frames != 2 * ARRAY_LEN (small_data), - "Line %d : frame count is %ld, should be %d\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * ARRAY_LEN (small_data)) ; + "Line %d : frame count is %" PRId64 ", should be %zd\n", __LINE__, sfinfo.frames, 2 * ARRAY_LEN (small_data)) ; - sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ; + sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ; - sf_close (file) ; + sf_close (file) ; - exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ; + exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ; unlink (filename) ; puts ("ok") ; diff --git a/libs/libsndfile/tests/pedantic-header-test.sh.in b/libs/libsndfile/tests/pedantic-header-test.sh.in new file mode 100644 index 0000000000..8b1962803a --- /dev/null +++ b/libs/libsndfile/tests/pedantic-header-test.sh.in @@ -0,0 +1,58 @@ +#!/bin/bash + +# Copyright (C) 2010-2011 Erik de Castro Lopo +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the author nor the names of any contributors may be used +# to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +if test ! -f @top_srcdir@/tests/sfversion.c ; then + exit 0 + fi + +echo -n " Pedantic header test : " + +# Only do this if the compiler is GCC. +if test -n "@GCC_MAJOR_VERSION@" ; then + + CC=`echo "@CC@" | sed "s/.*shave cc //"` + # Compile with -Werror and -pedantic. + $CC -std=c99 -Werror -pedantic -I@top_builddir@/src -c @top_srcdir@/tests/sfversion.c -o /dev/null + + # Check compiler return status. + if test $? -ne 0 ; then + echo + exit 1 + fi + + echo "ok" +else + echo "n/a" + fi + +exit 0 diff --git a/libs/libsndfile/tests/pipe_test.c b/libs/libsndfile/tests/pipe_test.c index 56f1bfca35..10fa5725c9 100644 --- a/libs/libsndfile/tests/pipe_test.c +++ b/libs/libsndfile/tests/pipe_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -26,12 +26,12 @@ #include #include -#if (OS_IS_WIN32) +#if (OS_IS_WIN32 || HAVE_PIPE == 0 || HAVE_WAITPID == 0) int main (void) { - puts (" pipe_test : this test doesn't work on win32.") ; + puts (" pipe_test : this test doesn't work on this OS.") ; return 0 ; } /* main */ diff --git a/libs/libsndfile/tests/pipe_test.tpl b/libs/libsndfile/tests/pipe_test.tpl index a39c27b023..1bc1f4367e 100644 --- a/libs/libsndfile/tests/pipe_test.tpl +++ b/libs/libsndfile/tests/pipe_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -27,12 +27,12 @@ #include #include -#if (OS_IS_WIN32) +#if (OS_IS_WIN32 || defined __OS2__ || HAVE_PIPE == 0 || HAVE_WAITPID == 0) int main (void) { - puts (" pipe_test : this test doesn't work on win32.") ; + puts (" pipe_test : this test doesn't work on this OS.") ; return 0 ; } /* main */ diff --git a/libs/libsndfile/tests/raw_test.c b/libs/libsndfile/tests/raw_test.c index e7bbe5d602..002f3ee4ab 100644 --- a/libs/libsndfile/tests/raw_test.c +++ b/libs/libsndfile/tests/raw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -31,7 +32,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<10) +#define BUFFER_LEN (1 << 10) #define LOG_BUFFER_SIZE 1024 static void raw_offset_test (const char *filename, int typeminor) ; @@ -60,7 +61,7 @@ raw_offset_test (const char *filename, int typeminor) { SNDFILE *sndfile ; SF_INFO sfinfo ; sf_count_t start ; - int k, frames ; + int k ; print_test_name ("raw_offset_test", filename) ; @@ -69,8 +70,6 @@ raw_offset_test (const char *filename, int typeminor) sfinfo.channels = 1 ; sfinfo.frames = 0 ; - frames = BUFFER_LEN / sfinfo.channels ; - sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; start = 0 ; @@ -86,7 +85,7 @@ raw_offset_test (const char *filename, int typeminor) check_log_buffer_or_die (sndfile, __LINE__) ; if (abs (BUFFER_LEN - sfinfo.frames) > 1) - { printf ("\n\nLine %d : Incorrect sample count (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), BUFFER_LEN) ; + { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ; dump_log_buffer (sndfile) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/rdwr_test.def b/libs/libsndfile/tests/rdwr_test.def new file mode 100644 index 0000000000..43c1089818 --- /dev/null +++ b/libs/libsndfile/tests/rdwr_test.def @@ -0,0 +1,32 @@ +autogen definitions rdwr_test.tpl; + +data_type = { + name = "short" ; + type = "short" ; + format = "SF_FORMAT_PCM_16" ; + } ; + +data_type = { + name = "int" ; + type = "int" ; + format = "SF_FORMAT_PCM_32" ; + } ; + +data_type = { + name = "float" ; + type = "float" ; + format = "SF_FORMAT_FLOAT" ; + } ; + +data_type = { + name = "double" ; + type = "double" ; + format = "SF_FORMAT_DOUBLE" ; + } ; + +data_type = { + name = "raw" ; + type = "unsigned char" ; + format = "SF_FORMAT_PCM_U8" ; + } ; + diff --git a/libs/libsndfile/tests/rdwr_test.tpl b/libs/libsndfile/tests/rdwr_test.tpl new file mode 100644 index 0000000000..8cfdd3687e --- /dev/null +++ b/libs/libsndfile/tests/rdwr_test.tpl @@ -0,0 +1,105 @@ +[+ AutoGen5 template c +] +/* +** Copyright (C) 2010-2012 Erik de Castro Lopo +** +** This program is free software ; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation ; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY ; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program ; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include +#include +#include + +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#if (HAVE_DECL_S_IRGRP == 0) +#include +#endif + +#if (defined (WIN32) || defined (_WIN32)) +#include +#include +#endif + +#include + +#include "utils.h" + +[+ FOR data_type ++]static void rdwr_[+ (get "name") +]_test (const char *filename) ; +[+ ENDFOR data_type ++] + +int +main (void) +{ + rdwr_short_test ("rdwr_short.wav") ; + rdwr_int_test ("rdwr_int.wav") ; + rdwr_float_test ("rdwr_float.wav") ; + rdwr_double_test ("rdwr_double.wav") ; + rdwr_raw_test ("rdwr_raw.wav") ; + + return 0 ; +} /* main */ + + +/*============================================================================================ +** Here are the test functions. +*/ + +[+ FOR data_type ++]static void +rdwr_[+ (get "name") +]_test (const char *filename) +{ SNDFILE *file ; + SF_INFO sfinfo ; + sf_count_t frames ; + [+ (get "type") +] buffer [160] ; + + print_test_name ("rdwr_[+ (get "name") +]_test", filename) ; + + memset (buffer, 0, sizeof (buffer)) ; + + /* Create sound file with no data. */ + sfinfo.format = SF_FORMAT_WAV | [+ (get "format") +] ; + sfinfo.samplerate = 16000 ; + sfinfo.channels = 1 ; + + unlink (filename) ; + + frames = ARRAY_LEN (buffer) ; + + /* Open again for read/write. */ + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; + + test_write_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; + + test_read_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; + + sf_close (file) ; + unlink (filename) ; + + puts ("ok") ; + return ; +} /* rdwr_[+ (get "name") +]_test */ + +[+ ENDFOR data_type ++] + diff --git a/libs/libsndfile/tests/scale_clip_test.c b/libs/libsndfile/tests/scale_clip_test.c index bdabd25673..57b0b96073 100644 --- a/libs/libsndfile/tests/scale_clip_test.c +++ b/libs/libsndfile/tests/scale_clip_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by diff --git a/libs/libsndfile/tests/scale_clip_test.tpl b/libs/libsndfile/tests/scale_clip_test.tpl index 4c5e43aa59..39ddf57c1f 100644 --- a/libs/libsndfile/tests/scale_clip_test.tpl +++ b/libs/libsndfile/tests/scale_clip_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,13 +22,13 @@ #include #include #include +#include +#include #if HAVE_UNISTD_H #include #endif -#include - #include #include "utils.h" @@ -167,7 +167,7 @@ main (void) } ; if (sfinfo.frames != BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; exit (1) ; } ; @@ -301,7 +301,7 @@ main (void) } ; if (sfinfo.frames != BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; exit (1) ; } ; @@ -380,7 +380,7 @@ main (void) } ; if (sfinfo.frames != 3 * BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ; + { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, 3 * BUFFER_SIZE, sfinfo.frames) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/sftest.c b/libs/libsndfile/tests/sftest.c new file mode 100644 index 0000000000..78a9f7faaf --- /dev/null +++ b/libs/libsndfile/tests/sftest.c @@ -0,0 +1,65 @@ +/* +** Copyright (C) 1999-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "sfconfig.h" + +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include + +#define BUFFER_SIZE (1024) + + +static short buffer [BUFFER_SIZE] ; + +int +main (int argc, char *argv []) +{ SNDFILE *file ; + SF_INFO sfinfo ; + int k, count, max = 0, total = 0 ; + + if (argc < 2) + { printf ("Expecting input file name.\n") ; + return 0 ; + } ; + + if (! (file = sf_open (argv [1], SFM_READ, &sfinfo))) + { printf ("sf_open_read failed with error : ") ; + puts (sf_strerror (NULL)) ; + exit (1) ; + } ; + + while ((count = sf_read_short (file, buffer, BUFFER_SIZE))) + { for (k = 0 ; k < count ; k++) + if (abs (buffer [k]) > max) + max = abs (buffer [k]) ; + total += count ; + } ; + + printf ("Total : %d\n", total) ; + printf ("Maximun value : %d\n", max) ; + + sf_close (file) ; + + return 0 ; +} /* main */ + diff --git a/libs/libsndfile/tests/sfversion.c b/libs/libsndfile/tests/sfversion.c index 503b30ca81..c464f08647 100644 --- a/libs/libsndfile/tests/sfversion.c +++ b/libs/libsndfile/tests/sfversion.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -16,24 +16,27 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "sfconfig.h" - #include +#include #include -#if HAVE_UNISTD_H -#include -#endif - #include #define BUFFER_SIZE (256) -static char strbuffer [BUFFER_SIZE] ; int main (void) -{ sf_command (NULL, SFC_GET_LIB_VERSION, strbuffer, sizeof (strbuffer)) ; +{ static char strbuffer [BUFFER_SIZE] ; + const char * ver ; + + sf_command (NULL, SFC_GET_LIB_VERSION, strbuffer, sizeof (strbuffer)) ; + ver = sf_version_string () ; + + if (strcmp (ver, strbuffer) != 0) + { printf ("Version mismatch : '%s' != '%s'\n\n", ver, strbuffer) ; + exit (1) ; + } ; printf ("%s", strbuffer) ; diff --git a/libs/libsndfile/tests/stdin_test.c b/libs/libsndfile/tests/stdin_test.c index 3589c481ea..a893915cce 100644 --- a/libs/libsndfile/tests/stdin_test.c +++ b/libs/libsndfile/tests/stdin_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ #include "utils.h" -#define BUFFER_LEN (1<<16) +#define BUFFER_LEN (1 << 16) static void stdin_test (int typemajor, int count) ; @@ -123,9 +123,9 @@ main (int argc, char *argv []) } ; if (test_count == 0) - { fprintf (stderr, "************************************\n") ; - fprintf (stderr, "* No '%s' test defined.\n", argv [1]) ; - fprintf (stderr, "************************************\n") ; + { fprintf (stderr, "\n*****************************************\n") ; + fprintf (stderr, "* stdin_test : No '%s' test defined.\n", argv [1]) ; + fprintf (stderr, "*****************************************\n") ; return 1 ; } ; @@ -138,7 +138,7 @@ stdin_test (int typemajor, int count) SNDFILE *file ; SF_INFO sfinfo ; - int k, total ; + int k, total, err ; if (typemajor == SF_FORMAT_RAW) { sfinfo.samplerate = 44100 ; @@ -147,15 +147,21 @@ stdin_test (int typemajor, int count) sfinfo.frames = 0 ; } else - sfinfo.format = 0 ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; - if (! (file = sf_open ("-", SFM_READ, &sfinfo))) - { fprintf (stderr, "sf_open_read failed with error : ") ; + if ((file = sf_open_fd (STDIN_FILENO, SFM_READ, &sfinfo, SF_TRUE)) == NULL) + { fprintf (stderr, "sf_open_fd failed with error : ") ; puts (sf_strerror (NULL)) ; dump_log_buffer (NULL) ; exit (1) ; } ; + err = sf_error (file) ; + if (err != SF_ERR_NO_ERROR) + { printf ("Line %d : unexpected error : %s\n", __LINE__, sf_error_number (err)) ; + exit (1) ; + } ; + if ((sfinfo.format & SF_FORMAT_TYPEMASK) != typemajor) { fprintf (stderr, "\n\nError : File type doesn't match.\n") ; exit (1) ; diff --git a/libs/libsndfile/tests/stdio_test.c b/libs/libsndfile/tests/stdio_test.c index 6b841591d7..80a696cf53 100644 --- a/libs/libsndfile/tests/stdio_test.c +++ b/libs/libsndfile/tests/stdio_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -40,7 +40,8 @@ #include "utils.h" -#if (OS_IS_WIN32) +/* EMX is OS/2. */ +#if (OS_IS_WIN32) || defined (__EMX__) int main (void) diff --git a/libs/libsndfile/tests/stdout_test.c b/libs/libsndfile/tests/stdout_test.c index 5e7308a0fd..850718dc1b 100644 --- a/libs/libsndfile/tests/stdout_test.c +++ b/libs/libsndfile/tests/stdout_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ main (int argc, char *argv []) exit (1) ; } ; - do_all =! strcmp (argv [1], "all") ; + do_all = ! strcmp (argv [1], "all") ; if (do_all || ! strcmp (argv [1], "raw")) { stdout_test (SF_FORMAT_RAW, PIPE_TEST_LEN) ; @@ -111,9 +111,9 @@ main (int argc, char *argv []) } ; if (test_count == 0) - { fprintf (stderr, "************************************\n") ; - fprintf (stderr, "* No '%s' test defined.\n", argv [1]) ; - fprintf (stderr, "************************************\n") ; + { fprintf (stderr, "\n******************************************\n") ; + fprintf (stderr, "* stdout_test : No '%s' test defined.\n", argv [1]) ; + fprintf (stderr, "******************************************\n") ; return 1 ; } ; diff --git a/libs/libsndfile/tests/string_test.c b/libs/libsndfile/tests/string_test.c index c74f6f1f60..eac716e8b2 100644 --- a/libs/libsndfile/tests/string_test.c +++ b/libs/libsndfile/tests/string_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2003-2009 Erik de Castro Lopo +** Copyright (C) 2003-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include #if HAVE_UNISTD_H #include @@ -39,6 +40,10 @@ static void string_start_end_test (const char *filename, int typemajor) ; static void string_multi_set_test (const char *filename, int typemajor) ; static void string_rdwr_test (const char *filename, int typemajor) ; static void string_short_rdwr_test (const char *filename, int typemajor) ; +static void string_rdwr_grow_test (const char *filename, int typemajor) ; +static void string_header_update (const char *filename, int typemajor) ; + +static void software_string_test (const char *filename) ; static int str_count (const char * haystack, const char * needle) ; @@ -58,13 +63,15 @@ main (int argc, char *argv []) exit (1) ; } ; - do_all =! strcmp (argv [1], "all") ; + do_all = ! strcmp (argv [1], "all") ; if (do_all || ! strcmp (argv [1], "wav")) { string_start_end_test ("strings.wav", SF_FORMAT_WAV) ; string_multi_set_test ("multi.wav", SF_FORMAT_WAV) ; string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV) ; string_short_rdwr_test ("short_rdwr.wav", SF_FORMAT_WAV) ; + string_rdwr_grow_test ("rdwr_grow.wav", SF_FORMAT_WAV) ; + string_header_update ("header_update.wav", SF_FORMAT_WAV) ; string_start_end_test ("strings.wavex", SF_FORMAT_WAVEX) ; string_multi_set_test ("multi.wavex", SF_FORMAT_WAVEX) ; @@ -75,16 +82,22 @@ main (int argc, char *argv []) string_multi_set_test ("multi.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; string_rdwr_test ("rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; string_short_rdwr_test ("short_rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; + + software_string_test ("software_string.wav") ; test_count++ ; } ; if (do_all || ! strcmp (argv [1], "aiff")) { string_start_end_test ("strings.aiff", SF_FORMAT_AIFF) ; /* + TODO : Fix src/aiff.c so these tests pass. string_multi_set_test ("multi.aiff", SF_FORMAT_AIFF) ; string_rdwr_test ("rdwr.aiff", SF_FORMAT_AIFF) ; string_short_rdwr_test ("short_rdwr.aiff", SF_FORMAT_AIFF) ; + string_rdwr_grow_test ("rdwr_grow.aiff", SF_FORMAT_AIFF) ; + string_header_update ("header_update.aiff", SF_FORMAT_AIFF) ; */ + test_count++ ; } ; @@ -140,7 +153,9 @@ static const char license [] = "The license", title [] = "This is the title", long_title [] = "This is a very long and very boring title for this file", - long_artist [] = "The artist who kept on changing its name" ; + long_artist [] = "The artist who kept on changing its name", + genre [] = "The genre", + trackno [] = "Track three" ; static short data_out [BUFFER_LEN] ; @@ -150,25 +165,24 @@ string_start_end_test (const char *filename, int typemajor) { const char *cptr ; SNDFILE *file ; SF_INFO sfinfo ; - int frames, errors = 0 ; - - typemajor = typemajor ; + int errors = 0 ; print_test_name ("string_start_end_test", filename) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; sfinfo.samplerate = 44100 ; sfinfo.channels = 1 ; sfinfo.frames = 0 ; sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - frames = BUFFER_LEN / sfinfo.channels ; - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; /* Write stuff at start of file. */ sf_set_string (file, SF_STR_TITLE, filename) ; sf_set_string (file, SF_STR_SOFTWARE, software) ; sf_set_string (file, SF_STR_ARTIST, artist) ; + sf_set_string (file, SF_STR_GENRE, genre) ; + sf_set_string (file, SF_STR_TRACKNUMBER, trackno) ; /* Write data to file. */ test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; @@ -240,6 +254,13 @@ string_start_end_test (const char *filename, int typemajor) puts ("\n") ; printf (" Bad date : %s\n", cptr) ; } ; + + cptr = sf_get_string (file, SF_STR_GENRE) ; + if (cptr == NULL || strcmp (genre, cptr) != 0) + { if (errors++ == 0) + puts ("\n") ; + printf (" Bad genre : %s\n", cptr) ; + } ; } ; switch (typemajor) @@ -264,6 +285,12 @@ string_start_end_test (const char *filename, int typemajor) printf (" Bad license : %s\n", cptr) ; } ; + cptr = sf_get_string (file, SF_STR_TRACKNUMBER) ; + if (cptr == NULL || strcmp (genre, cptr) != 0) + { if (errors++ == 0) + puts ("\n") ; + printf (" Bad track no. : %s\n", cptr) ; + } ; break ; } ; @@ -284,10 +311,11 @@ string_start_test (const char *filename, int typemajor) { const char *cptr ; SNDFILE *file ; SF_INFO sfinfo ; - int frames, errors = 0 ; + int errors = 0 ; print_test_name ("string_start_test", filename) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; sfinfo.samplerate = 44100 ; sfinfo.channels = 1 ; sfinfo.frames = 0 ; @@ -302,8 +330,6 @@ string_start_test (const char *filename, int typemajor) break ; } ; - frames = BUFFER_LEN / sfinfo.channels ; - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; /* Write stuff at start of file. */ @@ -425,6 +451,7 @@ string_multi_set_test (const char *filename, int typemajor) print_test_name (__func__, filename) ; + memset (&sfinfo, 0, sizeof (sfinfo)) ; sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; sfinfo.samplerate = 44100 ; sfinfo.channels = 1 ; @@ -501,7 +528,7 @@ string_rdwr_test (const char *filename, int typemajor) sf_close (file) ; file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; str = sf_get_string (file, SF_STR_TITLE) ; exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; @@ -528,7 +555,7 @@ string_rdwr_test (const char *filename, int typemajor) exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; sf_close (file) ; unlink (filename) ; @@ -562,7 +589,7 @@ string_short_rdwr_test (const char *filename, int typemajor) /* Open the file RDWR. */ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; str = sf_get_string (file, SF_STR_TITLE) ; exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; @@ -606,3 +633,163 @@ str_count (const char * haystack, const char * needle) return count ; } /* str_count */ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +static void +software_string_test (const char *filename) +{ size_t k ; + + print_test_name (__func__, filename) ; + + for (k = 0 ; k < 50 ; k++) + { const char *result ; + char sfname [64] = "" ; + SNDFILE *file ; + SF_INFO info ; + + sf_info_setup (&info, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 44100, 1) ; + file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_TRUE, __LINE__) ; + + snprintf (sfname, MIN (k, sizeof (sfname)), "%s", "abcdefghijklmnopqrestvwxyz0123456789abcdefghijklmnopqrestvwxyz") ; + + exit_if_true (sf_set_string (file, SF_STR_SOFTWARE, sfname), + "\n\nLine %d : sf_set_string (f, SF_STR_SOFTWARE, '%s') failed : %s\n", __LINE__, sfname, sf_strerror (file)) ; + + sf_close (file) ; + + file = test_open_file_or_die (filename, SFM_READ, &info, SF_TRUE, __LINE__) ; + result = sf_get_string (file, SF_STR_SOFTWARE) ; + + exit_if_true (result == NULL, "\n\nLine %d : sf_get_string (file, SF_STR_SOFTWARE) returned NULL.\n\n", __LINE__) ; + + exit_if_true (strstr (result, sfname) != result, + "\n\nLine %d : Can't fine string '%s' in '%s'\n\n", __LINE__, sfname, result) ; + sf_close (file) ; + } ; + + unlink (filename) ; + puts ("ok") ; +} /* software_string_test */ + + +static void +string_rdwr_grow_test (const char *filename, int typemajor) +{ SNDFILE *file ; + SF_INFO sfinfo ; + sf_count_t frames ; + const char * str ; + + print_test_name (__func__, filename) ; + + /* Create a file that contains some strings. Then open the file in RDWR mode and + grow the file by writing more audio data to it. Check that the audio data has + been added to the file, and that the strings are still there. */ + + /* Create a short file that contains a string. */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + sfinfo.samplerate = 44100 ; + sfinfo.channels = 2 ; + sfinfo.frames = 0 ; + sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; + /* Write data to file. */ + test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; + + /* Write some strings at end of file. */ + sf_set_string (file, SF_STR_TITLE , title) ; + sf_set_string (file, SF_STR_COMMENT, comment) ; + sf_close (file) ; + + + /* Now open file again in SFM_RDWR mode and write more audio data to it. */ + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; + /* Write more data to file. */ + test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; + sf_close (file) ; + + + /* Now open file again. It should now contain two BUFFER_LEN's worth of frames and the strings. */ + frames = 2 * BUFFER_LEN / sfinfo.channels ; + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; + + /* Check the strings */ + str = sf_get_string (file, SF_STR_TITLE) ; + exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; + exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; + + str = sf_get_string (file, SF_STR_COMMENT) ; + exit_if_true (str == NULL, "\n\nLine %d : SF_STR_COMMENT string is NULL.\n", __LINE__) ; + exit_if_true (strcmp (str, comment) != 0, "\n\nLine %d : SF_STR_COMMENT doesn't match what was written.\n", __LINE__) ; + + sf_close (file) ; + unlink (filename) ; + + puts ("ok") ; +} /* string_rdwr_grow_test */ + +static void +string_header_update (const char *filename, int typemajor) +{ SNDFILE *file , *file1 ; + SF_INFO sfinfo , sfinfo1 ; + sf_count_t frames ; + const char * str ; + const int GROW_BUFFER_AMOUNT = 4 ; /* this should be less than half the size of the string header */ + + print_test_name (__func__, filename) ; + + /* Create a short file. */ + memset (&sfinfo, 0, sizeof (sfinfo)) ; + sfinfo.samplerate = 44100 ; + sfinfo.channels = 2 ; + sfinfo.frames = 0 ; + sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; + + file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; + test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; + sf_set_string (file, SF_STR_TITLE, long_title) ; + sf_close (file) ; + + + /* Check that SFC_UPDATE_HEADER_NOW correctly calculates datalength. */ + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; + /* Write a very small amount of new audio data that doesn't completely overwrite the existing header. */ + test_write_short_or_die (file, 0, data_out, GROW_BUFFER_AMOUNT, __LINE__) ; + + /* Update the header without closing the file. */ + sf_command (file, SFC_UPDATE_HEADER_NOW, NULL, 0) ; + + /* The file should now contain BUFFER_LEN + GROW_BUFFER_AMOUNT frames. + Open a second handle to the file and check the reported length. */ + memset (&sfinfo1, 0, sizeof (sfinfo1)) ; + file1 = test_open_file_or_die (filename, SFM_READ, &sfinfo1, SF_TRUE, __LINE__) ; + + frames = (BUFFER_LEN + GROW_BUFFER_AMOUNT) / sfinfo.channels ; + exit_if_true (frames != sfinfo1.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo1.frames, frames) ; + + /* The strings are probably not readable by the second soundfile handle because write_tailer has not yet been called. + It's a design decision whether SFC_UPDATE_HEADER_NOW should write the tailer. I think it's fine that it doesn't. */ + + sf_close (file1) ; + sf_close (file) ; + + + /* Check that sf_close correctly calculates datalength. */ + file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; + /* Write a very small amount of new audio data that doesn't completely overwrite the existing header. */ + test_write_short_or_die (file, 0, data_out, GROW_BUFFER_AMOUNT, __LINE__) ; + sf_close (file) ; + + + /* Open file again and verify data and string. */ + file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; + frames = (BUFFER_LEN + 2*GROW_BUFFER_AMOUNT) / sfinfo.channels ; + exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; + str = sf_get_string (file, SF_STR_TITLE) ; + exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; + exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; + sf_close (file) ; + unlink (filename) ; + puts ("ok") ; +} /* string_header_update */ diff --git a/libs/libsndfile/tests/test_wrapper.sh.in b/libs/libsndfile/tests/test_wrapper.sh.in index 1caa614d50..daf030b05f 100644 --- a/libs/libsndfile/tests/test_wrapper.sh.in +++ b/libs/libsndfile/tests/test_wrapper.sh.in @@ -1,21 +1,83 @@ #!/bin/sh -if [ -f tests/sfversion@EXEEXT@ ]; then +# Copyright (C) 2008-2013 Erik de Castro Lopo +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the author nor the names of any contributors may be used +# to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +HOST_TRIPLET=@HOST_TRIPLET@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +LIB_VERSION=`echo $PACKAGE_VERSION | sed "s/[a-z].*//"` + +if test -f tests/sfversion@EXEEXT@ ; then cd tests fi -if [ ! -f sfversion@EXEEXT@ ]; then +if test ! -f sfversion@EXEEXT@ ; then echo "Not able to find test executables." exit 1 fi -sfversion=`./sfversion@EXEEXT@` +if test -f libsndfile.so.$LIB_VERSION ; then + # This will work on Linux, but not on Mac. + # Windows is already sorted out. + export LD_LIBRARY_PATH=`pwd` + if test ! -f libsndfile.so.1 ; then + ln -s libsndfile.so.$LIB_VERSION libsndfile.so.1 + fi + fi + +sfversion=`./sfversion@EXEEXT@ | sed "s/-exp$//"` + +if test $sfversion != libsndfile-$PACKAGE_VERSION ; then + echo "Error : sfversion ($sfversion) and PACKAGE_VERSION ($PACKAGE_VERSION) don't match." + exit 1 + fi # Force exit on errors. set -e -# generic-tests +# Generic-tests uname -a + +# Check the header file. +sh pedantic-header-test.sh + +# Need this for when we're running from files collected into the +# libsndfile-testsuite-@PACKAGE_VERSION@ tarball. +if test -x test_main@EXEEXT@ ; then + echo "Running unit tests from src/ directory of source code tree." + ./test_main@EXEEXT@ + echo + echo "Running end-to-end tests from tests/ directory." + fi + ./error_test@EXEEXT@ ./pcm_test@EXEEXT@ ./ulaw_test@EXEEXT@ @@ -30,14 +92,31 @@ uname -a ./command_test@EXEEXT@ current_sf_info ./command_test@EXEEXT@ bext ./command_test@EXEEXT@ bextch +./command_test@EXEEXT@ chanmap +./command_test@EXEEXT@ cart ./floating_point_test@EXEEXT@ ./checksum_test@EXEEXT@ ./scale_clip_test@EXEEXT@ ./headerless_test@EXEEXT@ +./rdwr_test@EXEEXT@ ./locale_test@EXEEXT@ ./win32_ordinal_test@EXEEXT@ ./external_libs_test@EXEEXT@ -./cpp_test@EXEEXT@ +./format_check_test@EXEEXT@ +./channel_test@EXEEXT@ + +# The w64 G++ compiler requires an extra runtime DLL which we don't have, +# so skip this test. +case "$HOST_TRIPLET" in + x86_64-w64-mingw32) + ;; + i686-w64-mingw32) + ;; + *) + ./cpp_test@EXEEXT@ + ;; + esac + echo "----------------------------------------------------------------------" echo " $sfversion passed common tests." echo "----------------------------------------------------------------------" @@ -56,6 +135,7 @@ echo "==========================" ./string_test@EXEEXT@ aiff ./multi_file_test@EXEEXT@ aiff ./aiff_rw_test@EXEEXT@ +./chunk_test@EXEEXT@ aiff echo "----------------------------------------------------------------------" echo " $sfversion passed tests on AIFF files." echo "----------------------------------------------------------------------" @@ -78,7 +158,9 @@ echo "----------------------------------------------------------------------" ./lossy_comp_test@EXEEXT@ caf_ulaw ./lossy_comp_test@EXEEXT@ caf_alaw ./header_test@EXEEXT@ caf +./peak_chunk_test@EXEEXT@ caf ./misc_test@EXEEXT@ caf +./chunk_test@EXEEXT@ caf echo "----------------------------------------------------------------------" echo " $sfversion passed tests on CAF files." echo "----------------------------------------------------------------------" @@ -97,6 +179,7 @@ echo "----------------------------------------------------------------------" ./misc_test@EXEEXT@ wav ./string_test@EXEEXT@ wav ./multi_file_test@EXEEXT@ wav +./chunk_test@EXEEXT@ wav echo "----------------------------------------------------------------------" echo " $sfversion passed tests on WAV files." echo "----------------------------------------------------------------------" @@ -255,6 +338,7 @@ echo "----------------------------------------------------------------------" # flac-tests ./write_read_test@EXEEXT@ flac +./compression_size_test@EXEEXT@ flac ./string_test@EXEEXT@ flac echo "----------------------------------------------------------------------" echo " $sfversion passed tests on FLAC files." @@ -262,7 +346,7 @@ echo "----------------------------------------------------------------------" # vorbis-tests ./ogg_test@EXEEXT@ -./vorbis_test@EXEEXT@ +./compression_size_test@EXEEXT@ vorbis ./lossy_comp_test@EXEEXT@ ogg_vorbis ./string_test@EXEEXT@ ogg ./misc_test@EXEEXT@ ogg diff --git a/libs/libsndfile/tests/ulaw_test.c b/libs/libsndfile/tests/ulaw_test.c index 6959e84c00..fc0d497aa0 100644 --- a/libs/libsndfile/tests/ulaw_test.c +++ b/libs/libsndfile/tests/ulaw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include #include +#include #if HAVE_UNISTD_H #include @@ -44,12 +45,11 @@ main (void) const char *filename ; int k ; + print_test_name ("ulaw_test", "encoder") ; + filename = "test.raw" ; - sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ULAW ; - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; - sfinfo.channels = 1 ; + sf_info_setup (&sfinfo, SF_FORMAT_RAW | SF_FORMAT_ULAW, 44100, 1) ; if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) { printf ("sf_open_write failed with error : ") ; @@ -94,7 +94,9 @@ main (void) sf_close (file) ; - printf (" ulaw_test : encoder ... ok\n") ; + puts ("ok") ; + + print_test_name ("ulaw_test", "decoder") ; /* Now generate a file containing all possible 8 bit encoded ** sample values and write it to disk as ulaw encoded.frames. @@ -139,7 +141,7 @@ main (void) sf_close (file) ; - printf (" ulaw_test : decoder ... ok\n") ; + puts ("ok") ; unlink (filename) ; @@ -201,21 +203,21 @@ unsigned char ulaw_encode (int sample) 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 } ; - int sign, exponent, mantissa ; - unsigned char ulawbyte ; + int sign, exponent, mantissa ; + unsigned char ulawbyte ; - /* Get the sample into sign-magnitude. */ - sign = (sample >> 8) & 0x80 ; /* set aside the sign */ - if ( sign != 0 ) + /* Get the sample into sign-magnitude. */ + sign = (sample >> 8) & 0x80 ; /* set aside the sign */ + if (sign != 0) sample = -sample ; /* get magnitude */ - if ( sample > uCLIP ) + if (sample > uCLIP) sample = uCLIP ; /* clip the magnitude */ - /* Convert from 16 bit linear to ulaw. */ - sample = sample + uBIAS ; - exponent = exp_lut [( sample >> 7 ) & 0xFF] ; - mantissa = (sample >> ( exponent + 3 ) ) & 0x0F ; - ulawbyte = ~ (sign | ( exponent << 4 ) | mantissa) ; + /* Convert from 16 bit linear to ulaw. */ + sample = sample + uBIAS ; + exponent = exp_lut [(sample >> 7) & 0xFF] ; + mantissa = (sample >> (exponent + 3)) & 0x0F ; + ulawbyte = ~ (sign | (exponent << 4) | mantissa) ; return ulawbyte ; } /* ulaw_encode */ @@ -240,16 +242,16 @@ unsigned char ulaw_encode (int sample) static int ulaw_decode (unsigned int ulawbyte) { static int exp_lut [8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 } ; - int sign, exponent, mantissa, sample ; + int sign, exponent, mantissa, sample ; - ulawbyte = ~ ulawbyte ; - sign = (ulawbyte & 0x80) ; - exponent = (ulawbyte >> 4) & 0x07 ; - mantissa = ulawbyte & 0x0F ; - sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ; - if (sign != 0) + ulawbyte = ~ ulawbyte ; + sign = (ulawbyte & 0x80) ; + exponent = (ulawbyte >> 4) & 0x07 ; + mantissa = ulawbyte & 0x0F ; + sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ; + if (sign != 0) sample = -sample ; - return sample ; + return sample ; } /* ulaw_decode */ diff --git a/libs/libsndfile/tests/utils.c b/libs/libsndfile/tests/utils.c index ba1f24ecd2..882c969ab1 100644 --- a/libs/libsndfile/tests/utils.c +++ b/libs/libsndfile/tests/utils.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -340,7 +340,7 @@ check_log_buffer_or_die (SNDFILE *file, int line_num) { static char buffer [LOG_BUFFER_SIZE] ; int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; @@ -379,7 +379,7 @@ string_in_log_buffer (SNDFILE *file, const char *s) { static char buffer [LOG_BUFFER_SIZE] ; int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; @@ -448,12 +448,11 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) void dump_log_buffer (SNDFILE *file) { static char buffer [LOG_BUFFER_SIZE] ; - int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ - count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; + sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; if (strlen (buffer) < 1) puts ("Log buffer empty.\n") ; @@ -469,7 +468,7 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo SNDFILE *file ; const char *modestr, *func_name ; - int oflags = 0, omode = 0 ; + int oflags = 0, omode = 0, err ; /* ** Need to test both sf_open() and sf_open_fd(). @@ -500,17 +499,20 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo } ; if (OS_IS_WIN32) - { /* Windows doesn't support Unix file permissions so set it to zero. */ - omode = 0 ; + { /* Windows does not understand and ignores the S_IRGRP flag, but Wine + ** gives a run time warning message, so just clear it. + */ + omode &= ~S_IRGRP ; } ; if (allow_fd && ((++count) & 1) == 1) { int fd ; - fd = open (filename, oflags, omode) ; + /* Only use the three argument open() function if omode != 0. */ + fd = (omode == 0) ? open (filename, oflags) : open (filename, oflags, omode) ; if (fd < 0) - { perror ("open") ; + { printf ("\n\n%s : open failed : %s\n", __func__, strerror (errno)) ; exit (1) ; } ; @@ -528,6 +530,13 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo exit (1) ; } ; + err = sf_error (file) ; + if (err != SF_ERR_NO_ERROR) + { printf ("\n\nLine %d : sf_error : %s\n\n", line_num, sf_error_number (err)) ; + dump_log_buffer (file) ; + exit (1) ; + } ; + return file ; } /* test_open_file_or_die */ @@ -629,7 +638,7 @@ test_read_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t items, } ; return ; -} /* test_read_short */ +} /* test_read_short_or_die */ void test_read_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t items, int line_num) @@ -647,7 +656,7 @@ test_read_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t items, int } ; return ; -} /* test_read_int */ +} /* test_read_int_or_die */ void test_read_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t items, int line_num) @@ -665,7 +674,7 @@ test_read_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t items, } ; return ; -} /* test_read_float */ +} /* test_read_float_or_die */ void test_read_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t items, int line_num) @@ -683,7 +692,7 @@ test_read_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t items } ; return ; -} /* test_read_double */ +} /* test_read_double_or_die */ void @@ -702,7 +711,7 @@ test_readf_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t frames } ; return ; -} /* test_readf_short */ +} /* test_readf_short_or_die */ void test_readf_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t frames, int line_num) @@ -720,7 +729,7 @@ test_readf_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t frames, in } ; return ; -} /* test_readf_int */ +} /* test_readf_int_or_die */ void test_readf_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t frames, int line_num) @@ -738,7 +747,7 @@ test_readf_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t frames } ; return ; -} /* test_readf_float */ +} /* test_readf_float_or_die */ void test_readf_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num) @@ -756,9 +765,27 @@ test_readf_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t fram } ; return ; -} /* test_readf_double */ +} /* test_readf_double_or_die */ +void +test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) +{ sf_count_t count ; + + if ((count = sf_read_raw (file, test, items)) != items) + { printf ("\n\nLine %d", line_num) ; + if (pass > 0) + printf (" (pass %d)", pass) ; + printf (" : sf_read_raw failed with short read (%ld => %ld).\n", + SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ; + fflush (stdout) ; + puts (sf_strerror (file)) ; + exit (1) ; + } ; + + return ; +} /* test_read_raw_or_die */ + void @@ -777,7 +804,7 @@ test_write_short_or_die (SNDFILE *file, int pass, const short *test, sf_count_t } ; return ; -} /* test_write_short */ +} /* test_write_short_or_die */ void test_write_int_or_die (SNDFILE *file, int pass, const int *test, sf_count_t items, int line_num) @@ -795,7 +822,7 @@ test_write_int_or_die (SNDFILE *file, int pass, const int *test, sf_count_t item } ; return ; -} /* test_write_int */ +} /* test_write_int_or_die */ void test_write_float_or_die (SNDFILE *file, int pass, const float *test, sf_count_t items, int line_num) @@ -813,7 +840,7 @@ test_write_float_or_die (SNDFILE *file, int pass, const float *test, sf_count_t } ; return ; -} /* test_write_float */ +} /* test_write_float_or_die */ void test_write_double_or_die (SNDFILE *file, int pass, const double *test, sf_count_t items, int line_num) @@ -831,7 +858,7 @@ test_write_double_or_die (SNDFILE *file, int pass, const double *test, sf_count_ } ; return ; -} /* test_write_double */ +} /* test_write_double_or_die */ void @@ -850,7 +877,7 @@ test_writef_short_or_die (SNDFILE *file, int pass, const short *test, sf_count_t } ; return ; -} /* test_writef_short */ +} /* test_writef_short_or_die */ void test_writef_int_or_die (SNDFILE *file, int pass, const int *test, sf_count_t frames, int line_num) @@ -868,7 +895,7 @@ test_writef_int_or_die (SNDFILE *file, int pass, const int *test, sf_count_t fra } ; return ; -} /* test_writef_int */ +} /* test_writef_int_or_die */ void test_writef_float_or_die (SNDFILE *file, int pass, const float *test, sf_count_t frames, int line_num) @@ -886,7 +913,7 @@ test_writef_float_or_die (SNDFILE *file, int pass, const float *test, sf_count_t } ; return ; -} /* test_writef_float */ +} /* test_writef_float_or_die */ void test_writef_double_or_die (SNDFILE *file, int pass, const double *test, sf_count_t frames, int line_num) @@ -904,7 +931,26 @@ test_writef_double_or_die (SNDFILE *file, int pass, const double *test, sf_count } ; return ; -} /* test_writef_double */ +} /* test_writef_double_or_die */ + + +void +test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) +{ sf_count_t count ; + + if ((count = sf_write_raw (file, test, items)) != items) + { printf ("\n\nLine %d", line_num) ; + if (pass > 0) + printf (" (pass %d)", pass) ; + printf (" : sf_write_raw failed with short write (%ld => %ld).\n", + SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ; + fflush (stdout) ; + puts (sf_strerror (file)) ; + exit (1) ; + } ; + + return ; +} /* test_write_raw_or_die */ void @@ -996,7 +1042,7 @@ static int allowed_open_files = -1 ; void count_open_files (void) { -#if (defined (WIN32) || defined (_WIN32)) +#if OS_IS_WIN32 return ; #else int k, count = 0 ; @@ -1021,7 +1067,7 @@ increment_open_file_count (void) void check_open_file_count_or_die (int lineno) { -#if (defined (WIN32) || defined (_WIN32)) +#if OS_IS_WIN32 lineno = 0 ; return ; #else diff --git a/libs/libsndfile/tests/utils.h b/libs/libsndfile/tests/utils.h index 9f9f684813..79da2861dc 100644 --- a/libs/libsndfile/tests/utils.h +++ b/libs/libsndfile/tests/utils.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -31,19 +31,15 @@ extern "C" { #include #include -#include -#include #define SF_COUNT_TO_LONG(x) ((long) (x)) #define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) #define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x))) +#define NOT(x) (! (x)) #define PIPE_INDEX(x) ((x) + 500) #define PIPE_TEST_LEN 12345 -#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__)) -#define snprintf _snprintf -#endif void gen_windowed_sine_float (float *data, int len, double maximum) ; void gen_windowed_sine_double (double *data, int len, double maximum) ; @@ -89,6 +85,21 @@ void check_open_file_count_or_die (int lineno) ; #ifdef SNDFILE_H +static inline void +sf_info_clear (SF_INFO * info) +{ memset (info, 0, sizeof (SF_INFO)) ; +} /* sf_info_clear */ + +static inline void +sf_info_setup (SF_INFO * info, int format, int samplerate, int channels) +{ sf_info_clear (info) ; + + info->format = format ; + info->samplerate = samplerate ; + info->channels = channels ; +} /* sf_info_setup */ + + void dump_log_buffer (SNDFILE *file) ; void check_log_buffer_or_die (SNDFILE *file, int line_num) ; int string_in_log_buffer (SNDFILE *file, const char *s) ; @@ -124,6 +135,9 @@ void test_readf_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num) ; +void +test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) ; + void test_write_short_or_die (SNDFILE *file, int pass, const short *test, sf_count_t items, int line_num) ; @@ -144,6 +158,9 @@ void test_writef_double_or_die (SNDFILE *file, int pass, const double *test, sf_count_t frames, int line_num) ; +void +test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) ; + void compare_short_or_die (const short *left, const short *right, unsigned count, int line_num) ; void compare_int_or_die (const int *left, const int *right, unsigned count, int line_num) ; void compare_float_or_die (const float *left, const float *right, unsigned count, int line_num) ; diff --git a/libs/libsndfile/tests/utils.tpl b/libs/libsndfile/tests/utils.tpl index 04aa7f7117..d88e263ff0 100644 --- a/libs/libsndfile/tests/utils.tpl +++ b/libs/libsndfile/tests/utils.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template h c +] /* -** Copyright (C) 2002-2009 Erik de Castro Lopo +** Copyright (C) 2002-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -34,16 +34,13 @@ extern "C" { #include #include -#define SF_COUNT_TO_LONG(x) ((long) (x)) #define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) #define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x))) +#define NOT(x) (! (x)) #define PIPE_INDEX(x) ((x) + 500) #define PIPE_TEST_LEN 12345 -#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__)) -#define snprintf _snprintf -#endif [+ FOR float_type +]void gen_windowed_sine_[+ (get "name") +] ([+ (get "name") +] *data, int len, double maximum) ; @@ -60,6 +57,16 @@ void dump_data_to_file (const char *filename, const void *data, unsigned int dat void write_mono_file (const char * filename, int format, int srate, float * output, int len) ; +#ifdef __GNUC__ +static inline void +exit_if_true (int test, const char *format, ...) +#ifdef __USE_MINGW_ANSI_STDIO + __attribute__ ((format (gnu_printf, 2, 3))) ; +#else + __attribute__ ((format (printf, 2, 3))) ; +#endif +#endif + static inline void exit_if_true (int test, const char *format, ...) { if (test) @@ -89,6 +96,21 @@ void check_open_file_count_or_die (int lineno) ; #ifdef SNDFILE_H +static inline void +sf_info_clear (SF_INFO * info) +{ memset (info, 0, sizeof (SF_INFO)) ; +} /* sf_info_clear */ + +static inline void +sf_info_setup (SF_INFO * info, int format, int samplerate, int channels) +{ sf_info_clear (info) ; + + info->format = format ; + info->samplerate = samplerate ; + info->channels = channels ; +} /* sf_info_setup */ + + void dump_log_buffer (SNDFILE *file) ; void check_log_buffer_or_die (SNDFILE *file, int line_num) ; int string_in_log_buffer (SNDFILE *file, const char *s) ; @@ -110,18 +132,24 @@ void test_seek_or_die (SNDFILE *file, int pass, [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ; [+ ENDFOR io_type +][+ ENDFOR read_op +] +void +test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) ; + [+ FOR write_op +] [+ FOR io_type +]void test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, int pass, const [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ; [+ ENDFOR io_type +][+ ENDFOR write_op +] +void +test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) ; + [+ FOR io_type -+]void compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num) ; ++]void compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *expected, const [+ (get "io_element") +] *actual, unsigned count, int line_num) ; [+ ENDFOR io_type +] -void gen_lowpass_noise_float (float *data, int len) ; +void gen_lowpass_signal_float (float *data, int len) ; sf_count_t file_length (const char * fname) ; sf_count_t file_length_fd (int fd) ; @@ -341,7 +369,7 @@ check_log_buffer_or_die (SNDFILE *file, int line_num) { static char buffer [LOG_BUFFER_SIZE] ; int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; @@ -380,7 +408,7 @@ string_in_log_buffer (SNDFILE *file, const char *s) { static char buffer [LOG_BUFFER_SIZE] ; int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; @@ -402,7 +430,7 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) int k, m, ch, readcount ; if (length > 1000000) - { printf ("\n\nError : length (%ld) too long.\n\n", SF_COUNT_TO_LONG (offset)) ; + { printf ("\n\nError : length (%" PRId64 ") too long.\n\n", offset) ; exit (1) ; } ; @@ -412,7 +440,7 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) } ; if (fseek (file, offset, SEEK_SET) != 0) - { printf ("\n\nError : fseek(file, %ld, SEEK_SET) failed : %s\n\n", SF_COUNT_TO_LONG (offset), strerror (errno)) ; + { printf ("\n\nError : fseek(file, %" PRId64 ", SEEK_SET) failed : %s\n\n", offset, strerror (errno)) ; exit (1) ; } ; @@ -421,7 +449,7 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) for (k = 0 ; k < length ; k+= sizeof (buffer)) { readcount = fread (buffer, 1, sizeof (buffer), file) ; - printf ("%08lx : ", SF_COUNT_TO_LONG (offset + k)) ; + printf ("%08" PRIx64 " : ", offset + k) ; for (m = 0 ; m < readcount ; m++) printf ("%02x ", buffer [m] & 0xFF) ; @@ -449,12 +477,11 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) void dump_log_buffer (SNDFILE *file) { static char buffer [LOG_BUFFER_SIZE] ; - int count ; - memset (buffer, 0, LOG_BUFFER_SIZE) ; + memset (buffer, 0, sizeof (buffer)) ; /* Get the log buffer data. */ - count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; + sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; if (strlen (buffer) < 1) puts ("Log buffer empty.\n") ; @@ -470,7 +497,7 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo SNDFILE *file ; const char *modestr, *func_name ; - int oflags = 0, omode = 0 ; + int oflags = 0, omode = 0, err ; /* ** Need to test both sf_open() and sf_open_fd(). @@ -501,17 +528,20 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo } ; if (OS_IS_WIN32) - { /* Windows doesn't support Unix file permissions so set it to zero. */ - omode = 0 ; + { /* Windows does not understand and ignores the S_IRGRP flag, but Wine + ** gives a run time warning message, so just clear it. + */ + omode &= ~S_IRGRP ; } ; if (allow_fd && ((++count) & 1) == 1) { int fd ; - fd = open (filename, oflags, omode) ; + /* Only use the three argument open() function if omode != 0. */ + fd = (omode == 0) ? open (filename, oflags) : open (filename, oflags, omode) ; if (fd < 0) - { perror ("open") ; + { printf ("\n\n%s : open failed : %s\n", __func__, strerror (errno)) ; exit (1) ; } ; @@ -529,6 +559,13 @@ test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allo exit (1) ; } ; + err = sf_error (file) ; + if (err != SF_ERR_NO_ERROR) + { printf ("\n\nLine %d : sf_error : %s\n\n", line_num, sf_error_number (err)) ; + dump_log_buffer (file) ; + exit (1) ; + } ; + return file ; } /* test_open_file_or_die */ @@ -541,7 +578,7 @@ test_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count { printf ("\n\nLine %d ", line_num) ; if (pass > 0) printf ("(pass %d): ", pass) ; - printf ("Read position (%ld) should be %ld.\n", SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (read_pos)) ; + printf ("Read position (%" PRId64 ") should be %" PRId64 ".\n", pos, read_pos) ; exit (1) ; } ; @@ -550,8 +587,7 @@ test_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count { printf ("\n\nLine %d", line_num) ; if (pass > 0) printf (" (pass %d)", pass) ; - printf (" : Write position (%ld) should be %ld.\n", - SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (write_pos)) ; + printf (" : Write position (%" PRId64 ") should be %" PRId64 ".\n", pos, write_pos) ; exit (1) ; } ; @@ -604,9 +640,8 @@ test_seek_or_die (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_p channel_name = (channels == 1) ? "Mono" : "Stereo" ; if ((position = sf_seek (file, offset, whence)) != new_pos) - { printf ("\n\nLine %d : %s : sf_seek (file, %ld, %s) returned %ld (should be %ld).\n\n", - line_num, channel_name, SF_COUNT_TO_LONG (offset), whence_name, - SF_COUNT_TO_LONG (position), SF_COUNT_TO_LONG (new_pos)) ; + { printf ("\n\nLine %d : %s : sf_seek (file, %" PRId64 ", %s) returned %" PRId64 " (should be %" PRId64 ").\n\n", + line_num, channel_name, offset, whence_name, position, new_pos) ; exit (1) ; } ; @@ -622,17 +657,34 @@ test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, in { printf ("\n\nLine %d", line_num) ; if (pass > 0) printf (" (pass %d)", pass) ; - printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%ld => %ld).\n", - SF_COUNT_TO_LONG ([+ (get "count_name") +]), SF_COUNT_TO_LONG (count)) ; + printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%" PRId64 " => %" PRId64 ").\n", + [+ (get "count_name") +], count) ; fflush (stdout) ; puts (sf_strerror (file)) ; exit (1) ; } ; return ; -} /* test_[+ (get "op_element") +]_[+ (get "io_element") +] */ +} /* test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die */ [+ ENDFOR io_type +][+ ENDFOR read_op +] +void +test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) +{ sf_count_t count ; + + if ((count = sf_read_raw (file, test, items)) != items) + { printf ("\n\nLine %d", line_num) ; + if (pass > 0) + printf (" (pass %d)", pass) ; + printf (" : sf_read_raw failed with short read (%" PRId64 " => %" PRId64 ").\n", items, count) ; + fflush (stdout) ; + puts (sf_strerror (file)) ; + exit (1) ; + } ; + + return ; +} /* test_read_raw_or_die */ + [+ FOR write_op +] [+ FOR io_type +] void @@ -643,26 +695,44 @@ test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, in { printf ("\n\nLine %d", line_num) ; if (pass > 0) printf (" (pass %d)", pass) ; - printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%ld => %ld).\n", - SF_COUNT_TO_LONG ([+ (get "count_name") +]), SF_COUNT_TO_LONG (count)) ; + printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%" PRId64 " => %" PRId64 ").\n", + [+ (get "count_name") +], count) ; fflush (stdout) ; puts (sf_strerror (file)) ; exit (1) ; } ; return ; -} /* test_[+ (get "op_element") +]_[+ (get "io_element") +] */ +} /* test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die */ [+ ENDFOR io_type +][+ ENDFOR write_op +] +void +test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) +{ sf_count_t count ; + + if ((count = sf_write_raw (file, test, items)) != items) + { printf ("\n\nLine %d", line_num) ; + if (pass > 0) + printf (" (pass %d)", pass) ; + printf (" : sf_write_raw failed with short write (%" PRId64 " => %" PRId64 ").\n", items, count) ; + fflush (stdout) ; + puts (sf_strerror (file)) ; + exit (1) ; + } ; + + return ; +} /* test_write_raw_or_die */ + + [+ FOR io_type +]void -compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num) +compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *expected, const [+ (get "io_element") +] *actual, unsigned count, int line_num) { unsigned k ; - for (k = 0 ; k < count ;k++) - if (left [k] != right [k]) - { printf ("\n\nLine %d : Error at index %d, " [+ (get "format_str") +] " should be " [+ (get "format_str") +] ".\n\n", line_num, k, left [k], right [k]) ; + for (k = 0 ; k < count ; k++) + if (expected [k] != actual [k]) + { printf ("\n\nLine %d : Error at index %d, got " [+ (get "format_str") +] ", should be " [+ (get "format_str") +] ".\n\n", line_num, k, actual [k], expected [k]) ; exit (1) ; } ; @@ -705,7 +775,7 @@ static int allowed_open_files = -1 ; void count_open_files (void) { -#if (defined (WIN32) || defined (_WIN32)) +#if OS_IS_WIN32 return ; #else int k, count = 0 ; @@ -730,8 +800,8 @@ increment_open_file_count (void) void check_open_file_count_or_die (int lineno) { -#if (defined (WIN32) || defined (_WIN32)) - lineno = 0 ; +#if OS_IS_WIN32 + (void) lineno ; return ; #else int k, count = 0 ; @@ -773,7 +843,7 @@ write_mono_file (const char * filename, int format, int srate, float * output, i } /* write_mono_file */ void -gen_lowpass_noise_float (float *data, int len) +gen_lowpass_signal_float (float *data, int len) { int32_t value = 0x1243456 ; double sample, last_val = 0.0 ; int k ; @@ -787,10 +857,12 @@ gen_lowpass_noise_float (float *data, int len) sample = value / (0x7fffffff * 1.000001) ; sample = 0.2 * sample - 0.9 * last_val ; - data [k] = last_val = sample ; + last_val = sample ; + + data [k] = 0.5 * (sample + sin (2.0 * k * M_PI * 1.0 / 32.0)) ; } ; -} /* gen_lowpass_noise_float */ +} /* gen_lowpass_signal_float */ /* diff --git a/libs/libsndfile/tests/virtual_io_test.c b/libs/libsndfile/tests/virtual_io_test.c index b84bf6b3b0..1aae063df8 100644 --- a/libs/libsndfile/tests/virtual_io_test.c +++ b/libs/libsndfile/tests/virtual_io_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -39,6 +39,7 @@ main (void) vio_test ("vio_pcm16.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; vio_test ("vio_pcm24.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ; vio_test ("vio_float.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ; + vio_test ("vio_pcm24.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_24) ; return 0 ; } /* main */ @@ -189,6 +190,11 @@ vio_test (const char *fname, int format) exit (1) ; } ; + if (vfget_filelen (&vio_data) < 0) + { printf ("\n\nLine %d : vfget_filelen returned negative length.\n\n", __LINE__) ; + exit (1) ; + } ; + gen_short_data (data, ARRAY_LEN (data), 0) ; sf_write_short (file, data, ARRAY_LEN (data)) ; diff --git a/libs/libsndfile/tests/vorbis_test.c b/libs/libsndfile/tests/vorbis_test.c index c86a22cfac..9f5797fde9 100644 --- a/libs/libsndfile/tests/vorbis_test.c +++ b/libs/libsndfile/tests/vorbis_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2007-2009 Erik de Castro Lopo +** Copyright (C) 2007-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -96,8 +96,8 @@ vorbis_test (void) for (k = 0 ; k < ARRAY_LEN (float_data) ; k ++) max_abs = max_float (max_abs, fabs (float_data [k])) ; - if (max_abs > 1.02) - { printf ("\n\n Error : max_abs %f should be < 1.02.\n\n", max_abs) ; + if (max_abs > 1.021) + { printf ("\n\n Error : max_abs %f should be < 1.021.\n\n", max_abs) ; exit (1) ; } ; diff --git a/libs/libsndfile/tests/win32_ordinal_test.c b/libs/libsndfile/tests/win32_ordinal_test.c index acdcc75343..5324a2ed57 100644 --- a/libs/libsndfile/tests/win32_ordinal_test.c +++ b/libs/libsndfile/tests/win32_ordinal_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2006-2009 Erik de Castro Lopo +** Copyright (C) 2006-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ */ #include "sfconfig.h" -#include "sndfile.h" #include #include @@ -47,7 +46,7 @@ static const char * locations [] = -{ "../src/", "src/", "../src/.libs/", "src/.libs/", +{ ".", "../src/", "src/", "../src/.libs/", "src/.libs/", NULL } ; /* locations. */ diff --git a/libs/libsndfile/tests/win32_test.c b/libs/libsndfile/tests/win32_test.c index 3f776b8378..d0dc6d8ea4 100644 --- a/libs/libsndfile/tests/win32_test.c +++ b/libs/libsndfile/tests/win32_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2009 Erik de Castro Lopo +** Copyright (C) 2001-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include #include +#include #if HAVE_UNISTD_H #include @@ -38,7 +39,8 @@ #define SIGNED_SIZEOF(x) ((int) sizeof (x)) -#if defined (__CYGWIN__) +/* EMX is OS/2. */ +#if defined (__CYGWIN__) || defined (__EMX__) #define LSEEK lseek #define FSTAT fstat @@ -74,6 +76,7 @@ static void show_fstat_error (void) ; static void show_lseek_error (void) ; static void show_stat_fstat_error (void) ; +static void write_to_closed_file (void) ; int main (void) @@ -88,6 +91,7 @@ main (void) show_fstat_error () ; show_lseek_error () ; show_stat_fstat_error () ; + write_to_closed_file () ; puts ("\n\n") ; @@ -100,7 +104,7 @@ show_fstat_error (void) static char data [256] ; STATBUF statbuf ; - int fd, mode, flags, ignored ; + int fd, mode, flags ; if (sizeof (statbuf.st_size) != sizeof (INT64)) { printf ("\n\nLine %d: Error, sizeof (statbuf.st_size) != 8.\n\n", __LINE__) ; @@ -116,7 +120,7 @@ show_fstat_error (void) { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; return ; } ; - ignored = write (fd, data, sizeof (data)) ; + assert (write (fd, data, sizeof (data)) > 0) ; close (fd) ; printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ; @@ -127,7 +131,7 @@ show_fstat_error (void) return ; } ; LSEEK (fd, 0, SEEK_END) ; - ignored = write (fd, data, sizeof (data)) ; + assert (write (fd, data, sizeof (data)) > 0) ; printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ; @@ -137,7 +141,7 @@ show_fstat_error (void) strncat (data, " ", sizeof (data) - 1 - strlen (data)) ; strncat (data, filename, sizeof (data) - 1 - strlen (data)) ; - ignored = system (data) ; + assert (system (data) >= 0) ; puts ("") ; printf ("3) Now use fstat() to get the file length.\n") ; @@ -165,7 +169,7 @@ show_lseek_error (void) static char data [256] ; INT64 retval ; - int fd, mode, flags, ignored ; + int fd, mode, flags ; puts ("\n64 bit lseek() test.\n--------------------") ; @@ -176,7 +180,7 @@ show_lseek_error (void) { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; return ; } ; - ignored = write (fd, data, sizeof (data)) ; + assert (write (fd, data, sizeof (data)) > 0) ; close (fd) ; printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ; @@ -188,7 +192,7 @@ show_lseek_error (void) } ; LSEEK (fd, 0, SEEK_END) ; - ignored = write (fd, data, sizeof (data)) ; + assert (write (fd, data, sizeof (data)) > 0) ; printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ; @@ -198,7 +202,7 @@ show_lseek_error (void) strncat (data, " ", sizeof (data) - 1 - strlen (data)) ; strncat (data, filename, sizeof (data) - 1 - strlen (data)) ; - ignored = system (data) ; + assert (system (data) >= 0) ; puts ("") ; printf ("3) Now use lseek() to go to the end of the file.\n") ; @@ -223,7 +227,7 @@ show_stat_fstat_error (void) static char data [256] ; int fd, mode, flags ; - int stat_size, fstat_size, ignored ; + int stat_size, fstat_size ; struct stat buf ; /* Known to fail on WinXP. */ @@ -238,7 +242,7 @@ show_stat_fstat_error (void) return ; } ; - ignored = write (fd, data, sizeof (data)) ; + assert (write (fd, data, sizeof (data)) > 0) ; printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ; @@ -254,7 +258,7 @@ show_stat_fstat_error (void) } ; fstat_size = buf.st_size ; - printf ("3) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ; + printf ("2) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ; if (stat_size == 0 || stat_size != fstat_size) @@ -271,3 +275,44 @@ error_exit : } /* show_stat_fstat_error */ +static void +write_to_closed_file (void) +{ const char * filename = "closed_write_test.txt" ; + struct stat buf ; + FILE * file ; + int fd ; + + puts ("\nWrite to closed file test.\n--------------------------") ; + + printf ("0) First we open file for write using fopen().\n") ; + if ((file = fopen (filename, "w")) == NULL) + { printf ("\n\nLine %d: fopen() failed : %s\n\n", __LINE__, strerror (errno)) ; + return ; + } ; + + printf ("1) Now we grab the file descriptor fileno().\n") ; + fd = fileno (file) ; + + printf ("2) Write some text via the file descriptor.\n") ; + assert (write (fd, "a\n", 2) > 0) ; + + printf ("3) Now we close the file using fclose().\n") ; + fclose (file) ; + + stat (filename, &buf) ; + printf (" File size is %d bytes.\n", (int) buf.st_size) ; + + printf ("4) Now write more data to the file descriptor which should fail.\n") ; + if (write (fd, "b\n", 2) < 0) + printf ("5) Good, write returned an error code as it should have.\n") ; + else + { printf ("5) Attempting to write to a closed file should have failed but didn't! *** WRONG ***\n") ; + + stat (filename, &buf) ; + printf (" File size is %d bytes.\n", (int) buf.st_size) ; + } ; + + unlink (filename) ; + + return ; +} /* write_to_closed_file */ diff --git a/libs/libsndfile/tests/write_read_test.c b/libs/libsndfile/tests/write_read_test.c index a758454cf1..9f8a8f538b 100644 --- a/libs/libsndfile/tests/write_read_test.c +++ b/libs/libsndfile/tests/write_read_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2011 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -347,9 +347,9 @@ main (int argc, char **argv) } ; if (do_all || ! strcmp (argv [1], "sds")) - { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_TRUE) ; - pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_TRUE) ; - pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_TRUE) ; + { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_FALSE) ; + pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_FALSE) ; + pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_FALSE) ; empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ; empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; @@ -435,8 +435,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_char (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - short *orig, *test ; - int k, items, allow_fd ; + short *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -451,13 +451,10 @@ pcm_test_char (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, 32000.0) ; orig = orig_data.s ; - test = test_data.s ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_char_test (filename, format, long_file_ok, allow_fd) ; @@ -954,8 +951,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_short (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - short *orig, *test ; - int k, items, allow_fd ; + short *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -970,13 +967,10 @@ pcm_test_short (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, 32000.0) ; orig = orig_data.s ; - test = test_data.s ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_short_test (filename, format, long_file_ok, allow_fd) ; @@ -1473,8 +1467,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_24bit (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - int *orig, *test ; - int k, items, allow_fd ; + int *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -1489,13 +1483,10 @@ pcm_test_24bit (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, (1.0 * 0x7F000000)) ; orig = orig_data.i ; - test = test_data.i ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_24bit_test (filename, format, long_file_ok, allow_fd) ; @@ -1992,8 +1983,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_int (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - int *orig, *test ; - int k, items, allow_fd ; + int *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -2008,13 +1999,10 @@ pcm_test_int (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, (1.0 * 0x7F000000)) ; orig = orig_data.i ; - test = test_data.i ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_int_test (filename, format, long_file_ok, allow_fd) ; @@ -2511,8 +2499,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_float (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - float *orig, *test ; - int k, items, allow_fd ; + float *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -2527,13 +2515,10 @@ pcm_test_float (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, 1.0) ; orig = orig_data.f ; - test = test_data.f ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_float_test (filename, format, long_file_ok, allow_fd) ; @@ -3030,8 +3015,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_double (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - double *orig, *test ; - int k, items, allow_fd ; + double *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -3046,13 +3031,10 @@ pcm_test_double (const char *filename, int format, int long_file_ok) gen_windowed_sine_double (orig_data.d, DATA_LENGTH, 1.0) ; orig = orig_data.d ; - test = test_data.d ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_double_test (filename, format, long_file_ok, allow_fd) ; diff --git a/libs/libsndfile/tests/write_read_test.def b/libs/libsndfile/tests/write_read_test.def index cfc7ce58dc..3316aec577 100644 --- a/libs/libsndfile/tests/write_read_test.def +++ b/libs/libsndfile/tests/write_read_test.def @@ -1,6 +1,6 @@ autogen definitions write_read_test.tpl; -data_type = { +data_type = { type_name = char ; data_type = short ; data_field = s ; @@ -10,7 +10,7 @@ data_type = { max_error = "255" ; } ; -data_type = { +data_type = { type_name = short ; data_type = short ; data_field = s ; @@ -20,7 +20,17 @@ data_type = { max_error = "0" ; } ; -data_type = { +data_type = { + type_name = "20bit" ; + data_type = int ; + data_field = i ; + error_func = BIT_20_ERROR ; + format_char = "0x%X" ; + max_val = "(1.0 * 0x7F00000)" ; + max_error = "4096" ; + } ; + +data_type = { type_name = "24bit" ; data_type = int ; data_field = i ; @@ -30,7 +40,7 @@ data_type = { max_error = "256" ; } ; -data_type = { +data_type = { type_name = int ; data_type = int ; data_field = i ; @@ -42,7 +52,7 @@ data_type = { /* Lite remove start */ -data_type = { +data_type = { type_name = float ; data_type = float ; data_field = f ; @@ -52,7 +62,7 @@ data_type = { max_error = "0" ; } ; -data_type = { +data_type = { type_name = double ; data_type = double ; data_field = d ; diff --git a/libs/libsndfile/tests/write_read_test.tpl b/libs/libsndfile/tests/write_read_test.tpl index 550e22494a..55bf1db173 100644 --- a/libs/libsndfile/tests/write_read_test.tpl +++ b/libs/libsndfile/tests/write_read_test.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template c +] /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2012 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,25 +22,21 @@ #include #include #include +#include +#include + #if HAVE_UNISTD_H #include #endif -#include +#include -#if (defined (WIN32) || defined (_WIN32)) -#include -static int truncate (const char *filename, int ignored) ; -#endif - -#include - -#include "utils.h" -#include "generate.h" +#include "utils.h" +#include "generate.h" #define SAMPLE_RATE 11025 -#define DATA_LENGTH (1<<12) +#define DATA_LENGTH (1 << 12) #define SILLY_WRITE_COUNT (234) @@ -191,6 +187,12 @@ main (int argc, char **argv) /* Lite remove start */ pcm_test_float ("float_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_FLOAT , SF_FALSE) ; pcm_test_double ("double_le.caf", SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_DOUBLE, SF_FALSE) ; + + pcm_test_short ("alac16.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_16, SF_FALSE) ; + pcm_test_20bit ("alac20.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_20, SF_FALSE) ; + pcm_test_24bit ("alac24.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_24, SF_FALSE) ; + pcm_test_int ("alac32.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_32, SF_FALSE) ; + /* Lite remove end */ test_count++ ; } ; @@ -345,9 +347,9 @@ main (int argc, char **argv) } ; if (do_all || ! strcmp (argv [1], "sds")) - { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_TRUE) ; - pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_TRUE) ; - pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_TRUE) ; + { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_FALSE) ; + pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_FALSE) ; + pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_FALSE) ; empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ; empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; @@ -359,6 +361,7 @@ main (int argc, char **argv) { pcm_test_char ("char.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_S8, SF_TRUE) ; pcm_test_short ("short.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_16, SF_TRUE) ; pcm_test_24bit ("24bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_24, SF_TRUE) ; + pcm_test_int ("32bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_32, SF_TRUE) ; test_count++ ; } ; @@ -409,12 +412,13 @@ main (int argc, char **argv) static void create_short_file (const char *filename) ; -#define CHAR_ERROR(x,y) (abs ((x) - (y)) > 255) -#define INT_ERROR(x,y) (((x) - (y)) != 0) -#define TRIBYTE_ERROR(x,y) (abs ((x) - (y)) > 255) -#define FLOAT_ERROR(x,y) (fabs ((x) - (y)) > 1e-5) +#define CHAR_ERROR(x, y) (abs ((x) - (y)) > 255) +#define INT_ERROR(x, y) (((x) - (y)) != 0) +#define BIT_20_ERROR(x, y) (abs ((x) - (y)) > 4095) +#define TRIBYTE_ERROR(x, y) (abs ((x) - (y)) > 255) +#define FLOAT_ERROR(x, y) (fabs ((x) - (y)) > 1e-5) -#define CONVERT_DATA(k,len,new,orig) \ +#define CONVERT_DATA(k, len, new, orig) \ { for ((k) = 0 ; (k) < (len) ; (k) ++) \ (new) [k] = (orig) [k] ; \ } @@ -434,8 +438,8 @@ static void write_seek_extend_test (const char * filename, int format) ; static void pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_file_ok) { SF_INFO sfinfo ; - [+ (get "data_type") +] *orig, *test ; - int k, items, allow_fd ; + [+ (get "data_type") +] *orig ; + int k, allow_fd ; /* Sd2 files cannot be opened from an existing file descriptor. */ allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; @@ -450,13 +454,10 @@ pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_fil gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ; orig = orig_data.[+ (get "data_field") +] ; - test = test_data.[+ (get "data_field") +] ; /* Make this a macro so gdb steps over it in one go. */ CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - items = DATA_LENGTH ; - /* Some test broken out here. */ mono_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; @@ -469,7 +470,12 @@ pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_fil return ; } ; - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC) + if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 + ) mono_rdwr_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; /* If the format doesn't support stereo we're done. */ @@ -484,9 +490,14 @@ pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_fil /* New read/write test. Not sure if this is needed yet. */ - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF && - (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC && - (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC) + if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF + && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC + && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 + && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 + ) new_rdwr_[+ (get "type_name") +]_test (filename, format, allow_fd) ; delete_file (format, filename) ; @@ -501,7 +512,7 @@ mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_fi SF_INFO sfinfo ; [+ (get "data_type") +] *orig, *test ; sf_count_t count ; - int k, items ; + int k, items, total ; sfinfo.samplerate = 44100 ; sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ @@ -540,12 +551,12 @@ mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_fi } ; if (sfinfo.frames < 2 * items) - { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), items) ; + { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; exit (1) ; } ; if (! long_file_ok && sfinfo.frames > 2 * items) - { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too long). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), items) ; + { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; exit (1) ; } ; @@ -564,6 +575,23 @@ mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_fi exit (1) ; } ; + /* Test multiple short reads. */ + test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; + + total = 0 ; + for (k = 1 ; k <= 32 ; k++) + { int ik ; + + test_read_[+ (get "data_type") +]_or_die (file, 0, test + total, k, __LINE__) ; + total += k ; + + for (ik = 0 ; ik < total ; ik++) + if ([+ (get "error_func") +] (orig [ik], test [ik])) + { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, ik, orig [ik], test [ik]) ; + exit (1) ; + } ; + } ; + /* Seek to start of file. */ test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; @@ -574,6 +602,7 @@ mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_fi exit (1) ; } ; + /* For some codecs we can't go past here. */ if ((format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_16 || (format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_24) { sf_close (file) ; @@ -628,7 +657,7 @@ mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_fi /* Check that we haven't read beyond EOF. */ if (count > sfinfo.frames) - { printf ("\n\nLines %d : read past end of file (%ld should be %ld)\n", __LINE__, (long) count, (long) sfinfo.frames) ; + { printf ("\n\nLines %d : read past end of file (%" PRId64 " should be %" PRId64 ")\n", __LINE__, count, sfinfo.frames) ; exit (1) ; } ; @@ -688,14 +717,14 @@ stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_ } ; if (sfinfo.frames < frames) - { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too short). (%ld should be %d)\n", - __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ; + { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", + __LINE__, sfinfo.frames, frames) ; exit (1) ; } ; if (! long_file_ok && sfinfo.frames > frames) - { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too long). (%ld should be %d)\n", - __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ; + { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", + __LINE__, sfinfo.frames, frames) ; exit (1) ; } ; @@ -781,6 +810,18 @@ mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int lo [+ (get "data_type") +] *orig, *test ; int k, pass ; + switch (format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_ALAC_16 : + case SF_FORMAT_ALAC_20 : + case SF_FORMAT_ALAC_24 : + case SF_FORMAT_ALAC_32 : + allow_fd = 0 ; + break ; + + default : + break ; + } ; + orig = orig_data.[+ (get "data_field") +] ; test = test_data.[+ (get "data_field") +] ; @@ -859,12 +900,12 @@ mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int lo } ; if (sfinfo.frames < 3 * DATA_LENGTH) - { printf ("\n\nLine %d : Not enough frames in file. (%ld < %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 3 * DATA_LENGTH ) ; + { printf ("\n\nLine %d : Not enough frames in file. (%" PRId64 " < %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; exit (1) ; } if (! long_file_ok && sfinfo.frames != 3 * DATA_LENGTH) - { printf ("\n\nLine %d : Incorrect number of frames in file. (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 3 * DATA_LENGTH ) ; + { printf ("\n\nLine %d : Incorrect number of frames in file. (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; exit (1) ; } ; @@ -926,7 +967,7 @@ new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int all rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; if (sfinfo.frames != 2 * frames) - { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ; + { printf ("\n\nLine %d : incorrect number of frames in file (%" PRId64 " should be %d)\n\n", __LINE__, sfinfo.frames, 2 * frames) ; exit (1) ; } ; @@ -976,8 +1017,8 @@ empty_file_test (const char *filename, int format) /* Open for read and check the length. */ file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; - if (SF_COUNT_TO_LONG (info.frames) != 0) - { printf ("\n\nError : frame count (%ld) should be zero.\n", SF_COUNT_TO_LONG (info.frames)) ; + if (info.frames != 0) + { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; exit (1) ; } ; @@ -986,8 +1027,8 @@ empty_file_test (const char *filename, int format) /* Open for read/write and check the length. */ file = test_open_file_or_die (filename, SFM_RDWR, &info, allow_fd, __LINE__) ; - if (SF_COUNT_TO_LONG (info.frames) != 0) - { printf ("\n\nError : frame count (%ld) should be zero.\n", SF_COUNT_TO_LONG (info.frames)) ; + if (info.frames != 0) + { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; exit (1) ; } ; @@ -996,8 +1037,8 @@ empty_file_test (const char *filename, int format) /* Open for read and check the length. */ file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; - if (SF_COUNT_TO_LONG (info.frames) != 0) - { printf ("\n\nError : frame count (%ld) should be zero.\n", SF_COUNT_TO_LONG (info.frames)) ; + if (info.frames != 0) + { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; exit (1) ; } ; @@ -1031,28 +1072,6 @@ create_short_file (const char *filename) fclose (file) ; } /* create_short_file */ -#if (defined (WIN32) || defined (__WIN32)) - -/* Win32 does not have truncate (nor does it have the POSIX function ftruncate). -** Hack somethng up here to over come this. This function can only truncate to a -** length of zero. -*/ - -static int -truncate (const char *filename, int ignored) -{ int fd ; - - ignored = 0 ; - - if ((fd = open (filename, O_RDWR | O_TRUNC | O_BINARY)) < 0) - return 0 ; - - close (fd) ; - - return 0 ; -} /* truncate */ - -#endif static void multi_seek_test (const char * filename, int format) @@ -1091,7 +1110,7 @@ write_seek_extend_test (const char * filename, int format) short *orig, *test ; unsigned items, k ; - /* This test doesn't work on the following. */ + /* This test doesn't work on the following container formats. */ switch (format & SF_FORMAT_TYPEMASK) { case SF_FORMAT_FLAC : case SF_FORMAT_HTK : @@ -1104,6 +1123,18 @@ write_seek_extend_test (const char * filename, int format) break ; } ; + /* This test doesn't work on the following codec formats. */ + switch (format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_ALAC_16 : + case SF_FORMAT_ALAC_20 : + case SF_FORMAT_ALAC_24 : + case SF_FORMAT_ALAC_32 : + return ; + + default : + break ; + } ; + memset (&info, 0, sizeof (info)) ; info.samplerate = 48000 ; diff --git a/libs/libteletone/src/libteletone.h b/libs/libteletone/src/libteletone.h index f9487f630d..38f2088bb0 100644 --- a/libs/libteletone/src/libteletone.h +++ b/libs/libteletone/src/libteletone.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_detect.c b/libs/libteletone/src/libteletone_detect.c index 5c5e2bcbe5..b89ea11645 100644 --- a/libs/libteletone/src/libteletone_detect.c +++ b/libs/libteletone/src/libteletone_detect.c @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_detect.h b/libs/libteletone/src/libteletone_detect.h index 7fc62b21bb..e3c6f4f095 100644 --- a/libs/libteletone/src/libteletone_detect.h +++ b/libs/libteletone/src/libteletone_detect.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_generate.c b/libs/libteletone/src/libteletone_generate.c index ef7a7e03ec..3638d94989 100644 --- a/libs/libteletone/src/libteletone_generate.c +++ b/libs/libteletone/src/libteletone_generate.c @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_generate.h b/libs/libteletone/src/libteletone_generate.h index 262adaac96..62c12767c7 100644 --- a/libs/libteletone/src/libteletone_generate.h +++ b/libs/libteletone/src/libteletone_generate.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libzrtp/projects/win/libzrtp.2012.vcxproj b/libs/libzrtp/projects/win/libzrtp.2012.vcxproj index a570f8139c..c8c9f686e9 100644 --- a/libs/libzrtp/projects/win/libzrtp.2012.vcxproj +++ b/libs/libzrtp/projects/win/libzrtp.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -98,6 +98,7 @@ Level3 ProgramDatabase CompileAsC + 4267;%(DisableSpecificWarnings) @@ -117,6 +118,7 @@ Level3 ProgramDatabase CompileAsC + 4267;%(DisableSpecificWarnings) @@ -137,6 +139,7 @@ Level3 ProgramDatabase CompileAsC + 4267;%(DisableSpecificWarnings) @@ -157,6 +160,7 @@ Level3 ProgramDatabase CompileAsC + 4267;%(DisableSpecificWarnings) diff --git a/libs/openzap/Makefile.am b/libs/openzap/Makefile.am index 52af5e3082..2ef8da70ff 100644 --- a/libs/openzap/Makefile.am +++ b/libs/openzap/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2007-2012, Anthony Minessale II +# Copyright (c) 2007-2014, Anthony Minessale II # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/configure.ac b/libs/openzap/configure.ac index 9b41d26953..187c419a79 100644 --- a/libs/openzap/configure.ac +++ b/libs/openzap/configure.ac @@ -86,7 +86,7 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then SOLINK="-dynamic -bundle -force-flat-namespace" ;; *) - AC_ERROR([Please update configure.in with SOLINK values for your compiler]) + SOLINK="-shared -Xlinker -x" ;; esac elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index d26b4b66fe..3b2886b3d7 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/openzap/src/include/libteletone.h b/libs/openzap/src/include/libteletone.h index 557aebe01a..a7fe60981f 100644 --- a/libs/openzap/src/include/libteletone.h +++ b/libs/openzap/src/include/libteletone.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -37,7 +37,7 @@ * source code outside the scope of the openzap library will nullify the * following license and reinact the MPL 1.1 as stated above. * - * Copyright (c) 2005-2012, Anthony Minessale II + * Copyright (c) 2005-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/include/libteletone_detect.h b/libs/openzap/src/include/libteletone_detect.h index 82e79225e4..31a3568812 100644 --- a/libs/openzap/src/include/libteletone_detect.h +++ b/libs/openzap/src/include/libteletone_detect.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * libteletone_detect.c Tone Detection Code * diff --git a/libs/openzap/src/include/libteletone_generate.h b/libs/openzap/src/include/libteletone_generate.h index e0a306a81b..fde4f90d1f 100644 --- a/libs/openzap/src/include/libteletone_generate.h +++ b/libs/openzap/src/include/libteletone_generate.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/include/openzap.h b/libs/openzap/src/include/openzap.h index 362fbbed5e..8d9b50483f 100644 --- a/libs/openzap/src/include/openzap.h +++ b/libs/openzap/src/include/openzap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/include/zap_buffer.h b/libs/openzap/src/include/zap_buffer.h index c35364dcf6..1a2b264f90 100644 --- a/libs/openzap/src/include/zap_buffer.h +++ b/libs/openzap/src/include/zap_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/include/zap_config.h b/libs/openzap/src/include/zap_config.h index 48de0f1fc3..db62b459a5 100644 --- a/libs/openzap/src/include/zap_config.h +++ b/libs/openzap/src/include/zap_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/include/zap_types.h b/libs/openzap/src/include/zap_types.h index 7c51401993..862d0f0051 100644 --- a/libs/openzap/src/include/zap_types.h +++ b/libs/openzap/src/include/zap_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/libteletone_detect.c b/libs/openzap/src/libteletone_detect.c index 6ac8fd4beb..da92525310 100644 --- a/libs/openzap/src/libteletone_detect.c +++ b/libs/openzap/src/libteletone_detect.c @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Much less efficient expansion interface was added to allow for the detection of * a single arbitrary tone combination which may also exceed 2 simultaneous tones. @@ -10,7 +10,7 @@ * * libteletone_detect.c Tone Detection Code * - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/libteletone_generate.c b/libs/openzap/src/libteletone_generate.c index 88d3c3510e..f0ab59e488 100644 --- a/libs/openzap/src/libteletone_generate.c +++ b/libs/openzap/src/libteletone_generate.c @@ -1,7 +1,7 @@ /* * libteletone_generate.c -- Tone Generator * - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/m3ua_client.h b/libs/openzap/src/m3ua_client.h index 85eb09b2d8..c8b62b0a35 100644 --- a/libs/openzap/src/m3ua_client.h +++ b/libs/openzap/src/m3ua_client.h @@ -5,7 +5,7 @@ * Created by Shane Burrell on 4/3/08. * Copyright 2008 Shane Burrell. All rights reserved. * - * Copyright (c) 2007-2012, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2014, Anthony Minessale II, Nenad Corbic * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c b/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c index 02ad7e146e..9c72b9e3eb 100644 --- a/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c +++ b/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h b/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h index 45017d8678..287441796c 100644 --- a/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h +++ b/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c b/libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c index 89b44ba7d0..750a70eaab 100644 --- a/libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c +++ b/libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h b/libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h index 7d0f055a84..7e1e70ea11 100644 --- a/libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h +++ b/libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.c b/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.c index f3aa7f9dcf..674e26129e 100644 --- a/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.c +++ b/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c b/libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c index 2cf1892fbf..e7283d0582 100644 --- a/libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c +++ b/libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_pika/zap_pika.h b/libs/openzap/src/ozmod/ozmod_pika/zap_pika.h index 9245695798..42e7571da2 100644 --- a/libs/openzap/src/ozmod/ozmod_pika/zap_pika.h +++ b/libs/openzap/src/ozmod/ozmod_pika/zap_pika.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c b/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c index cc55a5084d..616746debf 100644 --- a/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c +++ b/libs/openzap/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c b/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c index 5c1e1436f2..68f046799f 100644 --- a/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c +++ b/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2014, Anthony Minessale II, Nenad Corbic * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.h b/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.h index 5ba2636e83..bbed200765 100644 --- a/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.h +++ b/libs/openzap/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2014, Anthony Minessale II, Nenad Corbic * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_sangoma_boost/zap_sangoma_boost.h b/libs/openzap/src/ozmod/ozmod_sangoma_boost/zap_sangoma_boost.h index 5a9a4aeadd..ca4ecbf469 100644 --- a/libs/openzap/src/ozmod/ozmod_sangoma_boost/zap_sangoma_boost.h +++ b/libs/openzap/src/ozmod/ozmod_sangoma_boost/zap_sangoma_boost.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c b/libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c index 587cd35864..0c706fbd8f 100644 --- a/libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c +++ b/libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c b/libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c index 06373c4f31..0d35747461 100644 --- a/libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c +++ b/libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c b/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c index 5874dffc09..a6017529c8 100644 --- a/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c +++ b/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h b/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h index c114d51606..006c87a7fe 100644 --- a/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h +++ b/libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/priserver.c b/libs/openzap/src/priserver.c index 3377eb2b2d..1928786af0 100644 --- a/libs/openzap/src/priserver.c +++ b/libs/openzap/src/priserver.c @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/openzap/src/sangoma_pri.c b/libs/openzap/src/sangoma_pri.c index 9f3d0807d2..27a44cd1ff 100644 --- a/libs/openzap/src/sangoma_pri.c +++ b/libs/openzap/src/sangoma_pri.c @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/openzap/src/sangoma_pri.h b/libs/openzap/src/sangoma_pri.h index 5829a699ea..a706f7c0df 100644 --- a/libs/openzap/src/sangoma_pri.h +++ b/libs/openzap/src/sangoma_pri.h @@ -4,7 +4,7 @@ * Author(s): Anthony Minessale II * Nenad Corbic * - * Copyright: (c) 2005-2012 Anthony Minessale II + * Copyright: (c) 2005-2014 Anthony Minessale II * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/openzap/src/zap_buffer.c b/libs/openzap/src/zap_buffer.c index faf3249d30..e317ac23e2 100644 --- a/libs/openzap/src/zap_buffer.c +++ b/libs/openzap/src/zap_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/zap_config.c b/libs/openzap/src/zap_config.c index f0d40c641a..3951f6b4fe 100644 --- a/libs/openzap/src/zap_config.c +++ b/libs/openzap/src/zap_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/zap_io.c b/libs/openzap/src/zap_io.c index 8385b6ce25..24cc9da14a 100644 --- a/libs/openzap/src/zap_io.c +++ b/libs/openzap/src/zap_io.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2012, Anthony Minessale II + * Copyright (c) 2007-2014, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/src/zap_m3ua.c b/libs/openzap/src/zap_m3ua.c index e5bc4cdd38..c88b515d15 100644 --- a/libs/openzap/src/zap_m3ua.c +++ b/libs/openzap/src/zap_m3ua.c @@ -6,7 +6,7 @@ * Copyright 2008 Shane Burrell. All rights reserved. * * - * Copyright (c) 2007-2012, Anthony Minessale II, Nenad Corbic * + * Copyright (c) 2007-2014, Anthony Minessale II, Nenad Corbic * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/libs/portaudio/build/msvc/portaudio.2012.vcxproj b/libs/portaudio/build/msvc/portaudio.2012.vcxproj index 587d2ea593..3a44ba8692 100644 --- a/libs/portaudio/build/msvc/portaudio.2012.vcxproj +++ b/libs/portaudio/build/msvc/portaudio.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -140,6 +140,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -166,6 +167,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -191,6 +193,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -216,6 +219,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -241,6 +245,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -266,6 +271,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -292,6 +298,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -318,6 +325,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/libs/silk/src/Silk_FIX.2012.vcxproj b/libs/silk/src/Silk_FIX.2012.vcxproj index 6a23bc707c..c268944e18 100644 --- a/libs/silk/src/Silk_FIX.2012.vcxproj +++ b/libs/silk/src/Silk_FIX.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -78,7 +78,7 @@ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Fast Level3 @@ -92,7 +92,7 @@ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) false false - MultiThreaded + MultiThreadedDLL Fast Level3 @@ -108,7 +108,7 @@ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Fast Level3 @@ -129,7 +129,7 @@ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) false false - MultiThreaded + MultiThreadedDLL Fast Level3 @@ -270,4 +270,4 @@ - + \ No newline at end of file diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index bd0253e8c0..548e466bd2 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Fri Oct 25 23:51:29 CDT 2013 +Fri Feb 21 16:38:32 EST 2014 diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index a0b7c5ccb6..5c8a98df0b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -2142,6 +2142,7 @@ int nta_agent_add_tport(nta_agent_t *self, char const * const * tports = tports_sip; int error; ta_list ta; + char *tps[9] = {0}; if (self == NULL) { su_seterrno(EINVAL); @@ -2187,7 +2188,7 @@ int nta_agent_add_tport(nta_agent_t *self, if (url->url_params) { if (url_param(url->url_params, "transport", tp, sizeof(tp)) > 0) { if (strchr(tp, ',')) { - int i; char *t, *tps[9] = {0}; + int i; char *t; /* Split tp into transports */ for (i = 0, t = tp; t && i < 8; i++) { diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c index 9b862415a3..f0b4d35d58 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c @@ -270,8 +270,10 @@ void nua_session_usage_remove(nua_handle_t *nh, ss->ss_reporting = 0; } - if (cr == du->du_cr && cr->cr_orq) + if (cr == du->du_cr && cr->cr_orq) { + nua_client_request_unref(cr); continue; + } if (cr->cr_status < 200) { nua_stack_event(nh->nh_nua, nh, diff --git a/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c b/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c index 7877100978..f29d7139bb 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c +++ b/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c @@ -1808,8 +1808,10 @@ static int parse_ul(sdp_parser_t *p, char **r, } #if !HAVE_STRTOULL +#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800)) unsigned long long strtoull(char const *string, char **return_end, int base); #endif +#endif /* * parse_ull: parse an unsigned long long diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c index 8b2913f43b..884ad40706 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c @@ -311,7 +311,7 @@ issize_t sip_alert_info_e(char b[], isize_t bsiz, sip_header_t const *h, int f) * { * sip_common_t rplyto_common[1]; // Common fragment info - * sip_error_t *rplyto_next; // Dummy link to next header + * sip_reply_to_t *rplyto_next; // Dummy link to next header * char const *rplyto_display; // Display name * url_t rplyto_url[1]; // Return URI * msg_param_t const *rplyto_params; // List of optional parameters diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_extra.h.in b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_extra.h.in index 45fafdece4..1c79acd5e7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_extra.h.in +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_extra.h.in @@ -87,7 +87,7 @@ typedef struct sip_reply_to_s sip_reply_to_t; struct sip_reply_to_s { sip_common_t rplyto_common[1]; /**< Common fragment info */ - sip_error_t *rplyto_next; /**< Dummy link to next header */ + sip_reply_to_t *rplyto_next; /**< Dummy link to next header */ char const *rplyto_display; /**< Display name */ url_t rplyto_url[1]; /**< Return URI */ msg_param_t const *rplyto_params; /**< List of optional parameters */ diff --git a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h index 8e4815f33e..dd02ec8ee7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h +++ b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_alloc.h @@ -68,7 +68,7 @@ SU_DLL void *su_home_new(isize_t size) #if (defined(HAVE_MEMLEAK_LOG) && (HAVE_MEMLEAK_LOG != 1)) int _su_home_mutex_lock(su_home_t *home, const char *file, unsigned int line, const char *function); -int _su_home_mutex_lock(su_home_t *home, const char *file, unsigned int line, const char *function); +int _su_home_mutex_unlock(su_home_t *home, const char *file, unsigned int line, const char *function); #define su_home_mutex_lock(home) \ _su_home_mutex_lock((home), __FILE__, __LINE__, __func__) diff --git a/libs/sofia-sip/libsofia-sip-ua/su/strtoull.c b/libs/sofia-sip/libsofia-sip-ua/su/strtoull.c index c4854aaeac..824a39df43 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/strtoull.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/strtoull.c @@ -73,7 +73,10 @@ static char cvtIn[] = { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}; - + + +#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800)) + /**Convert an ASCII string into an unsigned long long integer. * * @param[in] string String of ASCII digits, possibly preceded by white @@ -284,3 +287,5 @@ strtoull(const char *string, char **endPtr, int base) return (unsigned longlong)-1; } + +#endif diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c index 0369e08b5c..005989bb75 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c @@ -238,7 +238,7 @@ enum { }; #define ALIGNMENT (8) -#define ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1)) +#define __ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1)) #define SIZEBITS (sizeof (unsigned) * 8 - 1) typedef struct { @@ -478,7 +478,7 @@ void *sub_alloc(su_home_t *home, sub->sub_preload && size <= sub->sub_prsize) { /* Use preloaded memory */ size_t prused = sub->sub_prused + size + MEMCHECK_EXTRA; - prused = ALIGN(prused); + prused = __ALIGN(prused); if (prused <= sub->sub_prsize) { preload = (char *)sub->sub_preload + sub->sub_prused; sub->sub_prused = (unsigned)prused; @@ -1313,7 +1313,7 @@ void su_home_preload(su_home_t *home, isize_t n, isize_t isize) size_t size; void *preload; - size = n * ALIGN(isize); + size = n * __ALIGN(isize); if (size > 65535) /* We have 16 bits... */ size = 65535 & (ALIGNMENT - 1); @@ -1334,13 +1334,13 @@ su_home_t *su_home_auto(void *area, isize_t size) { su_home_t *home; su_block_t *sub; - size_t homesize = ALIGN(sizeof *home); - size_t subsize = ALIGN(offsetof(su_block_t, sub_nodes[SUB_N_AUTO])); + size_t homesize = __ALIGN(sizeof *home); + size_t subsize = __ALIGN(offsetof(su_block_t, sub_nodes[SUB_N_AUTO])); size_t prepsize; char *p = area; - prepsize = homesize + subsize + (ALIGN((intptr_t)p) - (intptr_t)p); + prepsize = homesize + subsize + (__ALIGN((intptr_t)p) - (intptr_t)p); if (area == NULL || size < prepsize) return NULL; @@ -1443,11 +1443,11 @@ void *su_realloc(su_home_t *home, void *data, isize_t size) p = (char *)data - home->suh_blocks->sub_preload; p += sua->sua_size + MEMCHECK_EXTRA; - p = ALIGN(p); + p = __ALIGN(p); if (p == sub->sub_prused) { size_t p2 = (char *)data - sub->sub_preload + size + MEMCHECK_EXTRA; - p2 = ALIGN(p2); + p2 = __ALIGN(p2); if (p2 <= sub->sub_prsize) { /* Extend/reduce existing preload */ if (sub->sub_stats) { @@ -1840,7 +1840,7 @@ void su_home_stats_alloc(su_block_t *sub, void *p, void *preload, { su_home_stat_t *hs = sub->sub_stats; - size_t rsize = ALIGN(size); + size_t rsize = __ALIGN(size); hs->hs_rehash += (sub->sub_n != hs->hs_blocksize); hs->hs_blocksize = sub->sub_n; @@ -1869,7 +1869,7 @@ void su_home_stats_free(su_block_t *sub, void *p, void *preload, { su_home_stat_t *hs = sub->sub_stats; - size_t rsize = ALIGN(size); + size_t rsize = __ALIGN(size); if (preload) { hs->hs_frees.hsf_preload++; diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c b/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c index 65037c2d18..431a2dcb56 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c @@ -60,8 +60,10 @@ #include #ifndef HAVE_STRTOULL +#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800)) unsigned longlong strtoull(const char *, char **, int); #endif +#endif /**@defgroup su_tag Tag Item Lists * diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c b/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c index 526a392552..33e70c9b59 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c @@ -110,7 +110,8 @@ static int initialized; static union state * get_state(void) { - static union state *retval, state0[1]; + static union state state0[1]; + union state *retval; #if SU_HAVE_PTHREADS diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h b/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h index 3abbbcbac4..de96fca3d8 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h @@ -142,6 +142,12 @@ TPORT_DLL extern tag_typedef_t tptag_timeout; TPORT_DLL extern tag_typedef_t tptag_timeout_ref; #define TPTAG_TIMEOUT_REF(x) tptag_timeout_ref, tag_uint_vr(&(x)) +TPORT_DLL extern tag_typedef_t tptag_socket_keepalive; +#define TPTAG_SOCKET_KEEPALIVE(x) tptag_socket_keepalive, tag_uint_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_socket_keepalive_ref; +#define TPTAG_SOCKET_KEEPALIVE_REF(x) tptag_socket_keepalive_ref, tag_uint_vr(&(x)) + TPORT_DLL extern tag_typedef_t tptag_keepalive; #define TPTAG_KEEPALIVE(x) tptag_keepalive, tag_uint_v((x)) @@ -180,6 +186,20 @@ TPORT_DLL extern tag_typedef_t tptag_certificate; TPORT_DLL extern tag_typedef_t tptag_certificate_ref; #define TPTAG_CERTIFICATE_REF(x) tptag_certificate_ref, tag_str_vr(&(x)) +TPORT_DLL extern tag_typedef_t tptag_tls_ciphers; +#define TPTAG_TLS_CIPHERS(x) tptag_tls_ciphers, tag_str_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_tls_ciphers_ref; +#define TPTAG_TLS_CIPHERS_REF(x) tptag_tls_ciphers_ref, tag_str_vr(&(x)) + +enum tport_tls_version { + TPTLS_VERSION_SSLv2 = (1 << 0), + TPTLS_VERSION_SSLv3 = (1 << 1), + TPTLS_VERSION_TLSv1 = (1 << 2), + TPTLS_VERSION_TLSv1_1 = (1 << 3), + TPTLS_VERSION_TLSv1_2 = (1 << 4), +}; + TPORT_DLL extern tag_typedef_t tptag_tls_version; #define TPTAG_TLS_VERSION(x) tptag_tls_version, tag_uint_v((x)) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c index 62193e9135..dd9c40c802 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c @@ -520,6 +520,7 @@ tport_t *tport_tcreate(tp_stack_t *stack, tpp->tpp_idle = UINT_MAX; tpp->tpp_timeout = UINT_MAX; tpp->tpp_sigcomp_lifetime = UINT_MAX; + tpp->tpp_socket_keepalive = 30; tpp->tpp_keepalive = 0; tpp->tpp_pingpong = 0; tpp->tpp_pong2ping = 0; @@ -1218,6 +1219,7 @@ int tport_get_params(tport_t const *self, TPTAG_QUEUESIZE(tpp->tpp_qsize), TPTAG_IDLE(tpp->tpp_idle), TPTAG_TIMEOUT(tpp->tpp_timeout), + TPTAG_SOCKET_KEEPALIVE(tpp->tpp_socket_keepalive), TPTAG_KEEPALIVE(tpp->tpp_keepalive), TPTAG_PINGPONG(tpp->tpp_pingpong), TPTAG_PONG2PING(tpp->tpp_pong2ping), @@ -1283,6 +1285,7 @@ int tport_set_params(tport_t *self, TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)), TPTAG_IDLE_REF(tpp->tpp_idle), TPTAG_TIMEOUT_REF(tpp->tpp_timeout), + TPTAG_SOCKET_KEEPALIVE_REF(tpp->tpp_socket_keepalive), TPTAG_KEEPALIVE_REF(tpp->tpp_keepalive), TPTAG_PINGPONG_REF(tpp->tpp_pingpong), TPTAG_PONG2PING_REF(pong2ping), diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h b/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h index 5deac55268..f18fc93911 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h @@ -106,6 +106,7 @@ typedef struct { unsigned tpp_mtu; /**< Maximum packet size */ unsigned tpp_idle; /**< Allowed connection idle time. */ unsigned tpp_timeout; /**< Allowed idle time for message. */ + unsigned tpp_socket_keepalive;/**< Socket keepalive interval */ unsigned tpp_keepalive; /**< Keepalive PING interval */ unsigned tpp_pingpong; /**< PONG-to-PING interval */ diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c index 495eaaf997..35262f4fe9 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c @@ -179,6 +179,14 @@ tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle); */ tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout); +/**@def TPTAG_SOCKET_KEEPALIVE(x) + * + * Keepalive interval set on socket (where supported) in seconds. + * + * If 0 or UINT_MAX, do not use keepalives. Default value is 30. + */ +tag_typedef_t tptag_socket_keepalive = UINTTAG_TYPEDEF(socket_keepalive); + /**@def TPTAG_KEEPALIVE(x) * * Keepalive interval in milliseconds. @@ -270,6 +278,14 @@ tag_typedef_t tptag_certificate = STRTAG_TYPEDEF(certificate); */ tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(compartment); +/**@def TPTAG_TLS_CIPHERS(x) + * + * Sets the supported TLS cipher suites. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + */ +tag_typedef_t tptag_tls_ciphers = STRTAG_TYPEDEF(tls_ciphers); /**@def TPTAG_TLS_VERSION(x) * diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c index 28cdf69bd6..d6b9b324ce 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c @@ -202,7 +202,7 @@ void tls_set_default(tls_issues_t *i) i->key = i->key ? i->key : i->cert; i->randFile = i->randFile ? i->randFile : "tls_seed.dat"; i->CAfile = i->CAfile ? i->CAfile : "cafile.pem"; - i->cipher = i->cipher ? i->cipher : "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"; + i->ciphers = i->ciphers ? i->ciphers : "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"; /* Default SIP cipher */ /* "RSA-WITH-AES-128-CBC-SHA"; */ /* RFC-2543-compatibility ciphersuite */ @@ -267,6 +267,27 @@ void tls_init(void) { ONCE_INIT(tls_init_once); } +static +int tls_init_ecdh_curve(tls_t *tls) +{ + int nid; + EC_KEY *ecdh; + if (!(nid = OBJ_sn2nid("prime256v1"))) { + tls_log_errors(1, "Couldn't find specified curve", 0); + errno = EIO; + return -1; + } + if (!(ecdh = EC_KEY_new_by_curve_name(nid))) { + tls_log_errors(1, "Couldn't create specified curve", 0); + errno = EIO; + return -1; + } + SSL_CTX_set_options(tls->ctx, SSL_OP_SINGLE_ECDH_USE); + SSL_CTX_set_tmp_ecdh(tls->ctx, ecdh); + EC_KEY_free(ecdh); + return 0; +} + static int tls_init_context(tls_t *tls, tls_issues_t const *ti) { @@ -295,27 +316,23 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti) signal(SIGPIPE, SIG_IGN); #endif - if (tls->ctx == NULL) { - const SSL_METHOD *meth; - - /* meth = SSLv3_method(); */ - /* meth = SSLv23_method(); */ - - if (ti->version) - meth = TLSv1_method(); - else - meth = SSLv23_method(); - - tls->ctx = SSL_CTX_new((SSL_METHOD*)meth); - SSL_CTX_sess_set_remove_cb(tls->ctx, NULL); - } - - if (tls->ctx == NULL) { - tls_log_errors(1, "tls_init_context", 0); - errno = EIO; - return -1; - } - + if (tls->ctx == NULL) + if (!(tls->ctx = SSL_CTX_new((SSL_METHOD*)SSLv23_method()))) { + tls_log_errors(1, "SSL_CTX_new() failed", 0); + errno = EIO; + return -1; + } + if (!(ti->version & TPTLS_VERSION_SSLv2)) + SSL_CTX_set_options(tls->ctx, SSL_OP_NO_SSLv2); + if (!(ti->version & TPTLS_VERSION_SSLv3)) + SSL_CTX_set_options(tls->ctx, SSL_OP_NO_SSLv3); + if (!(ti->version & TPTLS_VERSION_TLSv1)) + SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1); + if (!(ti->version & TPTLS_VERSION_TLSv1_1)) + SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1_1); + if (!(ti->version & TPTLS_VERSION_TLSv1_2)) + SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1_2); + SSL_CTX_sess_set_remove_cb(tls->ctx, NULL); SSL_CTX_set_timeout(tls->ctx, ti->timeout); /* Set callback if we have a passphrase */ @@ -389,7 +406,13 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti) SSL_CTX_set_verify_depth(tls->ctx, ti->verify_depth); SSL_CTX_set_verify(tls->ctx, verify, tls_verify_cb); - if (!SSL_CTX_set_cipher_list(tls->ctx, ti->cipher)) { + if (tls_init_ecdh_curve(tls) == 0) { + SU_DEBUG_3(("%s\n", "tls: initialized ECDH")); + } else { + SU_DEBUG_3(("%s\n", "tls: failed to initialize ECDH")); + } + + if (!SSL_CTX_set_cipher_list(tls->ctx, ti->ciphers)) { SU_DEBUG_1(("%s: error setting cipher list\n", "tls_init_context")); tls_log_errors(3, "tls_init_context", 0); errno = EIO; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h index 24c51800e2..47d330a146 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h @@ -60,7 +60,7 @@ typedef struct tls_issues_s { char *randFile; /* Seed file for the PRNG (default: tls_seed.dat) */ char *CAfile; /* PEM file of CA's */ char *CApath; /* PEM file path of CA's */ - char *cipher; /* Should be one of the above defined ciphers * + char *ciphers; /* Should be one of the above defined ciphers * * or NULL (default: "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH */ int version; /* For tls1, version is 1. When ssl3/ssl2 is diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c index 7196955e27..9b700dc1a2 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c @@ -196,12 +196,18 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted, #if defined(SO_KEEPALIVE) setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val); #endif - val = 30; + val = (int)(self->tp_params->tpp_socket_keepalive); #if defined(TCP_KEEPIDLE) - setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val); + if (val != 0 && val != UINT_MAX) { + SU_DEBUG_3(("%s(%p): Setting TCP_KEEPIDLE to %d\n", + __func__, (void *)self, val)); + setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val);} #endif #if defined(TCP_KEEPINTVL) - setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, (void *)&val, sizeof val); + if (val != 0 && val != UINT_MAX) { + SU_DEBUG_3(("%s(%p): Setting TCP_KEEPINTVL to %d\n", + __func__, (void *)self, val)); + setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, (void *)&val, sizeof val);} #endif if (!accepted) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c index 60be814834..6165c73fec 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c @@ -180,6 +180,7 @@ static int tport_tls_init_master(tport_primary_t *pri, char *homedir; char *tbf = NULL; char const *path = NULL; + char const *tls_ciphers = NULL; unsigned tls_version = 1; unsigned tls_timeout = 300; unsigned tls_verify = 0; @@ -198,6 +199,7 @@ static int tport_tls_init_master(tport_primary_t *pri, tl_gets(tags, TPTAG_CERTIFICATE_REF(path), + TPTAG_TLS_CIPHERS_REF(tls_ciphers), TPTAG_TLS_VERSION_REF(tls_version), TPTAG_TLS_TIMEOUT_REF(tls_timeout), TPTAG_TLS_VERIFY_PEER_REF(tls_verify), @@ -229,6 +231,7 @@ static int tport_tls_init_master(tport_primary_t *pri, ti.CAfile = su_sprintf(autohome, "%s/%s", path, "cafile.pem"); if (access(ti.CAfile, R_OK) != 0) ti.CAfile = NULL; if (!ti.CAfile) ti.CAfile = su_sprintf(autohome, "%s/%s", path, "tls.pem"); + if (tls_ciphers) ti.ciphers = su_strdup(autohome, tls_ciphers); ti.version = tls_version; ti.timeout = tls_timeout; ti.CApath = su_strdup(autohome, path); diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c index 1f16d0f18c..a6cb2ba85b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c @@ -338,6 +338,7 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri, tport_ws_primary_t *wspri = (tport_ws_primary_t *)pri; const char *cert = "/ssl.pem"; const char *key = "/ssl.pem"; + const char *chain = NULL; char *homedir; char *tbf = NULL; su_home_t autohome[SU_HOME_AUTO_SIZE(1024)]; @@ -361,11 +362,13 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri, key = su_sprintf(autohome, "%s/%s", path, "wss.key"); if (access(key, R_OK) != 0) key = NULL; cert = su_sprintf(autohome, "%s/%s", path, "wss.crt"); + chain = su_sprintf(autohome, "%s/%s", path, "ca-bundle.crt"); if (access(cert, R_OK) != 0) cert = NULL; if ( !key ) key = su_sprintf(autohome, "%s/%s", path, "wss.pem"); if ( !cert ) cert = su_sprintf(autohome, "%s/%s", path, "wss.pem"); if (access(key, R_OK) != 0) key = NULL; if (access(cert, R_OK) != 0) cert = NULL; + if (access(chain, R_OK) != 0) chain = NULL; } init_ssl(); @@ -379,6 +382,10 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri, if ( !wspri->ssl_ctx ) goto done; + if (chain) { + SSL_CTX_use_certificate_chain_file(wspri->ssl_ctx, chain); + } + /* set the local certificate from CertFile */ SSL_CTX_use_certificate_file(wspri->ssl_ctx, cert, SSL_FILETYPE_PEM); /* set the private key from KeyFile */ diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 41df93fdcf..f5534d6175 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -290,7 +290,7 @@ int ws_handshake(wsh_t *wsh) ws_raw_write(wsh, respond, strlen(respond)); wsh->handshake = 1; - + return 0; err: @@ -809,7 +809,7 @@ int xp_errno(void) int xp_is_blocking(int errcode) { - return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR; + return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR || errcode == ETIMEDOUT; } #endif diff --git a/libs/spandsp/.gitignore b/libs/spandsp/.gitignore index 758e233b79..123403b0f9 100644 --- a/libs/spandsp/.gitignore +++ b/libs/spandsp/.gitignore @@ -9,3 +9,4 @@ src/v27ter_tx_2400_rrc.h src/v27ter_tx_4800_rrc.h src/v29rx_rrc.h src/v29tx_rrc.h +INSTALL diff --git a/libs/spandsp/INSTALL b/libs/spandsp/INSTALL deleted file mode 100644 index 007e9396d0..0000000000 --- a/libs/spandsp/INSTALL +++ /dev/null @@ -1,370 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, -Inc. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented -below. The lack of an optional feature in a given package is not -necessarily a bug. More recommendations for GNU packages can be found -in *note Makefile Conventions: (standards)Makefile Conventions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - - The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package, generally using the just-built uninstalled binaries. - - 4. Type `make install' to install the programs and any data files and - documentation. When installing into a prefix owned by root, it is - recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root - privileges. - - 5. Optionally, type `make installcheck' to repeat any self-tests, but - this time using the binaries in their final installed location. - This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required - root privileges, verifies that the installation completed - correctly. - - 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 7. Often, you can also type `make uninstall' to remove the installed - files again. In practice, not all packages have tested that - uninstallation works correctly, even though it is required by the - GNU Coding Standards. - - 8. Some packages, particularly those that use Automake, provide `make - distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. - This target is generally not run by end users. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an -absolute file name. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory -specifications that were not explicitly provided. - - The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or -both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without -having to reconfigure or recompile. - - The first method involves providing an override variable for each -affected directory. For example, `make install -prefix=/alternate/directory' will choose an alternate location for all -directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and -does not work on platforms that have drive letters. On the other hand, -it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. - -Optional Features -================= - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - - Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure ---enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure ---disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put `/usr/ucb' early in your `PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. - - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: - - CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index de395ec4cc..1810e07fe2 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -21,6 +21,10 @@ AC_PREREQ([2.59]) AC_INIT([spandsp], [1.99.0]) +CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" +CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" +LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" + SPANDSP_LT_CURRENT=3 SPANDSP_LT_REVISION=0 SPANDSP_LT_AGE=0 @@ -198,7 +202,17 @@ AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([string.h]) AC_CHECK_HEADERS([strings.h]) AC_CHECK_HEADERS([malloc.h]) -AC_CHECK_HEADERS([tgmath.h], [INSERT_TGMATH_HEADER="#include "]) + +case "$host" in + *freebsd*) + ;; + *dragonfly*) + ;; + *) + AC_CHECK_HEADERS([tgmath.h], [INSERT_TGMATH_HEADER="#include "]) + ;; +esac + AC_CHECK_HEADERS([math.h], [INSERT_MATH_HEADER="#include "]) AC_CHECK_HEADERS([float.h]) AC_CHECK_HEADERS([fcntl.h]) @@ -324,9 +338,11 @@ AX_CHECK_EXPORT_CAPABILITY([$host], saved_CFLAGS="$CFLAGS" AC_CACHE_CHECK([whether compiler supports -Wunused-but-set-variable], [ac_cv_gcc_unused_but_set_variable], [ -CFLAGS="$CFLAGS -Wunused-but-set-variable" -AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_unused_but_set_variable=yes],[ac_cv_gcc_unused_but_set_variable=no]) -]) + # We need to add -Werror here or clang doesn't fail (it just warns), even though it doesn't understand the + # -Wunused-but-set-variable tag + CFLAGS="$CFLAGS -Werror -Wunused-but-set-variable" + AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_unused_but_set_variable=yes],[ac_cv_gcc_unused_but_set_variable=no]) + ]) AC_MSG_RESULT($ac_cv_gcc_unused_but_set_variable) CFLAGS="$saved_CFLAGS" @@ -518,6 +534,13 @@ x86_64-* | i386-* | i686-*) ;; esac +case "$host" in + *bsd*) + CFLAGS="$CFLAGS -I/usr/local/include" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + ;; +esac + if test "$enable_builtin_tiff" = "yes" ; then abs_tiffdir="`cd $srcdir/../tiff-4.0.2/ && pwd`" save_CFLAGS=$CFLAGS diff --git a/libs/spandsp/m4/ax_check_arm_neon.m4 b/libs/spandsp/m4/ax_check_arm_neon.m4 index 1e972686ef..834b2e963f 100644 --- a/libs/spandsp/m4/ax_check_arm_neon.m4 +++ b/libs/spandsp/m4/ax_check_arm_neon.m4 @@ -20,8 +20,8 @@ ac_cv_symbol_arm_neon="no" case "${ax_cv_c_compiler_vendor}" in gnu) save_CFLAGS="${CFLAGS}" - CFLAGS="${CFLAGS} -mfpu=neon" - AC_COMPILE_IFELSE( + CFLAGS="${CFLAGS} -mfpu=neon -mfloat-abi=hard" + AC_RUN_IFELSE( [AC_LANG_PROGRAM( [ #include @@ -33,7 +33,7 @@ gnu) } ], [ - int32x4_t z; + volatile int32x4_t z; int16_t x[[8]]; int16_t y[[8]]; z = testfunc(x, y); @@ -45,6 +45,9 @@ gnu) COMP_VENDOR_CXXFLAGS="-mfpu=neon $COMP_VENDOR_CXXFLAGS" ac_cv_symbol_arm_neon="yes"], + [AC_MSG_RESULT([no])], + + dnl Assume "no" if cross-compiling [AC_MSG_RESULT([no])] ) CFLAGS="${save_CFLAGS}" diff --git a/libs/spandsp/spandsp/fax-tests.xml b/libs/spandsp/spandsp/fax-tests.xml index e770e244b8..23f333a396 100644 --- a/libs/spandsp/spandsp/fax-tests.xml +++ b/libs/spandsp/spandsp/fax-tests.xml @@ -87,6 +87,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/spandsp/tsb85.xml b/libs/spandsp/spandsp/tsb85.xml index 8826098946..482e18b989 100644 --- a/libs/spandsp/spandsp/tsb85.xml +++ b/libs/spandsp/spandsp/tsb85.xml @@ -423,7 +423,7 @@ - + diff --git a/libs/spandsp/src/ademco_contactid.c b/libs/spandsp/src/ademco_contactid.c index 453ccc0394..f497106d2f 100644 --- a/libs/spandsp/src/ademco_contactid.c +++ b/libs/spandsp/src/ademco_contactid.c @@ -504,7 +504,7 @@ SPAN_DECLARE(int) decode_msg(ademco_contactid_report_t *report, const char buf[] int x; char buf2[20]; - /* We need to remap normal DTMF (0-0, *, #, A-D) to Ademco's psuedo-hex (0-0, B-F, nothing for A) + /* We need to remap normal DTMF (0-0, *, #, A-D) to Ademco's pseudo-hex (0-0, B-F, nothing for A) and calculate the checksum */ for (sum = 0, s = buf, t = buf2; *s; s++, t++) { diff --git a/libs/spandsp/src/alloc.c b/libs/spandsp/src/alloc.c index b79aa166e7..b8cb6810c8 100644 --- a/libs/spandsp/src/alloc.c +++ b/libs/spandsp/src/alloc.c @@ -36,8 +36,12 @@ #if !defined(__USE_ISOC11) #define __USE_ISOC11 #endif +#if defined(__ISO_C_VISIBLE) && __ISO_C_VISIBLE < 2011 +#undef __ISO_C_VISIBLE +#define __ISO_C_VISIBLE 2011 +#endif #include -#if defined(HAVE_MALLOC_H) +#if defined(HAVE_MALLOC_H) && !defined(__OpenBSD__) && !defined(__DragonFly__) #include #endif #include diff --git a/libs/spandsp/src/at_interpreter.c b/libs/spandsp/src/at_interpreter.c index d43ffb3671..73cdf879a0 100644 --- a/libs/spandsp/src/at_interpreter.c +++ b/libs/spandsp/src/at_interpreter.c @@ -222,9 +222,9 @@ SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t) buf[1] = s->p.s_regs[4]; buf[2] = '\0'; if (s->p.result_code_format == ASCII_RESULT_CODES) - s->at_tx_handler(s, s->at_tx_user_data, buf, 2); - s->at_tx_handler(s, s->at_tx_user_data, (uint8_t *) t, strlen(t)); - s->at_tx_handler(s, s->at_tx_user_data, buf, 2); + s->at_tx_handler(s->at_tx_user_data, buf, 2); + s->at_tx_handler(s->at_tx_user_data, (uint8_t *) t, strlen(t)); + s->at_tx_handler(s->at_tx_user_data, buf, 2); } /*- End of function --------------------------------------------------------*/ @@ -249,7 +249,7 @@ SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code) break; case NUMERIC_RESULT_CODES: snprintf((char *) buf, sizeof(buf), "%d%c", code, s->p.s_regs[3]); - s->at_tx_handler(s, s->at_tx_user_data, buf, strlen((char *) buf)); + s->at_tx_handler(s->at_tx_user_data, buf, strlen((char *) buf)); break; default: /* No result codes */ @@ -361,7 +361,7 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event) { s->rx_data[s->rx_data_bytes++] = DLE; s->rx_data[s->rx_data_bytes++] = ETX; - s->at_tx_handler(s, s->at_tx_user_data, s->rx_data, s->rx_data_bytes); + s->at_tx_handler(s->at_tx_user_data, s->rx_data, s->rx_data_bytes); s->rx_data_bytes = 0; } if (s->at_rx_mode != AT_MODE_OFFHOOK_COMMAND && s->at_rx_mode != AT_MODE_ONHOOK_COMMAND) @@ -881,7 +881,7 @@ static int process_class1_cmd(at_state_t *s, const char **t) result = true; if (s->class1_handler) - result = s->class1_handler(s, s->class1_user_data, direction, operation, val); + result = s->class1_handler(s->class1_user_data, direction, operation, val); switch (result) { case 0: @@ -5461,7 +5461,7 @@ SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num) break; } /*endswitch*/ - return s->modem_control_handler(s, s->modem_control_user_data, op, num); + return s->modem_control_handler(s->modem_control_user_data, op, num); } /*- End of function --------------------------------------------------------*/ @@ -5474,7 +5474,7 @@ SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len) const char *t; if (s->p.echo) - s->at_tx_handler(s, s->at_tx_user_data, (uint8_t *) cmd, len); + s->at_tx_handler(s->at_tx_user_data, (uint8_t *) cmd, len); for (i = 0; i < len; i++) { @@ -5582,6 +5582,15 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(void) at_set_modem_control_handler(at_state_t *s, + at_modem_control_handler_t modem_control_handler, + void *modem_control_user_data) +{ + s->modem_control_handler = modem_control_handler; + s->modem_control_user_data = modem_control_user_data; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s) { return &s->logging; diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index 8d8b3b25bc..196c9ab0d3 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -77,6 +77,10 @@ #include "spandsp/v27ter_rx.h" #include "spandsp/v17tx.h" #include "spandsp/v17rx.h" +#if defined(SPANDSP_SUPPORT_V34) +#include "spandsp/bitstream.h" +#include "spandsp/v34.h" +#endif #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" @@ -103,6 +107,10 @@ #include "spandsp/private/fsk.h" #include "spandsp/private/modem_connect_tones.h" #include "spandsp/private/v8.h" +#if defined(SPANDSP_SUPPORT_V34) +#include "spandsp/private/bitstream.h" +#include "spandsp/private/v34.h" +#endif #include "spandsp/private/v17tx.h" #include "spandsp/private/v17rx.h" #include "spandsp/private/v27ter_tx.h" @@ -248,8 +256,7 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t return; t->current_rx_type = type; t->rx_bit_rate = bit_rate; - if (use_hdlc) - hdlc_rx_init(&t->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, t30_hdlc_accept, &s->t30); + hdlc_rx_init(&t->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, t); switch (type) { diff --git a/libs/spandsp/src/fax_modems.c b/libs/spandsp/src/fax_modems.c index e298f4d70a..b32fba7ada 100644 --- a/libs/spandsp/src/fax_modems.c +++ b/libs/spandsp/src/fax_modems.c @@ -5,7 +5,7 @@ * * Written by Steve Underwood * - * Copyright (C) 2003, 2005, 2006, 2008 Steve Underwood + * Copyright (C) 2003, 2005, 2006, 2008, 2013 Steve Underwood * * All rights reserved. * @@ -139,19 +139,26 @@ SPAN_DECLARE(const char *) fax_modem_to_str(int modem) return "V.27ter Rx"; case FAX_MODEM_V29_RX: return "V.29 Rx"; +#if defined(SPANDSP_SUPPORT_V34) + case FAX_MODEM_V34_TX: + return "V.34 HDX Tx"; + case FAX_MODEM_V34_RX: + return "V.34 HDX Rx"; +#endif } /*endswitch*/ return "???"; } /*- End of function --------------------------------------------------------*/ -static void fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok) +//static void fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok) +SPAN_DECLARE_NONSTD(void) fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok) { fax_modems_state_t *s; s = (fax_modems_state_t *) user_data; - if (ok) - s->rx_frame_received = false; + if (len >= 0 && ok) + s->rx_frame_received = true; if (s->hdlc_accept) s->hdlc_accept(s->hdlc_accept_user_data, msg, len, ok); } @@ -322,7 +329,7 @@ SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which) fsk_rx_init(&s->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &s->hdlc_rx); fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); fsk_rx_signal_cutoff(&s->v21_rx, -39.09f); - s->rx_frame_received = false; + //hdlc_rx_init(&s->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); break; case FAX_MODEM_CED_TONE_RX: modem_connect_tones_rx_init(&s->connect_rx, MODEM_CONNECT_TONES_FAX_CED, s->tone_callback, s->tone_callback_user_data); @@ -348,6 +355,8 @@ SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which) fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); break; } + /*endswitch*/ + s->rx_frame_received = false; } /*- End of function --------------------------------------------------------*/ @@ -365,6 +374,7 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, get_bit_user_data = (void *) &s->hdlc_tx; put_bit = (put_bit_func_t) hdlc_rx_put_bit; put_bit_user_data = (void *) &s->hdlc_rx; + //hdlc_rx_init(&s->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); } else { @@ -382,8 +392,6 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, s->current_rx_type = which; s->short_train = false; s->fast_modem = which; - if (hdlc_mode) - s->rx_frame_received = false; switch (s->fast_modem) { case FAX_MODEM_V27TER_RX: @@ -417,6 +425,18 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, fax_modems_set_tx_handler(s, (span_tx_handler_t) &v17_tx, &s->fast_modems.v17_tx); fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); break; +#if defined(SPANDSP_SUPPORT_V34) + case FAX_MODEM_V34_RX: + v34_init(&s->fast_modems.v34, 2400, s->bit_rate, true, false, NULL, NULL, put_bit, put_bit_user_data); + //fax_modems_set_tx_handler(s, (span_tx_handler_t) &v34_rx, &s->fast_modems.v34_rx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V34_TX: + v34_init(&s->fast_modems.v34, 2400, s->bit_rate, true, false, get_bit, get_bit_user_data, NULL, NULL); + //fax_modems_set_tx_handler(s, (span_tx_handler_t) &v34_tx, &s->fast_modems.v34_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; +#endif } /*endswitch*/ } @@ -461,10 +481,23 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, fax_modems_set_tx_handler(s, (span_tx_handler_t) &v17_tx, &s->fast_modems.v17_tx); fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); break; +#if defined(SPANDSP_SUPPORT_V34) + case FAX_MODEM_V34_RX: + v34_restart(&s->fast_modems.v34, 2400, s->bit_rate, false); + //fax_modems_set_tx_handler(s, (span_tx_handler_t) &v34_rx, &s->fast_modems.v34_rx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V34_TX: + v34_restart(&s->fast_modems.v34, 2400, s->bit_rate, false); + //fax_modems_set_tx_handler(s, (span_tx_handler_t) &v34_tx, &s->fast_modems.v34_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; +#endif } /*endswitch*/ } /*endif*/ + s->rx_frame_received = false; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/gsm0610_rpe.c b/libs/spandsp/src/gsm0610_rpe.c index 68ddff3e1e..0a6cbb649c 100644 --- a/libs/spandsp/src/gsm0610_rpe.c +++ b/libs/spandsp/src/gsm0610_rpe.c @@ -59,7 +59,7 @@ static void weighting_filter(int16_t x[40], const int16_t *e) // signal [-5..0.39.44] IN) { -#if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) && !(defined(__APPLE_CC__) && __APPLE_CC__ >= 5448) +#if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) && !(defined(__APPLE_CC__) && __APPLE_CC__ >= 5448) && !defined(__OpenBSD__) /* Table 4.4 Coefficients of the weighting filter */ /* This must be padded to a multiple of 4 for MMX to work */ static const union diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index 1768b92138..217e560260 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -685,7 +685,6 @@ static int image_format_to_bytes_per_pixel(int image_format) case T4_IMAGE_TYPE_4COLOUR_12BIT: return 8; } - return 1; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/libspandsp.2005.sln b/libs/spandsp/src/libspandsp.2005.sln deleted file mode 100644 index 0aa47bda59..0000000000 --- a/libs/spandsp/src/libspandsp.2005.sln +++ /dev/null @@ -1,68 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_at_dictionary", "msvc\make_at_dictionary.2005.vcproj", "{DEE932AB-5911-4700-9EEB-8C7090A0A330}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_modem_filter", "msvc\make_modem_filter.2005.vcproj", "{329A6FA0-0FCC-4435-A950-E670AEFA9838}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libspandsp.2005.vcproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" - ProjectSection(ProjectDependencies) = postProject - {329A6FA0-0FCC-4435-A950-E670AEFA9838} = {329A6FA0-0FCC-4435-A950-E670AEFA9838} - {DEE932AB-5911-4700-9EEB-8C7090A0A330} = {DEE932AB-5911-4700-9EEB-8C7090A0A330} - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} = {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp_sim", "..\spandsp-sim\libspandsp_sim.2005.vcproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" - ProjectSection(ProjectDependencies) = postProject - {329A6FA0-0FCC-4435-A950-E670AEFA9838} = {329A6FA0-0FCC-4435-A950-E670AEFA9838} - {DEE932AB-5911-4700-9EEB-8C7090A0A330} = {DEE932AB-5911-4700-9EEB-8C7090A0A330} - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} = {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libtiff.2005.vcproj", "{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}" - ProjectSection(ProjectDependencies) = postProject - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917} = {2B8A45C9-FEB4-4734-AB37-8DB9DB899917} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download TIFF", "msvc\Download_TIFF.2005.vcproj", "{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - All|Win32 = All|Win32 - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.Build.0 = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.Build.0 = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.Build.0 = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.Build.0 = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|Win32.ActiveCfg = All|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.ActiveCfg = Release|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.Build.0 = Release|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.Build.0 = Debug|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.ActiveCfg = Release|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.Build.0 = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.ActiveCfg = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.Build.0 = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.ActiveCfg = Debug|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.Build.0 = Debug|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.ActiveCfg = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.Build.0 = Release|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.Build.0 = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.Build.0 = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.Build.0 = All|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/spandsp/src/libspandsp.2008.sln b/libs/spandsp/src/libspandsp.2008.sln deleted file mode 100644 index 7a0323998b..0000000000 --- a/libs/spandsp/src/libspandsp.2008.sln +++ /dev/null @@ -1,209 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_at_dictionary", "msvc\make_at_dictionary.2008.vcproj", "{DEE932AB-5911-4700-9EEB-8C7090A0A330}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_modem_filter", "msvc\make_modem_filter.2008.vcproj", "{329A6FA0-0FCC-4435-A950-E670AEFA9838}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libspandsp.2008.vcproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" - ProjectSection(ProjectDependencies) = postProject - {329A6FA0-0FCC-4435-A950-E670AEFA9838} = {329A6FA0-0FCC-4435-A950-E670AEFA9838} - {DEE932AB-5911-4700-9EEB-8C7090A0A330} = {DEE932AB-5911-4700-9EEB-8C7090A0A330} - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} = {401A40CD-5DB4-4E34-AC68-FA99E9FAC014} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_line_models", "..\spandsp-sim\msvc\make_line_models.2008.vcproj", "{F290BADE-82DE-4037-B49D-D563E43169DA}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp_sim", "..\spandsp-sim\libspandsp_sim.2008.vcproj", "{502F1E51-F0A0-4607-AB7F-05BAB530AAE1}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libtiff.2008.vcproj", "{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}" - ProjectSection(ProjectDependencies) = postProject - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917} = {2B8A45C9-FEB4-4734-AB37-8DB9DB899917} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download TIFF", "msvc\Download_TIFF.2008.vcproj", "{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t38_core_tests", "..\tests\msvc\t38_core_tests.vcproj", "{A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t38_non_ecm_buffer_tests", "..\tests\msvc\t38_non_ecm_buffer_tests.vcproj", "{80A3D9D9-3846-4DA5-8676-F940D725EA62}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vector_int_tests", "..\tests\msvc\vector_int_tests.vcproj", "{80A60464-29E8-4EE8-BAFA-8708B7C08CC3}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vector_float_tests", "..\tests\msvc\vector_float_tests.vcproj", "{EA745FF7-9E4B-4C13-BA19-2EE8165A6245}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_tests", "..\tests\msvc\complex_tests.vcproj", "{A349379F-0FEA-49C8-9535-05F39663337B}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_vector_float_tests", "..\tests\msvc\complex_vector_float_tests.vcproj", "{2B0D705C-1CF2-401C-BFBC-A43FB806908C}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_vector_int_tests", "..\tests\msvc\complex_vector_int_tests.vcproj", "{C2E8B4D1-A398-4D57-94F8-B61F20C7D514}" - ProjectSection(ProjectDependencies) = postProject - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - All|Win32 = All|Win32 - All|x64 = All|x64 - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.Build.0 = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|x64.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.Build.0 = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|x64.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|Win32.ActiveCfg = All|Win32 - {DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|x64.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.Build.0 = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|x64.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.Build.0 = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|x64.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|Win32.ActiveCfg = All|Win32 - {329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|x64.ActiveCfg = All|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.ActiveCfg = Release|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|x64.ActiveCfg = Release|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|x64.Build.0 = Release|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.Build.0 = Debug|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|x64.ActiveCfg = Debug|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|x64.Build.0 = Debug|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.ActiveCfg = Release|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.Build.0 = Release|Win32 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|x64.ActiveCfg = Release|x64 - {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|x64.Build.0 = Release|x64 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.All|Win32.ActiveCfg = Release|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.All|Win32.Build.0 = Release|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.All|x64.ActiveCfg = Release|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Debug|Win32.ActiveCfg = Debug|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Debug|Win32.Build.0 = Debug|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Debug|x64.ActiveCfg = Debug|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Release|Win32.ActiveCfg = Release|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Release|Win32.Build.0 = Release|Win32 - {502F1E51-F0A0-4607-AB7F-05BAB530AAE1}.Release|x64.ActiveCfg = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.ActiveCfg = Release|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|x64.ActiveCfg = Release|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|x64.Build.0 = Release|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.ActiveCfg = Debug|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.Build.0 = Debug|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|x64.ActiveCfg = Debug|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|x64.Build.0 = Debug|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.ActiveCfg = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.Build.0 = Release|Win32 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|x64.ActiveCfg = Release|x64 - {401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|x64.Build.0 = Release|x64 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.Build.0 = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|x64.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.Build.0 = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|x64.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.ActiveCfg = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.Build.0 = All|Win32 - {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|x64.ActiveCfg = All|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|Win32.ActiveCfg = Release|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|Win32.Build.0 = Release|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|x64.ActiveCfg = Release|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|Win32.ActiveCfg = Debug|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|Win32.Build.0 = Debug|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|x64.ActiveCfg = Debug|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|Win32.ActiveCfg = Release|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|Win32.Build.0 = Release|Win32 - {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|x64.ActiveCfg = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|Win32.ActiveCfg = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|Win32.Build.0 = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|x64.ActiveCfg = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|Win32.ActiveCfg = Debug|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|Win32.Build.0 = Debug|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|x64.ActiveCfg = Debug|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|Win32.ActiveCfg = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|Win32.Build.0 = Release|Win32 - {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|x64.ActiveCfg = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|Win32.ActiveCfg = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|Win32.Build.0 = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|x64.ActiveCfg = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|Win32.Build.0 = Debug|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|x64.ActiveCfg = Debug|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|Win32.ActiveCfg = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|Win32.Build.0 = Release|Win32 - {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|x64.ActiveCfg = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|Win32.ActiveCfg = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|Win32.Build.0 = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|x64.ActiveCfg = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|Win32.ActiveCfg = Debug|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|Win32.Build.0 = Debug|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|x64.ActiveCfg = Debug|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|Win32.ActiveCfg = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|Win32.Build.0 = Release|Win32 - {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|x64.ActiveCfg = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.All|Win32.ActiveCfg = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.All|Win32.Build.0 = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.All|x64.ActiveCfg = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|Win32.ActiveCfg = Debug|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|Win32.Build.0 = Debug|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|x64.ActiveCfg = Debug|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Release|Win32.ActiveCfg = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Release|Win32.Build.0 = Release|Win32 - {A349379F-0FEA-49C8-9535-05F39663337B}.Release|x64.ActiveCfg = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|Win32.ActiveCfg = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|Win32.Build.0 = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|x64.ActiveCfg = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|Win32.ActiveCfg = Debug|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|Win32.Build.0 = Debug|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|x64.ActiveCfg = Debug|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|Win32.ActiveCfg = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|Win32.Build.0 = Release|Win32 - {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|x64.ActiveCfg = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|Win32.ActiveCfg = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|Win32.Build.0 = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|x64.ActiveCfg = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|Win32.ActiveCfg = Debug|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|Win32.Build.0 = Debug|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|x64.ActiveCfg = Debug|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|Win32.ActiveCfg = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|Win32.Build.0 = Release|Win32 - {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|x64.ActiveCfg = Release|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.All|Win32.ActiveCfg = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.All|Win32.Build.0 = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.All|x64.ActiveCfg = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Debug|Win32.ActiveCfg = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Debug|Win32.Build.0 = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Debug|x64.ActiveCfg = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Release|Win32.ActiveCfg = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Release|Win32.Build.0 = All|Win32 - {F290BADE-82DE-4037-B49D-D563E43169DA}.Release|x64.ActiveCfg = All|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/spandsp/src/libspandsp.2012.vcxproj b/libs/spandsp/src/libspandsp.2012.vcxproj index a73a1b3c88..ff7338af7a 100644 --- a/libs/spandsp/src/libspandsp.2012.vcxproj +++ b/libs/spandsp/src/libspandsp.2012.vcxproj @@ -87,7 +87,7 @@ MultiThreadedDebugDLL Level4 CompileAsC - 4127;%(DisableSpecificWarnings) + 4127;4324;4267;4306;%(DisableSpecificWarnings) true @@ -105,7 +105,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 - 4127;%(DisableSpecificWarnings) + 4127;4324;4267;4306;%(DisableSpecificWarnings) true @@ -129,7 +129,7 @@ MultiThreadedDebugDLL Level4 CompileAsC - 4127;%(DisableSpecificWarnings) + 4127;4324;4267;4306;%(DisableSpecificWarnings) true @@ -147,7 +147,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 - 4127;%(DisableSpecificWarnings) + 4127;4324;4267;4306;%(DisableSpecificWarnings) true diff --git a/libs/spandsp/src/msvc/config.h b/libs/spandsp/src/msvc/config.h index 876f66f56a..c974d7c7c4 100644 --- a/libs/spandsp/src/msvc/config.h +++ b/libs/spandsp/src/msvc/config.h @@ -74,7 +74,9 @@ #define _MMX_H_ + #if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800)) #define cbrtf(value) pow((float)value, (float).333) + #endif #include // To get alloca diff --git a/libs/spandsp/src/plc.c b/libs/spandsp/src/plc.c index 7b45dad988..cb40ea88e0 100644 --- a/libs/spandsp/src/plc.c +++ b/libs/spandsp/src/plc.c @@ -84,7 +84,7 @@ static __inline__ void normalise_history(plc_state_t *s) if (s->buf_ptr == 0) return; memcpy(tmp, s->history, sizeof(int16_t)*s->buf_ptr); - memcpy(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr)); + memmove(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr)); memcpy(s->history + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t)*s->buf_ptr); s->buf_ptr = 0; } diff --git a/libs/spandsp/src/sig_tone.c b/libs/spandsp/src/sig_tone.c index e40d39ac37..1b30d8e583 100644 --- a/libs/spandsp/src/sig_tone.c +++ b/libs/spandsp/src/sig_tone.c @@ -154,9 +154,15 @@ static const sig_tone_descriptor_t sig_tones[3] = }, &flat_coeffs[NOTCH_COEFF_SET_2280HZ], +#if defined(SPANDSP_USE_FIXED_POINT) + 13, + -30, + -30 +#else 13.0f, -30.0f, -30.0f +#endif }, { /* 2600Hz (e.g. many US protocols) */ @@ -176,9 +182,15 @@ static const sig_tone_descriptor_t sig_tones[3] = }, NULL, +#if defined(SPANDSP_USE_FIXED_POINT) + 16, + -30, + -30 +#else 15.6f, -30.0f, -30.0f +#endif }, { /* 2400Hz/2600Hz (e.g. SS5 and SS5bis) */ @@ -198,9 +210,15 @@ static const sig_tone_descriptor_t sig_tones[3] = }, NULL, +#if defined(SPANDSP_USE_FIXED_POINT) + 16, + -30, + -30 +#else 15.6f, -30.0f, -30.0f +#endif } }; diff --git a/libs/spandsp/src/spandsp/at_interpreter.h b/libs/spandsp/src/spandsp/at_interpreter.h index aa390d509b..1b6e1f7771 100644 --- a/libs/spandsp/src/spandsp/at_interpreter.h +++ b/libs/spandsp/src/spandsp/at_interpreter.h @@ -38,9 +38,9 @@ modem control commands. typedef struct at_state_s at_state_t; -typedef int (*at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num); -typedef int (*at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len); -typedef int (*at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val); +typedef int (*at_modem_control_handler_t)(void *user_data, int op, const char *num); +typedef int (*at_tx_handler_t)(void *user_data, const uint8_t *buf, size_t len); +typedef int (*at_class1_handler_t)(void *user_data, int direction, int operation, int val); enum at_rx_mode_e { @@ -173,6 +173,11 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand \return A pointer to the logging context */ SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s); + +SPAN_DECLARE(void) at_set_modem_control_handler(at_state_t *s, + at_modem_control_handler_t modem_control_handler, + void *modem_control_user_data); + /*! Initialise an AT interpreter context. \brief Initialise an AT interpreter context. \param s The AT context. diff --git a/libs/spandsp/src/spandsp/fast_convert.h b/libs/spandsp/src/spandsp/fast_convert.h index e6da451f9c..120050646f 100644 --- a/libs/spandsp/src/spandsp/fast_convert.h +++ b/libs/spandsp/src/spandsp/fast_convert.h @@ -247,6 +247,7 @@ extern "C" * Therefore implement inline versions of these functions here. */ +#if (_MSC_VER < 1800) __inline long int lrint(double x) { long int i; @@ -288,6 +289,7 @@ extern "C" frndint } } +#endif __inline long int lfastrint(double x) { @@ -317,6 +319,7 @@ extern "C" /* x86_64 machines will do best with a simple assignment. */ #include +#if (_MSC_VER < 1800) __inline long int lrint(double x) { return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) ); @@ -326,6 +329,7 @@ extern "C" { return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) ); } +#endif __inline long int lfastrint(double x) { diff --git a/libs/spandsp/src/spandsp/fax_modems.h b/libs/spandsp/src/spandsp/fax_modems.h index 2ffb7be7c5..6edfa967e7 100644 --- a/libs/spandsp/src/spandsp/fax_modems.h +++ b/libs/spandsp/src/spandsp/fax_modems.h @@ -59,6 +59,8 @@ extern "C" { #endif +SPAN_DECLARE_NONSTD(void) fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok); + /*! Convert a FAX modem type to a short text description. \brief Convert a FAX modem type to a short text description. \param modem The modem code. diff --git a/libs/spandsp/src/spandsp/private/g722.h b/libs/spandsp/src/spandsp/private/g722.h index 47b2abaa2f..81dfc68c30 100644 --- a/libs/spandsp/src/spandsp/private/g722.h +++ b/libs/spandsp/src/spandsp/private/g722.h @@ -64,8 +64,6 @@ struct g722_encode_state_s g722_band_t band[2]; - uint32_t in_buffer; - int in_bits; uint32_t out_buffer; int out_bits; }; @@ -94,8 +92,6 @@ struct g722_decode_state_s uint32_t in_buffer; int in_bits; - uint32_t out_buffer; - int out_bits; }; #endif diff --git a/libs/spandsp/src/spandsp/private/t31.h b/libs/spandsp/src/spandsp/private/t31.h index 1f7de41f99..2bfed82d0b 100644 --- a/libs/spandsp/src/spandsp/private/t31.h +++ b/libs/spandsp/src/spandsp/private/t31.h @@ -140,7 +140,7 @@ typedef struct /*! \brief True if we are using ECM mode. This is used to select HDLC faking, necessary with clunky class 1 modems. */ - bool ecm_mode; + int ecm_mode; /*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */ int non_ecm_trailer_bytes; diff --git a/libs/spandsp/src/spandsp/v17rx.h b/libs/spandsp/src/spandsp/v17rx.h index 74c4b1dd8e..d99674ddd5 100644 --- a/libs/spandsp/src/spandsp/v17rx.h +++ b/libs/spandsp/src/spandsp/v17rx.h @@ -241,7 +241,7 @@ SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_ \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. \param short_train True if a short training sequence is expected. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, bool short_train); +SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_train); /*! Release a V.17 modem receive context. \brief Release a V.17 modem receive context. diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 76aa7e56ab..978d099945 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -1358,55 +1358,54 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples) } /*- End of function --------------------------------------------------------*/ -static int t31_modem_control_handler(at_state_t *s, void *user_data, int op, const char *num) +static int t31_modem_control_handler(void *user_data, int op, const char *num) { - t31_state_t *t; + t31_state_t *s; - t = (t31_state_t *) user_data; + s = (t31_state_t *) user_data; switch (op) { case AT_MODEM_CONTROL_CALL: - t->call_samples = 0; - t38_core_restart(&t->t38_fe.t38); + s->call_samples = 0; + t38_core_restart(&s->t38_fe.t38); break; case AT_MODEM_CONTROL_ANSWER: - t->call_samples = 0; - t38_core_restart(&t->t38_fe.t38); + s->call_samples = 0; + t38_core_restart(&s->t38_fe.t38); break; case AT_MODEM_CONTROL_ONHOOK: - if (t->non_ecm_tx.holding) + if (s->non_ecm_tx.holding) { - t->non_ecm_tx.holding = false; + s->non_ecm_tx.holding = false; /* Tell the application to release further data */ - at_modem_control(&t->at_state, AT_MODEM_CONTROL_CTS, (void *) 1); + at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1); } /*endif*/ - if (t->at_state.rx_signal_present) + if (s->at_state.rx_signal_present) { - t->at_state.rx_data[t->at_state.rx_data_bytes++] = DLE; - t->at_state.rx_data[t->at_state.rx_data_bytes++] = ETX; - t->at_state.at_tx_handler(&t->at_state, - t->at_state.at_tx_user_data, - t->at_state.rx_data, - t->at_state.rx_data_bytes); - t->at_state.rx_data_bytes = 0; + s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE; + s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX; + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, + s->at_state.rx_data, + s->at_state.rx_data_bytes); + s->at_state.rx_data_bytes = 0; } /*endif*/ - restart_modem(t, FAX_MODEM_SILENCE_TX); + restart_modem(s, FAX_MODEM_SILENCE_TX); break; case AT_MODEM_CONTROL_RESTART: - restart_modem(t, (int) (intptr_t) num); + restart_modem(s, (int) (intptr_t) num); return 0; case AT_MODEM_CONTROL_DTE_TIMEOUT: if (num) - t->dte_data_timeout = t->call_samples + ms_to_samples((intptr_t) num); + s->dte_data_timeout = s->call_samples + ms_to_samples((intptr_t) num); else - t->dte_data_timeout = 0; + s->dte_data_timeout = 0; /*endif*/ return 0; } /*endswitch*/ - return t->modem_control_handler(t, t->modem_control_user_data, op, num); + return s->modem_control_handler(s, s->modem_control_user_data, op, num); } /*- End of function --------------------------------------------------------*/ @@ -1437,8 +1436,7 @@ static void non_ecm_rx_status(void *user_data, int status) { s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE; s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX; - s->at_state.at_tx_handler(&s->at_state, - s->at_state.at_tx_user_data, + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); s->at_state.rx_data_bytes = 0; @@ -1480,8 +1478,7 @@ static void non_ecm_put_bit(void *user_data, int bit) s->at_state.rx_data[s->at_state.rx_data_bytes++] = (uint8_t) s->audio.current_byte; if (s->at_state.rx_data_bytes >= 250) { - s->at_state.at_tx_handler(&s->at_state, - s->at_state.at_tx_user_data, + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); s->at_state.rx_data_bytes = 0; @@ -1515,8 +1512,7 @@ static void non_ecm_put(void *user_data, const uint8_t buf[], int len) s->at_state.rx_data[s->at_state.rx_data_bytes++] = buf[i]; if (s->at_state.rx_data_bytes >= 250) { - s->at_state.at_tx_handler(&s->at_state, - s->at_state.at_tx_user_data, + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); s->at_state.rx_data_bytes = 0; @@ -1860,7 +1856,7 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int /*endfor*/ s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE; s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX; - s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); s->at_state.rx_data_bytes = 0; if (msg[1] == 0x13 && ok) { @@ -2025,8 +2021,8 @@ static void t31_v21_rx(t31_state_t *s) s->hdlc_tx.len = 0; s->hdlc_tx.final = false; s->dled = false; - hdlc_rx_init(&s->audio.modems.hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s); fax_modems_start_slow_modem(&s->audio.modems, FAX_MODEM_V21_RX); + hdlc_rx_init(&s->audio.modems.hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s); s->at_state.transmit = true; } /*- End of function --------------------------------------------------------*/ @@ -2447,7 +2443,7 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len) } /*- End of function --------------------------------------------------------*/ -static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int operation, int val) +static int process_class1_cmd(void *user_data, int direction, int operation, int val) { int new_modem; int new_transmit; @@ -2549,7 +2545,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int /*endfor*/ s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE; s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX; - s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); s->at_state.rx_data_bytes = 0; } /*endif*/ @@ -2710,7 +2706,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) { s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE; s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX; - s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); + s->at_state.at_tx_handler(s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes); } /*endif*/ s->at_state.rx_data_bytes = 0; @@ -2983,6 +2979,7 @@ static int t31_t38_fe_init(t31_state_t *t, t->hdlc_tx.ptr = 0; + /* Prepare the non-ecm HDLC bit stream -> T.38 HDLC -> non-ecm HDLC bit stream path */ hdlc_tx_init(&s->hdlc_tx_non_ecm, false, 1, false, hdlc_tx_underflow2, s); hdlc_rx_init(&s->hdlc_rx_non_ecm, false, true, 2, hdlc_accept_non_ecm_frame, t); return 0; diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index d89e21e0c4..402c7cded2 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -75,6 +75,10 @@ #include "spandsp/v27ter_rx.h" #include "spandsp/v17tx.h" #include "spandsp/v17rx.h" +#if defined(SPANDSP_SUPPORT_V34) +#include "spandsp/bitstream.h" +#include "spandsp/v34.h" +#endif #include "spandsp/super_tone_rx.h" #include "spandsp/modem_connect_tones.h" #include "spandsp/timezone.h" @@ -100,6 +104,10 @@ #include "spandsp/private/silence_gen.h" #include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" +#if defined(SPANDSP_SUPPORT_V34) +#include "spandsp/private/bitstream.h" +#include "spandsp/private/v34.h" +#endif #include "spandsp/private/v17tx.h" #include "spandsp/private/v17rx.h" #include "spandsp/private/v27ter_tx.h" diff --git a/libs/spandsp/src/v17rx.c b/libs/spandsp/src/v17rx.c index 85d72d0ed6..4b61af1409 100644 --- a/libs/spandsp/src/v17rx.c +++ b/libs/spandsp/src/v17rx.c @@ -1392,7 +1392,7 @@ SPAN_DECLARE(logging_state_t *) v17_rx_get_logging_state(v17_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, bool short_train) +SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_train) { int i; diff --git a/libs/spandsp/src/vector_int.c b/libs/spandsp/src/vector_int.c index 66166e52eb..c2ed12f98e 100644 --- a/libs/spandsp/src/vector_int.c +++ b/libs/spandsp/src/vector_int.c @@ -147,7 +147,7 @@ SPAN_DECLARE(int32_t) vec_dot_prodi16(const int16_t x[], const int16_t y[], int " emms;\n" : "=a" (z) : "S" (x), "D" (y), "a" (n) - : "cc" + : "cc", "rdx", "mm0", "mm1", "mm2" ); #elif defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__i386__) __asm__ __volatile__( @@ -245,7 +245,7 @@ SPAN_DECLARE(int32_t) vec_dot_prodi16(const int16_t x[], const int16_t y[], int " emms;\n" : "=a" (z) : "S" (x), "D" (y), "a" (n) - : "cc" + : "cc", "edx", "mm0", "mm1", "mm2" ); #else int i; @@ -436,7 +436,7 @@ SPAN_DECLARE(int32_t) vec_min_maxi16(const int16_t x[], int n, int16_t out[]) " emms;\n" : "=a" (max) : "S" (x), "a" (n), "d" (out), [lower] "m" (lower_bound), [upper] "m" (upper_bound) - : "ecx" + : "ecx", "mm0", "mm1", "mm2", "mm3", "mm4" ); #elif defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__i386__) static const int32_t lower_bound = 0x80008000; @@ -589,7 +589,7 @@ SPAN_DECLARE(int32_t) vec_min_maxi16(const int16_t x[], int n, int16_t out[]) " emms;\n" : "=a" (max) : "S" (x), "a" (n), "d" (out), [lower] "m" (lower_bound), [upper] "m" (upper_bound) - : "ecx" + : "ecx", "mm0", "mm1", "mm2", "mm3", "mm4" ); #else int i; diff --git a/libs/spandsp/tests/at_interpreter_tests.c b/libs/spandsp/tests/at_interpreter_tests.c index bdb26e1bec..6826e030db 100644 --- a/libs/spandsp/tests/at_interpreter_tests.c +++ b/libs/spandsp/tests/at_interpreter_tests.c @@ -478,7 +478,7 @@ static int general_test(at_state_t *s) } /*- End of function --------------------------------------------------------*/ -static int modem_call_control(at_state_t *s, void *user_data, int op, const char *num) +static int modem_call_control(void *user_data, int op, const char *num) { switch (op) { @@ -534,7 +534,7 @@ static int modem_call_control(at_state_t *s, void *user_data, int op, const char } /*- End of function --------------------------------------------------------*/ -static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len) +static int at_tx_handler(void *user_data, const uint8_t *buf, size_t len) { int i; diff --git a/libs/spandsp/tests/pseudo_terminal_tests.c b/libs/spandsp/tests/pseudo_terminal_tests.c index b6d28d2b26..f9f0ed55f6 100644 --- a/libs/spandsp/tests/pseudo_terminal_tests.c +++ b/libs/spandsp/tests/pseudo_terminal_tests.c @@ -66,7 +66,7 @@ static int master(void) for (i = 0; i < 10; i++) { - if (psuedo_terminal_create(&modem[i])) + if (pseudo_terminal_create(&modem[i])) { printf("Failure\n"); exit(2); @@ -89,7 +89,7 @@ static int master(void) for (i = 0; i < 10; i++) { - if (psuedo_terminal_close(&modem[i])) + if (pseudo_terminal_close(&modem[i])) { printf("Failure\n"); exit(2); diff --git a/libs/spandsp/tests/pseudo_terminals.c b/libs/spandsp/tests/pseudo_terminals.c index 1f042be8b9..f651bbc847 100644 --- a/libs/spandsp/tests/pseudo_terminals.c +++ b/libs/spandsp/tests/pseudo_terminals.c @@ -53,7 +53,7 @@ int next_id = 0; const char *device_root_name = "/dev/spandsp"; -int psuedo_terminal_close(modem_t *modem) +int pseudo_terminal_close(modem_t *modem) { #if defined(WIN32) if (modem->master) @@ -84,7 +84,7 @@ int psuedo_terminal_close(modem_t *modem) } /*- End of function --------------------------------------------------------*/ -int psuedo_terminal_create(modem_t *modem) +int pseudo_terminal_create(modem_t *modem) { #if defined(WIN32) COMMTIMEOUTS timeouts = {0}; @@ -170,7 +170,7 @@ int psuedo_terminal_create(modem_t *modem) if (!SetCommTimeouts(modem->master, &timeouts)) { span_log(&modem->logging, SPAN_LOG_ERROR, "Cannot set up non-blocking read on %s\n", modem->devlink); - psuedo_terminal_close(modem); + pseudo_terminal_close(modem); return -1; } modem->threadAbort = CreateEvent(NULL, true, false, NULL); @@ -184,14 +184,14 @@ int psuedo_terminal_create(modem_t *modem) if (symlink(modem->stty, modem->devlink)) { span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to create %s symbolic link\n", modem->devlink); - psuedo_terminal_close(modem); + pseudo_terminal_close(modem); return -1; } if (fcntl(modem->master, F_SETFL, fcntl(modem->master, F_GETFL, 0) | O_NONBLOCK)) { span_log(&modem->logging, SPAN_LOG_ERROR, "Cannot set up non-blocking read on %s\n", ttyname(modem->master)); - psuedo_terminal_close(modem); + pseudo_terminal_close(modem); return -1; } #endif diff --git a/libs/spandsp/tests/pseudo_terminals.h b/libs/spandsp/tests/pseudo_terminals.h index b64fd1bd76..481530d875 100644 --- a/libs/spandsp/tests/pseudo_terminals.h +++ b/libs/spandsp/tests/pseudo_terminals.h @@ -41,6 +41,6 @@ struct modem_s typedef struct modem_s modem_t; -int psuedo_terminal_close(modem_t *modem); +int pseudo_terminal_close(modem_t *modem); -int psuedo_terminal_create(modem_t *modem); +int pseudo_terminal_create(modem_t *modem); diff --git a/libs/spandsp/tests/t31_pseudo_terminal_tests.c b/libs/spandsp/tests/t31_pseudo_terminal_tests.c index d4fc01efc3..e03fbed9b5 100644 --- a/libs/spandsp/tests/t31_pseudo_terminal_tests.c +++ b/libs/spandsp/tests/t31_pseudo_terminal_tests.c @@ -134,7 +134,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) } /*- End of function --------------------------------------------------------*/ -static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len) +static int at_tx_handler(void *user_data, const uint8_t *buf, size_t len) { #if defined(WIN32) DWORD res; @@ -220,7 +220,7 @@ static int t31_call_control(t31_state_t *s, void *user_data, int op, const char { case 1: x[0] = (num) ? 0x11 : 0x13; - at_tx_handler(&t31_state->at_state, user_data, x, 1); + at_tx_handler(user_data, x, 1); break; case 2: break; @@ -815,7 +815,7 @@ int main(int argc, char *argv[]) } } - if (psuedo_terminal_create(&modem[0])) + if (pseudo_terminal_create(&modem[0])) printf("Failure\n"); #if !defined(WIN32) @@ -825,7 +825,7 @@ int main(int argc, char *argv[]) #endif t30_tests(t38_mode, use_ecm, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no); - if (psuedo_terminal_close(&modem[0])) + if (pseudo_terminal_close(&modem[0])) printf("Failure\n"); printf("Tests passed\n"); return 0; diff --git a/libs/spandsp/tests/t31_tests.c b/libs/spandsp/tests/t31_tests.c index 12c3426b4d..9228eb9ea3 100644 --- a/libs/spandsp/tests/t31_tests.c +++ b/libs/spandsp/tests/t31_tests.c @@ -374,7 +374,7 @@ static int modem_call_control(t31_state_t *s, void *user_data, int op, const cha } /*- End of function --------------------------------------------------------*/ -static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len) +static int at_tx_handler(void *user_data, const uint8_t *buf, size_t len) { size_t i; diff --git a/libs/spandsp/tests/tsb85_extra_tests.sh b/libs/spandsp/tests/tsb85_extra_tests.sh index 2d64fb05b4..8aa3b24740 100755 --- a/libs/spandsp/tests/tsb85_extra_tests.sh +++ b/libs/spandsp/tests/tsb85_extra_tests.sh @@ -28,7 +28,7 @@ run_tsb85_test() fi } -for TEST in PPS-MPS-lost-PPS +for TEST in PPS-MPS-lost-PPS V17-12000-V29-9600 do run_tsb85_test done diff --git a/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj b/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj index acc04fee78..04106ac6a3 100644 --- a/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj +++ b/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj @@ -612,7 +612,6 @@ - diff --git a/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj.filters b/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj.filters index 51656a21b5..e3279b7d1b 100644 --- a/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj.filters +++ b/libs/speex/win32/VS2008/libspeex/libspeex.vcxproj.filters @@ -185,9 +185,6 @@ Header Files - - Header Files - Header Files diff --git a/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj b/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj index 944751476a..dd70393165 100644 --- a/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj +++ b/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj @@ -1,4 +1,4 @@ - + @@ -626,7 +626,6 @@ - diff --git a/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj.filters b/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj.filters new file mode 100644 index 0000000000..e3279b7d1b --- /dev/null +++ b/libs/speex/win32/VS2012/libspeex/libspeex.vcxproj.filters @@ -0,0 +1,207 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/libs/sqlite/configure.ac b/libs/sqlite/configure.ac index 3522235852..094548bc71 100644 --- a/libs/sqlite/configure.ac +++ b/libs/sqlite/configure.ac @@ -635,7 +635,7 @@ else AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap]) AC_CHECK_LIB([readline], [readline]) AC_CHECK_LIB([dl], [dlopen]) - TARGET_READLINE_LIBS="$LIBS" + TARGET_READLINE_LIBS="$LDFLAGS $LIBS" fi AC_SUBST(TARGET_READLINE_LIBS) diff --git a/libs/srtp/Makefile.am b/libs/srtp/Makefile.am index fb27e6c6d8..598a4e1414 100644 --- a/libs/srtp/Makefile.am +++ b/libs/srtp/Makefile.am @@ -5,28 +5,38 @@ AM_CFLAGS = $(new_AM_CFLAGS) -I./src -Icrypto/include -I$(srcdir)/include -I$ AM_CPPFLAGS = $(AM_CFLAGS) AM_LDFLAGS = $(new_AM_LDFLAGS) -L. +HMAC_OBJS = @HMAC_OBJS@ +RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@ +AES_ICM_OBJS = @AES_ICM_OBJS@ lib_LTLIBRARIES = libsrtp.la libcryptomath.la libsrtp_la_SOURCES = srtp/srtp.c srtp/ekt.c crypto/cipher/cipher.c crypto/cipher/null_cipher.c \ - crypto/cipher/aes.c crypto/cipher/aes_icm.c \ - crypto/cipher/aes_cbc.c \ - crypto/hash/null_auth.c crypto/hash/sha1.c \ - crypto/hash/hmac.c crypto/hash/auth.c \ + crypto/hash/null_auth.c crypto/hash/auth.c \ crypto/math/datatypes.c crypto/math/stat.c \ crypto/kernel/crypto_kernel.c crypto/kernel/alloc.c \ crypto/kernel/key.c \ crypto/rng/prng.c crypto/rng/ctr_prng.c \ crypto/kernel/err.c \ - crypto/replay/rdb.c crypto/replay/rdbx.c crypto/replay/ut_sim.c + crypto/replay/rdb.c crypto/replay/rdbx.c crypto/replay/ut_sim.c + libsrtp_la_LDFLAGS = -version-info 1:42:1 EXTRA_DIST= + +if ENABLE_OPENSSL +libsrtp_la_SOURCES += crypto/cipher/aes_icm_ossl.c crypto/cipher/aes_gcm_ossl.c +libsrtp_la_SOURCES += crypto/rng/rand_source_ossl.c +libsrtp_la_SOURCES += crypto/hash/hmac_ossl.c +else +libsrtp_la_SOURCES += crypto/hash/sha1.c crypto/hash/hmac.c +libsrtp_la_SOURCES += crypto/cipher/aes_icm.c crypto/cipher/aes.c crypto/cipher/aes_cbc.c if RNG_OBJS_LINUX libsrtp_la_SOURCES += crypto/rng/rand_linux_kernel.c EXTRA_DIST += crypto/rng/rand_source.c else libsrtp_la_SOURCES += crypto/rng/rand_source.c endif +endif if GDOI libsrtp_la_SOURCES += gdoi/srtp+gdoi.c diff --git a/libs/srtp/README b/libs/srtp/README index 08fafaedbc..8ea9f72d08 100644 --- a/libs/srtp/README +++ b/libs/srtp/README @@ -26,6 +26,7 @@ The configure script accepts the following options: --enable-syslog use syslog for error reporting --disable-stdout use stdout for error reporting --enable-console use /dev/console for error reporting + --enable-openssl use OpenSSL crypto primitives --gdoi use GDOI key management (disabled at present) By default, debbuging is enabled and stdout is used for debugging. @@ -77,7 +78,7 @@ Applications Manual srtp keying uses the -k option; automated key management using gdoi will be added later. -usage: rtpw [-d ]* [-k [-a][-e]] [-s | -r] dest_ip dest_port +usage: rtpw [-d ]* [-k [-a][-e ][-g]] [-s | -r] dest_ip dest_port or rtpw -l Either the -s (sender) or -r (receiver) option must be chosen. @@ -86,25 +87,15 @@ or rtpw -l which the dictionary will be sent, respectively. options: - - -s (s)rtp sender - causes app to send words - - -r (s)rtp receive - causes app to receve words - - -k use srtp master key , where the - key is a hexadecimal value (without the - leading "0x") - - -e encrypt/decrypt (for data confidentiality) - (requires use of -k option as well) - - -a message authentication - (requires use of -k option as well) - - -l list debug modules - - -d turn on debugging for module - + -a use message authentication + -e use encryption (use 128, 192, or 256 for key size) + -g Use AES-GCM mode (must be used with -e) + -k sets the srtp master key + -s act as rtp sender + -r act as rtp receiver + -l list debug modules + -d turn on debugging for module + -i specify input/output file In order to get random 30-byte values for use as key/salt pairs , you can use the following bash function to format the output of @@ -119,7 +110,7 @@ An example of an SRTP session using two rtpw programs follows: set k=c1eec3717da76195bb878578790af71c4ee9f859e197a414a78d5abc7451 -[sh1]$ test/rtpw -s -k $k -ea 0.0.0.0 9999 +[sh1]$ test/rtpw -s -k $k -e 128 -a 0.0.0.0 9999 Security services: confidentiality message authentication set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 setting SSRC to 2078917053 @@ -129,7 +120,7 @@ sending word: aa sending word: aal ... -[sh2]$ test/rtpw -r -k $k -ea 0.0.0.0 9999 +[sh2]$ test/rtpw -r -k $k -e 128 -a 0.0.0.0 9999 security services: confidentiality message authentication set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 19 octets received from SSRC 2078917053 word: A diff --git a/libs/srtp/VERSION b/libs/srtp/VERSION index 1c99cf0e80..e516bb9d96 100644 --- a/libs/srtp/VERSION +++ b/libs/srtp/VERSION @@ -1 +1 @@ -1.4.4 +1.4.5 diff --git a/libs/srtp/configure.gnu b/libs/srtp/configure.gnu index c78238de46..d561908e68 100644 --- a/libs/srtp/configure.gnu +++ b/libs/srtp/configure.gnu @@ -1,4 +1,4 @@ #! /bin/sh srcpath=$(dirname $0 2>/dev/null ) || srcpath="." -$srcpath/configure "$@" --disable-shared --with-pic +$srcpath/configure "$@" --disable-shared --with-pic --enable-openssl diff --git a/libs/srtp/configure.in b/libs/srtp/configure.in index d2a109cc53..b4245f495c 100644 --- a/libs/srtp/configure.in +++ b/libs/srtp/configure.in @@ -38,6 +38,7 @@ fi AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"]) +IN_LINE=inline case "$host" in *-solaris2*) @@ -136,27 +137,9 @@ if test "$enable_kernel_linux" = "yes"; then fi AC_MSG_RESULT($enable_kernel_linux) -if test "$cross_compiling" != yes; then - dnl Check for /dev/urandom - AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom, - [AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)]) -fi - -AC_MSG_CHECKING(which random device to use) -if test "$enable_kernel_linux" = "yes"; then - RNG_OBJS=rand_linux_kernel.o - AC_MSG_RESULT([Linux kernel builtin]) -else -RNG_OBJS=rand_source.o - if test -n "$DEV_URANDOM"; then - AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM",[Path to random device]) - AC_MSG_RESULT([$DEV_URANDOM]) - else - AC_MSG_RESULT([standard rand() function...]) - fi -fi -AC_SUBST(RNG_OBJS) -AM_CONDITIONAL(RNG_OBJS_LINUX, test x$enable_kernel_linux = xyes) +dnl Check for /dev/urandom +AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom, + [AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)]) dnl Checks for header files. AC_HEADER_STDC @@ -272,6 +255,56 @@ if test "$enable_generic_aesicm" = "yes"; then fi AC_MSG_RESULT($enable_generic_aesicm) +AC_MSG_CHECKING(whether to leverage OpenSSL crypto) +AC_ARG_ENABLE(openssl, + [AS_HELP_STRING([--enable-openssl], + [compile in OpenSSL crypto engine])], + [], enable_openssl=no) +if test "$enable_openssl" = "yes"; then + echo $enable_openssl + LDFLAGS="$LDFLAGS $(pkg-config --libs openssl)"; + CFLAGS="$CFLAGS $(pkg-config --cflags openssl)"; + + AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], + [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) + AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [], + [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) + AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [], + [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) + AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.]) + AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o" + RNG_OBJS=rand_source_ossl.o + HMAC_OBJS=crypto/hash/hmac_ossl.o + USE_OPENSSL=1 + AC_SUBST(USE_OPENSSL) +else + echo $enable_openssl + AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o crypto/cipher/aes_cbc.o" + AC_MSG_CHECKING(which random device to use) + if test "$enable_kernel_linux" = "yes"; then + RNG_OBJS=rand_linux_kernel.o + AC_MSG_RESULT([Linux kernel builtin]) + else + RNG_OBJS=rand_source.o + if test -n "$DEV_URANDOM"; then + AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM",[Path to random device]) + AC_MSG_RESULT([$DEV_URANDOM]) + else + AC_MSG_RESULT([standard rand() function...]) + fi + fi + RNG_EXTRA_OBJS="crypto/rng/prng.o crypto/rng/ctr_prng.o" + HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" +fi +AM_CONDITIONAL([ENABLE_OPENSSL],[test "${enable_openssl}" = "yes"]) +AM_CONDITIONAL([RNG_OBJS_LINUX], test x$enable_kernel_linux = xyes) + +AC_SUBST(AES_ICM_OBJS) +AC_SUBST(RNG_OBJS) +AC_SUBST(RNG_EXTRA_OBJS) +AC_SUBST(HMAC_OBJS) +AC_MSG_RESULT($enable_openssl) + AC_MSG_CHECKING(whether to use syslog for error reporting) AC_ARG_ENABLE(syslog, [AS_HELP_STRING([--enable-syslog], [use syslog for error reporting])], diff --git a/libs/srtp/crypto/Makefile.in b/libs/srtp/crypto/Makefile.in index 9d52104210..c6248fcf63 100644 --- a/libs/srtp/crypto/Makefile.in +++ b/libs/srtp/crypto/Makefile.in @@ -9,14 +9,14 @@ top_builddir = @top_builddir@ VPATH = @srcdir@ CC = @CC@ -INCDIR = -Iinclude -I$(srcdir)/include +INCDIR = -Iinclude -I$(srcdir)/include DEFS = @DEFS@ CPPFLAGS= @CPPFLAGS@ CFLAGS = @CFLAGS@ LIBS = @LIBS@ -LDFLAGS = @LDFLAGS@ -L. +LDFLAGS = @LDFLAGS@ -L. -L.. COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS) -CRYPTOLIB = -lcryptomodule +CRYPTOLIB = -lsrtp RANLIB = @RANLIB@ @@ -25,7 +25,7 @@ RANLIB = @RANLIB@ # `make clean` will work on the cygwin platform EXE = @EXE@ # Random source. -RNG_OBJS = @RNG_OBJS@ +USE_OPENSSL = @USE_OPENSSL@ ifdef ARCH DEFS += -D$(ARCH)=1 @@ -41,9 +41,13 @@ dummy : all runtest # test applications +ifneq (1, $(USE_OPENSSL)) +AES_CALC = test/aes_calc$(EXE) +endif + testapp = #test/cipher_driver$(EXE) test/datatypes_driver$(EXE) \ #test/stat_driver$(EXE) test/sha1_driver$(EXE) \ - #test/kernel_driver$(EXE) test/aes_calc$(EXE) test/rand_gen$(EXE) \ + #test/kernel_driver$(EXE) $(AES_CALC) test/rand_gen$(EXE) \ #test/env$(EXE) # data values used to test the aes_calc application for AES-128 @@ -58,60 +62,31 @@ p256=00112233445566778899aabbccddeeff c256=8ea2b7ca516745bfeafc49904b496089 -runtest: libcryptomodule.a $(testapp) +runtest: $(testapp) test/env$(EXE) # print out information on the build environment - @echo "running libcryptomodule test applications..." + @echo "running crypto test applications..." +ifneq (1, $(USE_OPENSSL)) test `test/aes_calc $(k128) $(p128)` = $(c128) test `test/aes_calc $(k256) $(p256)` = $(c256) +endif test/cipher_driver$(EXE) -v >/dev/null test/datatypes_driver$(EXE) -v >/dev/null test/stat_driver$(EXE) >/dev/null test/sha1_driver$(EXE) -v >/dev/null test/kernel_driver$(EXE) -v >/dev/null test/rand_gen$(EXE) -n 256 >/dev/null - @echo "libcryptomodule test applications passed." + @echo "crypto test applications passed." -# libcryptomodule.a (the crypto engine) - -ciphers = cipher/cipher.o cipher/null_cipher.o \ - cipher/aes.o cipher/aes_icm.o \ - cipher/aes_cbc.o - -hashes = hash/null_auth.o hash/sha1.o \ - hash/hmac.o hash/auth.o - -math = math/datatypes.o math/stat.o - -rng = rng/$(RNG_OBJS) rng/rand_source.o rng/prng.o rng/ctr_prng.o - -err = kernel/err.o - -kernel = kernel/crypto_kernel.o kernel/alloc.o \ - kernel/key.o $(rng) $(err) - -xfm = ae_xfm/xfm.o - -cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(xfm) # the rule for making object files and test apps %.o: %.c $(COMPILE) -c $< -o $@ -%$(EXE): %.c libcryptomodule.a +%$(EXE): %.c $(COMPILE) $(LDFLAGS) $< -o $@ $(CRYPTOLIB) $(LIBS) -ifndef AR - AR=ar -endif - -# and the crypto module library itself - -libcryptomodule.a: $(cryptobj) - $(AR) cr libcryptomodule.a $(cryptobj) - $(RANLIB) libcryptomodule.a - -all: libcryptomodule.a $(testapp) +all: $(testapp) # housekeeping functions diff --git a/libs/srtp/crypto/ae_xfm/xfm.c b/libs/srtp/crypto/ae_xfm/xfm.c index 7aa338830f..997ccbc282 100644 --- a/libs/srtp/crypto/ae_xfm/xfm.c +++ b/libs/srtp/crypto/ae_xfm/xfm.c @@ -177,7 +177,7 @@ aes_128_cbc_hmac_sha1_96_inv(void *key, #define ENC 1 -#define DEBUG 0 +#define DEBUG_PRINT 0 err_status_t aes_128_cbc_hmac_sha1_96_enc(void *key, @@ -208,7 +208,7 @@ aes_128_cbc_hmac_sha1_96_enc(void *key, } else { -#if DEBUG +#if DEBUG_PRINT printf("ENC using key %s\n", octet_string_hex_string(key, KEY_LEN)); #endif @@ -236,7 +236,7 @@ aes_128_cbc_hmac_sha1_96_enc(void *key, status = aes_cbc_set_iv(&aes_ctx, iv); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("plaintext len: %d\n", *opaque_len); printf("iv: %s\n", octet_string_hex_string(iv, IV_LEN)); printf("plaintext: %s\n", octet_string_hex_string(opaque, *opaque_len)); @@ -248,7 +248,7 @@ aes_128_cbc_hmac_sha1_96_enc(void *key, if (status) return status; #endif -#if DEBUG +#if DEBUG_PRINT printf("ciphertext len: %d\n", *opaque_len); printf("ciphertext: %s\n", octet_string_hex_string(opaque, *opaque_len)); #endif @@ -266,7 +266,7 @@ aes_128_cbc_hmac_sha1_96_enc(void *key, status = hmac_update(&hmac_ctx, clear, clear_len); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("hmac input: %s\n", octet_string_hex_string(clear, clear_len)); #endif @@ -274,14 +274,14 @@ aes_128_cbc_hmac_sha1_96_enc(void *key, auth_tag += *opaque_len; status = hmac_compute(&hmac_ctx, opaque, *opaque_len, TAG_LEN, auth_tag); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("hmac input: %s\n", octet_string_hex_string(opaque, *opaque_len)); #endif /* bump up the opaque_len to reflect the authentication tag */ *opaque_len += TAG_LEN; -#if DEBUG +#if DEBUG_PRINT printf("prot data len: %d\n", *opaque_len); printf("prot data: %s\n", octet_string_hex_string(opaque, *opaque_len)); #endif @@ -321,7 +321,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, return err_status_fail; } else { -#if DEBUG +#if DEBUG_PRINT printf("DEC using key %s\n", octet_string_hex_string(key, KEY_LEN)); #endif @@ -336,7 +336,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, status = hmac_compute(&hmac_ctx, "MAC", 3, MAC_KEY_LEN, mac_key); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("prot data len: %d\n", *opaque_len); printf("prot data: %s\n", octet_string_hex_string(opaque, *opaque_len)); #endif @@ -347,7 +347,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, */ ciphertext_len = *opaque_len - TAG_LEN; -#if DEBUG +#if DEBUG_PRINT printf("ciphertext len: %d\n", ciphertext_len); #endif /* verify the authentication tag */ @@ -365,7 +365,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, status = hmac_update(&hmac_ctx, clear, clear_len); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("hmac input: %s\n", octet_string_hex_string(clear, clear_len)); #endif @@ -373,7 +373,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, status = hmac_compute(&hmac_ctx, opaque, ciphertext_len, TAG_LEN, tmp_tag); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("hmac input: %s\n", octet_string_hex_string(opaque, ciphertext_len)); #endif @@ -384,7 +384,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, */ auth_tag = (unsigned char *)opaque; auth_tag += ciphertext_len; -#if DEBUG +#if DEBUG_PRINT printf("auth_tag: %s\n", octet_string_hex_string(auth_tag, TAG_LEN)); printf("tmp_tag: %s\n", octet_string_hex_string(tmp_tag, TAG_LEN)); #endif @@ -402,7 +402,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, status = aes_cbc_set_iv(&aes_ctx, iv); if (status) return status; -#if DEBUG +#if DEBUG_PRINT printf("ciphertext: %s\n", octet_string_hex_string(opaque, *opaque_len)); printf("iv: %s\n", octet_string_hex_string(iv, IV_LEN)); #endif @@ -412,7 +412,7 @@ aes_128_cbc_hmac_sha1_96_dec(void *key, if (status) return status; #endif -#if DEBUG +#if DEBUG_PRINT printf("plaintext len: %d\n", ciphertext_len); printf("plaintext: %s\n", octet_string_hex_string(opaque, ciphertext_len)); @@ -464,14 +464,14 @@ null_enc(void *key, } else { -#if DEBUG +#if DEBUG_PRINT printf("NULL ENC using key %s\n", octet_string_hex_string(key, KEY_LEN)); printf("NULL_TAG_LEN: %d\n", NULL_TAG_LEN); printf("plaintext len: %d\n", *opaque_len); #endif for (i=0; i < IV_LEN; i++) init_vec[i] = i + (i * 16); -#if DEBUG +#if DEBUG_PRINT printf("iv: %s\n", octet_string_hex_string(iv, IV_LEN)); printf("plaintext: %s\n", @@ -482,7 +482,7 @@ null_enc(void *key, for (i=0; i < NULL_TAG_LEN; i++) auth_tag[i] = i + (i * 16); *opaque_len += NULL_TAG_LEN; -#if DEBUG +#if DEBUG_PRINT printf("protected data len: %d\n", *opaque_len); printf("protected data: %s\n", octet_string_hex_string(opaque, *opaque_len)); @@ -517,7 +517,7 @@ null_dec(void *key, } else { -#if DEBUG +#if DEBUG_PRINT printf("NULL DEC using key %s\n", octet_string_hex_string(key, KEY_LEN)); printf("protected data len: %d\n", *opaque_len); @@ -526,11 +526,11 @@ null_dec(void *key, #endif auth_tag = opaque; auth_tag += (*opaque_len - NULL_TAG_LEN); -#if DEBUG +#if DEBUG_PRINT printf("iv: %s\n", octet_string_hex_string(iv, IV_LEN)); #endif *opaque_len -= NULL_TAG_LEN; -#if DEBUG +#if DEBUG_PRINT printf("plaintext len: %d\n", *opaque_len); printf("plaintext: %s\n", octet_string_hex_string(opaque, *opaque_len)); diff --git a/libs/srtp/crypto/cipher/aes_cbc.c b/libs/srtp/crypto/cipher/aes_cbc.c index ed33f5b01c..fad74a411e 100644 --- a/libs/srtp/crypto/cipher/aes_cbc.c +++ b/libs/srtp/crypto/cipher/aes_cbc.c @@ -104,36 +104,25 @@ aes_cbc_dealloc(cipher_t *c) { } err_status_t -aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, int key_len, - cipher_direction_t dir) { - err_status_t status; +aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, int key_len) { debug_print(mod_aes_cbc, "key: %s", octet_string_hex_string(key, key_len)); - /* expand key for the appropriate direction */ - switch (dir) { - case (direction_encrypt): - status = aes_expand_encryption_key(key, key_len, &c->expanded_key); - if (status) - return status; - break; - case (direction_decrypt): - status = aes_expand_decryption_key(key, key_len, &c->expanded_key); - if (status) - return status; - break; - default: - return err_status_bad_param; - } - + /* + * Save the key until we have the IV later. We don't + * know the direction until the IV is set. + */ + c->key_len = (key_len <= 32 ? key_len : 32); + memcpy(c->key, key, c->key_len); return err_status_ok; } err_status_t -aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv) { +aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv, int direction) { + err_status_t status; int i; /* v128_t *input = iv; */ uint8_t *input = (uint8_t*) iv; @@ -144,6 +133,24 @@ aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv) { debug_print(mod_aes_cbc, "setting iv: %s", v128_hex_string(&c->state)); + /* expand key for the appropriate direction */ + switch (direction) { + case (direction_encrypt): + status = aes_expand_encryption_key(c->key, c->key_len, &c->expanded_key); + memset(c->key, 0, 32); + if (status) + return status; + break; + case (direction_decrypt): + status = aes_expand_decryption_key(c->key, c->key_len, &c->expanded_key); + memset(c->key, 0, 32); + if (status) + return status; + break; + default: + return err_status_bad_param; + } + return err_status_ok; } @@ -375,6 +382,8 @@ cipher_test_case_t aes_cbc_test_case_0 = { aes_cbc_test_case_0_plaintext, /* plaintext */ 32, /* octets in ciphertext */ aes_cbc_test_case_0_ciphertext, /* ciphertext */ + 0, + NULL, NULL /* pointer to next testcase */ }; @@ -426,6 +435,8 @@ cipher_test_case_t aes_cbc_test_case_1 = { aes_cbc_test_case_1_plaintext, /* plaintext */ 80, /* octets in ciphertext */ aes_cbc_test_case_1_ciphertext, /* ciphertext */ + 0, + NULL, &aes_cbc_test_case_0 /* pointer to next testcase */ }; @@ -467,6 +478,8 @@ cipher_test_case_t aes_cbc_test_case_2 = { aes_cbc_test_case_2_plaintext, /* plaintext */ 32, /* octets in ciphertext */ aes_cbc_test_case_2_ciphertext, /* ciphertext */ + 0, + NULL, &aes_cbc_test_case_1 /* pointer to next testcase */ }; @@ -520,6 +533,8 @@ cipher_test_case_t aes_cbc_test_case_3 = { aes_cbc_test_case_3_plaintext, /* plaintext */ 80, /* octets in ciphertext */ aes_cbc_test_case_3_ciphertext, /* ciphertext */ + 0, + NULL, &aes_cbc_test_case_2 /* pointer to next testcase */ }; @@ -527,9 +542,11 @@ cipher_type_t aes_cbc = { (cipher_alloc_func_t) aes_cbc_alloc, (cipher_dealloc_func_t) aes_cbc_dealloc, (cipher_init_func_t) aes_cbc_context_init, + (cipher_set_aad_func_t) 0, (cipher_encrypt_func_t) aes_cbc_nist_encrypt, (cipher_decrypt_func_t) aes_cbc_nist_decrypt, (cipher_set_iv_func_t) aes_cbc_set_iv, + (cipher_get_tag_func_t) 0, (char *) aes_cbc_description, (int) 0, /* instance count */ (cipher_test_case_t *) &aes_cbc_test_case_3, diff --git a/libs/srtp/crypto/cipher/aes_gcm_ossl.c b/libs/srtp/crypto/cipher/aes_gcm_ossl.c new file mode 100644 index 0000000000..f36ce9d3b2 --- /dev/null +++ b/libs/srtp/crypto/cipher/aes_gcm_ossl.c @@ -0,0 +1,529 @@ +/* + * aes_gcm_ossl.c + * + * AES Galois Counter Mode + * + * John A. Foley + * Cisco Systems, Inc. + * + */ + +/* + * + * Copyright (c) 2013, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "aes_icm_ossl.h" +#include "aes_gcm_ossl.h" +#include "alloc.h" +#include "crypto_types.h" + + +debug_module_t mod_aes_gcm = { + 0, /* debugging is off by default */ + "aes gcm" /* printable module name */ +}; + +/* + * The following are the global singleton instances for the + * 128-bit and 256-bit GCM ciphers. + */ +extern cipher_type_t aes_gcm_128_openssl; +extern cipher_type_t aes_gcm_256_openssl; + +/* + * For now we only support 8 octet tags. The spec allows for + * optional 12 and 16 byte tags. These longer tag lengths may + * be implemented in the future. + */ +#define GCM_AUTH_TAG_LEN 8 + + +/* + * This function allocates a new instance of this crypto engine. + * The key_len parameter should be one of 30 or 46 for + * AES-128-GCM or AES-256-GCM respectively. Note that the + * key length includes the 14 byte salt value that is used when + * initializing the KDF. + */ +err_status_t aes_gcm_openssl_alloc (cipher_t **c, int key_len) +{ + aes_gcm_ctx_t *gcm; + int tmp; + uint8_t *allptr; + + debug_print(mod_aes_gcm, "allocating cipher with key length %d", key_len); + + /* + * Verify the key_len is valid for one of: AES-128/256 + */ + if (key_len != AES_128_KEYSIZE_WSALT && + key_len != AES_256_KEYSIZE_WSALT) { + return (err_status_bad_param); + } + + /* allocate memory a cipher of type aes_gcm */ + tmp = sizeof(cipher_t) + sizeof(aes_gcm_ctx_t); + allptr = crypto_alloc(tmp); + if (allptr == NULL) { + return (err_status_alloc_fail); + } + + /* set pointers */ + *c = (cipher_t*)allptr; + (*c)->state = allptr + sizeof(cipher_t); + gcm = (aes_gcm_ctx_t *)(*c)->state; + + /* increment ref_count */ + switch (key_len) { + case AES_128_KEYSIZE_WSALT: + (*c)->type = &aes_gcm_128_openssl; + (*c)->algorithm = AES_128_GCM; + aes_gcm_128_openssl.ref_count++; + ((aes_gcm_ctx_t*)(*c)->state)->key_size = AES_128_KEYSIZE; + ((aes_gcm_ctx_t*)(*c)->state)->tag_len = GCM_AUTH_TAG_LEN; + break; + case AES_256_KEYSIZE_WSALT: + (*c)->type = &aes_gcm_256_openssl; + (*c)->algorithm = AES_256_GCM; + aes_gcm_256_openssl.ref_count++; + ((aes_gcm_ctx_t*)(*c)->state)->key_size = AES_256_KEYSIZE; + ((aes_gcm_ctx_t*)(*c)->state)->tag_len = GCM_AUTH_TAG_LEN; + break; + } + + /* set key size */ + (*c)->key_len = key_len; + EVP_CIPHER_CTX_init(&gcm->ctx); + + return (err_status_ok); +} + + +/* + * This function deallocates a GCM session + */ +err_status_t aes_gcm_openssl_dealloc (cipher_t *c) +{ + aes_gcm_ctx_t *ctx; + + ctx = (aes_gcm_ctx_t*)c->state; + if (ctx) { + EVP_CIPHER_CTX_cleanup(&ctx->ctx); + /* decrement ref_count for the appropriate engine */ + switch (ctx->key_size) { + case AES_256_KEYSIZE: + aes_gcm_256_openssl.ref_count--; + break; + case AES_128_KEYSIZE: + aes_gcm_128_openssl.ref_count--; + break; + default: + return (err_status_dealloc_fail); + break; + } + } + + /* zeroize entire state*/ + octet_string_set_to_zero((uint8_t*)c, sizeof(cipher_t) + sizeof(aes_gcm_ctx_t)); + + /* free memory */ + crypto_free(c); + + return (err_status_ok); +} + +/* + * aes_gcm_openssl_context_init(...) initializes the aes_gcm_context + * using the value in key[]. + * + * the key is the secret key + */ +err_status_t aes_gcm_openssl_context_init (aes_gcm_ctx_t *c, const uint8_t *key) +{ + c->dir = direction_any; + + /* copy key to be used later when CiscoSSL crypto context is created */ + v128_copy_octet_string((v128_t*)&c->key, key); + + if (c->key_size == AES_256_KEYSIZE) { + debug_print(mod_aes_gcm, "Copying last 16 bytes of key: %s", + v128_hex_string((v128_t*)(key + AES_128_KEYSIZE))); + v128_copy_octet_string(((v128_t*)(&c->key.v8)) + 1, + key + AES_128_KEYSIZE); + } + + debug_print(mod_aes_gcm, "key: %s", v128_hex_string((v128_t*)&c->key)); + + EVP_CIPHER_CTX_cleanup(&c->ctx); + + return (err_status_ok); +} + + +/* + * aes_gcm_openssl_set_iv(c, iv) sets the counter value to the exor of iv with + * the offset + */ +err_status_t aes_gcm_openssl_set_iv (aes_gcm_ctx_t *c, void *iv, + int direction) +{ + const EVP_CIPHER *evp; + v128_t *nonce = iv; + + if (direction != direction_encrypt && direction != direction_decrypt) { + return (err_status_bad_param); + } + c->dir = direction; + + debug_print(mod_aes_gcm, "setting iv: %s", v128_hex_string(nonce)); + + switch (c->key_size) { + case AES_256_KEYSIZE: + evp = EVP_aes_256_gcm(); + break; + case AES_128_KEYSIZE: + evp = EVP_aes_128_gcm(); + break; + default: + return (err_status_bad_param); + break; + } + + if (!EVP_CipherInit_ex(&c->ctx, evp, NULL, (const unsigned char*)&c->key.v8, + NULL, (c->dir == direction_encrypt ? 1 : 0))) { + return (err_status_init_fail); + } + + /* set IV len and the IV value, the followiong 3 calls are required */ + if (!EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_IVLEN, 12, 0)) { + return (err_status_init_fail); + } + if (!EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_IV_FIXED, -1, iv)) { + return (err_status_init_fail); + } + if (!EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_IV_GEN, 0, iv)) { + return (err_status_init_fail); + } + + return (err_status_ok); +} + +/* + * This function processes the AAD + * + * Parameters: + * c Crypto context + * aad Additional data to process for AEAD cipher suites + * aad_len length of aad buffer + */ +err_status_t aes_gcm_openssl_set_aad (aes_gcm_ctx_t *c, unsigned char *aad, + unsigned int aad_len) +{ + int rv; + + /* + * Set dummy tag, OpenSSL requires the Tag to be set before + * processing AAD + */ + EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_TAG, c->tag_len, aad); + + rv = EVP_Cipher(&c->ctx, NULL, aad, aad_len); + if (rv != aad_len) { + return (err_status_algo_fail); + } else { + return (err_status_ok); + } +} + +/* + * This function encrypts a buffer using AES GCM mode + * + * Parameters: + * c Crypto context + * buf data to encrypt + * enc_len length of encrypt buffer + */ +err_status_t aes_gcm_openssl_encrypt (aes_gcm_ctx_t *c, unsigned char *buf, + unsigned int *enc_len) +{ + if (c->dir != direction_encrypt && c->dir != direction_decrypt) { + return (err_status_bad_param); + } + + /* + * Encrypt the data + */ + EVP_Cipher(&c->ctx, buf, buf, *enc_len); + + return (err_status_ok); +} + +/* + * This function calculates and returns the GCM tag for a given context. + * This should be called after encrypting the data. The *len value + * is increased by the tag size. The caller must ensure that *buf has + * enough room to accept the appended tag. + * + * Parameters: + * c Crypto context + * buf data to encrypt + * len length of encrypt buffer + */ +err_status_t aes_gcm_openssl_get_tag (aes_gcm_ctx_t *c, unsigned char *buf, + int *len) +{ + /* + * Calculate the tag + */ + EVP_Cipher(&c->ctx, NULL, NULL, 0); + + /* + * Retreive the tag + */ + EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_GET_TAG, c->tag_len, buf); + + /* + * Increase encryption length by desired tag size + */ + *len = c->tag_len; + + return (err_status_ok); +} + + +/* + * This function decrypts a buffer using AES GCM mode + * + * Parameters: + * c Crypto context + * buf data to encrypt + * enc_len length of encrypt buffer + */ +err_status_t aes_gcm_openssl_decrypt (aes_gcm_ctx_t *c, unsigned char *buf, + unsigned int *enc_len) +{ + if (c->dir != direction_encrypt && c->dir != direction_decrypt) { + return (err_status_bad_param); + } + + /* + * Set the tag before decrypting + */ + EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_TAG, c->tag_len, + buf + (*enc_len - c->tag_len)); + EVP_Cipher(&c->ctx, buf, buf, *enc_len - c->tag_len); + + /* + * Check the tag + */ + if (EVP_Cipher(&c->ctx, NULL, NULL, 0)) { + return (err_status_auth_fail); + } + + /* + * Reduce the buffer size by the tag length since the tag + * is not part of the original payload + */ + *enc_len -= c->tag_len; + + return (err_status_ok); +} + + + +/* + * Name of this crypto engine + */ +char aes_gcm_128_openssl_description[] = "AES-128 GCM using openssl"; +char aes_gcm_256_openssl_description[] = "AES-256 GCM using openssl"; + + +/* + * KAT values for AES self-test. These + * values we're derived from independent test code + * using OpenSSL. + */ +uint8_t aes_gcm_test_case_0_key[AES_128_KEYSIZE_WSALT] = { + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, +}; + +uint8_t aes_gcm_test_case_0_iv[12] = { + 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88 +}; + +uint8_t aes_gcm_test_case_0_plaintext[60] = { + 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, + 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, + 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, + 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, + 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, + 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, + 0xba, 0x63, 0x7b, 0x39 +}; + +uint8_t aes_gcm_test_case_0_aad[20] = { + 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xab, 0xad, 0xda, 0xd2 +}; + +uint8_t aes_gcm_test_case_0_ciphertext[68] = { + 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, + 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, + 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, + 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, + 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, + 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, + 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, + 0x3d, 0x58, 0xe0, 0x91, + /* the last 8 bytes are the tag */ + 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb, +}; + +cipher_test_case_t aes_gcm_test_case_0 = { + AES_128_KEYSIZE_WSALT, /* octets in key */ + aes_gcm_test_case_0_key, /* key */ + aes_gcm_test_case_0_iv, /* packet index */ + 60, /* octets in plaintext */ + aes_gcm_test_case_0_plaintext, /* plaintext */ + 68, /* octets in ciphertext */ + aes_gcm_test_case_0_ciphertext, /* ciphertext + tag */ + 20, /* octets in AAD */ + aes_gcm_test_case_0_aad, /* AAD */ + NULL /* pointer to next testcase */ +}; + +uint8_t aes_gcm_test_case_1_key[AES_256_KEYSIZE_WSALT] = { + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0xa5, 0x59, 0x09, 0xc5, 0x54, 0x66, 0x93, 0x1c, + 0xaf, 0xf5, 0x26, 0x9a, 0x21, 0xd5, 0x14, 0xb2, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + +}; + +uint8_t aes_gcm_test_case_1_iv[12] = { + 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88 +}; + +uint8_t aes_gcm_test_case_1_plaintext[60] = { + 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, + 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, + 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, + 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, + 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, + 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, + 0xba, 0x63, 0x7b, 0x39 +}; + +uint8_t aes_gcm_test_case_1_aad[20] = { + 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, + 0xab, 0xad, 0xda, 0xd2 +}; + +uint8_t aes_gcm_test_case_1_ciphertext[68] = { + 0x0b, 0x11, 0xcf, 0xaf, 0x68, 0x4d, 0xae, 0x46, + 0xc7, 0x90, 0xb8, 0x8e, 0xb7, 0x6a, 0x76, 0x2a, + 0x94, 0x82, 0xca, 0xab, 0x3e, 0x39, 0xd7, 0x86, + 0x1b, 0xc7, 0x93, 0xed, 0x75, 0x7f, 0x23, 0x5a, + 0xda, 0xfd, 0xd3, 0xe2, 0x0e, 0x80, 0x87, 0xa9, + 0x6d, 0xd7, 0xe2, 0x6a, 0x7d, 0x5f, 0xb4, 0x80, + 0xef, 0xef, 0xc5, 0x29, 0x12, 0xd1, 0xaa, 0x10, + 0x09, 0xc9, 0x86, 0xc1, + /* the last 8 bytes are the tag */ + 0x45, 0xbc, 0x03, 0xe6, 0xe1, 0xac, 0x0a, 0x9f, +}; + +cipher_test_case_t aes_gcm_test_case_1 = { + AES_256_KEYSIZE_WSALT, /* octets in key */ + aes_gcm_test_case_1_key, /* key */ + aes_gcm_test_case_1_iv, /* packet index */ + 60, /* octets in plaintext */ + aes_gcm_test_case_1_plaintext, /* plaintext */ + 68, /* octets in ciphertext */ + aes_gcm_test_case_1_ciphertext, /* ciphertext + tag */ + 20, /* octets in AAD */ + aes_gcm_test_case_1_aad, /* AAD */ + NULL /* pointer to next testcase */ +}; + +/* + * This is the vector function table for this crypto engine. + */ +cipher_type_t aes_gcm_128_openssl = { + (cipher_alloc_func_t) aes_gcm_openssl_alloc, + (cipher_dealloc_func_t) aes_gcm_openssl_dealloc, + (cipher_init_func_t) aes_gcm_openssl_context_init, + (cipher_set_aad_func_t) aes_gcm_openssl_set_aad, + (cipher_encrypt_func_t) aes_gcm_openssl_encrypt, + (cipher_decrypt_func_t) aes_gcm_openssl_decrypt, + (cipher_set_iv_func_t) aes_gcm_openssl_set_iv, + (cipher_get_tag_func_t) aes_gcm_openssl_get_tag, + (char*) aes_gcm_128_openssl_description, + (int) 0, /* instance count */ + (cipher_test_case_t*) &aes_gcm_test_case_0, + (debug_module_t*) &mod_aes_gcm, + (cipher_type_id_t) AES_128_GCM +}; + +/* + * This is the vector function table for this crypto engine. + */ +cipher_type_t aes_gcm_256_openssl = { + (cipher_alloc_func_t) aes_gcm_openssl_alloc, + (cipher_dealloc_func_t) aes_gcm_openssl_dealloc, + (cipher_init_func_t) aes_gcm_openssl_context_init, + (cipher_set_aad_func_t) aes_gcm_openssl_set_aad, + (cipher_encrypt_func_t) aes_gcm_openssl_encrypt, + (cipher_decrypt_func_t) aes_gcm_openssl_decrypt, + (cipher_set_iv_func_t) aes_gcm_openssl_set_iv, + (cipher_get_tag_func_t) aes_gcm_openssl_get_tag, + (char*) aes_gcm_256_openssl_description, + (int) 0, /* instance count */ + (cipher_test_case_t*) &aes_gcm_test_case_1, + (debug_module_t*) &mod_aes_gcm, + (cipher_type_id_t) AES_256_GCM +}; + diff --git a/libs/srtp/crypto/cipher/aes_icm.c b/libs/srtp/crypto/cipher/aes_icm.c index ff330ffd81..7a8e56f850 100644 --- a/libs/srtp/crypto/cipher/aes_icm.c +++ b/libs/srtp/crypto/cipher/aes_icm.c @@ -9,7 +9,7 @@ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,9 +49,6 @@ #include "aes_icm.h" #include "alloc.h" -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif debug_module_t mod_aes_icm = { 0, /* debugging is off by default */ @@ -168,7 +165,7 @@ aes_icm_dealloc(cipher_t *c) { err_status_t aes_icm_context_init(aes_icm_ctx_t *c, const uint8_t *key, int key_len) { err_status_t status; - int base_key_len; + int base_key_len, copy_len; if (key_len > 16 && key_len < 30) /* Ismacryp */ base_key_len = 16; @@ -177,15 +174,21 @@ aes_icm_context_init(aes_icm_ctx_t *c, const uint8_t *key, int key_len) { else return err_status_bad_param; - /* set counter and initial values to 'offset' value */ - /* Note this copies past the end of the 'key' array by 2 bytes! */ - v128_copy_octet_string(&c->counter, key + base_key_len); - v128_copy_octet_string(&c->offset, key + base_key_len); + /* + * set counter and initial values to 'offset' value, being careful not to + * go past the end of the key buffer + */ + v128_set_to_zero(&c->counter); + v128_set_to_zero(&c->offset); + + copy_len = key_len - base_key_len; + /* force last two octets of the offset to be left zero (for srtp compatibility) */ + if (copy_len > 14) + copy_len = 14; + + memcpy(&c->counter, key + base_key_len, copy_len); + memcpy(&c->offset, key + base_key_len, copy_len); - /* force last two octets of the offset to zero (for srtp compatibility) */ - c->offset.v8[14] = c->offset.v8[15] = 0; - c->counter.v8[14] = c->counter.v8[15] = 0; - debug_print(mod_aes_icm, "key: %s", octet_string_hex_string(key, base_key_len)); debug_print(mod_aes_icm, @@ -269,7 +272,7 @@ aes_icm_set_octet(aes_icm_ctx_t *c, */ err_status_t -aes_icm_set_iv(aes_icm_ctx_t *c, void *iv) { +aes_icm_set_iv(aes_icm_ctx_t *c, void *iv, int direction) { v128_t *nonce = (v128_t *) iv; debug_print(mod_aes_icm, @@ -500,6 +503,8 @@ cipher_test_case_t aes_icm_test_case_0 = { aes_icm_test_case_0_plaintext, /* plaintext */ 32, /* octets in ciphertext */ aes_icm_test_case_0_ciphertext, /* ciphertext */ + 0, + NULL, NULL /* pointer to next testcase */ }; @@ -539,6 +544,8 @@ cipher_test_case_t aes_icm_test_case_1 = { aes_icm_test_case_1_plaintext, /* plaintext */ 32, /* octets in ciphertext */ aes_icm_test_case_1_ciphertext, /* ciphertext */ + 0, + NULL, &aes_icm_test_case_0 /* pointer to next testcase */ }; @@ -552,9 +559,11 @@ cipher_type_t aes_icm = { (cipher_alloc_func_t) aes_icm_alloc, (cipher_dealloc_func_t) aes_icm_dealloc, (cipher_init_func_t) aes_icm_context_init, + (cipher_set_aad_func_t) 0, (cipher_encrypt_func_t) aes_icm_encrypt, (cipher_decrypt_func_t) aes_icm_encrypt, (cipher_set_iv_func_t) aes_icm_set_iv, + (cipher_get_tag_func_t) 0, (char *) aes_icm_description, (int) 0, /* instance count */ (cipher_test_case_t *) &aes_icm_test_case_1, diff --git a/libs/srtp/crypto/cipher/aes_icm_ossl.c b/libs/srtp/crypto/cipher/aes_icm_ossl.c new file mode 100644 index 0000000000..2d9d4e068b --- /dev/null +++ b/libs/srtp/crypto/cipher/aes_icm_ossl.c @@ -0,0 +1,537 @@ +/* + * aes_icm_ossl.c + * + * AES Integer Counter Mode + * + * John A. Foley + * Cisco Systems, Inc. + * + * 2/24/2012: This module was modified to use CiscoSSL for AES counter + * mode. Eddy Lem contributed the code to allow this. + * + * 12/20/2012: Added support for AES-192 and AES-256. + */ + +/* + * + * Copyright (c) 2013, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "aes_icm_ossl.h" +#include "crypto_types.h" +#include "alloc.h" +#include "crypto_types.h" + + +debug_module_t mod_aes_icm = { + 0, /* debugging is off by default */ + "aes icm ossl" /* printable module name */ +}; +extern cipher_test_case_t aes_icm_test_case_0; +extern cipher_type_t aes_icm; +extern cipher_type_t aes_icm_192; +extern cipher_type_t aes_icm_256; + +/* + * integer counter mode works as follows: + * + * 16 bits + * <-----> + * +------+------+------+------+------+------+------+------+ + * | nonce | pakcet index | ctr |---+ + * +------+------+------+------+------+------+------+------+ | + * | + * +------+------+------+------+------+------+------+------+ v + * | salt |000000|->(+) + * +------+------+------+------+------+------+------+------+ | + * | + * +---------+ + * | encrypt | + * +---------+ + * | + * +------+------+------+------+------+------+------+------+ | + * | keystream block |<--+ + * +------+------+------+------+------+------+------+------+ + * + * All fields are big-endian + * + * ctr is the block counter, which increments from zero for + * each packet (16 bits wide) + * + * packet index is distinct for each packet (48 bits wide) + * + * nonce can be distinct across many uses of the same key, or + * can be a fixed value per key, or can be per-packet randomness + * (64 bits) + * + */ + +/* + * This function allocates a new instance of this crypto engine. + * The key_len parameter should be one of 30, 38, or 46 for + * AES-128, AES-192, and AES-256 respectively. Note, this key_len + * value is inflated, as it also accounts for the 112 bit salt + * value. + */ +err_status_t aes_icm_openssl_alloc (cipher_t **c, int key_len, int x) +{ + aes_icm_ctx_t *icm; + int tmp; + uint8_t *allptr; + + debug_print(mod_aes_icm, "allocating cipher with key length %d", key_len); + + /* + * Verify the key_len is valid for one of: AES-128/192/256 + */ + if (key_len != AES_128_KEYSIZE_WSALT && key_len != AES_192_KEYSIZE_WSALT && + key_len != AES_256_KEYSIZE_WSALT) { + return err_status_bad_param; + } + + /* allocate memory a cipher of type aes_icm */ + tmp = sizeof(cipher_t) + sizeof(aes_icm_ctx_t); + allptr = (uint8_t*)crypto_alloc(tmp); + if (allptr == NULL) { + return err_status_alloc_fail; + } + + /* set pointers */ + *c = (cipher_t*)allptr; + (*c)->state = allptr + sizeof(cipher_t); + icm = (aes_icm_ctx_t*)(*c)->state; + + /* increment ref_count */ + switch (key_len) { + case AES_128_KEYSIZE_WSALT: + (*c)->algorithm = AES_128_ICM; + (*c)->type = &aes_icm; + aes_icm.ref_count++; + ((aes_icm_ctx_t*)(*c)->state)->key_size = AES_128_KEYSIZE; + break; + case AES_192_KEYSIZE_WSALT: + (*c)->algorithm = AES_192_ICM; + (*c)->type = &aes_icm_192; + aes_icm_192.ref_count++; + ((aes_icm_ctx_t*)(*c)->state)->key_size = AES_192_KEYSIZE; + break; + case AES_256_KEYSIZE_WSALT: + (*c)->algorithm = AES_256_ICM; + (*c)->type = &aes_icm_256; + aes_icm_256.ref_count++; + ((aes_icm_ctx_t*)(*c)->state)->key_size = AES_256_KEYSIZE; + break; + } + + /* set key size */ + (*c)->key_len = key_len; + EVP_CIPHER_CTX_init(&icm->ctx); + + return err_status_ok; +} + + +/* + * This function deallocates an instance of this engine + */ +err_status_t aes_icm_openssl_dealloc (cipher_t *c) +{ + aes_icm_ctx_t *ctx; + + if (c == NULL) { + return err_status_bad_param; + } + + /* + * Free the EVP context + */ + ctx = (aes_icm_ctx_t*)c->state; + if (ctx != NULL) { + EVP_CIPHER_CTX_cleanup(&ctx->ctx); + /* decrement ref_count for the appropriate engine */ + switch (ctx->key_size) { + case AES_256_KEYSIZE: + aes_icm_256.ref_count--; + break; + case AES_192_KEYSIZE: + aes_icm_192.ref_count--; + break; + case AES_128_KEYSIZE: + aes_icm.ref_count--; + break; + default: + return err_status_dealloc_fail; + break; + } + } + + /* zeroize entire state*/ + octet_string_set_to_zero((uint8_t*)c, + sizeof(cipher_t) + sizeof(aes_icm_ctx_t)); + + /* free memory */ + crypto_free(c); + + return err_status_ok; +} + +/* + * aes_icm_openssl_context_init(...) initializes the aes_icm_context + * using the value in key[]. + * + * the key is the secret key + * + * the salt is unpredictable (but not necessarily secret) data which + * randomizes the starting point in the keystream + */ +err_status_t aes_icm_openssl_context_init (aes_icm_ctx_t *c, const uint8_t *key) +{ + /* + * set counter and initial values to 'offset' value, being careful not to + * go past the end of the key buffer + */ + v128_set_to_zero(&c->counter); + v128_set_to_zero(&c->offset); + memcpy(&c->counter, key + c->key_size, SALT_SIZE); + memcpy(&c->offset, key + c->key_size, SALT_SIZE); + + /* force last two octets of the offset to zero (for srtp compatibility) */ + c->offset.v8[SALT_SIZE] = c->offset.v8[SALT_SIZE + 1] = 0; + c->counter.v8[SALT_SIZE] = c->counter.v8[SALT_SIZE + 1] = 0; + + /* copy key to be used later when CiscoSSL crypto context is created */ + v128_copy_octet_string((v128_t*)&c->key, key); + + /* if the key is greater than 16 bytes, copy the second + * half. Note, we treat AES-192 and AES-256 the same here + * for simplicity. The storage location receiving the + * key is statically allocated to handle a full 32 byte key + * regardless of the cipher in use. + */ + if (c->key_size == AES_256_KEYSIZE || c->key_size == AES_192_KEYSIZE) { + debug_print(mod_aes_icm, "Copying last 16 bytes of key: %s", + v128_hex_string((v128_t*)(key + AES_128_KEYSIZE))); + v128_copy_octet_string(((v128_t*)(&c->key.v8)) + 1, key + AES_128_KEYSIZE); + } + + debug_print(mod_aes_icm, "key: %s", v128_hex_string((v128_t*)&c->key)); + debug_print(mod_aes_icm, "offset: %s", v128_hex_string(&c->offset)); + + EVP_CIPHER_CTX_cleanup(&c->ctx); + + return err_status_ok; +} + + +/* + * aes_icm_set_iv(c, iv) sets the counter value to the exor of iv with + * the offset + */ +err_status_t aes_icm_openssl_set_iv (aes_icm_ctx_t *c, void *iv, int dir) +{ + const EVP_CIPHER *evp; + v128_t *nonce = (v128_t*)iv; + + debug_print(mod_aes_icm, "setting iv: %s", v128_hex_string(nonce)); + + v128_xor(&c->counter, &c->offset, nonce); + + debug_print(mod_aes_icm, "set_counter: %s", v128_hex_string(&c->counter)); + + switch (c->key_size) { + case AES_256_KEYSIZE: + evp = EVP_aes_256_ctr(); + break; + case AES_192_KEYSIZE: + evp = EVP_aes_192_ctr(); + break; + case AES_128_KEYSIZE: + evp = EVP_aes_128_ctr(); + break; + default: + return err_status_bad_param; + break; + } + + if (!EVP_EncryptInit_ex(&c->ctx, evp, + NULL, c->key.v8, c->counter.v8)) { + return err_status_fail; + } else { + return err_status_ok; + } +} + +/* + * This function encrypts a buffer using AES CTR mode + * + * Parameters: + * c Crypto context + * buf data to encrypt + * enc_len length of encrypt buffer + */ +err_status_t aes_icm_openssl_encrypt (aes_icm_ctx_t *c, unsigned char *buf, unsigned int *enc_len) +{ + int len = 0; + + debug_print(mod_aes_icm, "rs0: %s", v128_hex_string(&c->counter)); + + if (!EVP_EncryptUpdate(&c->ctx, buf, &len, buf, *enc_len)) { + return err_status_cipher_fail; + } + *enc_len = len; + + if (!EVP_EncryptFinal_ex(&c->ctx, buf, (int*)&len)) { + return err_status_cipher_fail; + } + *enc_len += len; + + return err_status_ok; +} + +/* + * Abstraction layer for encrypt. + */ +err_status_t aes_icm_output (aes_icm_ctx_t *c, uint8_t *buffer, int num_octets_to_output) +{ + unsigned int len = num_octets_to_output; + + /* zeroize the buffer */ + octet_string_set_to_zero(buffer, num_octets_to_output); + + /* exor keystream into buffer */ + return aes_icm_openssl_encrypt(c, buffer, &len); +} + +/* + * Name of this crypto engine + */ +char aes_icm_openssl_description[] = "AES-128 counter mode using openssl"; +char aes_icm_192_openssl_description[] = "AES-192 counter mode using openssl"; +char aes_icm_256_openssl_description[] = "AES-256 counter mode using openssl"; + + +/* + * KAT values for AES self-test. These + * values came from the legacy libsrtp code. + */ +uint8_t aes_icm_test_case_0_key[AES_128_KEYSIZE_WSALT] = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd +}; + +uint8_t aes_icm_test_case_0_nonce[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8_t aes_icm_test_case_0_plaintext[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +uint8_t aes_icm_test_case_0_ciphertext[32] = { + 0xe0, 0x3e, 0xad, 0x09, 0x35, 0xc9, 0x5e, 0x80, + 0xe1, 0x66, 0xb1, 0x6d, 0xd9, 0x2b, 0x4e, 0xb4, + 0xd2, 0x35, 0x13, 0x16, 0x2b, 0x02, 0xd0, 0xf7, + 0x2a, 0x43, 0xa2, 0xfe, 0x4a, 0x5f, 0x97, 0xab +}; + +cipher_test_case_t aes_icm_test_case_0 = { + AES_128_KEYSIZE_WSALT, /* octets in key */ + aes_icm_test_case_0_key, /* key */ + aes_icm_test_case_0_nonce, /* packet index */ + 32, /* octets in plaintext */ + aes_icm_test_case_0_plaintext, /* plaintext */ + 32, /* octets in ciphertext */ + aes_icm_test_case_0_ciphertext, /* ciphertext */ + 0, + NULL, + NULL /* pointer to next testcase */ +}; + +/* + * KAT values for AES-192-CTR self-test. These + * values came from section 7 of RFC 6188. + */ +uint8_t aes_icm_192_test_case_1_key[AES_192_KEYSIZE_WSALT] = { + 0xea, 0xb2, 0x34, 0x76, 0x4e, 0x51, 0x7b, 0x2d, + 0x3d, 0x16, 0x0d, 0x58, 0x7d, 0x8c, 0x86, 0x21, + 0x97, 0x40, 0xf6, 0x5f, 0x99, 0xb6, 0xbc, 0xf7, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd +}; + +uint8_t aes_icm_192_test_case_1_nonce[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8_t aes_icm_192_test_case_1_plaintext[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +uint8_t aes_icm_192_test_case_1_ciphertext[32] = { + 0x35, 0x09, 0x6c, 0xba, 0x46, 0x10, 0x02, 0x8d, + 0xc1, 0xb5, 0x75, 0x03, 0x80, 0x4c, 0xe3, 0x7c, + 0x5d, 0xe9, 0x86, 0x29, 0x1d, 0xcc, 0xe1, 0x61, + 0xd5, 0x16, 0x5e, 0xc4, 0x56, 0x8f, 0x5c, 0x9a +}; + +cipher_test_case_t aes_icm_192_test_case_1 = { + AES_192_KEYSIZE_WSALT, /* octets in key */ + aes_icm_192_test_case_1_key, /* key */ + aes_icm_192_test_case_1_nonce, /* packet index */ + 32, /* octets in plaintext */ + aes_icm_192_test_case_1_plaintext, /* plaintext */ + 32, /* octets in ciphertext */ + aes_icm_192_test_case_1_ciphertext, /* ciphertext */ + 0, + NULL, + NULL /* pointer to next testcase */ +}; + + +/* + * KAT values for AES-256-CTR self-test. These + * values came from section 7 of RFC 6188. + */ +uint8_t aes_icm_256_test_case_2_key[AES_256_KEYSIZE_WSALT] = { + 0x57, 0xf8, 0x2f, 0xe3, 0x61, 0x3f, 0xd1, 0x70, + 0xa8, 0x5e, 0xc9, 0x3c, 0x40, 0xb1, 0xf0, 0x92, + 0x2e, 0xc4, 0xcb, 0x0d, 0xc0, 0x25, 0xb5, 0x82, + 0x72, 0x14, 0x7c, 0xc4, 0x38, 0x94, 0x4a, 0x98, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd +}; + +uint8_t aes_icm_256_test_case_2_nonce[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8_t aes_icm_256_test_case_2_plaintext[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +uint8_t aes_icm_256_test_case_2_ciphertext[32] = { + 0x92, 0xbd, 0xd2, 0x8a, 0x93, 0xc3, 0xf5, 0x25, + 0x11, 0xc6, 0x77, 0xd0, 0x8b, 0x55, 0x15, 0xa4, + 0x9d, 0xa7, 0x1b, 0x23, 0x78, 0xa8, 0x54, 0xf6, + 0x70, 0x50, 0x75, 0x6d, 0xed, 0x16, 0x5b, 0xac +}; + +cipher_test_case_t aes_icm_256_test_case_2 = { + AES_256_KEYSIZE_WSALT, /* octets in key */ + aes_icm_256_test_case_2_key, /* key */ + aes_icm_256_test_case_2_nonce, /* packet index */ + 32, /* octets in plaintext */ + aes_icm_256_test_case_2_plaintext, /* plaintext */ + 32, /* octets in ciphertext */ + aes_icm_256_test_case_2_ciphertext, /* ciphertext */ + 0, + NULL, + NULL /* pointer to next testcase */ +}; + +/* + * This is the function table for this crypto engine. + * note: the encrypt function is identical to the decrypt function + */ +cipher_type_t aes_icm = { + (cipher_alloc_func_t) aes_icm_openssl_alloc, + (cipher_dealloc_func_t) aes_icm_openssl_dealloc, + (cipher_init_func_t) aes_icm_openssl_context_init, + (cipher_set_aad_func_t) 0, + (cipher_encrypt_func_t) aes_icm_openssl_encrypt, + (cipher_decrypt_func_t) aes_icm_openssl_encrypt, + (cipher_set_iv_func_t) aes_icm_openssl_set_iv, + (cipher_get_tag_func_t) 0, + (char*) aes_icm_openssl_description, + (int) 0, /* instance count */ + (cipher_test_case_t*) &aes_icm_test_case_0, + (debug_module_t*) &mod_aes_icm, + (cipher_type_id_t) AES_ICM +}; + +/* + * This is the function table for this crypto engine. + * note: the encrypt function is identical to the decrypt function + */ +cipher_type_t aes_icm_192 = { + (cipher_alloc_func_t) aes_icm_openssl_alloc, + (cipher_dealloc_func_t) aes_icm_openssl_dealloc, + (cipher_init_func_t) aes_icm_openssl_context_init, + (cipher_set_aad_func_t) 0, + (cipher_encrypt_func_t) aes_icm_openssl_encrypt, + (cipher_decrypt_func_t) aes_icm_openssl_encrypt, + (cipher_set_iv_func_t) aes_icm_openssl_set_iv, + (cipher_get_tag_func_t) 0, + (char*) aes_icm_192_openssl_description, + (int) 0, /* instance count */ + (cipher_test_case_t*) &aes_icm_192_test_case_1, + (debug_module_t*) &mod_aes_icm, + (cipher_type_id_t) AES_192_ICM +}; + +/* + * This is the function table for this crypto engine. + * note: the encrypt function is identical to the decrypt function + */ +cipher_type_t aes_icm_256 = { + (cipher_alloc_func_t) aes_icm_openssl_alloc, + (cipher_dealloc_func_t) aes_icm_openssl_dealloc, + (cipher_init_func_t) aes_icm_openssl_context_init, + (cipher_set_aad_func_t) 0, + (cipher_encrypt_func_t) aes_icm_openssl_encrypt, + (cipher_decrypt_func_t) aes_icm_openssl_encrypt, + (cipher_set_iv_func_t) aes_icm_openssl_set_iv, + (cipher_get_tag_func_t) 0, + (char*) aes_icm_256_openssl_description, + (int) 0, /* instance count */ + (cipher_test_case_t*) &aes_icm_256_test_case_2, + (debug_module_t*) &mod_aes_icm, + (cipher_type_id_t) AES_256_ICM +}; + diff --git a/libs/srtp/crypto/cipher/cipher.c b/libs/srtp/crypto/cipher/cipher.c index f465ec6c5a..07b472ebff 100644 --- a/libs/srtp/crypto/cipher/cipher.c +++ b/libs/srtp/crypto/cipher/cipher.c @@ -10,7 +10,7 @@ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ */ #include "cipher.h" +#include "crypto_types.h" #include "rand_source.h" /* used in invertibiltiy tests */ #include "alloc.h" /* for crypto_alloc(), crypto_free() */ @@ -87,6 +88,7 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { err_status_t status; uint8_t buffer[SELF_TEST_BUF_OCTETS]; uint8_t buffer2[SELF_TEST_BUF_OCTETS]; + int tag_len; unsigned int len; int i, j, case_num = 0; @@ -105,7 +107,6 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { * encryption and decryption functions */ while (test_case != NULL) { - /* allocate cipher */ status = cipher_type_alloc(ct, &c, test_case->key_length_octets); if (status) @@ -117,7 +118,7 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { debug_print(mod_cipher, "testing encryption", NULL); /* initialize cipher */ - status = cipher_init(c, test_case->key, direction_encrypt); + status = cipher_init(c, test_case->key); if (status) { cipher_dealloc(c); return status; @@ -136,12 +137,30 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { test_case->plaintext_length_octets)); /* set the initialization vector */ - status = cipher_set_iv(c, test_case->idx); + status = cipher_set_iv(c, test_case->idx, direction_encrypt); if (status) { cipher_dealloc(c); return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + debug_print(mod_cipher, "IV: %s", + octet_string_hex_string(test_case->idx, 12)); + + /* + * Set the AAD + */ + status = cipher_set_aad(c, test_case->aad, + test_case->aad_length_octets); + if (status) { + cipher_dealloc(c); + return status; + } + debug_print(mod_cipher, "AAD: %s", + octet_string_hex_string(test_case->aad, + test_case->aad_length_octets)); + } + /* encrypt */ len = test_case->plaintext_length_octets; status = cipher_encrypt(c, buffer, &len); @@ -150,6 +169,18 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + /* + * Get the GCM tag + */ + status = cipher_get_tag(c, buffer + len, &tag_len); + if (status) { + cipher_dealloc(c); + return status; + } + len += tag_len; + } + debug_print(mod_cipher, "ciphertext: %s", octet_string_hex_string(buffer, test_case->ciphertext_length_octets)); @@ -184,7 +215,7 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { debug_print(mod_cipher, "testing decryption", NULL); /* re-initialize cipher for decryption */ - status = cipher_init(c, test_case->key, direction_decrypt); + status = cipher_init(c, test_case->key); if (status) { cipher_dealloc(c); return status; @@ -203,12 +234,27 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { test_case->plaintext_length_octets)); /* set the initialization vector */ - status = cipher_set_iv(c, test_case->idx); + status = cipher_set_iv(c, test_case->idx, direction_decrypt); if (status) { cipher_dealloc(c); return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + /* + * Set the AAD + */ + status = cipher_set_aad(c, test_case->aad, + test_case->aad_length_octets); + if (status) { + cipher_dealloc(c); + return status; + } + debug_print(mod_cipher, "AAD: %s", + octet_string_hex_string(test_case->aad, + test_case->aad_length_octets)); + } + /* decrypt */ len = test_case->ciphertext_length_octets; status = cipher_decrypt(c, buffer, &len); @@ -297,19 +343,34 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { if (status) return status; /* initialize cipher */ - status = cipher_init(c, key, direction_encrypt); + status = cipher_init(c, key); if (status) { cipher_dealloc(c); return status; } /* set initialization vector */ - status = cipher_set_iv(c, test_case->idx); + status = cipher_set_iv(c, test_case->idx, direction_encrypt); if (status) { cipher_dealloc(c); return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + /* + * Set the AAD + */ + status = cipher_set_aad(c, test_case->aad, + test_case->aad_length_octets); + if (status) { + cipher_dealloc(c); + return status; + } + debug_print(mod_cipher, "AAD: %s", + octet_string_hex_string(test_case->aad, + test_case->aad_length_octets)); + } + /* encrypt buffer with cipher */ plaintext_len = length; status = cipher_encrypt(c, buffer, &length); @@ -317,6 +378,17 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { cipher_dealloc(c); return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + /* + * Get the GCM tag + */ + status = cipher_get_tag(c, buffer + length, &tag_len); + if (status) { + cipher_dealloc(c); + return status; + } + length += tag_len; + } debug_print(mod_cipher, "ciphertext: %s", octet_string_hex_string(buffer, length)); @@ -324,16 +396,30 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { * re-initialize cipher for decryption, re-set the iv, then * decrypt the ciphertext */ - status = cipher_init(c, key, direction_decrypt); + status = cipher_init(c, key); if (status) { cipher_dealloc(c); return status; } - status = cipher_set_iv(c, test_case->idx); + status = cipher_set_iv(c, test_case->idx, direction_decrypt); if (status) { cipher_dealloc(c); return status; } + if (c->algorithm == AES_128_GCM || c->algorithm == AES_256_GCM) { + /* + * Set the AAD + */ + status = cipher_set_aad(c, test_case->aad, + test_case->aad_length_octets); + if (status) { + cipher_dealloc(c); + return status; + } + debug_print(mod_cipher, "AAD: %s", + octet_string_hex_string(test_case->aad, + test_case->aad_length_octets)); + } status = cipher_decrypt(c, buffer, &length); if (status) { cipher_dealloc(c); @@ -344,8 +430,9 @@ cipher_type_test(const cipher_type_t *ct, const cipher_test_case_t *test_data) { octet_string_hex_string(buffer, length)); /* compare the resulting plaintext with the original one */ - if (length != (unsigned int)plaintext_len) + if (length != (unsigned int)plaintext_len) { return err_status_algo_fail; + } status = err_status_ok; for (i=0; i < plaintext_len; i++) if (buffer[i] != buffer2[i]) { @@ -405,7 +492,7 @@ cipher_bits_per_second(cipher_t *c, int octets_in_buffer, int num_trials) { v128_set_to_zero(&nonce); timer = clock(); for(i=0; i < num_trials; i++, nonce.v32[3] = i) { - cipher_set_iv(c, &nonce); + cipher_set_iv(c, &nonce, direction_encrypt); cipher_encrypt(c, enc_buf, &len); } timer = clock() - timer; diff --git a/libs/srtp/crypto/cipher/null_cipher.c b/libs/srtp/crypto/cipher/null_cipher.c index d99a0e85af..001e20ff47 100644 --- a/libs/srtp/crypto/cipher/null_cipher.c +++ b/libs/srtp/crypto/cipher/null_cipher.c @@ -10,7 +10,7 @@ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,9 +48,6 @@ #include "null_cipher.h" #include "alloc.h" -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif /* the null_cipher uses the cipher debug module */ @@ -133,6 +130,8 @@ null_cipher_test_0 = { NULL, /* plaintext */ 0, /* octets in plaintext */ NULL, /* ciphertext */ + 0, + NULL, NULL /* pointer to next testcase */ }; @@ -145,9 +144,11 @@ cipher_type_t null_cipher = { (cipher_alloc_func_t) null_cipher_alloc, (cipher_dealloc_func_t) null_cipher_dealloc, (cipher_init_func_t) null_cipher_init, + (cipher_set_aad_func_t) 0, (cipher_encrypt_func_t) null_cipher_encrypt, (cipher_decrypt_func_t) null_cipher_encrypt, (cipher_set_iv_func_t) null_cipher_set_iv, + (cipher_get_tag_func_t) 0, (char *) null_cipher_description, (int) 0, (cipher_test_case_t *) &null_cipher_test_0, diff --git a/libs/srtp/crypto/hash/hmac_ossl.c b/libs/srtp/crypto/hash/hmac_ossl.c new file mode 100644 index 0000000000..dcf91b57ea --- /dev/null +++ b/libs/srtp/crypto/hash/hmac_ossl.c @@ -0,0 +1,297 @@ +/* + * hmac_ossl.c + * + * Implementation of hmac auth_type_t that leverages OpenSSL + * + * John A. Foley + * Cisco Systems, Inc. + */ +/* + * + * Copyright(c) 2013, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "hmac.h" +#include "alloc.h" +#include + +/* the debug module for authentiation */ + +debug_module_t mod_hmac = { + 0, /* debugging is off by default */ + "hmac sha-1 openssl" /* printable name for module */ +}; + + +err_status_t +hmac_alloc (auth_t **a, int key_len, int out_len) +{ + extern auth_type_t hmac; + uint8_t *pointer; + hmac_ctx_t *new_hmac_ctx; + + debug_print(mod_hmac, "allocating auth func with key length %d", key_len); + debug_print(mod_hmac, " tag length %d", out_len); + + /* + * check key length - note that we don't support keys larger + * than 20 bytes yet + */ + if (key_len > 20) { + return err_status_bad_param; + } + + /* check output length - should be less than 20 bytes */ + if (out_len > 20) { + return err_status_bad_param; + } + + /* allocate memory for auth and hmac_ctx_t structures */ + pointer = (uint8_t*)crypto_alloc(sizeof(hmac_ctx_t) + sizeof(auth_t)); + if (pointer == NULL) { + return err_status_alloc_fail; + } + + /* set pointers */ + *a = (auth_t*)pointer; + (*a)->type = &hmac; + (*a)->state = pointer + sizeof(auth_t); + (*a)->out_len = out_len; + (*a)->key_len = key_len; + (*a)->prefix_len = 0; + new_hmac_ctx = (hmac_ctx_t*)((*a)->state); + memset(new_hmac_ctx, 0, sizeof(hmac_ctx_t)); + + /* increment global count of all hmac uses */ + hmac.ref_count++; + + return err_status_ok; +} + +err_status_t +hmac_dealloc (auth_t *a) +{ + extern auth_type_t hmac; + hmac_ctx_t *hmac_ctx; + + hmac_ctx = (hmac_ctx_t*)a->state; + if (hmac_ctx->ctx_initialized) { + EVP_MD_CTX_cleanup(&hmac_ctx->ctx); + } + if (hmac_ctx->init_ctx_initialized) { + EVP_MD_CTX_cleanup(&hmac_ctx->init_ctx); + } + + /* zeroize entire state*/ + octet_string_set_to_zero((uint8_t*)a, + sizeof(hmac_ctx_t) + sizeof(auth_t)); + + /* free memory */ + crypto_free(a); + + /* decrement global count of all hmac uses */ + hmac.ref_count--; + + return err_status_ok; +} + +err_status_t +hmac_init (hmac_ctx_t *state, const uint8_t *key, int key_len) +{ + int i; + uint8_t ipad[64]; + + /* + * check key length - note that we don't support keys larger + * than 20 bytes yet + */ + if (key_len > 20) { + return err_status_bad_param; + } + + /* + * set values of ipad and opad by exoring the key into the + * appropriate constant values + */ + for (i = 0; i < key_len; i++) { + ipad[i] = key[i] ^ 0x36; + state->opad[i] = key[i] ^ 0x5c; + } + /* set the rest of ipad, opad to constant values */ + for (; i < 64; i++) { + ipad[i] = 0x36; + ((uint8_t*)state->opad)[i] = 0x5c; + } + + debug_print(mod_hmac, "ipad: %s", octet_string_hex_string(ipad, 64)); + + /* initialize sha1 context */ + sha1_init(&state->init_ctx); + state->init_ctx_initialized = 1; + + /* hash ipad ^ key */ + sha1_update(&state->init_ctx, ipad, 64); + return (hmac_start(state)); +} + +err_status_t +hmac_start (hmac_ctx_t *state) +{ + if (state->ctx_initialized) { + EVP_MD_CTX_cleanup(&state->ctx); + } + if (!EVP_MD_CTX_copy(&state->ctx, &state->init_ctx)) { + return err_status_auth_fail; + } else { + state->ctx_initialized = 1; + return err_status_ok; + } +} + +err_status_t +hmac_update (hmac_ctx_t *state, const uint8_t *message, int msg_octets) +{ + + debug_print(mod_hmac, "input: %s", + octet_string_hex_string(message, msg_octets)); + + /* hash message into sha1 context */ + sha1_update(&state->ctx, message, msg_octets); + + return err_status_ok; +} + +err_status_t +hmac_compute (hmac_ctx_t *state, const void *message, + int msg_octets, int tag_len, uint8_t *result) +{ + uint32_t hash_value[5]; + uint32_t H[5]; + int i; + + /* check tag length, return error if we can't provide the value expected */ + if (tag_len > 20) { + return err_status_bad_param; + } + + /* hash message, copy output into H */ + sha1_update(&state->ctx, message, msg_octets); + sha1_final(&state->ctx, H); + + /* + * note that we don't need to debug_print() the input, since the + * function hmac_update() already did that for us + */ + debug_print(mod_hmac, "intermediate state: %s", + octet_string_hex_string((uint8_t*)H, 20)); + + /* re-initialize hash context */ + sha1_init(&state->ctx); + + /* hash opad ^ key */ + sha1_update(&state->ctx, (uint8_t*)state->opad, 64); + + /* hash the result of the inner hash */ + sha1_update(&state->ctx, (uint8_t*)H, 20); + + /* the result is returned in the array hash_value[] */ + sha1_final(&state->ctx, hash_value); + + /* copy hash_value to *result */ + for (i = 0; i < tag_len; i++) { + result[i] = ((uint8_t*)hash_value)[i]; + } + + debug_print(mod_hmac, "output: %s", + octet_string_hex_string((uint8_t*)hash_value, tag_len)); + + return err_status_ok; +} + + +/* begin test case 0 */ + +uint8_t + hmac_test_case_0_key[20] = { + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b +}; + +uint8_t + hmac_test_case_0_data[8] = { + 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 /* "Hi There" */ +}; + +uint8_t + hmac_test_case_0_tag[20] = { + 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, + 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, + 0xf1, 0x46, 0xbe, 0x00 +}; + +auth_test_case_t + hmac_test_case_0 = { + 20, /* octets in key */ + hmac_test_case_0_key, /* key */ + 8, /* octets in data */ + hmac_test_case_0_data, /* data */ + 20, /* octets in tag */ + hmac_test_case_0_tag, /* tag */ + NULL /* pointer to next testcase */ +}; + +/* end test case 0 */ + +char hmac_description[] = "hmac sha-1 authentication function"; + +/* + * auth_type_t hmac is the hmac metaobject + */ + +auth_type_t + hmac = { + (auth_alloc_func) hmac_alloc, + (auth_dealloc_func) hmac_dealloc, + (auth_init_func) hmac_init, + (auth_compute_func) hmac_compute, + (auth_update_func) hmac_update, + (auth_start_func) hmac_start, + (char*) hmac_description, + (int) 0, /* instance count */ + (auth_test_case_t*) &hmac_test_case_0, + (debug_module_t*) &mod_hmac, + (auth_type_id_t) HMAC_SHA1 +}; + diff --git a/libs/srtp/crypto/hash/null_auth.c b/libs/srtp/crypto/hash/null_auth.c index 1fa2660840..5d810dd5b7 100644 --- a/libs/srtp/crypto/hash/null_auth.c +++ b/libs/srtp/crypto/hash/null_auth.c @@ -48,9 +48,6 @@ #include "null_auth.h" #include "alloc.h" -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif /* null_auth uses the auth debug module */ diff --git a/libs/srtp/crypto/include/aes_cbc.h b/libs/srtp/crypto/include/aes_cbc.h index bc4e41a4c1..f92591d968 100644 --- a/libs/srtp/crypto/include/aes_cbc.h +++ b/libs/srtp/crypto/include/aes_cbc.h @@ -17,6 +17,8 @@ typedef struct { v128_t state; /* cipher chaining state */ v128_t previous; /* previous ciphertext block */ + uint8_t key[32]; + int key_len; aes_expanded_key_t expanded_key; /* the cipher key */ } aes_cbc_ctx_t; @@ -31,10 +33,10 @@ aes_cbc_encrypt(aes_cbc_ctx_t *c, err_status_t aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, - int key_len, cipher_direction_t dir); + int key_len); err_status_t -aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv); +aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv, int direction); err_status_t aes_cbc_nist_encrypt(aes_cbc_ctx_t *c, diff --git a/libs/srtp/crypto/include/aes_gcm_ossl.h b/libs/srtp/crypto/include/aes_gcm_ossl.h new file mode 100644 index 0000000000..87b3e9f7e1 --- /dev/null +++ b/libs/srtp/crypto/include/aes_gcm_ossl.h @@ -0,0 +1,62 @@ +/* + * aes_gcm_ossl.h + * + * Header for AES Galois Counter Mode. + * + * John A. Foley + * Cisco Systems, Inc. + * + */ +/* + * + * Copyright (c) 2013, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef AES_GCM_OSSL_H +#define AES_GCM_OSSL_H + +#include "cipher.h" +#include +#include + +typedef struct { + v256_t key; + int key_size; + int tag_len; + EVP_CIPHER_CTX ctx; + cipher_direction_t dir; +} aes_gcm_ctx_t; + +#endif /* AES_GCM_OSSL_H */ + diff --git a/libs/srtp/crypto/include/aes_icm.h b/libs/srtp/crypto/include/aes_icm.h index dac0cdccc6..bbcc6c3f5c 100644 --- a/libs/srtp/crypto/include/aes_icm.h +++ b/libs/srtp/crypto/include/aes_icm.h @@ -29,7 +29,7 @@ aes_icm_context_init(aes_icm_ctx_t *c, int key_len); err_status_t -aes_icm_set_iv(aes_icm_ctx_t *c, void *iv); +aes_icm_set_iv(aes_icm_ctx_t *c, void *iv, int direction); err_status_t aes_icm_encrypt(aes_icm_ctx_t *c, diff --git a/libs/srtp/crypto/include/aes_icm_ossl.h b/libs/srtp/crypto/include/aes_icm_ossl.h new file mode 100644 index 0000000000..89da7e0693 --- /dev/null +++ b/libs/srtp/crypto/include/aes_icm_ossl.h @@ -0,0 +1,73 @@ +/* + * aes_icm.h + * + * Header for AES Integer Counter Mode. + * + * David A. McGrew + * Cisco Systems, Inc. + * + */ +/* + * + * Copyright (c) 2001-2005,2012, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef AES_ICM_H +#define AES_ICM_H + +#include "cipher.h" +#include +#include + +#define SALT_SIZE 14 +#define AES_128_KEYSIZE AES_BLOCK_SIZE +#define AES_192_KEYSIZE AES_BLOCK_SIZE + AES_BLOCK_SIZE / 2 +#define AES_256_KEYSIZE AES_BLOCK_SIZE * 2 +#define AES_128_KEYSIZE_WSALT AES_128_KEYSIZE + SALT_SIZE +#define AES_192_KEYSIZE_WSALT AES_192_KEYSIZE + SALT_SIZE +#define AES_256_KEYSIZE_WSALT AES_256_KEYSIZE + SALT_SIZE + +typedef struct { + v128_t counter; /* holds the counter value */ + v128_t offset; /* initial offset value */ + v256_t key; + int key_size; + EVP_CIPHER_CTX ctx; +} aes_icm_ctx_t; + +err_status_t aes_icm_openssl_set_iv(aes_icm_ctx_t *c, void *iv, int dir); + + +#endif /* AES_ICM_H */ + diff --git a/libs/srtp/crypto/include/cipher.h b/libs/srtp/crypto/include/cipher.h index eff6dd154b..f98d2398d1 100644 --- a/libs/srtp/crypto/include/cipher.h +++ b/libs/srtp/crypto/include/cipher.h @@ -8,7 +8,7 @@ */ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,11 +84,10 @@ typedef err_status_t (*cipher_alloc_func_t) /* * a cipher_init_func_t [re-]initializes a cipher_t with a given key - * and direction (i.e., encrypt or decrypt) */ typedef err_status_t (*cipher_init_func_t) -(void *state, const uint8_t *key, int key_len, cipher_direction_t dir); +(void *state, const uint8_t *key, int key_len); /* a cipher_dealloc_func_t de-allocates a cipher_t */ @@ -99,6 +98,13 @@ typedef err_status_t (*cipher_dealloc_func_t)(cipher_pointer_t cp); typedef err_status_t (*cipher_set_segment_func_t) (void *state, xtd_seq_num_t idx); +/* + * a cipher_set_aad_func_t processes the AAD data for AEAD ciphers + */ +typedef err_status_t (*cipher_set_aad_func_t) + (void *state, uint8_t *aad, unsigned int aad_len); + + /* a cipher_encrypt_func_t encrypts data in-place */ typedef err_status_t (*cipher_encrypt_func_t) @@ -114,7 +120,15 @@ typedef err_status_t (*cipher_decrypt_func_t) */ typedef err_status_t (*cipher_set_iv_func_t) - (cipher_pointer_t cp, void *iv); + (cipher_pointer_t cp, void *iv, cipher_direction_t direction); + +/* + * a cipher_get_tag_funct_t function is used to get the authentication + * tag that was calculated by an AEAD cipher. + */ +typedef err_status_t (*cipher_get_tag_func_t) + (void *state, void *tag, int *len); + /* * cipher_test_case_t is a (list of) key, salt, xtd_seq_num_t, @@ -132,6 +146,8 @@ typedef struct cipher_test_case_t { uint8_t *plaintext; /* plaintext */ int ciphertext_length_octets; /* octets in plaintext */ uint8_t *ciphertext; /* ciphertext */ + int aad_length_octets; /* octets in AAD */ + uint8_t *aad; /* AAD */ struct cipher_test_case_t *next_test_case; /* pointer to next testcase */ } cipher_test_case_t; @@ -141,9 +157,11 @@ typedef struct cipher_type_t { cipher_alloc_func_t alloc; cipher_dealloc_func_t dealloc; cipher_init_func_t init; + cipher_set_aad_func_t set_aad; cipher_encrypt_func_t encrypt; cipher_encrypt_func_t decrypt; cipher_set_iv_func_t set_iv; + cipher_get_tag_func_t get_tag; char *description; int ref_count; cipher_test_case_t *test_data; @@ -160,9 +178,7 @@ typedef struct cipher_t { cipher_type_t *type; void *state; int key_len; -#ifdef FORCE_64BIT_ALIGN - int pad; -#endif + int algorithm; } cipher_t; /* some syntactic sugar on these function types */ @@ -171,16 +187,23 @@ typedef struct cipher_t { #define cipher_dealloc(c) (((c)->type)->dealloc(c)) -#define cipher_init(c, k, dir) (((c)->type)->init(((c)->state), (k), ((c)->key_len), (dir))) +#define cipher_init(c, k) (((c)->type)->init(((c)->state), (k), ((c)->key_len))) #define cipher_encrypt(c, buf, len) \ (((c)->type)->encrypt(((c)->state), (buf), (len))) +#define cipher_get_tag(c, buf, len) \ + (((c)->type)->get_tag(((c)->state), (buf), (len))) + #define cipher_decrypt(c, buf, len) \ (((c)->type)->decrypt(((c)->state), (buf), (len))) -#define cipher_set_iv(c, n) \ - ((c) ? (((c)->type)->set_iv(((cipher_pointer_t)(c)->state), (n))) : \ +#define cipher_set_iv(c, n, dir) \ + ((c) ? (((c)->type)->set_iv(((cipher_pointer_t)(c)->state), (n), (dir))) : \ + err_status_no_such_op) +#define cipher_set_aad(c, a, l) \ + (((c) && (((c)->type)->set_aad)) ? \ + (((c)->type)->set_aad(((c)->state), (a), (l))) : \ err_status_no_such_op) err_status_t diff --git a/libs/srtp/crypto/include/crypto_types.h b/libs/srtp/crypto/include/crypto_types.h index 35317108c3..dbb50c37fe 100644 --- a/libs/srtp/crypto/include/crypto_types.h +++ b/libs/srtp/crypto/include/crypto_types.h @@ -8,7 +8,7 @@ */ /* * - * Copyright(c) 2001-2006 Cisco Systems, Inc. + * Copyright(c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -141,6 +141,34 @@ */ #define STRONGHOLD_CIPHER AES_ICM +/** + * @brief AES-192 Integer Counter Mode (AES ICM) + * AES-192 ICM is a deprecated alternate name for AES ICM. + */ +#define AES_192_ICM 4 + +/** + * @brief AES-256 Integer Counter Mode (AES ICM) + * AES-256 ICM is a deprecated alternate name for AES ICM. + */ +#define AES_256_ICM 5 + +/** + * @brief AES-128_GCM Galois Counter Mode (AES GCM) + * + * AES-128 GCM is the variant of galois counter mode that is used by + * Secure RTP. This cipher uses a 16-octet key. + */ +#define AES_128_GCM 6 + +/** + * @brief AES-256_GCM Galois Counter Mode (AES GCM) + * + * AES-256 GCM is the variant of galois counter mode that is used by + * Secure RTP. This cipher uses a 32-octet key. + */ +#define AES_256_GCM 7 + /** * @} */ diff --git a/libs/srtp/crypto/include/datatypes.h b/libs/srtp/crypto/include/datatypes.h index 6f18e9ebbf..11078e6dc4 100644 --- a/libs/srtp/crypto/include/datatypes.h +++ b/libs/srtp/crypto/include/datatypes.h @@ -92,6 +92,12 @@ typedef union { uint64_t v64[2]; } v128_t; +typedef union { + uint8_t v8[32]; + uint16_t v16[16]; + uint32_t v32[8]; + uint64_t v64[4]; +} v256_t; /* some useful and simple math functions */ @@ -393,7 +399,7 @@ octet_string_set_to_zero(uint8_t *s, int len); # define be64_to_cpu(x) bswap_64((x)) #else -#if defined(__GNUC__) && defined(HAVE_X86) && !defined(__FreeBSD__) +#if defined(__GNUC__) && defined(HAVE_X86) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) && !defined(__sun) /* Fall back. */ static inline uint32_t be32_to_cpu(uint32_t v) { /* optimized for x86. */ @@ -409,12 +415,16 @@ static inline uint32_t be32_to_cpu(uint32_t v) { # define be32_to_cpu(x) ntohl((x)) # endif /* HAVE_X86 */ +static inline uint64_t be64_to_cpu(uint64_t v) { # ifdef NO_64BIT_MATH /* use the make64 functions to do 64-bit math */ -# define be64_to_cpu(v) (make64(htonl(low32(v)),htonl(high32(v)))) + v = make64(htonl(low32(v)),htonl(high32(v))); # else -# define be64_to_cpu(v) ((ntohl((uint32_t)(v >> 32))) | (((uint64_t)ntohl((uint32_t)v)) << 32)) + /* use the native 64-bit math */ + v= (uint64_t)((be32_to_cpu((uint32_t)(v >> 32))) | (((uint64_t)be32_to_cpu((uint32_t)v)) << 32)); # endif + return v; +} #endif /* ! SRTP_KERNEL_LINUX */ diff --git a/libs/srtp/crypto/include/hmac.h b/libs/srtp/crypto/include/hmac.h index 262c0e2d6e..875f45c649 100644 --- a/libs/srtp/crypto/include/hmac.h +++ b/libs/srtp/crypto/include/hmac.h @@ -9,7 +9,7 @@ */ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013, Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,6 +53,10 @@ typedef struct { uint8_t opad[64]; sha1_ctx_t ctx; sha1_ctx_t init_ctx; +#ifdef OPENSSL + int ctx_initialized; + int init_ctx_initialized; +#endif } hmac_ctx_t; err_status_t diff --git a/libs/srtp/crypto/include/prng.h b/libs/srtp/crypto/include/prng.h index fb96b5ebaa..c493383cba 100644 --- a/libs/srtp/crypto/include/prng.h +++ b/libs/srtp/crypto/include/prng.h @@ -12,7 +12,12 @@ #include "rand_source.h" /* for rand_source_func_t definition */ #include "aes.h" /* for aes */ +//FIXME: this is temporary until we pull in the code to use OpenSSL for RNG +#ifdef OPENSSL +#include "aes_icm_ossl.h" /* for aes ctr */ +#else #include "aes_icm.h" /* for aes ctr */ +#endif #define MAX_PRNG_OUT_LEN 0xffffffffU diff --git a/libs/srtp/crypto/include/sha1.h b/libs/srtp/crypto/include/sha1.h index e3af4d4b4b..8b02f76811 100644 --- a/libs/srtp/crypto/include/sha1.h +++ b/libs/srtp/crypto/include/sha1.h @@ -48,6 +48,43 @@ #define SHA1_H #include "err.h" +#ifdef OPENSSL +#include + +typedef EVP_MD_CTX sha1_ctx_t; + +/* + * sha1_init(&ctx) initializes the SHA1 context ctx + * + * sha1_update(&ctx, msg, len) hashes the len octets starting at msg + * into the SHA1 context + * + * sha1_final(&ctx, output) performs the final processing of the SHA1 + * context and writes the result to the 20 octets at output + * + * Return values are ignored on the EVP functions since all three + * of these functions return void. + * + */ + +void inline sha1_init (sha1_ctx_t *ctx) +{ + EVP_MD_CTX_init(ctx); + EVP_DigestInit(ctx, EVP_sha1()); +} + +void inline sha1_update (sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg) +{ + EVP_DigestUpdate(ctx, M, octets_in_msg); +} + +void inline sha1_final (sha1_ctx_t *ctx, uint32_t *output) +{ + unsigned int len = 0; + + EVP_DigestFinal(ctx, (unsigned char*)output, &len); +} +#else #include "datatypes.h" typedef struct { @@ -104,5 +141,7 @@ sha1_final(sha1_ctx_t *ctx, uint32_t output[5]); void sha1_core(const uint32_t M[16], uint32_t hash_value[5]); + +#endif /* else OPENSSL */ #endif /* SHA1_H */ diff --git a/libs/srtp/crypto/kernel/alloc.c b/libs/srtp/crypto/kernel/alloc.c index 5dd0947490..150d60af82 100644 --- a/libs/srtp/crypto/kernel/alloc.c +++ b/libs/srtp/crypto/kernel/alloc.c @@ -73,8 +73,9 @@ crypto_alloc(size_t size) { if (ptr) { debug_print(mod_alloc, "(location: %p) allocated", ptr); - } else + } else { debug_print(mod_alloc, "allocation failed (asked for %d bytes)\n", size); + } return ptr; } diff --git a/libs/srtp/crypto/kernel/crypto_kernel.c b/libs/srtp/crypto/kernel/crypto_kernel.c index 90c4a3073a..656c010460 100644 --- a/libs/srtp/crypto/kernel/crypto_kernel.c +++ b/libs/srtp/crypto/kernel/crypto_kernel.c @@ -8,7 +8,7 @@ */ /* * - * Copyright(c) 2001-2006 Cisco Systems, Inc. + * Copyright(c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,7 +69,12 @@ extern debug_module_t mod_alloc; extern cipher_type_t null_cipher; extern cipher_type_t aes_icm; +#ifndef OPENSSL extern cipher_type_t aes_cbc; +#else +extern cipher_type_t aes_gcm_128_openssl; +extern cipher_type_t aes_gcm_256_openssl; +#endif /* @@ -137,6 +142,7 @@ crypto_kernel_init() { if (status) return status; +#ifndef OPENSSL /* initialize pseudorandom number generator */ status = ctr_prng_init(rand_source_get_octet_string); if (status) @@ -146,6 +152,7 @@ crypto_kernel_init() { status = stat_test_rand_source_with_repetition(ctr_prng_get_octet_string, MAX_RNG_TRIALS); if (status) return status; +#endif /* load cipher types */ status = crypto_kernel_load_cipher_type(&null_cipher, NULL_CIPHER); @@ -154,9 +161,20 @@ crypto_kernel_init() { status = crypto_kernel_load_cipher_type(&aes_icm, AES_ICM); if (status) return status; +#ifndef OPENSSL status = crypto_kernel_load_cipher_type(&aes_cbc, AES_CBC); if (status) return status; +#else + status = crypto_kernel_load_cipher_type(&aes_gcm_128_openssl, AES_128_GCM); + if (status) { + return status; + } + status = crypto_kernel_load_cipher_type(&aes_gcm_256_openssl, AES_256_GCM); + if (status) { + return status; + } +#endif /* load auth func types */ status = crypto_kernel_load_auth_type(&null_auth, NULL_AUTH); @@ -567,7 +585,11 @@ crypto_kernel_set_debug_module(char *name, int on) { err_status_t crypto_get_random(unsigned char *buffer, unsigned int length) { if (crypto_kernel.state == crypto_kernel_state_secure) +#ifdef OPENSSL + return rand_source_get_octet_string(buffer, length); +#else return ctr_prng_get_octet_string(buffer, length); +#endif else return err_status_fail; } diff --git a/libs/srtp/crypto/kernel/err.c b/libs/srtp/crypto/kernel/err.c index 6b00e7b877..4a3a8589e9 100644 --- a/libs/srtp/crypto/kernel/err.c +++ b/libs/srtp/crypto/kernel/err.c @@ -50,9 +50,6 @@ # endif #endif -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif /* err_level reflects the level of errors that are reported */ diff --git a/libs/srtp/crypto/math/stat.c b/libs/srtp/crypto/math/stat.c index a744f91f88..cf928a80f6 100644 --- a/libs/srtp/crypto/math/stat.c +++ b/libs/srtp/crypto/math/stat.c @@ -24,11 +24,11 @@ debug_module_t mod_stat = { err_status_t stat_test_monobit(uint8_t *data) { uint8_t *data_end = data + STAT_TEST_DATA_LEN; - int ones_count; + uint16_t ones_count; ones_count = 0; while (data < data_end) { - ones_count += octet_get_weight(*data); + ones_count += (uint16_t)octet_get_weight(*data); data++; } diff --git a/libs/srtp/crypto/replay/ut_sim.c b/libs/srtp/crypto/replay/ut_sim.c index 465e8c85ca..837aad7a3c 100644 --- a/libs/srtp/crypto/replay/ut_sim.c +++ b/libs/srtp/crypto/replay/ut_sim.c @@ -47,10 +47,6 @@ #include "ut_sim.h" -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif - int ut_compar(const void *a, const void *b) { return rand() > (RAND_MAX/2) ? -1 : 1; diff --git a/libs/srtp/crypto/rng/ctr_prng.c b/libs/srtp/crypto/rng/ctr_prng.c index 41d46a8f55..285124d415 100644 --- a/libs/srtp/crypto/rng/ctr_prng.c +++ b/libs/srtp/crypto/rng/ctr_prng.c @@ -66,7 +66,11 @@ ctr_prng_init(rand_source_func_t random_source) { return status; /* initialize aes ctr context with random key */ +#ifdef OPENSSL + status = aes_icm_openssl_context_init(&ctr_prng.state, tmp_key, 30); +#else status = aes_icm_context_init(&ctr_prng.state, tmp_key, 30); +#endif if (status) return status; diff --git a/libs/srtp/crypto/rng/rand_source_ossl.c b/libs/srtp/crypto/rng/rand_source_ossl.c new file mode 100644 index 0000000000..ee836ce750 --- /dev/null +++ b/libs/srtp/crypto/rng/rand_source_ossl.c @@ -0,0 +1,66 @@ +/* + * rand_source_ossl.c + * + * implements a random source based on OpenSSL RAND_bytes() + * + * John A. Foley + * Cisco Systems, Inc. + */ +/* + * + * Copyright(c) 2013, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met:crypto/test/aes_calc.c + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "rand_source.h" +#include + + +err_status_t rand_source_init (void) +{ + return err_status_ok; +} + +err_status_t rand_source_get_octet_string (void *dest, uint32_t len) +{ + if (RAND_bytes(dest, len) == 1) { + return err_status_ok; + } else { + return err_status_fail; + } +} + +err_status_t rand_source_deinit (void) +{ + return err_status_ok; +} diff --git a/libs/srtp/crypto/test/cipher_driver.c b/libs/srtp/crypto/test/cipher_driver.c index ea41ff5a4c..c4b4d668de 100644 --- a/libs/srtp/crypto/test/cipher_driver.c +++ b/libs/srtp/crypto/test/cipher_driver.c @@ -9,7 +9,7 @@ /* * - * Copyright (c) 2001-2006, Cisco Systems, Inc. + * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,12 @@ #include /* for memset() */ #include /* for getopt() */ #include "cipher.h" +#ifdef OPENSSL +#include "aes_icm_ossl.h" +#include "aes_gcm_ossl.h" +#else #include "aes_icm.h" +#endif #include "null_cipher.h" #define PRINT_DEBUG 0 @@ -114,7 +119,14 @@ check_status(err_status_t s) { extern cipher_type_t null_cipher; extern cipher_type_t aes_icm; +#ifndef OPENSSL extern cipher_type_t aes_cbc; +#else +extern cipher_type_t aes_icm_192; +extern cipher_type_t aes_icm_256; +extern cipher_type_t aes_gcm_128_openssl; +extern cipher_type_t aes_gcm_256_openssl; +#endif int main(int argc, char *argv[]) { @@ -171,6 +183,7 @@ main(int argc, char *argv[]) { for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) cipher_driver_test_array_throughput(&aes_icm, 30, num_cipher); +#ifndef OPENSSL for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) cipher_driver_test_array_throughput(&aes_icm, 46, num_cipher); @@ -179,19 +192,41 @@ main(int argc, char *argv[]) { for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) cipher_driver_test_array_throughput(&aes_cbc, 32, num_cipher); +#else + for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) + cipher_driver_test_array_throughput(&aes_icm_192, 38, num_cipher); + + for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) + cipher_driver_test_array_throughput(&aes_icm_256, 46, num_cipher); + + for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) { + cipher_driver_test_array_throughput(&aes_gcm_128_openssl, 30, num_cipher); + } + + for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8) { + cipher_driver_test_array_throughput(&aes_gcm_256_openssl, 46, num_cipher); + } +#endif } if (do_validation) { cipher_driver_self_test(&null_cipher); cipher_driver_self_test(&aes_icm); +#ifndef OPENSSL cipher_driver_self_test(&aes_cbc); +#else + cipher_driver_self_test(&aes_icm_192); + cipher_driver_self_test(&aes_icm_256); + cipher_driver_self_test(&aes_gcm_128_openssl); + cipher_driver_self_test(&aes_gcm_256_openssl); +#endif } /* do timing and/or buffer_test on null_cipher */ status = cipher_type_alloc(&null_cipher, &c, 0); check_status(status); - status = cipher_init(c, NULL, direction_encrypt); + status = cipher_init(c, NULL); check_status(status); if (do_timing_test) @@ -211,7 +246,7 @@ main(int argc, char *argv[]) { exit(status); } - status = cipher_init(c, test_key, direction_encrypt); + status = cipher_init(c, test_key); check_status(status); if (do_timing_test) @@ -226,13 +261,17 @@ main(int argc, char *argv[]) { check_status(status); /* repeat the tests with 256-bit keys */ +#ifndef OPENSSL status = cipher_type_alloc(&aes_icm, &c, 46); +#else + status = cipher_type_alloc(&aes_icm_256, &c, 46); +#endif if (status) { fprintf(stderr, "error: can't allocate cipher\n"); exit(status); } - status = cipher_init(c, test_key, direction_encrypt); + status = cipher_init(c, test_key); check_status(status); if (do_timing_test) @@ -245,8 +284,48 @@ main(int argc, char *argv[]) { status = cipher_dealloc(c); check_status(status); - - return 0; + +#ifdef OPENSSL + /* run the throughput test on the aes_gcm_128_openssl cipher */ + status = cipher_type_alloc(&aes_gcm_128_openssl, &c, 30); + if (status) { + fprintf(stderr, "error: can't allocate GCM 128 cipher\n"); + exit(status); + } + status = cipher_init(c, test_key); + check_status(status); + if (do_timing_test) { + cipher_driver_test_throughput(c); + } + + if (do_validation) { + status = cipher_driver_test_buffering(c); + check_status(status); + } + status = cipher_dealloc(c); + check_status(status); + + /* run the throughput test on the aes_gcm_256_openssl cipher */ + status = cipher_type_alloc(&aes_gcm_256_openssl, &c, 46); + if (status) { + fprintf(stderr, "error: can't allocate GCM 256 cipher\n"); + exit(status); + } + status = cipher_init(c, test_key); + check_status(status); + if (do_timing_test) { + cipher_driver_test_throughput(c); + } + + if (do_validation) { + status = cipher_driver_test_buffering(c); + check_status(status); + } + status = cipher_dealloc(c); + check_status(status); +#endif + + return 0; } void @@ -306,7 +385,7 @@ cipher_driver_test_buffering(cipher_t *c) { buffer0[j] = buffer1[j] = 0; /* initialize cipher */ - status = cipher_set_iv(c, idx); + status = cipher_set_iv(c, idx, direction_encrypt); if (status) return status; @@ -316,7 +395,7 @@ cipher_driver_test_buffering(cipher_t *c) { return status; /* re-initialize cipher */ - status = cipher_set_iv(c, idx); + status = cipher_set_iv(c, idx, direction_encrypt); if (status) return status; @@ -409,7 +488,7 @@ cipher_array_alloc_init(cipher_t ***ca, int num_ciphers, key[j] = (uint8_t) rand(); for (; j < klen_pad; j++) key[j] = 0; - status = cipher_init(*cipher_array, key, direction_encrypt); + status = cipher_init(*cipher_array, key); if (status) return status; @@ -476,7 +555,7 @@ cipher_array_bits_per_second(cipher_t *cipher_array[], int num_cipher, unsigned octets_to_encrypt = octets_in_buffer; /* encrypt buffer with cipher */ - cipher_set_iv(cipher_array[cipher_index], &nonce); + cipher_set_iv(cipher_array[cipher_index], &nonce, direction_encrypt); cipher_encrypt(cipher_array[cipher_index], enc_buf, &octets_to_encrypt); /* choose a cipher at random from the array*/ diff --git a/libs/srtp/crypto/test/env.c b/libs/srtp/crypto/test/env.c index 37a6e2731b..4967ad5050 100644 --- a/libs/srtp/crypto/test/env.c +++ b/libs/srtp/crypto/test/env.c @@ -80,6 +80,7 @@ main(void) { printf("using stdout for error reporting\t(ERR_REPORTING_STDOUT == 1)\n"); #endif +#ifndef OPENSSL #ifdef DEV_URANDOM str = DEV_URANDOM; #else @@ -90,6 +91,7 @@ main(void) { if (strcmp("", str) == 0) { err_count++; } +#endif if (err_count) printf("warning: configuration is probably in error " diff --git a/libs/srtp/crypto/test/stat_driver.c b/libs/srtp/crypto/test/stat_driver.c index f9d75b7656..b2738e8fb4 100644 --- a/libs/srtp/crypto/test/stat_driver.c +++ b/libs/srtp/crypto/test/stat_driver.c @@ -32,10 +32,14 @@ err_check(err_status_t s) { int main (int argc, char *argv[]) { - uint8_t buffer[2500]; + uint8_t buffer[2532]; unsigned int buf_len = 2500; int i, j; extern cipher_type_t aes_icm; +#ifdef OPENSSL + extern cipher_type_t aes_gcm_128_openssl; + extern cipher_type_t aes_gcm_256_openssl; +#endif cipher_t *c; uint8_t key[46] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -51,6 +55,7 @@ main (int argc, char *argv[]) { printf("statistical tests driver\n"); + v128_set_to_zero(&nonce); for (i=0; i < 2500; i++) buffer[i] = 0; @@ -72,8 +77,8 @@ main (int argc, char *argv[]) { for (i=0; i < 2500; i++) buffer[i] = 0; err_check(cipher_type_alloc(&aes_icm, &c, 30)); - err_check(cipher_init(c, key, direction_encrypt)); - err_check(cipher_set_iv(c, &nonce)); + err_check(cipher_init(c, key)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); err_check(cipher_encrypt(c, buffer, &buf_len)); /* run tests on cipher outout */ printf("monobit %d\n", stat_test_monobit(buffer)); @@ -88,7 +93,7 @@ main (int argc, char *argv[]) { for (i=0; i < 2500; i++) buffer[i] = 0; nonce.v32[3] = i; - err_check(cipher_set_iv(c, &nonce)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); err_check(cipher_encrypt(c, buffer, &buf_len)); if (stat_test_runs(buffer)) { num_fail++; @@ -106,8 +111,8 @@ main (int argc, char *argv[]) { for (i=0; i < 2500; i++) buffer[i] = 0; err_check(cipher_type_alloc(&aes_icm, &c, 46)); - err_check(cipher_init(c, key, direction_encrypt)); - err_check(cipher_set_iv(c, &nonce)); + err_check(cipher_init(c, key)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); err_check(cipher_encrypt(c, buffer, &buf_len)); /* run tests on cipher outout */ printf("monobit %d\n", stat_test_monobit(buffer)); @@ -122,13 +127,75 @@ main (int argc, char *argv[]) { for (i=0; i < 2500; i++) buffer[i] = 0; nonce.v32[3] = i; - err_check(cipher_set_iv(c, &nonce)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); err_check(cipher_encrypt(c, buffer, &buf_len)); if (stat_test_runs(buffer)) { num_fail++; } } +#ifdef OPENSSL + { + printf("running stat_tests on AES-128-GCM, expecting success\n"); + /* set buffer to cipher output */ + for (i=0; i < 2500; i++) { + buffer[i] = 0; + } + err_check(cipher_type_alloc(&aes_gcm_128_openssl, &c, 30)); + err_check(cipher_init(c, key)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); + err_check(cipher_encrypt(c, buffer, &buf_len)); + /* run tests on cipher outout */ + printf("monobit %d\n", stat_test_monobit(buffer)); + printf("poker %d\n", stat_test_poker(buffer)); + printf("runs %d\n", stat_test_runs(buffer)); + fflush(stdout); + num_fail = 0; + v128_set_to_zero(&nonce); + for(j=0; j < num_trials; j++) { + for (i=0; i < 2500; i++) { + buffer[i] = 0; + } + nonce.v32[3] = i; + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); + err_check(cipher_encrypt(c, buffer, &buf_len)); + buf_len = 2500; + if (stat_test_runs(buffer)) { + num_fail++; + } + } + + printf("running stat_tests on AES-256-GCM, expecting success\n"); + /* set buffer to cipher output */ + for (i=0; i < 2500; i++) { + buffer[i] = 0; + } + err_check(cipher_type_alloc(&aes_gcm_256_openssl, &c, 46)); + err_check(cipher_init(c, key)); + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); + err_check(cipher_encrypt(c, buffer, &buf_len)); + /* run tests on cipher outout */ + printf("monobit %d\n", stat_test_monobit(buffer)); + printf("poker %d\n", stat_test_poker(buffer)); + printf("runs %d\n", stat_test_runs(buffer)); + fflush(stdout); + num_fail = 0; + v128_set_to_zero(&nonce); + for(j=0; j < num_trials; j++) { + for (i=0; i < 2500; i++) { + buffer[i] = 0; + } + nonce.v32[3] = i; + err_check(cipher_set_iv(c, &nonce, direction_encrypt)); + err_check(cipher_encrypt(c, buffer, &buf_len)); + buf_len = 2500; + if (stat_test_runs(buffer)) { + num_fail++; + } + } + } +#endif + printf("%d failures in %d tests\n", num_fail, num_trials); printf("(nota bene: a small fraction of stat_test failures does not \n" "indicate that the random source is invalid)\n"); diff --git a/libs/srtp/doc/libsrtp.pdf b/libs/srtp/doc/libsrtp.pdf index 6f5e448e89..578f0c643c 100644 Binary files a/libs/srtp/doc/libsrtp.pdf and b/libs/srtp/doc/libsrtp.pdf differ diff --git a/libs/srtp/include/srtp.h b/libs/srtp/include/srtp.h index eb95e7d477..a9c73d46e7 100644 --- a/libs/srtp/include/srtp.h +++ b/libs/srtp/include/srtp.h @@ -88,6 +88,13 @@ extern "C" { */ #define SRTP_MAX_TRAILER_LEN SRTP_MAX_TAG_LEN +/* + * SRTP_AEAD_SALT_LEN is the length of the SALT values used with + * GCM mode. GCM mode requires an IV. The SALT value is used + * as part of the IV formation logic applied to each RTP packet. + */ +#define SRTP_AEAD_SALT_LEN 12 + /* * nota bene: since libSRTP doesn't support the use of the MKI, the * SRTP_MAX_TRAILER_LEN value is just the maximum tag length @@ -304,6 +311,11 @@ srtp_shutdown(void); * packet, and assumes that the RTP packet is aligned on a 32-bit * boundary. * + * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN + * into the location in memory immediately following the RTP packet. + * Callers MUST ensure that this much writable memory is available in + * the buffer that holds the RTP packet. + * * @param ctx is the SRTP context to use in processing the packet. * * @param rtp_hdr is a pointer to the RTP packet (before the call); after @@ -658,6 +670,130 @@ void crypto_policy_set_aes_cm_256_hmac_sha1_80(crypto_policy_t *p); void crypto_policy_set_aes_cm_256_hmac_sha1_32(crypto_policy_t *p); +/** + * @brief crypto_policy_set_aes_cm_256_null_auth() sets a crypto + * policy structure to an encryption-only policy + * + * @param p is a pointer to the policy structure to be set + * + * The function call crypto_policy_set_aes_cm_256_null_auth(&p) sets + * the crypto_policy_t at location p to use the SRTP default cipher + * (AES-256 Counter Mode), but to use no authentication method. This + * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 + * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). + * + * This function is a convenience that helps to avoid dealing directly + * with the policy data structure. You are encouraged to initialize + * policy elements with this function call. Doing so may allow your + * code to be forward compatible with later versions of libSRTP that + * include more elements in the crypto_policy_t datatype. + * + * @warning This policy is NOT RECOMMENDED for SRTP unless it is + * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see + * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). + * + * @return void. + * + */ +void +crypto_policy_set_aes_cm_256_null_auth(crypto_policy_t *p); + +/** + * @brief crypto_policy_set_aes_gcm_128_8_auth() sets a crypto + * policy structure to an AEAD encryption policy. + * + * @param p is a pointer to the policy structure to be set + * + * The function call crypto_policy_set_aes_gcm_128_8_auth(&p) sets + * the crypto_policy_t at location p to use the SRTP default cipher + * (AES-128 Galois Counter Mode) with 8 octet auth tag. This + * policy applies confidentiality and authentication to both the + * RTP and RTCP packets. + * + * This function is a convenience that helps to avoid dealing directly + * with the policy data structure. You are encouraged to initialize + * policy elements with this function call. Doing so may allow your + * code to be forward compatible with later versions of libSRTP that + * include more elements in the crypto_policy_t datatype. + * + * @return void. + * + */ +void +crypto_policy_set_aes_gcm_128_8_auth(crypto_policy_t *p); + +/** + * @brief crypto_policy_set_aes_gcm_256_8_auth() sets a crypto + * policy structure to an AEAD encryption policy + * + * @param p is a pointer to the policy structure to be set + * + * The function call crypto_policy_set_aes_gcm_256_8_auth(&p) sets + * the crypto_policy_t at location p to use the SRTP default cipher + * (AES-256 Galois Counter Mode) with 8 octet auth tag. This + * policy applies confidentiality and authentication to both the + * RTP and RTCP packets. + * + * This function is a convenience that helps to avoid dealing directly + * with the policy data structure. You are encouraged to initialize + * policy elements with this function call. Doing so may allow your + * code to be forward compatible with later versions of libSRTP that + * include more elements in the crypto_policy_t datatype. + * + * @return void. + * + */ +void +crypto_policy_set_aes_gcm_256_8_auth(crypto_policy_t *p); + +/** + * @brief crypto_policy_set_aes_gcm_128_8_only_auth() sets a crypto + * policy structure to an AEAD authentication-only policy + * + * @param p is a pointer to the policy structure to be set + * + * The function call crypto_policy_set_aes_gcm_128_8_only_auth(&p) sets + * the crypto_policy_t at location p to use the SRTP default cipher + * (AES-128 Galois Counter Mode) with 8 octet auth tag. This policy + * applies confidentiality and authentication to the RTP packets, + * but only authentication to the RTCP packets. + * + * This function is a convenience that helps to avoid dealing directly + * with the policy data structure. You are encouraged to initialize + * policy elements with this function call. Doing so may allow your + * code to be forward compatible with later versions of libSRTP that + * include more elements in the crypto_policy_t datatype. + * + * @return void. + * + */ +void +crypto_policy_set_aes_gcm_128_8_only_auth(crypto_policy_t *p); + +/** + * @brief crypto_policy_set_aes_gcm_256_8_only_auth() sets a crypto + * policy structure to an AEAD authentication-only policy + * + * @param p is a pointer to the policy structure to be set + * + * The function call crypto_policy_set_aes_gcm_256_8_only_auth(&p) sets + * the crypto_policy_t at location p to use the SRTP default cipher + * (AES-256 Galois Counter Mode) with 8 octet auth tag. This policy + * applies confidentiality and authentication to the RTP packets, + * but only authentication to the RTCP packets. + * + * This function is a convenience that helps to avoid dealing directly + * with the policy data structure. You are encouraged to initialize + * policy elements with this function call. Doing so may allow your + * code to be forward compatible with later versions of libSRTP that + * include more elements in the crypto_policy_t datatype. + * + * @return void. + * + */ +void +crypto_policy_set_aes_gcm_256_8_only_auth(crypto_policy_t *p); + /** * @brief srtp_dealloc() deallocates storage for an SRTP session @@ -823,6 +959,11 @@ append_salt_to_key(unsigned char *key, unsigned int bytes_in_key, * packet, and assumes that the RTCP packet is aligned on a 32-bit * boundary. * + * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 + * into the location in memory immediately following the RTCP packet. + * Callers MUST ensure that this much writable memory is available in + * the buffer that holds the RTCP packet. + * * @param ctx is the SRTP context to use in processing the packet. * * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after diff --git a/libs/srtp/include/srtp_priv.h b/libs/srtp/include/srtp_priv.h index 8425b351ce..270ebafca5 100644 --- a/libs/srtp/include/srtp_priv.h +++ b/libs/srtp/include/srtp_priv.h @@ -77,7 +77,7 @@ typedef struct { unsigned m:1; /* marker bit */ unsigned seq:16; /* sequence number */ unsigned ts:32; /* timestamp */ - unsigned ssrc:32; /* synchronization source */ + uint32_t ssrc; /* synchronization source */ } srtp_hdr_t; #else /* BIG_ENDIAN */ @@ -91,7 +91,7 @@ typedef struct { unsigned pt:7; /* payload type */ unsigned seq:16; /* sequence number */ unsigned ts:32; /* timestamp */ - unsigned ssrc:32; /* synchronization source */ + uint32_t ssrc; /* synchronization source */ } srtp_hdr_t; #endif @@ -117,7 +117,7 @@ typedef struct { unsigned version:2; /* protocol version */ unsigned pt:8; /* payload type */ unsigned len:16; /* length */ - unsigned ssrc:32; /* synchronization source */ + uint32_t ssrc; /* synchronization source */ } srtcp_hdr_t; typedef struct { @@ -133,10 +133,10 @@ typedef struct { typedef struct { unsigned version:2; /* protocol version */ unsigned p:1; /* padding flag */ - unsigned rc:5; /* reception report count */ - unsigned pt:8; /* payload type */ - uint16_t len; /* length */ - uint32_t ssrc; /* synchronization source */ + unsigned rc:5; /* reception report count */ + unsigned pt:8; /* payload type */ + uint16_t len; /* length */ + uint32_t ssrc; /* synchronization source */ } srtcp_hdr_t; typedef struct { @@ -220,6 +220,8 @@ typedef struct srtp_stream_ctx_t { direction_t direction; int allow_repeat_tx; ekt_stream_t ekt; + uint8_t salt[SRTP_AEAD_SALT_LEN]; /* used with GCM mode for SRTP */ + uint8_t c_salt[SRTP_AEAD_SALT_LEN]; /* used with GCM mode for SRTCP */ struct srtp_stream_ctx_t *next; /* linked list of streams */ } srtp_stream_ctx_t; diff --git a/libs/srtp/libsrtp.2010.vcxproj b/libs/srtp/libsrtp.2010.vcxproj index 554e943fe0..56a6ba6cf7 100644 --- a/libs/srtp/libsrtp.2010.vcxproj +++ b/libs/srtp/libsrtp.2010.vcxproj @@ -136,6 +136,7 @@ false Level4 true + 4305;4100;4244;%(DisableSpecificWarnings) @@ -156,6 +157,7 @@ Default Level4 false + 4305;4100;4244;%(DisableSpecificWarnings) @@ -170,6 +172,7 @@ Default Level4 true + 4305;4100;4244;%(DisableSpecificWarnings) @@ -187,6 +190,7 @@ Default Level4 false + 4305;4100;4244;%(DisableSpecificWarnings) diff --git a/libs/srtp/libsrtp.2012.vcxproj b/libs/srtp/libsrtp.2012.vcxproj index 331131a10e..473bf9a314 100644 --- a/libs/srtp/libsrtp.2012.vcxproj +++ b/libs/srtp/libsrtp.2012.vcxproj @@ -144,6 +144,7 @@ false Level4 true + 4305;4100;4244;%(DisableSpecificWarnings) @@ -164,6 +165,7 @@ Default Level4 false + 4305;4100;4244;%(DisableSpecificWarnings) @@ -178,6 +180,7 @@ Default Level4 true + 4305;4100;4244;%(DisableSpecificWarnings) @@ -195,6 +198,7 @@ Default Level4 false + 4305;4100;4244;%(DisableSpecificWarnings) @@ -224,6 +228,7 @@ Level4 true EditAndContinue + 4305;%(DisableSpecificWarnings) Ws2_32.lib;%(AdditionalDependencies) @@ -266,6 +271,7 @@ Level4 true ProgramDatabase + 4305;%(DisableSpecificWarnings) Ws2_32.lib;%(AdditionalDependencies) @@ -303,6 +309,7 @@ Level4 true ProgramDatabase + 4305;%(DisableSpecificWarnings) Ws2_32.lib;%(AdditionalDependencies) @@ -337,6 +344,7 @@ Level4 true ProgramDatabase + 4305;%(DisableSpecificWarnings) Ws2_32.lib;%(AdditionalDependencies) diff --git a/libs/srtp/libsrtp.2012.vcxproj.filters b/libs/srtp/libsrtp.2012.vcxproj.filters index 80b52717d3..ba160b64ac 100644 --- a/libs/srtp/libsrtp.2012.vcxproj.filters +++ b/libs/srtp/libsrtp.2012.vcxproj.filters @@ -96,6 +96,9 @@ Source Files\Math + + Source Files + diff --git a/libs/srtp/srtp/ekt.c b/libs/srtp/srtp/ekt.c index 03300691f8..1079809d8f 100644 --- a/libs/srtp/srtp/ekt.c +++ b/libs/srtp/srtp/ekt.c @@ -47,9 +47,6 @@ #include "srtp_priv.h" #include "ekt.h" -#ifdef _MSC_VER -#pragma warning(disable:4100) -#endif extern debug_module_t mod_srtp; @@ -152,10 +149,13 @@ ekt_stream_init_from_policy(ekt_stream_t stream_data, ekt_policy_t policy) { void aes_decrypt_with_raw_key(void *ciphertext, const void *key, int key_len) { +#ifndef OPENSSL +//FIXME: need to get this working through the crypto module interface aes_expanded_key_t expanded_key; aes_expand_decryption_key(key, key_len, &expanded_key); aes_decrypt(ciphertext, &expanded_key); +#endif } /* @@ -170,7 +170,6 @@ srtp_stream_init_from_ekt(srtp_stream_t stream, err_status_t err; const uint8_t *master_key; srtp_policy_t srtp_policy; - unsigned master_key_len; uint32_t roc; /* @@ -182,7 +181,6 @@ srtp_stream_init_from_ekt(srtp_stream_t stream, if (stream->ekt->data->ekt_cipher_type != EKT_CIPHER_AES_128_ECB) return err_status_bad_param; - master_key_len = 16; /* decrypt the Encrypted Master Key field */ master_key = srtcp_packet_get_emk_location(srtcp_hdr, pkt_octet_len); diff --git a/libs/srtp/srtp/srtp.c b/libs/srtp/srtp/srtp.c index a1f1fc8327..4dbda3e272 100644 --- a/libs/srtp/srtp/srtp.c +++ b/libs/srtp/srtp/srtp.c @@ -232,6 +232,13 @@ srtp_stream_dealloc(srtp_t session, srtp_stream_ctx_t *stream) { return status; /* DAM - need to deallocate EKT here */ + + /* + * zeroize the salt value + */ + memset(stream->salt, 0, SRTP_AEAD_SALT_LEN); + memset(stream->c_salt, 0, SRTP_AEAD_SALT_LEN); + /* deallocate srtp stream context */ crypto_free(stream); @@ -271,14 +278,20 @@ srtp_stream_clone(const srtp_stream_ctx_t *stream_template, /* set key limit to point to that of the template */ status = key_limit_clone(stream_template->limit, &str->limit); - if (status) + if (status) { + crypto_free(*str_ptr); + *str_ptr = NULL; return status; + } /* initialize replay databases */ status = rdbx_init(&str->rtp_rdbx, rdbx_get_window_size(&stream_template->rtp_rdbx)); - if (status) + if (status) { + crypto_free(*str_ptr); + *str_ptr = NULL; return status; + } rdb_init(&str->rtcp_rdb); str->allow_repeat_tx = stream_template->allow_repeat_tx; @@ -293,6 +306,10 @@ srtp_stream_clone(const srtp_stream_ctx_t *stream_template, /* set pointer to EKT data associated with stream */ str->ekt = stream_template->ekt; + /* Copy the salt values */ + memcpy(str->salt, stream_template->salt, SRTP_AEAD_SALT_LEN); + memcpy(str->c_salt, stream_template->c_salt, SRTP_AEAD_SALT_LEN); + /* defensive coding */ str->next = NULL; @@ -343,7 +360,7 @@ srtp_kdf_init(srtp_kdf_t *kdf, cipher_type_id_t cipher_id, const uint8_t *key, i if (stat) return stat; - stat = cipher_init(kdf->cipher, key, direction_encrypt); + stat = cipher_init(kdf->cipher, key); if (stat) { cipher_dealloc(kdf->cipher); return stat; @@ -363,7 +380,7 @@ srtp_kdf_generate(srtp_kdf_t *kdf, srtp_prf_label label, v128_set_to_zero(&nonce); nonce.v8[7] = label; - status = cipher_set_iv(kdf->cipher, &nonce); + status = cipher_set_iv(kdf->cipher, &nonce, direction_encrypt); if (status) return status; @@ -401,11 +418,24 @@ srtp_kdf_clear(srtp_kdf_t *kdf) { * TODO: key and salt lengths should be separate fields in the policy. */ static inline int base_key_length(const cipher_type_t *cipher, int key_length) { - if (cipher->id != AES_ICM) - return key_length; - else if (key_length > 16 && key_length < 30) + switch (cipher->id) { + case AES_128_ICM: + case AES_192_ICM: + case AES_256_ICM: + /* The legacy modes are derived from + * the configured key length on the policy */ + return key_length - 14; + break; + case AES_128_GCM: return 16; - return key_length - 14; + break; + case AES_256_GCM: + return 32; + break; + default: + return key_length; + break; + } } err_status_t @@ -427,6 +457,8 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { rtcp_keylen = cipher_get_key_length(srtp->rtcp_cipher); if (rtcp_keylen > kdf_keylen) kdf_keylen = rtcp_keylen; + debug_print(mod_srtp, "srtp key len: %d", rtp_keylen); + debug_print(mod_srtp, "srtcp key len: %d", rtcp_keylen); /* initialize KDF state */ stat = srtp_kdf_init(&kdf, AES_ICM, (const uint8_t *)key, kdf_keylen); @@ -436,6 +468,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { rtp_base_key_len = base_key_length(srtp->rtp_cipher->type, rtp_keylen); rtp_salt_len = rtp_keylen - rtp_base_key_len; + debug_print(mod_srtp, "rtp salt len: %d", rtp_salt_len); /* generate encryption key */ stat = srtp_kdf_generate(&kdf, label_rtp_encryption, @@ -461,6 +494,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN); return err_status_init_fail; } + memcpy(srtp->salt, tmp_key + rtp_base_key_len, SRTP_AEAD_SALT_LEN); } debug_print(mod_srtp, "cipher key: %s", octet_string_hex_string(tmp_key, rtp_base_key_len)); @@ -470,7 +504,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { } /* initialize cipher */ - stat = cipher_init(srtp->rtp_cipher, tmp_key, direction_any); + stat = cipher_init(srtp->rtp_cipher, tmp_key); if (stat) { /* zeroize temp buffer */ octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN); @@ -503,6 +537,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { rtcp_base_key_len = base_key_length(srtp->rtcp_cipher->type, rtcp_keylen); rtcp_salt_len = rtcp_keylen - rtcp_base_key_len; + debug_print(mod_srtp, "rtcp salt len: %d", rtcp_salt_len); /* generate encryption key */ stat = srtp_kdf_generate(&kdf, label_rtcp_encryption, @@ -529,6 +564,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN); return err_status_init_fail; } + memcpy(srtp->c_salt, tmp_key + rtcp_base_key_len, SRTP_AEAD_SALT_LEN); } debug_print(mod_srtp, "rtcp cipher key: %s", octet_string_hex_string(tmp_key, rtcp_base_key_len)); @@ -538,7 +574,7 @@ srtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) { } /* initialize cipher */ - stat = cipher_init(srtp->rtcp_cipher, tmp_key, direction_any); + stat = cipher_init(srtp->rtcp_cipher, tmp_key); if (stat) { /* zeroize temp buffer */ octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN); @@ -711,6 +747,365 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, return err_status_ok; } +/* + * AEAD uses a new IV formation method. This function implements + * section 9.1 from draft-ietf-avtcore-srtp-aes-gcm-07.txt. The + * calculation is defined as, where (+) is the xor operation: + * + * + * 0 0 0 0 0 0 0 0 0 0 1 1 + * 0 1 2 3 4 5 6 7 8 9 0 1 + * +--+--+--+--+--+--+--+--+--+--+--+--+ + * |00|00| SSRC | ROC | SEQ |---+ + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | Encryption Salt |->(+) + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | Initialization Vector |<--+ + * +--+--+--+--+--+--+--+--+--+--+--+--+* + * + * Input: *stream - pointer to SRTP stream context, used to retrieve + * the SALT + * *iv - Pointer to receive the calculated IV + * *seq - The ROC and SEQ value to use for the + * IV calculation. + * *hdr - The RTP header, used to get the SSRC value + * + */ +static void srtp_calc_aead_iv(srtp_stream_ctx_t *stream, v128_t *iv, + xtd_seq_num_t *seq, srtp_hdr_t *hdr) +{ + v128_t in; + v128_t salt; + v128_t roc_seq; + + memset(&in, 0, sizeof(v128_t)); + memset(&salt, 0, sizeof(v128_t)); + + /* + * Convert seq# to v128_t so we can manipulate the byte order + */ + v128_copy_octet_string(&roc_seq, (const uint8_t *)seq); + debug_print(mod_srtp, "GCM/CCM ROC/SEQ = %s\n", v128_hex_string(&roc_seq)); + + /* + * Now move ROC and SEQ into input array in the + * proper order + */ + in.v8[11] = roc_seq.v8[0]; + in.v8[10] = roc_seq.v8[1]; + in.v8[9] = roc_seq.v8[2]; + in.v8[8] = roc_seq.v8[3]; + in.v8[7] = roc_seq.v8[4]; + in.v8[6] = roc_seq.v8[5]; + + /* + * Copy in the RTP SSRC value + */ + memcpy(&in.v8[2], &hdr->ssrc, 4); + debug_print(mod_srtp, "Pre-salted RTP IV = %s\n", v128_hex_string(&in)); + + /* + * Get the SALT value from the context + */ + memcpy(salt.v8, stream->salt, SRTP_AEAD_SALT_LEN); + debug_print(mod_srtp, "RTP SALT = %s\n", v128_hex_string(&salt)); + + /* + * Finally, apply tyhe SALT to the input + */ + v128_xor(iv, &in, &salt); +} + + +/* + * This function handles outgoing SRTP packets while in AEAD mode, + * which currently supports AES-GCM encryption. All packets are + * encrypted and authenticated. + */ +static err_status_t +srtp_protect_aead (srtp_ctx_t *ctx, srtp_stream_ctx_t *stream, + void *rtp_hdr, int *pkt_octet_len) +{ + srtp_hdr_t *hdr = (srtp_hdr_t*)rtp_hdr; + uint32_t *enc_start; /* pointer to start of encrypted portion */ + unsigned enc_octet_len = 0; /* number of octets in encrypted portion */ + xtd_seq_num_t est; /* estimated xtd_seq_num_t of *hdr */ + int delta; /* delta of local pkt idx and that in hdr */ + err_status_t status; + int tag_len; + v128_t iv; + unsigned int aad_len; + + debug_print(mod_srtp, "function srtp_protect_aead", NULL); + + /* + * update the key usage limit, and check it to make sure that we + * didn't just hit either the soft limit or the hard limit, and call + * the event handler if we hit either. + */ + switch (key_limit_update(stream->limit)) { + case key_event_normal: + break; + case key_event_hard_limit: + srtp_handle_event(ctx, stream, event_key_hard_limit); + return err_status_key_expired; + case key_event_soft_limit: + default: + srtp_handle_event(ctx, stream, event_key_soft_limit); + break; + } + + /* get tag length from stream */ + tag_len = auth_get_tag_length(stream->rtp_auth); + + /* + * find starting point for encryption and length of data to be + * encrypted - the encrypted portion starts after the rtp header + * extension, if present; otherwise, it starts after the last csrc, + * if any are present + * + * if we're not providing confidentiality, set enc_start to NULL + */ + if (stream->rtp_services & sec_serv_conf) { + enc_start = (uint32_t*)hdr + uint32s_in_rtp_header + hdr->cc; + if (hdr->x == 1) { + srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t*)enc_start; + enc_start += (ntohs(xtn_hdr->length) + 1); + } + enc_octet_len = (unsigned int)(*pkt_octet_len - + ((enc_start - (uint32_t*)hdr) << 2)); + } else { + enc_start = NULL; + } + + /* + * estimate the packet index using the start of the replay window + * and the sequence number from the header + */ + delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs(hdr->seq)); + status = rdbx_check(&stream->rtp_rdbx, delta); + if (status) { + if (status != err_status_replay_fail || !stream->allow_repeat_tx) { + return status; /* we've been asked to reuse an index */ + } + } else { + rdbx_add_index(&stream->rtp_rdbx, delta); + } + +#ifdef NO_64BIT_MATH + debug_print2(mod_srtp, "estimated packet index: %08x%08x", + high32(est), low32(est)); +#else + debug_print(mod_srtp, "estimated packet index: %016llx", est); +#endif + + /* + * AEAD uses a new IV formation method + */ + srtp_calc_aead_iv(stream, &iv, &est, hdr); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_encrypt); + if (status) { + return err_status_cipher_fail; + } + + /* shift est, put into network byte order */ +#ifdef NO_64BIT_MATH + est = be64_to_cpu(make64((high32(est) << 16) | + (low32(est) >> 16), + low32(est) << 16)); +#else + est = be64_to_cpu(est << 16); +#endif + + /* + * Set the AAD over the RTP header + */ + aad_len = (uint8_t *)enc_start - (uint8_t *)hdr; + status = cipher_set_aad(stream->rtp_cipher, (uint8_t*)hdr, aad_len); + if (status) { + return ( err_status_cipher_fail); + } + + /* Encrypt the payload */ + status = cipher_encrypt(stream->rtp_cipher, + (uint8_t*)enc_start, &enc_octet_len); + if (status) { + return err_status_cipher_fail; + } + /* + * If we're doing GCM, we need to get the tag + * and append that to the output + */ + status = cipher_get_tag(stream->rtp_cipher, + (uint8_t*)enc_start+enc_octet_len, &tag_len); + if (status) { + return ( err_status_cipher_fail); + } + enc_octet_len += tag_len; + + /* increase the packet length by the length of the auth tag */ + *pkt_octet_len += tag_len; + + return err_status_ok; +} + + +/* + * This function handles incoming SRTP packets while in AEAD mode, + * which currently supports AES-GCM encryption. All packets are + * encrypted and authenticated. Note, the auth tag is at the end + * of the packet stream and is automatically checked by GCM + * when decrypting the payload. + */ +static err_status_t +srtp_unprotect_aead (srtp_ctx_t *ctx, srtp_stream_ctx_t *stream, int delta, + xtd_seq_num_t est, void *srtp_hdr, int *pkt_octet_len) +{ + srtp_hdr_t *hdr = (srtp_hdr_t*)srtp_hdr; + uint32_t *enc_start; /* pointer to start of encrypted portion */ + unsigned enc_octet_len = 0; /* number of octets in encrypted portion */ + v128_t iv; + err_status_t status; + int tag_len; + unsigned int aad_len; + + debug_print(mod_srtp, "function srtp_unprotect_aead", NULL); + +#ifdef NO_64BIT_MATH + debug_print2(mod_srtp, "estimated u_packet index: %08x%08x", high32(est), low32(est)); +#else + debug_print(mod_srtp, "estimated u_packet index: %016llx", est); +#endif + + /* get tag length from stream */ + tag_len = auth_get_tag_length(stream->rtp_auth); + + /* + * AEAD uses a new IV formation method + */ + srtp_calc_aead_iv(stream, &iv, &est, hdr); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_decrypt); + if (status) { + return err_status_cipher_fail; + } + + /* + * find starting point for decryption and length of data to be + * decrypted - the encrypted portion starts after the rtp header + * extension, if present; otherwise, it starts after the last csrc, + * if any are present + */ + enc_start = (uint32_t*)hdr + uint32s_in_rtp_header + hdr->cc; + if (hdr->x == 1) { + srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t*)enc_start; + enc_start += (ntohs(xtn_hdr->length) + 1); + } + /* + * We pass the tag down to the cipher when doing GCM mode + */ + enc_octet_len = (unsigned int) *pkt_octet_len - + ((enc_start - (uint32_t *)hdr) << 2); + + /* + * update the key usage limit, and check it to make sure that we + * didn't just hit either the soft limit or the hard limit, and call + * the event handler if we hit either. + */ + switch (key_limit_update(stream->limit)) { + case key_event_normal: + break; + case key_event_soft_limit: + srtp_handle_event(ctx, stream, event_key_soft_limit); + break; + case key_event_hard_limit: + srtp_handle_event(ctx, stream, event_key_hard_limit); + return err_status_key_expired; + default: + break; + } + + /* + * Set the AAD for AES-GCM, which is the RTP header + */ + aad_len = (uint8_t *)enc_start - (uint8_t *)hdr; + status = cipher_set_aad(stream->rtp_cipher, (uint8_t*)hdr, aad_len); + if (status) { + return ( err_status_cipher_fail); + } + + /* Decrypt the ciphertext. This also checks the auth tag based + * on the AAD we just specified above */ + status = cipher_decrypt(stream->rtp_cipher, + (uint8_t*)enc_start, &enc_octet_len); + if (status) { + return status; + } + + /* + * verify that stream is for received traffic - this check will + * detect SSRC collisions, since a stream that appears in both + * srtp_protect() and srtp_unprotect() will fail this test in one of + * those functions. + * + * we do this check *after* the authentication check, so that the + * latter check will catch any attempts to fool us into thinking + * that we've got a collision + */ + if (stream->direction != dir_srtp_receiver) { + if (stream->direction == dir_unknown) { + stream->direction = dir_srtp_receiver; + } else { + srtp_handle_event(ctx, stream, event_ssrc_collision); + } + } + + /* + * if the stream is a 'provisional' one, in which the template context + * is used, then we need to allocate a new stream at this point, since + * the authentication passed + */ + if (stream == ctx->stream_template) { + srtp_stream_ctx_t *new_stream; + + /* + * allocate and initialize a new stream + * + * note that we indicate failure if we can't allocate the new + * stream, and some implementations will want to not return + * failure here + */ + status = srtp_stream_clone(ctx->stream_template, hdr->ssrc, &new_stream); + if (status) { + return status; + } + + /* add new stream to the head of the stream_list */ + new_stream->next = ctx->stream_list; + ctx->stream_list = new_stream; + + /* set stream (the pointer used in this function) */ + stream = new_stream; + } + + /* + * the message authentication function passed, so add the packet + * index into the replay database + */ + rdbx_add_index(&stream->rtp_rdbx, delta); + + /* decrease the packet length by the length of the auth tag */ + *pkt_octet_len -= tag_len; + + return err_status_ok; +} + + + + err_status_t srtp_protect(srtp_ctx_t *ctx, void *rtp_hdr, int *pkt_octet_len) { srtp_hdr_t *hdr = (srtp_hdr_t *)rtp_hdr; @@ -772,13 +1167,22 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, * srtp_protect() and srtp_unprotect() will fail this test in one of * those functions. */ - if (stream->direction != dir_srtp_sender) { + if (stream->direction != dir_srtp_sender) { if (stream->direction == dir_unknown) { stream->direction = dir_srtp_sender; } else { srtp_handle_event(ctx, stream, event_ssrc_collision); } - } + } + + /* + * Check if this is an AEAD stream (GCM mode). If so, then dispatch + * the request to our AEAD handler. + */ + if (stream->rtp_cipher->algorithm == AES_128_GCM || + stream->rtp_cipher->algorithm == AES_256_GCM) { + return srtp_protect_aead(ctx, stream, rtp_hdr, pkt_octet_len); + } /* * update the key usage limit, and check it to make sure that we @@ -838,7 +1242,7 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, * estimate the packet index using the start of the replay window * and the sequence number from the header */ - delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs((uint16_t)hdr->seq)); + delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs(hdr->seq)); status = rdbx_check(&stream->rtp_rdbx, delta); if (status) { if (status != err_status_replay_fail || !stream->allow_repeat_tx) @@ -857,7 +1261,8 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, /* * if we're using rindael counter mode, set nonce and seq */ - if (stream->rtp_cipher->type->id == AES_ICM) { + if (stream->rtp_cipher->type->id == AES_ICM || + stream->rtp_cipher->type->id == AES_256_ICM) { v128_t iv; iv.v32[0] = 0; @@ -868,7 +1273,7 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, #else iv.v64[1] = be64_to_cpu(est << 16); #endif - status = cipher_set_iv(stream->rtp_cipher, &iv); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_encrypt); } else { v128_t iv; @@ -881,7 +1286,7 @@ srtp_stream_init(srtp_stream_ctx_t *srtp, iv.v64[0] = 0; #endif iv.v64[1] = be64_to_cpu(est); - status = cipher_set_iv(stream->rtp_cipher, &iv); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_encrypt); } if (status) return err_status_cipher_fail; @@ -999,7 +1404,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { est = (xtd_seq_num_t) make64(0,ntohs(hdr->seq)); delta = low32(est); #else - est = (xtd_seq_num_t) ntohs((uint16_t)hdr->seq); + est = (xtd_seq_num_t) ntohs(hdr->seq); delta = (int)est; #endif } else { @@ -1013,7 +1418,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { } else { /* estimate packet index from seq. num. in header */ - delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs((uint16_t)hdr->seq)); + delta = rdbx_estimate_index(&stream->rtp_rdbx, &est, ntohs(hdr->seq)); /* check replay database */ status = rdbx_check(&stream->rtp_rdbx, delta); @@ -1027,6 +1432,15 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { debug_print(mod_srtp, "estimated u_packet index: %016llx", est); #endif + /* + * Check if this is an AEAD stream (GCM mode). If so, then dispatch + * the request to our AEAD handler. + */ + if (stream->rtp_cipher->algorithm == AES_128_GCM || + stream->rtp_cipher->algorithm == AES_256_GCM) { + return srtp_unprotect_aead(ctx, stream, delta, est, srtp_hdr, pkt_octet_len); + } + /* get tag length from stream */ tag_len = auth_get_tag_length(stream->rtp_auth); @@ -1034,7 +1448,8 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { * set the cipher's IV properly, depending on whatever cipher we * happen to be using */ - if (stream->rtp_cipher->type->id == AES_ICM) { + if (stream->rtp_cipher->type->id == AES_ICM || + stream->rtp_cipher->type->id == AES_256_ICM) { /* aes counter mode */ iv.v32[0] = 0; @@ -1045,7 +1460,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { #else iv.v64[1] = be64_to_cpu(est << 16); #endif - status = cipher_set_iv(stream->rtp_cipher, &iv); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_decrypt); } else { /* no particular format - set the iv to the pakcet index */ @@ -1056,7 +1471,7 @@ srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len) { iv.v64[0] = 0; #endif iv.v64[1] = be64_to_cpu(est); - status = cipher_set_iv(stream->rtp_cipher, &iv); + status = cipher_set_iv(stream->rtp_cipher, &iv, direction_decrypt); } if (status) return err_status_cipher_fail; @@ -1613,11 +2028,470 @@ crypto_policy_set_aes_cm_256_hmac_sha1_32(crypto_policy_t *p) { p->sec_serv = sec_serv_conf_and_auth; } +/* + * AES-256 with no authentication. + */ +void +crypto_policy_set_aes_cm_256_null_auth (crypto_policy_t *p) +{ + p->cipher_type = AES_ICM; + p->cipher_key_len = 46; + p->auth_type = NULL_AUTH; + p->auth_key_len = 0; + p->auth_tag_len = 0; + p->sec_serv = sec_serv_conf; +} + +#ifdef OPENSSL +/* + * AES-128 GCM mode with 8 octet auth tag. + */ +void +crypto_policy_set_aes_gcm_128_8_auth(crypto_policy_t *p) { + p->cipher_type = AES_128_GCM; + p->cipher_key_len = AES_128_KEYSIZE_WSALT; + p->auth_type = NULL_AUTH; /* GCM handles the auth for us */ + p->auth_key_len = 0; + p->auth_tag_len = 8; /* 8 octet tag length */ + p->sec_serv = sec_serv_conf_and_auth; +} + +/* + * AES-256 GCM mode with 8 octet auth tag. + */ +void +crypto_policy_set_aes_gcm_256_8_auth(crypto_policy_t *p) { + p->cipher_type = AES_256_GCM; + p->cipher_key_len = AES_256_KEYSIZE_WSALT; + p->auth_type = NULL_AUTH; /* GCM handles the auth for us */ + p->auth_key_len = 0; + p->auth_tag_len = 8; /* 8 octet tag length */ + p->sec_serv = sec_serv_conf_and_auth; +} + +/* + * AES-128 GCM mode with 8 octet auth tag, no RTCP encryption. + */ +void +crypto_policy_set_aes_gcm_128_8_only_auth(crypto_policy_t *p) { + p->cipher_type = AES_128_GCM; + p->cipher_key_len = AES_128_KEYSIZE_WSALT; + p->auth_type = NULL_AUTH; /* GCM handles the auth for us */ + p->auth_key_len = 0; + p->auth_tag_len = 8; /* 8 octet tag length */ + p->sec_serv = sec_serv_auth; /* This only applies to RTCP */ +} + +/* + * AES-256 GCM mode with 8 octet auth tag, no RTCP encryption. + */ +void +crypto_policy_set_aes_gcm_256_8_only_auth(crypto_policy_t *p) { + p->cipher_type = AES_256_GCM; + p->cipher_key_len = AES_256_KEYSIZE_WSALT; + p->auth_type = NULL_AUTH; /* GCM handles the auth for us */ + p->auth_key_len = 0; + p->auth_tag_len = 8; /* 8 octet tag length */ + p->sec_serv = sec_serv_auth; /* This only applies to RTCP */ +} +#endif /* * secure rtcp functions */ +/* + * AEAD uses a new IV formation method. This function implements + * section 10.1 from draft-ietf-avtcore-srtp-aes-gcm-07.txt. The + * calculation is defined as, where (+) is the xor operation: + * + * 0 1 2 3 4 5 6 7 8 9 10 11 + * +--+--+--+--+--+--+--+--+--+--+--+--+ + * |00|00| SSRC |00|00|0+SRTCP Idx|---+ + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | Encryption Salt |->(+) + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | + * +--+--+--+--+--+--+--+--+--+--+--+--+ | + * | Initialization Vector |<--+ + * +--+--+--+--+--+--+--+--+--+--+--+--+* + * + * Input: *stream - pointer to SRTP stream context, used to retrieve + * the SALT + * *iv - Pointer to recieve the calculated IV + * seq_num - The SEQ value to use for the IV calculation. + * *hdr - The RTP header, used to get the SSRC value + * + */ +static void srtp_calc_aead_iv_srtcp(srtp_stream_ctx_t *stream, v128_t *iv, + uint32_t seq_num, srtcp_hdr_t *hdr) +{ + v128_t in; + v128_t salt; + + memset(&in, 0, sizeof(v128_t)); + memset(&salt, 0, sizeof(v128_t)); + + in.v16[0] = 0; + memcpy(&in.v16[1], &hdr->ssrc, 4); /* still in network order! */ + in.v16[3] = 0; + in.v32[2] = 0x7FFFFFFF & htonl(seq_num); /* bit 32 is suppose to be zero */ + + debug_print(mod_srtp, "Pre-salted RTCP IV = %s\n", v128_hex_string(&in)); + + /* + * Get the SALT value from the context + */ + memcpy(salt.v8, stream->c_salt, 12); + debug_print(mod_srtp, "RTCP SALT = %s\n", v128_hex_string(&salt)); + + /* + * Finally, apply the SALT to the input + */ + v128_xor(iv, &in, &salt); +} + +/* + * This code handles AEAD ciphers for outgoing RTCP. We currently support + * AES-GCM mode with 128 or 256 bit keys. + */ +static err_status_t +srtp_protect_rtcp_aead (srtp_t ctx, srtp_stream_ctx_t *stream, + void *rtcp_hdr, int *pkt_octet_len) +{ + srtcp_hdr_t *hdr = (srtcp_hdr_t*)rtcp_hdr; + uint32_t *enc_start; /* pointer to start of encrypted portion */ + uint32_t *trailer; /* pointer to start of trailer */ + unsigned enc_octet_len = 0; /* number of octets in encrypted portion */ + uint8_t *auth_tag = NULL; /* location of auth_tag within packet */ + err_status_t status; + int tag_len; + uint32_t seq_num; + v128_t iv; + uint32_t tseq; + + /* get tag length from stream context */ + tag_len = auth_get_tag_length(stream->rtcp_auth); + + /* + * set encryption start and encryption length - if we're not + * providing confidentiality, set enc_start to NULL + */ + enc_start = (uint32_t*)hdr + uint32s_in_rtcp_header; + enc_octet_len = *pkt_octet_len - octets_in_rtcp_header; + + /* NOTE: hdr->length is not usable - it refers to only the first + RTCP report in the compound packet! */ + /* NOTE: trailer is 32-bit aligned because RTCP 'packets' are always + multiples of 32-bits (RFC 3550 6.1) */ + trailer = (uint32_t*)((char*)enc_start + enc_octet_len + tag_len); + + if (stream->rtcp_services & sec_serv_conf) { + *trailer = htonl(SRTCP_E_BIT); /* set encrypt bit */ + } else { + enc_start = NULL; + enc_octet_len = 0; + /* 0 is network-order independant */ + *trailer = 0x00000000; /* set encrypt bit */ + } + + /* + * set the auth_tag pointer to the proper location, which is after + * the payload, but before the trailer + * (note that srtpc *always* provides authentication, unlike srtp) + */ + /* Note: This would need to change for optional mikey data */ + auth_tag = (uint8_t*)hdr + *pkt_octet_len; + + /* + * check sequence number for overruns, and copy it into the packet + * if its value isn't too big + */ + status = rdb_increment(&stream->rtcp_rdb); + if (status) { + return status; + } + seq_num = rdb_get_value(&stream->rtcp_rdb); + *trailer |= htonl(seq_num); + debug_print(mod_srtp, "srtcp index: %x", seq_num); + + /* + * Calculating the IV and pass it down to the cipher + */ + srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_encrypt); + if (status) { + return err_status_cipher_fail; + } + + /* + * Set the AAD for GCM mode + */ + if (enc_start) { + /* + * If payload encryption is enabled, then the AAD consist of + * the RTCP header and the seq# at the end of the packet + */ + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)hdr, + octets_in_rtcp_header); + if (status) { + return ( err_status_cipher_fail); + } + } else { + /* + * Since payload encryption is not enabled, we must authenticate + * the entire packet as described in section 10.3 in revision 07 + * of the draft. + */ + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)hdr, + *pkt_octet_len); + if (status) { + return ( err_status_cipher_fail); + } + } + /* + * put the idx# into network byte order and process it as AAD + */ + tseq = htonl(*trailer); + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)&tseq, + sizeof(srtcp_trailer_t)); + if (status) { + return ( err_status_cipher_fail); + } + + /* if we're encrypting, exor keystream into the message */ + if (enc_start) { + status = cipher_encrypt(stream->rtcp_cipher, + (uint8_t*)enc_start, &enc_octet_len); + if (status) { + return err_status_cipher_fail; + } + /* + * Get the tag and append that to the output + */ + status = cipher_get_tag(stream->rtcp_cipher, (uint8_t*)auth_tag, + &tag_len); + if (status) { + return ( err_status_cipher_fail); + } + enc_octet_len += tag_len; + } else { + /* + * Even though we're not encrypting the payload, we need + * to run the cipher to get the auth tag. + */ + unsigned nolen = 0; + status = cipher_encrypt(stream->rtcp_cipher, NULL, &nolen); + if (status) { + return err_status_cipher_fail; + } + /* + * Get the tag and append that to the output + */ + status = cipher_get_tag(stream->rtcp_cipher, (uint8_t*)auth_tag, + &tag_len); + if (status) { + return ( err_status_cipher_fail); + } + enc_octet_len += tag_len; + } + + /* increase the packet length by the length of the auth tag and seq_num*/ + *pkt_octet_len += (tag_len + sizeof(srtcp_trailer_t)); + + return err_status_ok; +} + +/* + * This function handles incoming SRTCP packets while in AEAD mode, + * which currently supports AES-GCM encryption. Note, the auth tag is + * at the end of the packet stream and is automatically checked by GCM + * when decrypting the payload. + */ +static err_status_t +srtp_unprotect_rtcp_aead (srtp_t ctx, srtp_stream_ctx_t *stream, + void *srtcp_hdr, int *pkt_octet_len) +{ + srtcp_hdr_t *hdr = (srtcp_hdr_t*)srtcp_hdr; + uint32_t *enc_start; /* pointer to start of encrypted portion */ + uint32_t *trailer; /* pointer to start of trailer */ + unsigned enc_octet_len = 0; /* number of octets in encrypted portion */ + uint8_t *auth_tag = NULL; /* location of auth_tag within packet */ + err_status_t status; + int tag_len; + unsigned int tmp_len; + uint32_t seq_num; + v128_t iv; + uint32_t tseq; + + /* get tag length from stream context */ + tag_len = auth_get_tag_length(stream->rtcp_auth); + + /* Validate packet length */ + if (*pkt_octet_len < (octets_in_rtcp_header + tag_len + + sizeof(srtcp_trailer_t))) { + return err_status_bad_param; + } + + /* + * set encryption start, encryption length, and trailer + */ + /* index & E (encryption) bit follow normal data. hdr->len + is the number of words (32-bit) in the normal packet minus 1 */ + /* This should point trailer to the word past the end of the + normal data. */ + /* This would need to be modified for optional mikey data */ + /* + * NOTE: trailer is 32-bit aligned because RTCP 'packets' are always + * multiples of 32-bits (RFC 3550 6.1) + */ + trailer = (uint32_t*)((char*)hdr + *pkt_octet_len - sizeof(srtcp_trailer_t)); + /* + * We pass the tag down to the cipher when doing GCM mode + */ + enc_octet_len = *pkt_octet_len - (octets_in_rtcp_header + + sizeof(srtcp_trailer_t)); + auth_tag = (uint8_t*)hdr + *pkt_octet_len - tag_len - sizeof(srtcp_trailer_t); + + if (*((unsigned char*)trailer) & SRTCP_E_BYTE_BIT) { + enc_start = (uint32_t*)hdr + uint32s_in_rtcp_header; + } else { + enc_octet_len = 0; + enc_start = NULL; /* this indicates that there's no encryption */ + } + + /* + * check the sequence number for replays + */ + /* this is easier than dealing with bitfield access */ + seq_num = ntohl(*trailer) & SRTCP_INDEX_MASK; + debug_print(mod_srtp, "srtcp index: %x", seq_num); + status = rdb_check(&stream->rtcp_rdb, seq_num); + if (status) { + return status; + } + + /* + * Calculate and set the IV + */ + srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_decrypt); + if (status) { + return err_status_cipher_fail; + } + + /* + * Set the AAD for GCM mode + */ + if (enc_start) { + /* + * If payload encryption is enabled, then the AAD consist of + * the RTCP header and the seq# at the end of the packet + */ + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)hdr, + octets_in_rtcp_header); + if (status) { + return ( err_status_cipher_fail); + } + } else { + /* + * Since payload encryption is not enabled, we must authenticate + * the entire packet as described in section 10.3 in revision 07 + * of the draft. + */ + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)hdr, + (*pkt_octet_len - tag_len - sizeof(srtcp_trailer_t))); + if (status) { + return ( err_status_cipher_fail); + } + } + + /* + * put the idx# into network byte order, and process it as AAD + */ + tseq = htonl(*trailer); + status = cipher_set_aad(stream->rtcp_cipher, (uint8_t*)&tseq, + sizeof(srtcp_trailer_t)); + if (status) { + return ( err_status_cipher_fail); + } + + /* if we're decrypting, exor keystream into the message */ + if (enc_start) { + status = cipher_decrypt(stream->rtcp_cipher, + (uint8_t*)enc_start, &enc_octet_len); + if (status) { + return status; + } + } else { + /* + * Still need to run the cipher to check the tag + */ + tmp_len = tag_len; + status = cipher_decrypt(stream->rtcp_cipher, (uint8_t*)auth_tag, + &tmp_len); + if (status) { + return status; + } + } + + /* decrease the packet length by the length of the auth tag and seq_num*/ + *pkt_octet_len -= (tag_len + sizeof(srtcp_trailer_t)); + + /* + * verify that stream is for received traffic - this check will + * detect SSRC collisions, since a stream that appears in both + * srtp_protect() and srtp_unprotect() will fail this test in one of + * those functions. + * + * we do this check *after* the authentication check, so that the + * latter check will catch any attempts to fool us into thinking + * that we've got a collision + */ + if (stream->direction != dir_srtp_receiver) { + if (stream->direction == dir_unknown) { + stream->direction = dir_srtp_receiver; + } else { + srtp_handle_event(ctx, stream, event_ssrc_collision); + } + } + + /* + * if the stream is a 'provisional' one, in which the template context + * is used, then we need to allocate a new stream at this point, since + * the authentication passed + */ + if (stream == ctx->stream_template) { + srtp_stream_ctx_t *new_stream; + + /* + * allocate and initialize a new stream + * + * note that we indicate failure if we can't allocate the new + * stream, and some implementations will want to not return + * failure here + */ + status = srtp_stream_clone(ctx->stream_template, hdr->ssrc, &new_stream); + if (status) { + return status; + } + + /* add new stream to the head of the stream_list */ + new_stream->next = ctx->stream_list; + ctx->stream_list = new_stream; + + /* set stream (the pointer used in this function) */ + stream = new_stream; + } + + /* we've passed the authentication check, so add seq_num to the rdb */ + rdb_add_index(&stream->rtcp_rdb, seq_num); + + return err_status_ok; +} + err_status_t srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len) { srtcp_hdr_t *hdr = (srtcp_hdr_t *)rtcp_hdr; @@ -1677,6 +2551,15 @@ srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len) { } } + /* + * Check if this is an AEAD stream (GCM mode). If so, then dispatch + * the request to our AEAD handler. + */ + if (stream->rtp_cipher->algorithm == AES_128_GCM || + stream->rtp_cipher->algorithm == AES_256_GCM) { + return srtp_protect_rtcp_aead(ctx, stream, rtcp_hdr, pkt_octet_len); + } + /* get tag length from stream context */ tag_len = auth_get_tag_length(stream->rtcp_auth); @@ -1736,7 +2619,7 @@ srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len) { iv.v32[1] = hdr->ssrc; /* still in network order! */ iv.v32[2] = htonl(seq_num >> 16); iv.v32[3] = htonl(seq_num << 16); - status = cipher_set_iv(stream->rtcp_cipher, &iv); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_encrypt); } else { v128_t iv; @@ -1746,7 +2629,7 @@ srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len) { iv.v32[1] = 0; iv.v32[2] = 0; iv.v32[3] = htonl(seq_num); - status = cipher_set_iv(stream->rtcp_cipher, &iv); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_encrypt); } if (status) return err_status_cipher_fail; @@ -1817,6 +2700,8 @@ srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len) { srtp_stream_ctx_t *stream; int prefix_len; uint32_t seq_num; + int e_bit_in_packet; /* whether the E-bit was found in the packet */ + int sec_serv_confidentiality; /* whether confidentiality was requested */ /* we assume the hdr is 32-bit aligned to start */ /* @@ -1855,6 +2740,18 @@ srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len) { } } + /* + * Check if this is an AEAD stream (GCM mode). If so, then dispatch + * the request to our AEAD handler. + */ + if (stream->rtp_cipher->algorithm == AES_128_GCM || + stream->rtp_cipher->algorithm == AES_256_GCM) { + return srtp_unprotect_rtcp_aead(ctx, stream, srtcp_hdr, pkt_octet_len); + } + + sec_serv_confidentiality = stream->rtcp_services == sec_serv_conf || + stream->rtcp_services == sec_serv_conf_and_auth; + /* get tag length from stream context */ tag_len = auth_get_tag_length(stream->rtcp_auth); @@ -1873,8 +2770,13 @@ srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len) { * multiples of 32-bits (RFC 3550 6.1) */ trailer = (uint32_t *) ((char *) hdr + - *pkt_octet_len -(tag_len + sizeof(srtcp_trailer_t))); - if (*((unsigned char *) trailer) & SRTCP_E_BYTE_BIT) { + *pkt_octet_len -(tag_len + sizeof(srtcp_trailer_t))); + e_bit_in_packet = + (*((unsigned char *) trailer) & SRTCP_E_BYTE_BIT) == SRTCP_E_BYTE_BIT; + if (e_bit_in_packet != sec_serv_confidentiality) { + return err_status_cant_check; + } + if (sec_serv_confidentiality) { enc_start = (uint32_t *)hdr + uint32s_in_rtcp_header; } else { enc_octet_len = 0; @@ -1924,7 +2826,7 @@ srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len) { iv.v32[1] = hdr->ssrc; /* still in network order! */ iv.v32[2] = htonl(seq_num >> 16); iv.v32[3] = htonl(seq_num << 16); - status = cipher_set_iv(stream->rtcp_cipher, &iv); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_decrypt); } else { v128_t iv; @@ -1934,7 +2836,7 @@ srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len) { iv.v32[1] = 0; iv.v32[2] = 0; iv.v32[3] = htonl(seq_num); - status = cipher_set_iv(stream->rtcp_cipher, &iv); + status = cipher_set_iv(stream->rtcp_cipher, &iv, direction_decrypt); } if (status) @@ -2052,24 +2954,19 @@ crypto_policy_set_from_profile_for_rtp(crypto_policy_t *policy, /* set SRTP policy from the SRTP profile in the key set */ switch(profile) { case srtp_profile_aes128_cm_sha1_80: - crypto_policy_set_aes_cm_128_hmac_sha1_80(policy); crypto_policy_set_aes_cm_128_hmac_sha1_80(policy); break; case srtp_profile_aes128_cm_sha1_32: crypto_policy_set_aes_cm_128_hmac_sha1_32(policy); - crypto_policy_set_aes_cm_128_hmac_sha1_80(policy); break; case srtp_profile_null_sha1_80: - crypto_policy_set_null_cipher_hmac_sha1_80(policy); crypto_policy_set_null_cipher_hmac_sha1_80(policy); break; case srtp_profile_aes256_cm_sha1_80: - crypto_policy_set_aes_cm_256_hmac_sha1_80(policy); crypto_policy_set_aes_cm_256_hmac_sha1_80(policy); break; case srtp_profile_aes256_cm_sha1_32: crypto_policy_set_aes_cm_256_hmac_sha1_32(policy); - crypto_policy_set_aes_cm_256_hmac_sha1_80(policy); break; /* the following profiles are not (yet) supported */ case srtp_profile_null_sha1_32: @@ -2090,6 +2987,8 @@ crypto_policy_set_from_profile_for_rtcp(crypto_policy_t *policy, crypto_policy_set_aes_cm_128_hmac_sha1_80(policy); break; case srtp_profile_aes128_cm_sha1_32: + /* We do not honor the 32-bit auth tag request since + * this is not compliant with RFC 3711 */ crypto_policy_set_aes_cm_128_hmac_sha1_80(policy); break; case srtp_profile_null_sha1_80: @@ -2099,6 +2998,8 @@ crypto_policy_set_from_profile_for_rtcp(crypto_policy_t *policy, crypto_policy_set_aes_cm_256_hmac_sha1_80(policy); break; case srtp_profile_aes256_cm_sha1_32: + /* We do not honor the 32-bit auth tag request since + * this is not compliant with RFC 3711 */ crypto_policy_set_aes_cm_256_hmac_sha1_80(policy); break; /* the following profiles are not (yet) supported */ diff --git a/libs/srtp/test/rtpw.c b/libs/srtp/test/rtpw.c index f18d42045e..ae902689d0 100644 --- a/libs/srtp/test/rtpw.c +++ b/libs/srtp/test/rtpw.c @@ -90,8 +90,7 @@ #define USEC_RATE (5e5) #define MAX_WORD_LEN 128 #define ADDR_IS_MULTICAST(a) IN_MULTICAST(htonl(a)) -#define MAX_KEY_LEN 64 -#define MASTER_KEY_LEN 30 +#define MAX_KEY_LEN 96 #ifndef HAVE_USLEEP @@ -153,6 +152,8 @@ main (int argc, char *argv[]) { sec_serv_t sec_servs = sec_serv_none; unsigned char ttl = 5; int c; + int key_size = 128; + int gcm_on = 0; char *input_key = NULL; char *address = NULL; char key[MAX_KEY_LEN]; @@ -187,7 +188,7 @@ main (int argc, char *argv[]) { /* check args */ while (1) { - c = getopt_s(argc, argv, "k:rsaeld:"); + c = getopt_s(argc, argv, "k:rsgae:ld:"); if (c == -1) { break; } @@ -196,11 +197,20 @@ main (int argc, char *argv[]) { input_key = optarg_s; break; case 'e': + key_size = atoi(optarg_s); + if (key_size != 128 && key_size != 256) { + printf("error: encryption key size must be 128 or 256 (%d)\n", key_size); + exit(1); + } sec_servs |= sec_serv_conf; break; case 'a': sec_servs |= sec_serv_auth; break; + case 'g': + gcm_on = 1; + sec_servs |= sec_serv_auth; + break; case 'r': prog_type = receiver; break; @@ -331,16 +341,73 @@ main (int argc, char *argv[]) { */ switch (sec_servs) { case sec_serv_conf_and_auth: - crypto_policy_set_rtp_default(&policy.rtp); - crypto_policy_set_rtcp_default(&policy.rtcp); + if (gcm_on) { +#ifdef OPENSSL + switch (key_size) { + case 128: + crypto_policy_set_aes_gcm_128_8_auth(&policy.rtp); + crypto_policy_set_aes_gcm_128_8_auth(&policy.rtcp); + break; + case 256: + crypto_policy_set_aes_gcm_256_8_auth(&policy.rtp); + crypto_policy_set_aes_gcm_256_8_auth(&policy.rtcp); + break; + } +#else + printf("error: GCM mode only supported when using the OpenSSL crypto engine.\n"); + return 0; +#endif + } else { + switch (key_size) { + case 128: + crypto_policy_set_rtp_default(&policy.rtp); + crypto_policy_set_rtcp_default(&policy.rtcp); + break; + case 256: + crypto_policy_set_aes_cm_256_hmac_sha1_80(&policy.rtp); + crypto_policy_set_rtcp_default(&policy.rtcp); + break; + } + } break; case sec_serv_conf: - crypto_policy_set_aes_cm_128_null_auth(&policy.rtp); - crypto_policy_set_rtcp_default(&policy.rtcp); + if (gcm_on) { + printf("error: GCM mode must always be used with auth enabled\n"); + return -1; + } else { + switch (key_size) { + case 128: + crypto_policy_set_aes_cm_128_null_auth(&policy.rtp); + crypto_policy_set_rtcp_default(&policy.rtcp); + break; + case 256: + crypto_policy_set_aes_cm_256_null_auth(&policy.rtp); + crypto_policy_set_rtcp_default(&policy.rtcp); + break; + } + } break; case sec_serv_auth: - crypto_policy_set_null_cipher_hmac_sha1_80(&policy.rtp); - crypto_policy_set_rtcp_default(&policy.rtcp); + if (gcm_on) { +#ifdef OPENSSL + switch (key_size) { + case 128: + crypto_policy_set_aes_gcm_128_8_only_auth(&policy.rtp); + crypto_policy_set_aes_gcm_128_8_only_auth(&policy.rtcp); + break; + case 256: + crypto_policy_set_aes_gcm_256_8_only_auth(&policy.rtp); + crypto_policy_set_aes_gcm_256_8_only_auth(&policy.rtcp); + break; + } +#else + printf("error: GCM mode only supported when using the OpenSSL crypto engine.\n"); + return 0; +#endif + } else { + crypto_policy_set_null_cipher_hmac_sha1_80(&policy.rtp); + crypto_policy_set_rtcp_default(&policy.rtcp); + } break; default: printf("error: unknown security service requested\n"); @@ -359,21 +426,21 @@ main (int argc, char *argv[]) { /* * read key from hexadecimal on command line into an octet string */ - len = hex_string_to_octet_string(key, input_key, MASTER_KEY_LEN*2); + len = hex_string_to_octet_string(key, input_key, policy.rtp.cipher_key_len*2); /* check that hex string is the right length */ - if (len < MASTER_KEY_LEN*2) { + if (len < policy.rtp.cipher_key_len*2) { fprintf(stderr, "error: too few digits in key/salt " "(should be %d hexadecimal digits, found %d)\n", - MASTER_KEY_LEN*2, len); + policy.rtp.cipher_key_len*2, len); exit(1); } - if (strlen(input_key) > MASTER_KEY_LEN*2) { + if (strlen(input_key) > policy.rtp.cipher_key_len*2) { fprintf(stderr, "error: too many digits in key/salt " "(should be %d hexadecimal digits, found %u)\n", - MASTER_KEY_LEN*2, (unsigned)strlen(input_key)); + policy.rtp.cipher_key_len*2, (unsigned)strlen(input_key)); exit(1); } @@ -541,7 +608,8 @@ usage(char *string) { "[-s | -r] dest_ip dest_port\n" "or %s -l\n" "where -a use message authentication\n" - " -e use encryption\n" + " -e use encryption (use 128 or 256 for key size)\n" + " -g Use AES-GCM mode (must be used with -e)\n" " -k sets the srtp master key\n" " -s act as rtp sender\n" " -r act as rtp receiver\n" diff --git a/libs/srtp/test/rtpw_test.sh b/libs/srtp/test/rtpw_test.sh index b5d66ee0a5..c3c32caf6b 100755 --- a/libs/srtp/test/rtpw_test.sh +++ b/libs/srtp/test/rtpw_test.sh @@ -10,7 +10,7 @@ DURATION=3 key=2b2edc5034f61a72345ca5986d7bfd0189aa6dc2ecab32fd9af74df6dfc6 -ARGS="-k $key -ae" +ARGS="-k $key -a -e 128" # First, we run "killall" to get rid of all existing rtpw processes. # This step also enables this script to clean up after itself; if this @@ -66,6 +66,55 @@ kill $sender_pid wait $receiver_pid wait $sender_pid + +key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6 + +ARGS="-k $key -a -e 256" + +echo $0 ": starting rtpw receiver process... " + +$RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & + +receiver_pid=$! + +echo $0 ": receiver PID = $receiver_pid" + +sleep 1 + +# verify that the background job is running +ps | grep -q $receiver_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 254 +fi + +echo $0 ": starting rtpw sender process..." + +$RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & + +sender_pid=$! + +echo $0 ": sender PID = $sender_pid" + +# verify that the background job is running +ps | grep -q $sender_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 255 +fi + +sleep $DURATION + +kill $receiver_pid +kill $sender_pid + +wait $receiver_pid +wait $sender_pid + echo $0 ": done (test passed)" else diff --git a/libs/srtp/test/rtpw_test_gcm.sh b/libs/srtp/test/rtpw_test_gcm.sh new file mode 100644 index 0000000000..dfac33514e --- /dev/null +++ b/libs/srtp/test/rtpw_test_gcm.sh @@ -0,0 +1,119 @@ +#!/bin/sh +# +# usage: rtpw_test +# +# tests the rtpw sender and receiver functions + +RTPW=./rtpw +DEST_PORT=9999 +DURATION=3 + +# First, we run "killall" to get rid of all existing rtpw processes. +# This step also enables this script to clean up after itself; if this +# script is interrupted after the rtpw processes are started but before +# they are killed, those processes will linger. Re-running the script +# will get rid of them. + +killall rtpw 2>/dev/null + +if test -x $RTPW; then + +GCMARGS128="-k 012345678901234567890123456789012345678901234567890123456789 -g -e 128" +echo $0 ": starting GCM mode 128-bit rtpw receiver process... " + +exec $RTPW $* $GCMARGS128 -r 127.0.0.1 $DEST_PORT & + +receiver_pid=$! + +echo $0 ": receiver PID = $receiver_pid" + +sleep 1 + +# verify that the background job is running +ps | grep -q $receiver_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 254 +fi + +echo $0 ": starting GCM 128-bit rtpw sender process..." + +exec $RTPW $* $GCMARGS128 -s 127.0.0.1 $DEST_PORT & + +sender_pid=$! + +echo $0 ": sender PID = $sender_pid" + +# verify that the background job is running +ps | grep -q $sender_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 255 +fi + +sleep $DURATION + +kill $receiver_pid +kill $sender_pid + + + +GCMARGS256="-k 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 -g -e 256" +echo $0 ": starting GCM mode 256-bit rtpw receiver process... " + +exec $RTPW $* $GCMARGS256 -r 127.0.0.1 $DEST_PORT & + +receiver_pid=$! + +echo $0 ": receiver PID = $receiver_pid" + +sleep 1 + +# verify that the background job is running +ps | grep -q $receiver_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 254 +fi + +echo $0 ": starting GCM 256-bit rtpw sender process..." + +exec $RTPW $* $GCMARGS256 -s 127.0.0.1 $DEST_PORT & + +sender_pid=$! + +echo $0 ": sender PID = $sender_pid" + +# verify that the background job is running +ps | grep -q $sender_pid +retval=$? +echo $retval +if [ $retval != 0 ]; then + echo $0 ": error" + exit 255 +fi + +sleep $DURATION + +kill $receiver_pid +kill $sender_pid + + +echo $0 ": done (test passed)" + +else + +echo "error: can't find executable" $RTPW +exit 1 + +fi + +# EOF + + diff --git a/libs/srtp/test/srtp_driver.c b/libs/srtp/test/srtp_driver.c index a1b48661f0..783d5182e3 100644 --- a/libs/srtp/test/srtp_driver.c +++ b/libs/srtp/test/srtp_driver.c @@ -104,7 +104,7 @@ srtp_packet_to_string(srtp_hdr_t *hdr, int packet_len); double mips_estimate(int num_trials, int *ignore); -extern uint8_t test_key[30]; +extern uint8_t test_key[46]; void usage(char *prog_name) { @@ -288,6 +288,8 @@ main (int argc, char *argv[]) { exit(1); } +//FIXME: need to get this working with the OpenSSL AES module +#ifndef OPENSSL /* * run validation test against the reference packets for * AES-256 @@ -300,6 +302,7 @@ main (int argc, char *argv[]) { printf("failed\n"); exit(1); } +#endif /* * test the function srtp_remove_stream() @@ -1527,10 +1530,12 @@ srtp_test_remove_stream() { * srtp policy definitions - these definitions are used above */ -unsigned char test_key[30] = { +unsigned char test_key[46] = { 0xe1, 0xf9, 0x7a, 0x0d, 0x3e, 0x01, 0x8b, 0xe0, 0xd6, 0x4f, 0xa3, 0x2c, 0x06, 0xde, 0x41, 0x39, 0x0e, 0xc6, 0x75, 0xad, 0x49, 0x8a, 0xfe, 0xeb, + 0xb6, 0x96, 0x0b, 0x3a, 0xab, 0xe6, 0xc1, 0x73, + 0xc3, 0x17, 0xf2, 0xda, 0xbe, 0x35, 0x77, 0x93, 0xb6, 0x96, 0x0b, 0x3a, 0xab, 0xe6 }; @@ -1660,6 +1665,108 @@ const srtp_policy_t hmac_only_policy = { NULL }; +#ifdef OPENSSL +const srtp_policy_t aes128_gcm_8_policy = { + { ssrc_any_outbound, 0 }, /* SSRC */ + { /* SRTP policy */ + AES_128_GCM, /* cipher type */ + 30, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + { /* SRTCP policy */ + AES_128_GCM, /* cipher type */ + 30, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + test_key, + NULL, /* indicates that EKT is not in use */ + 128, /* replay window size */ + 0, /* retransmission not allowed */ + NULL +}; + +const srtp_policy_t aes128_gcm_8_cauth_policy = { + { ssrc_any_outbound, 0 }, /* SSRC */ + { /* SRTP policy */ + AES_128_GCM, /* cipher type */ + 30, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + { /* SRTCP policy */ + AES_128_GCM, /* cipher type */ + 30, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_auth /* security services flag */ + }, + test_key, + NULL, /* indicates that EKT is not in use */ + 128, /* replay window size */ + 0, /* retransmission not allowed */ + NULL +}; + +const srtp_policy_t aes256_gcm_8_policy = { + { ssrc_any_outbound, 0 }, /* SSRC */ + { /* SRTP policy */ + AES_256_GCM, /* cipher type */ + 46, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + { /* SRTCP policy */ + AES_256_GCM, /* cipher type */ + 46, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + test_key, + NULL, /* indicates that EKT is not in use */ + 128, /* replay window size */ + 0, /* retransmission not allowed */ + NULL +}; + +const srtp_policy_t aes256_gcm_8_cauth_policy = { + { ssrc_any_outbound, 0 }, /* SSRC */ + { /* SRTP policy */ + AES_256_GCM, /* cipher type */ + 46, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_conf_and_auth /* security services flag */ + }, + { /* SRTCP policy */ + AES_256_GCM, /* cipher type */ + 46, /* cipher key length in octets */ + NULL_AUTH, /* authentication func type */ + 0, /* auth key length in octets */ + 8, /* auth tag length in octets */ + sec_serv_auth /* security services flag */ + }, + test_key, + NULL, /* indicates that EKT is not in use */ + 128, /* replay window size */ + 0, /* retransmission not allowed */ + NULL +}; +#endif + const srtp_policy_t null_policy = { { ssrc_any_outbound, 0 }, /* SSRC */ { @@ -1783,6 +1890,12 @@ policy_array[] = { &aes_tmmh_policy, #endif &default_policy, +#ifdef OPENSSL + &aes128_gcm_8_policy, + &aes128_gcm_8_cauth_policy, + &aes256_gcm_8_policy, + &aes256_gcm_8_cauth_policy, +#endif &null_policy, &aes_256_hmac_policy, &hmac_only_with_ekt_policy, diff --git a/libs/stfu/stfu.c b/libs/stfu/stfu.c index be49b6c3e9..374185ac9f 100644 --- a/libs/stfu/stfu.c +++ b/libs/stfu/stfu.c @@ -1,6 +1,6 @@ /* * STFU (S)ort (T)ransportable (F)ramed (U)tterances - * Copyright (c) 2007-2012 Anthony Minessale II + * Copyright (c) 2007-2014 Anthony Minessale II * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation diff --git a/libs/stfu/stfu.h b/libs/stfu/stfu.h index e1a0d439a3..3ff5326271 100644 --- a/libs/stfu/stfu.h +++ b/libs/stfu/stfu.h @@ -1,6 +1,6 @@ /* * STFU (S)ort (T)ransportable (F)ramed (U)tterances - * Copyright (c) 2007-2012 Anthony Minessale II + * Copyright (c) 2007-2014 Anthony Minessale II * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -77,6 +77,7 @@ typedef unsigned long in_addr_t; #include #include typedef SOCKET stfu_socket_t; +#ifndef _STDINT typedef unsigned __int64 uint64_t; typedef unsigned __int32 uint32_t; typedef unsigned __int16 uint16_t; @@ -85,6 +86,7 @@ typedef __int64 int64_t; typedef __int32 int32_t; typedef __int16 int16_t; typedef __int8 int8_t; +#endif typedef intptr_t stfu_ssize_t; typedef int stfu_filehandle_t; #define STFU_SOCK_INVALID INVALID_SOCKET diff --git a/libs/tiff-4.0.2/.gitignore b/libs/tiff-4.0.2/.gitignore new file mode 100644 index 0000000000..13d669caff --- /dev/null +++ b/libs/tiff-4.0.2/.gitignore @@ -0,0 +1,3 @@ +config/compile +config/depcomp +config/missing diff --git a/libs/tiff-4.0.2/config/.emptydir b/libs/tiff-4.0.2/config/.emptydir new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/tiff-4.0.2/config/compile b/libs/tiff-4.0.2/config/compile deleted file mode 100755 index 1b1d232169..0000000000 --- a/libs/tiff-4.0.2/config/compile +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. - -scriptversion=2005-05-14.22 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; -esac - -ofile= -cfile= -eat= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/tiff-4.0.2/config/depcomp b/libs/tiff-4.0.2/config/depcomp deleted file mode 100755 index 04701da536..0000000000 --- a/libs/tiff-4.0.2/config/depcomp +++ /dev/null @@ -1,530 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2005-07-09.11 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - stat=$? - - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" - fi - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - outname="$stripped.o" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/tiff-4.0.2/config/missing b/libs/tiff-4.0.2/config/missing deleted file mode 100755 index 894e786e16..0000000000 --- a/libs/tiff-4.0.2/config/missing +++ /dev/null @@ -1,360 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2005-06-08.21 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case "$1" in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/tiff-4.0.2/config/mkinstalldirs b/libs/tiff-4.0.2/config/mkinstalldirs deleted file mode 100755 index 259dbfcd35..0000000000 --- a/libs/tiff-4.0.2/config/mkinstalldirs +++ /dev/null @@ -1,158 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy - -scriptversion=2005-06-29.22 - -# Original author: Noah Friedman -# Created: 1993-05-16 -# Public domain. -# -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -errstatus=0 -dirmode= - -usage="\ -Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... - -Create each directory DIR (with mode MODE, if specified), including all -leading file name components. - -Report bugs to ." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" - exit $? - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --version) - echo "$0 $scriptversion" - exit $? - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and -# mkdir -p a/c at the same time, both will detect that a is missing, -# one will create a, then the other will try to create a and die with -# a "File exists" error. This is a problem when calling mkinstalldirs -# from a parallel make. We use --version in the probe to restrict -# ourselves to GNU mkdir, which is thread-safe. -case $dirmode in - '') - if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - test -d ./-p && rmdir ./-p - test -d ./--version && rmdir ./--version - fi - ;; - *) - if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && - test ! -d ./--version; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - else - # Clean up after NextStep and OpenStep mkdir. - for d in ./-m ./-p ./--version "./$dirmode"; - do - test -d $d && rmdir $d - done - fi - ;; -esac - -for file -do - case $file in - /*) pathcomp=/ ;; - *) pathcomp= ;; - esac - oIFS=$IFS - IFS=/ - set fnord $file - shift - IFS=$oIFS - - for d - do - test "x$d" = x && continue - - pathcomp=$pathcomp$d - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp=$pathcomp/ - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/win32/Download OPENSSL.2010.vcxproj b/libs/win32/Download OPENSSL.2010.vcxproj index bd3ec16307..74dbda16e6 100644 --- a/libs/win32/Download OPENSSL.2010.vcxproj +++ b/libs/win32/Download OPENSSL.2010.vcxproj @@ -51,11 +51,11 @@ Document Downloading OPENSSL - if not exist "$(ProjectDir)..\openssl-1.0.1c" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1c.tar.gz "$(ProjectDir).." + if not exist "$(ProjectDir)..\openssl-1.0.1f" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1f.tar.gz "$(ProjectDir).." $(ProjectDir)..\OPENSSL;%(Outputs) Downloading OPENSSL - if not exist "$(ProjectDir)..\openssl-1.0.1c" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1c.tar.gz "$(ProjectDir).." + if not exist "$(ProjectDir)..\openssl-1.0.1f" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1f.tar.gz "$(ProjectDir).." $(ProjectDir)..\OPENSSL;%(Outputs) diff --git a/libs/win32/Download OPENSSL.2012.vcxproj b/libs/win32/Download OPENSSL.2012.vcxproj index 114e21d193..3a881d7bd1 100644 --- a/libs/win32/Download OPENSSL.2012.vcxproj +++ b/libs/win32/Download OPENSSL.2012.vcxproj @@ -53,11 +53,11 @@ Document Downloading OPENSSL - if not exist "$(ProjectDir)..\openssl-1.0.1c" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1c.tar.gz "$(ProjectDir).." + if not exist "$(ProjectDir)..\openssl-1.0.1f" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1f.tar.gz "$(ProjectDir).." $(ProjectDir)..\OPENSSL;%(Outputs) Downloading OPENSSL - if not exist "$(ProjectDir)..\openssl-1.0.1c" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1c.tar.gz "$(ProjectDir).." + if not exist "$(ProjectDir)..\openssl-1.0.1f" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/openssl-1.0.1f.tar.gz "$(ProjectDir).." $(ProjectDir)..\OPENSSL;%(Outputs) diff --git a/libs/win32/Download OPUS.2010.vcxproj b/libs/win32/Download OPUS.2010.vcxproj new file mode 100644 index 0000000000..36688eba3a --- /dev/null +++ b/libs/win32/Download OPUS.2010.vcxproj @@ -0,0 +1,78 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Download OPUS + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547} + Download OPUS + Win32Proj + + + + Utility + MultiByte + + + Utility + MultiByte + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\OPUS\$(Configuration)\ + $(PlatformName)\OPUS\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Downloading OPUS. + if not exist "$(ProjectDir)..\opus-1.1" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\opus-1.1;%(Outputs) + Downloading OPUS. + if not exist "$(ProjectDir)..\opus-1.1" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\opus-1.1;%(Outputs) + + + + + + diff --git a/libs/win32/Download OPUS.2012.vcxproj b/libs/win32/Download OPUS.2012.vcxproj new file mode 100644 index 0000000000..42553ea7ee --- /dev/null +++ b/libs/win32/Download OPUS.2012.vcxproj @@ -0,0 +1,80 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Download OPUS + {092124C9-09ED-43C7-BD6D-4AE5D6B3C547} + Download OPUS + Win32Proj + + + + Utility + MultiByte + v110 + + + Utility + MultiByte + v110 + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\OPUS\$(Configuration)\ + $(PlatformName)\OPUS\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Downloading OPUS. + if not exist "$(ProjectDir)..\opus-1.1" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\opus-1.1;%(Outputs) + Downloading OPUS. + if not exist "$(ProjectDir)..\opus-1.1" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\opus-1.1;%(Outputs) + + + + + + diff --git a/libs/win32/Download V8.2010.vcxproj b/libs/win32/Download V8.2010.vcxproj new file mode 100644 index 0000000000..fe2b60935c --- /dev/null +++ b/libs/win32/Download V8.2010.vcxproj @@ -0,0 +1,82 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Download V8 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} + Download V8 + Win32Proj + + + + Utility + MultiByte + + + Utility + MultiByte + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Downloading V8. + if not exist "$(ProjectDir)..\v8-$(V8Version)" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version).tar.bz2 "$(ProjectDir).." +if not exist "$(ProjectDir)..\v8-$(V8Version)\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version)-win.tar.bz2 "$(ProjectDir).." + + $(ProjectDir)..\v8-$(V8Version);%(Outputs) + Downloading V8. + if not exist "$(ProjectDir)..\v8-$(V8Version)" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version).tar.bz2 "$(ProjectDir).." +if not exist "$(ProjectDir)..\v8-$(V8Version)\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version)-win.tar.bz2 "$(ProjectDir).." + + $(ProjectDir)..\v8-$(V8Version);%(Outputs) + + + + + + diff --git a/libs/win32/Download V8.2012.vcxproj b/libs/win32/Download V8.2012.vcxproj new file mode 100644 index 0000000000..352bacb744 --- /dev/null +++ b/libs/win32/Download V8.2012.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Download V8 + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} + Download V8 + Win32Proj + + + + Utility + MultiByte + v110 + + + Utility + MultiByte + v110 + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Downloading V8. + if not exist "$(ProjectDir)..\v8-$(V8Version)" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version).tar.bz2 "$(ProjectDir).." +if not exist "$(ProjectDir)..\v8-$(V8Version)\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version)-win.tar.bz2 "$(ProjectDir).." + + $(ProjectDir)..\v8-$(V8Version);%(Outputs) + Downloading V8. + if not exist "$(ProjectDir)..\v8-$(V8Version)" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version).tar.bz2 "$(ProjectDir).." +if not exist "$(ProjectDir)..\v8-$(V8Version)\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-$(V8Version)-win.tar.bz2 "$(ProjectDir).." + + $(ProjectDir)..\v8-$(V8Version);%(Outputs) + + + + + + diff --git a/libs/win32/apr-util/libaprutil.2012.vcxproj b/libs/win32/apr-util/libaprutil.2012.vcxproj index 000db000e4..7fd1ca83ab 100644 --- a/libs/win32/apr-util/libaprutil.2012.vcxproj +++ b/libs/win32/apr-util/libaprutil.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -89,6 +89,7 @@ xcopy "$(ProjectDir)..\..\apr-util\include\*.h" "$(ProjectDir)..\..\include\" /C MultiThreadedDebugDLL Level3 true + 4244;4018;4267;%(DisableSpecificWarnings) _DEBUG;APU_VERSION_ONLY;%(PreprocessorDefinitions) @@ -127,6 +128,7 @@ xcopy "$(ProjectDir)..\..\apr-util\include\*.h" "$(ProjectDir)..\..\include\" /C MultiThreadedDebugDLL Level3 true + 4244;4018;4267;%(DisableSpecificWarnings) _DEBUG;APU_VERSION_ONLY;%(PreprocessorDefinitions) @@ -167,6 +169,7 @@ xcopy "$(ProjectDir)..\..\apr-util\include\*.h" "$(ProjectDir)..\..\include\" /C true Level3 true + 4244;4018;4267;%(DisableSpecificWarnings) NDEBUG;APU_VERSION_ONLY;%(PreprocessorDefinitions) @@ -208,6 +211,7 @@ xcopy "$(ProjectDir)..\..\apr-util\include\*.h" "$(ProjectDir)..\..\include\" /C true Level3 true + 4244;4018;4267;%(DisableSpecificWarnings) NDEBUG;APU_VERSION_ONLY;%(PreprocessorDefinitions) diff --git a/libs/win32/apr-util/xml.2012.vcxproj b/libs/win32/apr-util/xml.2012.vcxproj index 866199a371..3c970e41ec 100644 --- a/libs/win32/apr-util/xml.2012.vcxproj +++ b/libs/win32/apr-util/xml.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -88,6 +88,7 @@ true Level3 true + 4244;%(DisableSpecificWarnings) 0x0409 @@ -113,6 +114,7 @@ true Level3 true + 4244;%(DisableSpecificWarnings) 0x0409 @@ -133,6 +135,7 @@ MultiThreadedDebugDLL Level3 true + 4244;%(DisableSpecificWarnings) 0x0409 @@ -156,6 +159,7 @@ MultiThreadedDebugDLL Level3 true + 4244;%(DisableSpecificWarnings) 0x0409 diff --git a/libs/win32/apr/libapr.2012.vcxproj b/libs/win32/apr/libapr.2012.vcxproj index 39cc98d863..617f66a356 100644 --- a/libs/win32/apr/libapr.2012.vcxproj +++ b/libs/win32/apr/libapr.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -85,6 +85,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MultiThreadedDebugDLL Level3 true + 4244;4018;4267;4090;4133;%(DisableSpecificWarnings) _DEBUG;APR_VERSION_ONLY;%(PreprocessorDefinitions) @@ -120,6 +121,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MultiThreadedDebugDLL Level3 true + 4244;4018;4267;4090;4133;%(DisableSpecificWarnings) _DEBUG;APR_VERSION_ONLY;%(PreprocessorDefinitions) @@ -155,6 +157,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / true Level3 true + 4244;4018;4267;4090;4133;%(DisableSpecificWarnings) NDEBUG;APR_VERSION_ONLY;%(PreprocessorDefinitions) @@ -191,6 +194,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / true Level3 true + 4244;4018;4267;4090;4133;%(DisableSpecificWarnings) NDEBUG;APR_VERSION_ONLY;%(PreprocessorDefinitions) diff --git a/libs/win32/celt/libcelt.2012.vcxproj b/libs/win32/celt/libcelt.2012.vcxproj index 3661a6f4f2..1931cb0d43 100644 --- a/libs/win32/celt/libcelt.2012.vcxproj +++ b/libs/win32/celt/libcelt.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -79,6 +79,7 @@ EnableFastChecks MultiThreadedDebugDLL Level3 + 4305;4267;4101;4554;4018;4244;%(DisableSpecificWarnings) @@ -93,6 +94,7 @@ EnableFastChecks MultiThreadedDebugDLL Level3 + 4305;4267;4101;4554;4018;4244;%(DisableSpecificWarnings) @@ -104,6 +106,7 @@ MultiThreadedDLL true Level3 + 4305;4267;4101;4554;4018;4244;%(DisableSpecificWarnings) @@ -118,6 +121,7 @@ MultiThreadedDLL true Level3 + 4305;4267;4101;4554;4018;4244;%(DisableSpecificWarnings) @@ -142,7 +146,7 @@ - + {fff82f9b-6a2b-4be3-95d8-dc5a4fc71e19} false diff --git a/libs/win32/curl/curllib.2010.vcxproj b/libs/win32/curl/curllib.2010.vcxproj index 8e736d99cb..27e0dacafe 100644 --- a/libs/win32/curl/curllib.2010.vcxproj +++ b/libs/win32/curl/curllib.2010.vcxproj @@ -80,7 +80,7 @@ MaxSpeed OnlyExplicitInline - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -111,7 +111,7 @@ MaxSpeed OnlyExplicitInline - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -141,7 +141,7 @@ Disabled - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true EnableFastChecks @@ -171,7 +171,7 @@ Disabled - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true EnableFastChecks diff --git a/libs/win32/curl/curllib.2012.vcxproj b/libs/win32/curl/curllib.2012.vcxproj index c6f519ff3e..c9ad1a58c8 100644 --- a/libs/win32/curl/curllib.2012.vcxproj +++ b/libs/win32/curl/curllib.2012.vcxproj @@ -84,7 +84,7 @@ MaxSpeed OnlyExplicitInline - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -115,7 +115,7 @@ MaxSpeed OnlyExplicitInline - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -145,7 +145,7 @@ Disabled - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true EnableFastChecks @@ -175,7 +175,7 @@ Disabled - ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\curl\lib\;..\..\curl\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;BUILDING_LIBCURL;USE_SSLEAY;USE_OPENSSL;%(PreprocessorDefinitions) true EnableFastChecks diff --git a/libs/win32/flite/flite.2012.vcxproj b/libs/win32/flite/flite.2012.vcxproj index b02fb49880..d69896fd68 100644 --- a/libs/win32/flite/flite.2012.vcxproj +++ b/libs/win32/flite/flite.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -78,7 +78,7 @@ EnableFastChecks MultiThreadedDebugDLL Level4 - 4100;4057;4706;%(DisableSpecificWarnings) + 4305;4090;4018;4701;4054;4055;4133;4127;4702;4996;4244;4100;4057;4706;%(DisableSpecificWarnings) diff --git a/libs/win32/iksemel/iksemel.2010.vcxproj b/libs/win32/iksemel/iksemel.2010.vcxproj index 91e2852c92..2fb1620ec2 100644 --- a/libs/win32/iksemel/iksemel.2010.vcxproj +++ b/libs/win32/iksemel/iksemel.2010.vcxproj @@ -69,7 +69,7 @@ Disabled - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks @@ -79,7 +79,7 @@ - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL TurnOffAllWarnings @@ -91,7 +91,7 @@ Disabled - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks @@ -104,7 +104,7 @@ X64 - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL TurnOffAllWarnings diff --git a/libs/win32/iksemel/iksemel.2012.vcxproj b/libs/win32/iksemel/iksemel.2012.vcxproj index fdb233dbe9..a95f224d15 100644 --- a/libs/win32/iksemel/iksemel.2012.vcxproj +++ b/libs/win32/iksemel/iksemel.2012.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks @@ -83,7 +83,7 @@ - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL TurnOffAllWarnings @@ -95,7 +95,7 @@ Disabled - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks @@ -108,7 +108,7 @@ X64 - ..\..\iksemel\include;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\iksemel\include;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL TurnOffAllWarnings diff --git a/libs/win32/json/libjson.2012.vcxproj b/libs/win32/json/libjson.2012.vcxproj index 01b0ee276e..21fb08793e 100644 --- a/libs/win32/json/libjson.2012.vcxproj +++ b/libs/win32/json/libjson.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -74,11 +74,12 @@ Disabled .;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 + 4018;4244;4996;%(DisableSpecificWarnings) @@ -88,11 +89,12 @@ Disabled .;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 + 4244;4996;%(DisableSpecificWarnings) @@ -100,10 +102,11 @@ MaxSpeed true .;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 + 4018;4244;4996;%(DisableSpecificWarnings) @@ -114,10 +117,11 @@ MaxSpeed true .;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_STDARG_H;STDC_HEADERS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 + 4244;4996;%(DisableSpecificWarnings) diff --git a/libs/win32/ldns/ldns-lib/ldns-lib.2012.vcxproj b/libs/win32/ldns/ldns-lib/ldns-lib.2012.vcxproj index 090ac61455..fba4c2fda5 100644 --- a/libs/win32/ldns/ldns-lib/ldns-lib.2012.vcxproj +++ b/libs/win32/ldns/ldns-lib/ldns-lib.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -91,12 +91,16 @@ MultiThreadedDebugDLL Level3 EditAndContinue + 4013;4101;4996;4267;4244;%(DisableSpecificWarnings) if not exist "$(ProjectDir)..\..\..\ldns\ldns\config.h" type "$(ProjectDir)\config.h" > "$(ProjectDir)..\..\..\ldns\ldns\config.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\util.h" type "$(ProjectDir)\util.h" > "$(ProjectDir)..\..\..\ldns\ldns\util.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" > "$(ProjectDir)..\..\..\ldns\ldns\net.h" + + /ignore:4221 %(AdditionalOptions) + @@ -107,12 +111,16 @@ if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" MultiThreadedDebugDLL Level3 ProgramDatabase + 4013;4101;4996;4267;4244;%(DisableSpecificWarnings) if not exist "$(ProjectDir)..\..\..\ldns\ldns\config.h" type "$(ProjectDir)\config.h" > "$(ProjectDir)..\..\..\ldns\ldns\config.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\util.h" type "$(ProjectDir)\util.h" > "$(ProjectDir)..\..\..\ldns\ldns\util.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" > "$(ProjectDir)..\..\..\ldns\ldns\net.h" + + /ignore:4221 %(AdditionalOptions) + @@ -124,6 +132,7 @@ if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" ProgramDatabase HAVE_STRUCT_ADDRINFO;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) ..\..\..\ldns\;.;%(AdditionalIncludeDirectories) + 4013;4101;4996;4267;4244;%(DisableSpecificWarnings) true @@ -136,6 +145,9 @@ if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\util.h" type "$(ProjectDir)\util.h" > "$(ProjectDir)..\..\..\ldns\ldns\util.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" > "$(ProjectDir)..\..\..\ldns\ldns\net.h" + + /ignore:4221 %(AdditionalOptions) + @@ -147,6 +159,7 @@ if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" ProgramDatabase HAVE_STRUCT_ADDRINFO;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) ..\..\..\ldns\;.;%(AdditionalIncludeDirectories) + 4013;4101;4996;4267;4244;%(DisableSpecificWarnings) true @@ -159,6 +172,9 @@ if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\util.h" type "$(ProjectDir)\util.h" > "$(ProjectDir)..\..\..\ldns\ldns\util.h" if not exist "$(ProjectDir)..\..\..\ldns\ldns\net.h" type "$(ProjectDir)\net.h" > "$(ProjectDir)..\..\..\ldns\ldns\net.h" + + /ignore:4221 %(AdditionalOptions) + diff --git a/libs/win32/libcbt/libcbt.2012.vcxproj b/libs/win32/libcbt/libcbt.2012.vcxproj index 0bcb540224..7e7b557531 100644 --- a/libs/win32/libcbt/libcbt.2012.vcxproj +++ b/libs/win32/libcbt/libcbt.2012.vcxproj @@ -75,7 +75,7 @@ - + $(PlatformName)\$(Configuration)\ @@ -90,26 +90,34 @@ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions) true $(SolutionDir)src\mod\endpoints\mod_gsmopen\libctb-0.16\include + 4800;4101;4267;%(DisableSpecificWarnings) Windows true + + /ignore:4042 %(AdditionalOptions) + - - NotUsing - Level3 - Disabled - _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions) - true - $(SolutionDir)src\mod\endpoints\mod_gsmopen\libctb-0.16\include - - - Windows - true - - + + NotUsing + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;%(PreprocessorDefinitions) + true + $(SolutionDir)src\mod\endpoints\mod_gsmopen\libctb-0.16\include + 4800;4101;4267;%(DisableSpecificWarnings) + + + Windows + true + + + /ignore:4042 %(AdditionalOptions) + + Level3 @@ -120,6 +128,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)src\mod\endpoints\mod_gsmopen\libctb-0.16\include + 4800;4101;4267;%(DisableSpecificWarnings) Windows @@ -127,6 +136,9 @@ true true + + /ignore:4042 %(AdditionalOptions) + @@ -138,6 +150,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)src\mod\endpoints\mod_gsmopen\libctb-0.16\include + 4800;4101;4267;%(DisableSpecificWarnings) Windows @@ -145,6 +158,9 @@ true true + + /ignore:4042 %(AdditionalOptions) + diff --git a/libs/win32/libcbt/libcbt.2012.vcxproj.filters b/libs/win32/libcbt/libcbt.2012.vcxproj.filters index b5b7ad717d..660ade5727 100644 --- a/libs/win32/libcbt/libcbt.2012.vcxproj.filters +++ b/libs/win32/libcbt/libcbt.2012.vcxproj.filters @@ -37,4 +37,16 @@ include - + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/win32/libjpeg/libjpeg.2012.vcxproj b/libs/win32/libjpeg/libjpeg.2012.vcxproj index dbf90a9761..d27c9ed818 100644 --- a/libs/win32/libjpeg/libjpeg.2012.vcxproj +++ b/libs/win32/libjpeg/libjpeg.2012.vcxproj @@ -153,6 +153,7 @@ true true ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + 4267;%(DisableSpecificWarnings) Windows @@ -175,6 +176,7 @@ true true ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + 4267;%(DisableSpecificWarnings) Windows @@ -198,6 +200,8 @@ ..\..\jpeg-8d;%(AdditionalIncludeDirectories) false Disabled + 4267;%(DisableSpecificWarnings) + MultiThreadedDebugDLL Windows @@ -223,6 +227,7 @@ ..\..\jpeg-8d;%(AdditionalIncludeDirectories) false MultiThreadedDebugDLL + 4267;%(DisableSpecificWarnings) Windows diff --git a/libs/win32/libmp3lame/libmp3lame.2012.vcxproj b/libs/win32/libmp3lame/libmp3lame.2012.vcxproj index 2fdcbb61d0..822f988021 100644 --- a/libs/win32/libmp3lame/libmp3lame.2012.vcxproj +++ b/libs/win32/libmp3lame/libmp3lame.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -69,7 +69,7 @@ - /GAy /QIfdiv /QI0f %(AdditionalOptions) + /GAy %(AdditionalOptions) MaxSpeed .;..\..\lame-3.98.4;..\..\lame-3.98.4\include;%(AdditionalIncludeDirectories) NDEBUG;_WINDOWS;WIN32;HAVE_CONFIG_H;%(PreprocessorDefinitions) @@ -92,7 +92,7 @@ X64 - /GAy /QIfdiv /QI0f %(AdditionalOptions) + /GAy %(AdditionalOptions) MaxSpeed .;..\..\lame-3.98.4;..\..\lame-3.98.4\include;%(AdditionalIncludeDirectories) NDEBUG;_WINDOWS;WIN32;HAVE_CONFIG_H;%(PreprocessorDefinitions) diff --git a/libs/win32/libsndfile/config.h b/libs/win32/libsndfile/config.h index f36852d9f6..a9d75002e3 100644 --- a/libs/win32/libsndfile/config.h +++ b/libs/win32/libsndfile/config.h @@ -24,6 +24,8 @@ #pragma warning (disable : 4244) #pragma warning (disable : 4761) +#include + /* Set to 1 if the compile is GNU GCC. */ /* #undef COMPILER_IS_GCC */ @@ -200,16 +202,16 @@ #define PACKAGE_NAME "libsndfile" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libsndfile 1.0.12" +#define PACKAGE_STRING "libsndfile 1.0.26pre5" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libsndfile" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.0.12" +#define PACKAGE_VERSION "1.0.26pre5" /* Set to maximum allowed value of sf_count_t type. */ -#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFi64 +//#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFi64 /* The size of a `double', as computed by sizeof. */ #define SIZEOF_DOUBLE 8 @@ -265,6 +267,8 @@ /* Version number of package */ #define VERSION "1.0.18" +#define HAVE_STDINT_H 1 + /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ @@ -280,6 +284,7 @@ typedef __int32 int32_t; typedef intptr_t ssize_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; +#define PRId64 "I64d" #define __func__ __FUNCTION__ #define snprintf _snprintf diff --git a/libs/win32/libsndfile/libsndfile.2010.vcxproj b/libs/win32/libsndfile/libsndfile.2010.vcxproj index ea9e3be89a..2b06e70d6c 100644 --- a/libs/win32/libsndfile/libsndfile.2010.vcxproj +++ b/libs/win32/libsndfile/libsndfile.2010.vcxproj @@ -116,12 +116,24 @@ + + + + + + + + + + + + @@ -144,6 +156,7 @@ + @@ -194,6 +207,9 @@ + + + diff --git a/libs/win32/libsndfile/libsndfile.2010.vcxproj.filters b/libs/win32/libsndfile/libsndfile.2010.vcxproj.filters index f16a39b0c7..a4335a1522 100644 --- a/libs/win32/libsndfile/libsndfile.2010.vcxproj.filters +++ b/libs/win32/libsndfile/libsndfile.2010.vcxproj.filters @@ -19,6 +19,9 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + {f00f84d5-78ae-4996-bee3-00106a731232} + @@ -225,10 +228,58 @@ Source Files\G72X Sources + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + Source Files + + Header Files + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + \ No newline at end of file diff --git a/libs/win32/libsndfile/libsndfile.2012.vcxproj b/libs/win32/libsndfile/libsndfile.2012.vcxproj index 6e76110e21..39dd95373a 100644 --- a/libs/win32/libsndfile/libsndfile.2012.vcxproj +++ b/libs/win32/libsndfile/libsndfile.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -120,12 +120,24 @@ + + + + + + + + + + + + @@ -148,6 +160,7 @@ + @@ -198,9 +211,12 @@ + + + - + \ No newline at end of file diff --git a/libs/win32/libsndfile/libsndfile.2012.vcxproj.filters b/libs/win32/libsndfile/libsndfile.2012.vcxproj.filters index f16a39b0c7..a4335a1522 100644 --- a/libs/win32/libsndfile/libsndfile.2012.vcxproj.filters +++ b/libs/win32/libsndfile/libsndfile.2012.vcxproj.filters @@ -19,6 +19,9 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + {f00f84d5-78ae-4996-bee3-00106a731232} + @@ -225,10 +228,58 @@ Source Files\G72X Sources + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + Source Files + + Header Files + + + Source Files\ALLAC Sources + + + Source Files\ALLAC Sources + \ No newline at end of file diff --git a/libs/win32/libsndfile/sndfile.h b/libs/win32/libsndfile/sndfile.h index 7fc07e0aa3..fa11e700e2 100644 --- a/libs/win32/libsndfile/sndfile.h +++ b/libs/win32/libsndfile/sndfile.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2009 Erik de Castro Lopo +** Copyright (C) 1999-2013 Erik de Castro Lopo ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -105,6 +105,11 @@ enum SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ + SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */ + SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */ + SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */ + SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */ + /* Endian-ness options. */ SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ @@ -192,6 +197,11 @@ enum SFC_WAVEX_GET_AMBISONIC = 0x1201, SFC_SET_VBR_ENCODING_QUALITY = 0x1300, + SFC_SET_COMPRESSION_LEVEL = 0x1301, + + /* Cart Chunk support */ + SFC_SET_CART_INFO = 0x1400, + SFC_GET_CART_INFO = 0x1401, /* Following commands for testing only. */ SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, @@ -199,7 +209,7 @@ enum /* ** SFC_SET_ADD_* values are deprecated and will disappear at some ** time in the future. They are guaranteed to be here up to and - ** including version 1.0.8 to avoid breakage of existng software. + ** including version 1.0.8 to avoid breakage of existing software. ** They currently do nothing and will continue to do nothing. */ SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, @@ -221,7 +231,9 @@ enum SF_STR_COMMENT = 0x05, SF_STR_DATE = 0x06, SF_STR_ALBUM = 0x07, - SF_STR_LICENSE = 0x08 + SF_STR_LICENSE = 0x08, + SF_STR_TRACKNUMBER = 0x09, + SF_STR_GENRE = 0x10 } ; /* @@ -230,7 +242,7 @@ enum */ #define SF_STR_FIRST SF_STR_TITLE -#define SF_STR_LAST SF_STR_LICENSE +#define SF_STR_LAST SF_STR_GENRE enum { /* True and false */ @@ -267,27 +279,34 @@ enum enum { SF_CHANNEL_MAP_INVALID = 0, SF_CHANNEL_MAP_MONO = 1, - SF_CHANNEL_MAP_LEFT, - SF_CHANNEL_MAP_RIGHT, - SF_CHANNEL_MAP_CENTER, + SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */ + SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */ + SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */ SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_RIGHT, SF_CHANNEL_MAP_FRONT_CENTER, - SF_CHANNEL_MAP_REAR_CENTER, - SF_CHANNEL_MAP_REAR_LEFT, - SF_CHANNEL_MAP_REAR_RIGHT, - SF_CHANNEL_MAP_LFE, - SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, - SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, - SF_CHANNEL_MAP_SIDE_LEFT, - SF_CHANNEL_MAP_SIDE_RIGHT, - SF_CHANNEL_MAP_TOP_CENTER, - SF_CHANNEL_MAP_TOP_FRONT_LEFT, - SF_CHANNEL_MAP_TOP_FRONT_RIGHT, - SF_CHANNEL_MAP_TOP_FRONT_CENTER, - SF_CHANNEL_MAP_TOP_REAR_LEFT, - SF_CHANNEL_MAP_TOP_REAR_RIGHT, - SF_CHANNEL_MAP_TOP_REAR_CENTER + SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */ + SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */ + SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */ + SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */ + SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */ + SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */ + SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */ + SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */ + SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */ + SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */ + SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */ + SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */ + SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */ + SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */ + SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */ + + SF_CHANNEL_MAP_AMBISONIC_B_W, + SF_CHANNEL_MAP_AMBISONIC_B_X, + SF_CHANNEL_MAP_AMBISONIC_B_Y, + SF_CHANNEL_MAP_AMBISONIC_B_Z, + + SF_CHANNEL_MAP_MAX } ; @@ -296,18 +315,24 @@ enum typedef struct SNDFILE_tag SNDFILE ; /* The following typedef is system specific and is defined when libsndfile is -** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t -** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same -** header file to be compiler by both GCC and the microsoft compiler. +** compiled. sf_count_t will be a 64 bit value when the underlying OS allows +** 64 bit file offsets. +** On windows, we need to allow the same header file to be compiler by both GCC +** and the Microsoft compiler. */ -typedef __int64 sf_count_t ; +#if (defined (_MSCVER) || defined (_MSC_VER)) +typedef __int64 sf_count_t ; +#define SF_COUNT_MAX 0x7fffffffffffffffi64 +#else +typedef @TYPEOF_SF_COUNT_T@ sf_count_t ; +#define SF_COUNT_MAX @SF_COUNT_MAX@ +#endif -#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFi64 -/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. +/* A pointer to a SF_INFO structure is passed to sf_open () and filled in. ** On write, the SF_INFO structure is filled in by the user and passed into -** sf_open_write (). +** sf_open (). */ struct SF_INFO @@ -391,9 +416,9 @@ typedef struct struct { int mode ; - unsigned int start ; - unsigned int end ; - unsigned int count ; + uint32_t start ; + uint32_t end ; + uint32_t count ; } loops [16] ; /* make variable in a sensible way */ } SF_INSTRUMENT ; @@ -411,7 +436,7 @@ typedef struct /* a full bar of 7/8 is 7 beats */ float bpm ; /* suggestion, as it can be calculated using other fields:*/ - /* file's lenght, file's sampleRate and our time_sig_den*/ + /* file's length, file's sampleRate and our time_sig_den*/ /* -> bpms are always the amount of _quarter notes_ per minute */ int root_key ; /* MIDI note, or -1 for None */ @@ -424,23 +449,56 @@ typedef struct */ #define SF_BROADCAST_INFO_VAR(coding_hist_size) \ struct \ - { char description [256] ; \ - char originator [32] ; \ - char originator_reference [32] ; \ - char origination_date [10] ; \ - char origination_time [8] ; \ - unsigned int time_reference_low ; \ - unsigned int time_reference_high ; \ - short version ; \ - char umid [64] ; \ - char reserved [190] ; \ - unsigned int coding_history_size ; \ - char coding_history [coding_hist_size] ; \ + { char description [256] ; \ + char originator [32] ; \ + char originator_reference [32] ; \ + char origination_date [10] ; \ + char origination_time [8] ; \ + uint32_t time_reference_low ; \ + uint32_t time_reference_high ; \ + short version ; \ + char umid [64] ; \ + char reserved [190] ; \ + uint32_t coding_history_size ; \ + char coding_history [coding_hist_size] ; \ } /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; +struct SF_CART_TIMER +{ char usage[4] ; + int32_t value ; +} ; + +typedef struct SF_CART_TIMER SF_CART_TIMER ; + +#define SF_CART_INFO_VAR(p_tag_text_size) \ + struct \ + { char version [4] ; \ + char title [64] ; \ + char artist [64] ; \ + char cut_id [64] ; \ + char client_id [64] ; \ + char category [64] ; \ + char classification [64] ; \ + char out_cue [64] ; \ + char start_date [10] ; \ + char start_time [8] ; \ + char end_date [10] ; \ + char end_time [8] ; \ + char producer_app_id [64] ; \ + char producer_app_version [64] ; \ + char user_def [64] ; \ + int32_t level_reference ; \ + SF_CART_TIMER post_timers [8] ; \ + char reserved [276] ; \ + char url [1024] ; \ + uint32_t tag_text_size ; \ + char tag_text[p_tag_text_size] ; \ + } + +typedef SF_CART_INFO_VAR (256) SF_CART_INFO ; /* Virtual I/O functionality. */ @@ -460,6 +518,7 @@ struct SF_VIRTUAL_IO typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; + /* Open the specified file for read, write or both. On error, this will ** return a NULL pointer. To find the error number, pass a NULL SNDFILE ** to sf_strerror (). @@ -468,6 +527,7 @@ typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; + /* Use the existing file descriptor to create a SNDFILE object. If close_desc ** is TRUE, the file descriptor will be closed when sf_close() is called. If ** it is FALSE, the descritor will not be closed. @@ -484,18 +544,21 @@ SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; + /* sf_error () returns a error number which can be translated to a text ** string using sf_error_number(). */ int sf_error (SNDFILE *sndfile) ; + /* sf_strerror () returns to the caller a pointer to the current error message for ** the given SNDFILE. */ const char* sf_strerror (SNDFILE *sndfile) ; + /* sf_error_number () allows the retrieval of the error string for each internal ** error number. ** @@ -503,6 +566,7 @@ const char* sf_strerror (SNDFILE *sndfile) ; const char* sf_error_number (int errnum) ; + /* The following two error functions are deprecated but they will remain in the ** library for the forseeable future. The function sf_strerror() should be used ** in their place. @@ -516,10 +580,12 @@ int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; + /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ int sf_format_check (const SF_INFO *info) ; + /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as ** stdio.h function fseek (). @@ -534,6 +600,7 @@ int sf_format_check (const SF_INFO *info) ; sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; + /* Functions for retrieving and setting string data within sound files. ** Not all file types support this features; AIFF and WAV do. For both ** functions, the str_type parameter must be one of the SF_STR_* values @@ -546,12 +613,31 @@ int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; const char* sf_get_string (SNDFILE *sndfile, int str_type) ; + +/* Return the library version string. */ + +const char * sf_version_string (void) ; + +/* Return the current byterate at this point in the file. The byte rate in this +** case is the number of bytes per second of audio data. For instance, for a +** stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate +** would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec. +** For some file formats the returned value will be accurate and exact, for some +** it will be a close approximation, for some it will be the average bitrate for +** the whole file and for some it will be a time varying value that was accurate +** when the file was most recently read or written. +** To get the bitrate, multiple this value by 8. +** Returns -1 for unknown. +*/ +int sf_current_byterate (SNDFILE *sndfile) ; + /* Functions for reading/writing the waveform data of a sound file. */ sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; + /* Functions for reading and writing the data chunk in terms of frames. ** The number of items actually read/written = frames * number of channels. ** sf_xxxx_raw read/writes the raw data bytes from/to the file @@ -574,6 +660,7 @@ sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frame sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; + /* Functions for reading and writing the data chunk in terms of items. ** Otherwise similar to above. ** All of these read/write function return number of items read/written. @@ -591,6 +678,7 @@ sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; + /* Close the SNDFILE and clean up all memory allocations associated with this ** file. ** Returns 0 on success, or an error number. @@ -598,6 +686,7 @@ sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t item int sf_close (SNDFILE *sndfile) ; + /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file ** to force the writing of data to disk. If the file is opened SFM_READ ** no action is taken. @@ -605,8 +694,124 @@ int sf_close (SNDFILE *sndfile) ; void sf_write_sync (SNDFILE *sndfile) ; + + +/* The function sf_wchar_open() is Windows Only! +** Open a file passing in a Windows Unicode filename. Otherwise, this is +** the same as sf_open(). +** +** In order for this to work, you need to do the following: +** +** #include +** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 +** #including +*/ + +#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES) +SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; +#endif + + + + +/* Getting and setting of chunks from within a sound file. +** +** These functions allow the getting and setting of chunks within a sound file +** (for those formats which allow it). +** +** These functions fail safely. Specifically, they will not allow you to overwrite +** existing chunks or add extra versions of format specific reserved chunks but +** should allow you to retrieve any and all chunks (may not be implemented for +** all chunks or all file formats). +*/ + +struct SF_CHUNK_INFO +{ char id [64] ; /* The chunk identifier. */ + unsigned id_size ; /* The size of the chunk identifier. */ + unsigned datalen ; /* The size of that data. */ + void *data ; /* Pointer to the data. */ +} ; + +typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ; + +/* Set the specified chunk info (must be done before any audio data is written +** to the file). This will fail for format specific reserved chunks. +** The chunk_info->data pointer must be valid until the file is closed. +** Returns SF_ERR_NO_ERROR on success or non-zero on failure. +*/ +int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* +** An opaque structure to an iterator over the all chunks of a given id +*/ +typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ; + +/* Get an iterator for all chunks matching chunk_info. +** The iterator will point to the first chunk matching chunk_info. +** Chunks are matching, if (chunk_info->id) matches the first +** (chunk_info->id_size) bytes of a chunk found in the SNDFILE* handle. +** If chunk_info is NULL, an iterator to all chunks in the SNDFILE* handle +** is returned. +** The values of chunk_info->datalen and chunk_info->data are ignored. +** If no matching chunks are found in the sndfile, NULL is returned. +** The returned iterator will stay valid until one of the following occurs: +** a) The sndfile is closed. +** b) A new chunk is added using sf_set_chunk(). +** c) Another chunk iterator function is called on the same SNDFILE* handle +** that causes the iterator to be modified. +** The memory for the iterator belongs to the SNDFILE* handle and is freed when +** sf_close() is called. +*/ +SF_CHUNK_ITERATOR * +sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* Iterate through chunks by incrementing the iterator. +** Increments the iterator and returns a handle to the new one. +** After this call, iterator will no longer be valid, and you must use the +** newly returned handle from now on. +** The returned handle can be used to access the next chunk matching +** the criteria as defined in sf_get_chunk_iterator(). +** If iterator points to the last chunk, this will free all resources +** associated with iterator and return NULL. +** The returned iterator will stay valid until sf_get_chunk_iterator_next +** is called again, the sndfile is closed or a new chunk us added. +*/ +SF_CHUNK_ITERATOR * +sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ; + + +/* Get the size of the specified chunk. +** If the specified chunk exists, the size will be returned in the +** datalen field of the SF_CHUNK_INFO struct. +** Additionally, the id of the chunk will be copied to the id +** field of the SF_CHUNK_INFO struct and it's id_size field will +** be updated accordingly. +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + +/* Get the specified chunk data. +** If the specified chunk exists, up to chunk_info->datalen bytes of +** the chunk data will be copied into the chunk_info->data buffer +** (allocated by the caller) and the chunk_info->datalen field +** updated to reflect the size of the data. The id and id_size +** field will be updated according to the retrieved chunk +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* SNDFILE_H */ + diff --git a/libs/win32/mpg123/libmpg123.2012.vcxproj b/libs/win32/mpg123/libmpg123.2012.vcxproj index b62c6083c5..c72a669d8d 100644 --- a/libs/win32/mpg123/libmpg123.2012.vcxproj +++ b/libs/win32/mpg123/libmpg123.2012.vcxproj @@ -247,7 +247,7 @@ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) @@ -265,7 +265,7 @@ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) @@ -289,7 +289,7 @@ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) @@ -307,13 +307,13 @@ MultiThreadedDLL false false - StreamingSIMDExtensions + NotSet Precise false Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) @@ -332,7 +332,7 @@ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) $(ProjectDir)Debug\$(ProjectName).dll @@ -359,7 +359,7 @@ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) $(ProjectDir)Debug\$(ProjectName).dll @@ -392,7 +392,7 @@ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) $(ProjectDir)Release\$(ProjectName).dll @@ -423,7 +423,7 @@ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) $(ProjectDir)Release\$(ProjectName).dll @@ -447,7 +447,7 @@ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnow.asm" @@ -534,7 +534,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnow.asm" @@ -627,7 +627,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnow.asm" @@ -720,7 +720,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ Level3 ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnow.asm" @@ -809,7 +809,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnow.asm" @@ -903,7 +903,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnow.asm" @@ -1006,7 +1006,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnow.asm" @@ -1112,7 +1112,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ false ProgramDatabase CompileAsC - 4996;%(DisableSpecificWarnings) + 4028;4334;4267;4996;%(DisableSpecificWarnings) cl /I "..\.." /EP /TC "$(ProjectDir)..\..\libmpg123\src\libmpg123\dct36_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnow.asm" diff --git a/libs/win32/mpg123/libmpg123.2012.vcxproj.filters b/libs/win32/mpg123/libmpg123.2012.vcxproj.filters index c2b9a2adca..8224e57fbd 100644 --- a/libs/win32/mpg123/libmpg123.2012.vcxproj.filters +++ b/libs/win32/mpg123/libmpg123.2012.vcxproj.filters @@ -15,68 +15,192 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + Source Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/win32/openssl/include/buffer.h b/libs/win32/openssl/include/buffer.h index 178e418282..f8da32b485 100644 --- a/libs/win32/openssl/include/buffer.h +++ b/libs/win32/openssl/include/buffer.h @@ -88,7 +88,7 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len); char * BUF_strdup(const char *str); char * BUF_strndup(const char *str, size_t siz); void * BUF_memdup(const void *data, size_t siz); -void BUF_reverse(unsigned char *out, unsigned char *in, size_t siz); +void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); /* safe string functions */ size_t BUF_strlcpy(char *dst,const char *src,size_t siz); diff --git a/libs/win32/openssl/include/crypto.h b/libs/win32/openssl/include/crypto.h index 6aeda0a9ac..f92fc5182d 100644 --- a/libs/win32/openssl/include/crypto.h +++ b/libs/win32/openssl/include/crypto.h @@ -488,10 +488,10 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), long (**go)(void)); void *CRYPTO_malloc_locked(int num, const char *file, int line); -void CRYPTO_free_locked(void *); +void CRYPTO_free_locked(void *ptr); void *CRYPTO_malloc(int num, const char *file, int line); char *CRYPTO_strdup(const char *str, const char *file, int line); -void CRYPTO_free(void *); +void CRYPTO_free(void *ptr); void *CRYPTO_realloc(void *addr,int num, const char *file, int line); void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, int line); @@ -574,6 +574,13 @@ void OPENSSL_init(void); #define fips_cipher_abort(alg) while(0) #endif +/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It + * takes an amount of time dependent on |len|, but independent of the contents + * of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a + * defined order as the return value when a != b is undefined, other than to be + * non-zero. */ +int CRYPTO_memcmp(const void *a, const void *b, size_t len); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. diff --git a/libs/win32/openssl/include/dtls1.h b/libs/win32/openssl/include/dtls1.h index 5008bf6081..e65d501191 100644 --- a/libs/win32/openssl/include/dtls1.h +++ b/libs/win32/openssl/include/dtls1.h @@ -57,8 +57,8 @@ * */ -#ifndef HEADER_DTLS1_H -#define HEADER_DTLS1_H +#ifndef HEADER_DTLS1_H +#define HEADER_DTLS1_H #include #include @@ -72,8 +72,12 @@ #elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_) #include #else +#if defined(OPENSSL_SYS_VXWORKS) +#include +#else #include #endif +#endif #ifdef __cplusplus extern "C" { diff --git a/libs/win32/openssl/include/ec.h b/libs/win32/openssl/include/ec.h index 9d01325af3..dfe8710d33 100644 --- a/libs/win32/openssl/include/ec.h +++ b/libs/win32/openssl/include/ec.h @@ -274,10 +274,10 @@ int EC_GROUP_get_curve_name(const EC_GROUP *group); void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); int EC_GROUP_get_asn1_flag(const EC_GROUP *group); -void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); +void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form); point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); -unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); size_t EC_GROUP_get_seed_len(const EC_GROUP *); size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); @@ -626,8 +626,8 @@ int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *c */ int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); -int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); -int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); +int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); +int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); /** Computes r = generator * n sum_{i=0}^num p[i] * m[i] * \param group underlying EC_GROUP object @@ -800,16 +800,24 @@ const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); unsigned EC_KEY_get_enc_flags(const EC_KEY *key); -void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); -point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); -void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); +void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); +void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); /* functions to set/get method specific data */ -void *EC_KEY_get_key_method_data(EC_KEY *, +void *EC_KEY_get_key_method_data(EC_KEY *key, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); -void EC_KEY_insert_key_method_data(EC_KEY *, void *data, +/** Sets the key method data of an EC_KEY object, if none has yet been set. + * \param key EC_KEY object + * \param data opaque data to install. + * \param dup_func a function that duplicates |data|. + * \param free_func a function that frees |data|. + * \param clear_free_func a function that wipes and frees |data|. + * \return the previously set data pointer, or NULL if |data| was inserted. + */ +void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); /* wrapper functions for the underlying EC_GROUP object */ -void EC_KEY_set_asn1_flag(EC_KEY *, int); +void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); /** Creates a table of pre-computed multiples of the generator to * accelerate further EC_KEY operations. diff --git a/libs/win32/openssl/include/evp.h b/libs/win32/openssl/include/evp.h index 0d1b20a7d3..faeb3c24e6 100644 --- a/libs/win32/openssl/include/evp.h +++ b/libs/win32/openssl/include/evp.h @@ -402,7 +402,6 @@ struct evp_cipher_st /* Length of tag for TLS */ #define EVP_GCM_TLS_TAG_LEN 16 - typedef struct evp_cipher_info_st { const EVP_CIPHER *cipher; @@ -789,8 +788,8 @@ const EVP_CIPHER *EVP_aes_128_cfb128(void); # define EVP_aes_128_cfb EVP_aes_128_cfb128 const EVP_CIPHER *EVP_aes_128_ofb(void); const EVP_CIPHER *EVP_aes_128_ctr(void); -const EVP_CIPHER *EVP_aes_128_gcm(void); const EVP_CIPHER *EVP_aes_128_ccm(void); +const EVP_CIPHER *EVP_aes_128_gcm(void); const EVP_CIPHER *EVP_aes_128_xts(void); const EVP_CIPHER *EVP_aes_192_ecb(void); const EVP_CIPHER *EVP_aes_192_cbc(void); @@ -800,8 +799,8 @@ const EVP_CIPHER *EVP_aes_192_cfb128(void); # define EVP_aes_192_cfb EVP_aes_192_cfb128 const EVP_CIPHER *EVP_aes_192_ofb(void); const EVP_CIPHER *EVP_aes_192_ctr(void); -const EVP_CIPHER *EVP_aes_192_gcm(void); const EVP_CIPHER *EVP_aes_192_ccm(void); +const EVP_CIPHER *EVP_aes_192_gcm(void); const EVP_CIPHER *EVP_aes_256_ecb(void); const EVP_CIPHER *EVP_aes_256_cbc(void); const EVP_CIPHER *EVP_aes_256_cfb1(void); @@ -810,8 +809,8 @@ const EVP_CIPHER *EVP_aes_256_cfb128(void); # define EVP_aes_256_cfb EVP_aes_256_cfb128 const EVP_CIPHER *EVP_aes_256_ofb(void); const EVP_CIPHER *EVP_aes_256_ctr(void); -const EVP_CIPHER *EVP_aes_256_gcm(void); const EVP_CIPHER *EVP_aes_256_ccm(void); +const EVP_CIPHER *EVP_aes_256_gcm(void); const EVP_CIPHER *EVP_aes_256_xts(void); #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); @@ -1243,6 +1242,8 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); +void EVP_add_alg_module(void); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. @@ -1257,6 +1258,7 @@ void ERR_load_EVP_strings(void); #define EVP_F_AES_INIT_KEY 133 #define EVP_F_AES_XTS 172 #define EVP_F_AES_XTS_CIPHER 175 +#define EVP_F_ALG_MODULE_INIT 177 #define EVP_F_CAMELLIA_INIT_KEY 159 #define EVP_F_CMAC_INIT 173 #define EVP_F_D2I_PKEY 100 @@ -1350,15 +1352,19 @@ void ERR_load_EVP_strings(void); #define EVP_R_DIFFERENT_PARAMETERS 153 #define EVP_R_DISABLED_FOR_FIPS 163 #define EVP_R_ENCODE_ERROR 115 +#define EVP_R_ERROR_LOADING_SECTION 165 +#define EVP_R_ERROR_SETTING_FIPS_MODE 166 #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 #define EVP_R_EXPECTING_AN_RSA_KEY 127 #define EVP_R_EXPECTING_A_DH_KEY 128 #define EVP_R_EXPECTING_A_DSA_KEY 129 #define EVP_R_EXPECTING_A_ECDSA_KEY 141 #define EVP_R_EXPECTING_A_EC_KEY 142 +#define EVP_R_FIPS_MODE_NOT_SUPPORTED 167 #define EVP_R_INITIALIZATION_ERROR 134 #define EVP_R_INPUT_NOT_INITIALIZED 111 #define EVP_R_INVALID_DIGEST 152 +#define EVP_R_INVALID_FIPS_MODE 168 #define EVP_R_INVALID_KEY_LENGTH 130 #define EVP_R_INVALID_OPERATION 148 #define EVP_R_IV_TOO_LARGE 102 @@ -1383,6 +1389,7 @@ void ERR_load_EVP_strings(void); #define EVP_R_TOO_LARGE 164 #define EVP_R_UNKNOWN_CIPHER 160 #define EVP_R_UNKNOWN_DIGEST 161 +#define EVP_R_UNKNOWN_OPTION 169 #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 #define EVP_R_UNSUPPORTED_ALGORITHM 156 diff --git a/libs/win32/openssl/include/md2.h b/libs/win32/openssl/include/md2.h deleted file mode 100644 index d59c9f2593..0000000000 --- a/libs/win32/openssl/include/md2.h +++ /dev/null @@ -1,95 +0,0 @@ -/* crypto/md/md2.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_MD2_H -#define HEADER_MD2_H - -#include /* OPENSSL_NO_MD2, MD2_INT */ -#ifdef OPENSSL_NO_MD2 -#error MD2 is disabled. -#endif -#include - -#define MD2_DIGEST_LENGTH 16 -#define MD2_BLOCK 16 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct MD2state_st - { - unsigned int num; - unsigned char data[MD2_BLOCK]; - MD2_INT cksm[MD2_BLOCK]; - MD2_INT state[MD2_BLOCK]; - } MD2_CTX; - -const char *MD2_options(void); -#ifdef OPENSSL_FIPS -int private_MD2_Init(MD2_CTX *c); -#endif -int MD2_Init(MD2_CTX *c); -int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); -int MD2_Final(unsigned char *md, MD2_CTX *c); -unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/win32/openssl/include/o_dir.h b/libs/win32/openssl/include/o_dir.h deleted file mode 100644 index 4b725c0312..0000000000 --- a/libs/win32/openssl/include/o_dir.h +++ /dev/null @@ -1,53 +0,0 @@ -/* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */ -/* Copied from Richard Levitte's (richard@levitte.org) LP library. All - * symbol names have been changed, with permission from the author. - */ - -/* $LP: LPlib/source/LPdir.h,v 1.1 2004/06/14 08:56:04 _cvs_levitte Exp $ */ -/* - * Copyright (c) 2004, Richard Levitte - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -#ifndef O_DIR_H -#define O_DIR_H - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX; - - /* returns NULL on error or end-of-directory. - If it is end-of-directory, errno will be zero */ - const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory); - /* returns 1 on success, 0 on error */ - int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* LPDIR_H */ diff --git a/libs/win32/openssl/include/o_str.h b/libs/win32/openssl/include/o_str.h deleted file mode 100644 index dfc98494c6..0000000000 --- a/libs/win32/openssl/include/o_str.h +++ /dev/null @@ -1,68 +0,0 @@ -/* crypto/o_str.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2003. - */ -/* ==================================================================== - * Copyright (c) 2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_O_STR_H -#define HEADER_O_STR_H - -#include /* to get size_t */ - -int OPENSSL_strcasecmp(const char *str1, const char *str2); -int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n); -int OPENSSL_memcmp(const void *p1,const void *p2,size_t n); - -#endif diff --git a/libs/win32/openssl/include/opensslv.h b/libs/win32/openssl/include/opensslv.h index 71be3590af..b27a5bb8c0 100644 --- a/libs/win32/openssl/include/opensslv.h +++ b/libs/win32/openssl/include/opensslv.h @@ -25,11 +25,11 @@ * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -#define OPENSSL_VERSION_NUMBER 0x1000103fL +#define OPENSSL_VERSION_NUMBER 0x1000106fL #ifdef OPENSSL_FIPS -#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1c-fips 10 May 2012" +#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1f-fips 6 Jan 2014" #else -#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1c 10 May 2012" +#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1f 6 Jan 2014" #endif #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT diff --git a/libs/win32/openssl/include/pq_compat.h b/libs/win32/openssl/include/pq_compat.h deleted file mode 100644 index 8745d1d788..0000000000 --- a/libs/win32/openssl/include/pq_compat.h +++ /dev/null @@ -1,2 +0,0 @@ -/* file generated by 'generate-global-headers.bat' */ -#include "..\../crypto/pqueue/pq_compat.h" diff --git a/libs/win32/openssl/include/rand.h b/libs/win32/openssl/include/rand.h index dc8fcf94c5..bb5520e80a 100644 --- a/libs/win32/openssl/include/rand.h +++ b/libs/win32/openssl/include/rand.h @@ -138,6 +138,7 @@ void ERR_load_RAND_strings(void); #define RAND_F_SSLEAY_RAND_BYTES 100 /* Reason codes. */ +#define RAND_R_DUAL_EC_DRBG_DISABLED 104 #define RAND_R_ERROR_INITIALISING_DRBG 102 #define RAND_R_ERROR_INSTANTIATING_DRBG 103 #define RAND_R_NO_FIPS_RANDOM_METHOD_SET 101 diff --git a/libs/win32/openssl/include/rc5.h b/libs/win32/openssl/include/rc5.h deleted file mode 100644 index 4b3c153b50..0000000000 --- a/libs/win32/openssl/include/rc5.h +++ /dev/null @@ -1,118 +0,0 @@ -/* crypto/rc5/rc5.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_RC5_H -#define HEADER_RC5_H - -#include /* OPENSSL_NO_RC5 */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_NO_RC5 -#error RC5 is disabled. -#endif - -#define RC5_ENCRYPT 1 -#define RC5_DECRYPT 0 - -/* 32 bit. For Alpha, things may get weird */ -#define RC5_32_INT unsigned long - -#define RC5_32_BLOCK 8 -#define RC5_32_KEY_LENGTH 16 /* This is a default, max is 255 */ - -/* This are the only values supported. Tweak the code if you want more - * The most supported modes will be - * RC5-32/12/16 - * RC5-32/16/8 - */ -#define RC5_8_ROUNDS 8 -#define RC5_12_ROUNDS 12 -#define RC5_16_ROUNDS 16 - -typedef struct rc5_key_st - { - /* Number of rounds */ - int rounds; - RC5_32_INT data[2*(RC5_16_ROUNDS+1)]; - } RC5_32_KEY; - - -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds); -void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key, - int enc); -void RC5_32_encrypt(unsigned long *data,RC5_32_KEY *key); -void RC5_32_decrypt(unsigned long *data,RC5_32_KEY *key); -void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *ks, unsigned char *iv, - int enc); -void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/win32/openssl/include/rsa.h b/libs/win32/openssl/include/rsa.h index 4814a2fc15..5f269e577a 100644 --- a/libs/win32/openssl/include/rsa.h +++ b/libs/win32/openssl/include/rsa.h @@ -280,7 +280,7 @@ struct rsa_st RSA * RSA_new(void); RSA * RSA_new_method(ENGINE *engine); -int RSA_size(const RSA *); +int RSA_size(const RSA *rsa); /* Deprecated version */ #ifndef OPENSSL_NO_DEPRECATED diff --git a/libs/win32/openssl/include/ssl.h b/libs/win32/openssl/include/ssl.h index 8b0c2a2dac..dece04de01 100644 --- a/libs/win32/openssl/include/ssl.h +++ b/libs/win32/openssl/include/ssl.h @@ -493,6 +493,9 @@ struct ssl_session_st char *psk_identity_hint; char *psk_identity; #endif + /* Used to indicate that session resumption is not allowed. + * Applications can also set this bit for a new session via + * not_resumable_session_cb to disable session caching and tickets. */ int not_resumable; /* The cert is the certificate used to establish this connection */ @@ -535,7 +538,7 @@ struct ssl_session_st #endif /* OPENSSL_NO_EC */ /* RFC4507 info */ unsigned char *tlsext_tick; /* Session ticket */ - size_t tlsext_ticklen; /* Session ticket length */ + size_t tlsext_ticklen; /* Session ticket length */ long tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */ #endif #ifndef OPENSSL_NO_SRP @@ -552,11 +555,14 @@ struct ssl_session_st #define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L #define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L #define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L -#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ +#define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040L #define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L #define SSL_OP_TLS_D5_BUG 0x00000100L #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L +/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */ +#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0 + /* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added * in OpenSSL 0.9.6d. Usually (depending on the application protocol) * the workaround is not needed. Unfortunately some broken SSL/TLS @@ -638,6 +644,12 @@ struct ssl_session_st * TLS only.) "Released" buffers are put onto a free-list in the context * or just freed (depending on the context's setting for freelist_max_len). */ #define SSL_MODE_RELEASE_BUFFERS 0x00000010L +/* Send the current time in the Random fields of the ClientHello and + * ServerHello records for compatibility with hypothetical implementations + * that require it. + */ +#define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L +#define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, * they cannot be used to clear bits. */ @@ -927,6 +939,7 @@ struct ssl_ctx_st /* Callback for status request */ int (*tlsext_status_cb)(SSL *ssl, void *arg); void *tlsext_status_arg; + /* draft-rescorla-tls-opaque-prf-input-00.txt information */ int (*tlsext_opaque_prf_input_callback)(SSL *, void *peerinput, size_t len, void *arg); void *tlsext_opaque_prf_input_callback_arg; @@ -952,6 +965,7 @@ struct ssl_ctx_st #endif #ifndef OPENSSL_NO_TLSEXT + # ifndef OPENSSL_NO_NEXTPROTONEG /* Next protocol negotiation information */ /* (for experimental NPN extension). */ @@ -2206,6 +2220,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL_GET_NEW_SESSION 181 #define SSL_F_SSL_GET_PREV_SESSION 217 #define SSL_F_SSL_GET_SERVER_SEND_CERT 182 +#define SSL_F_SSL_GET_SERVER_SEND_PKEY 317 #define SSL_F_SSL_GET_SIGN_PKEY 183 #define SSL_F_SSL_INIT_WBIO_BUFFER 184 #define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 diff --git a/libs/win32/openssl/include/ssl3.h b/libs/win32/openssl/include/ssl3.h index 112e627de0..cb8b2492ec 100644 --- a/libs/win32/openssl/include/ssl3.h +++ b/libs/win32/openssl/include/ssl3.h @@ -539,6 +539,15 @@ typedef struct ssl3_state_st /* Set if we saw the Next Protocol Negotiation extension from our peer. */ int next_proto_neg_seen; #endif + +#ifndef OPENSSL_NO_TLSEXT +#ifndef OPENSSL_NO_EC + /* This is set to true if we believe that this is a version of Safari + * running on OS X 10.6 or newer. We wish to know this because Safari + * on 10.8 .. 10.8.3 has broken ECDHE-ECDSA support. */ + char is_probably_safari; +#endif /* !OPENSSL_NO_EC */ +#endif /* !OPENSSL_NO_TLSEXT */ } SSL3_STATE; #endif @@ -578,8 +587,10 @@ typedef struct ssl3_state_st #define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) #define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) #define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) +#ifndef OPENSSL_NO_NEXTPROTONEG #define SSL3_ST_CW_NEXT_PROTO_A (0x200|SSL_ST_CONNECT) #define SSL3_ST_CW_NEXT_PROTO_B (0x201|SSL_ST_CONNECT) +#endif #define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) #define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) /* read from server */ @@ -629,8 +640,10 @@ typedef struct ssl3_state_st #define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) #define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) #define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) +#ifndef OPENSSL_NO_NEXTPROTONEG #define SSL3_ST_SR_NEXT_PROTO_A (0x210|SSL_ST_ACCEPT) #define SSL3_ST_SR_NEXT_PROTO_B (0x211|SSL_ST_ACCEPT) +#endif #define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) #define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) /* write to client */ @@ -655,7 +668,9 @@ typedef struct ssl3_state_st #define SSL3_MT_CLIENT_KEY_EXCHANGE 16 #define SSL3_MT_FINISHED 20 #define SSL3_MT_CERTIFICATE_STATUS 22 +#ifndef OPENSSL_NO_NEXTPROTONEG #define SSL3_MT_NEXT_PROTO 67 +#endif #define DTLS1_MT_HELLO_VERIFY_REQUEST 3 diff --git a/libs/win32/openssl/include/store.h b/libs/win32/openssl/include/store.h deleted file mode 100644 index 0a28c7d5a2..0000000000 --- a/libs/win32/openssl/include/store.h +++ /dev/null @@ -1,561 +0,0 @@ -/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2003. - */ -/* ==================================================================== - * Copyright (c) 2003 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_STORE_H -#define HEADER_STORE_H - -#include - -#ifdef OPENSSL_NO_STORE -#error STORE is disabled. -#endif - -#include -#ifndef OPENSSL_NO_DEPRECATED -#include -#include -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct store_st STORE; */ -/* typedef struct store_method_st STORE_METHOD; */ - - -/* All the following functions return 0, a negative number or NULL on error. - When everything is fine, they return a positive value or a non-NULL - pointer, all depending on their purpose. */ - -/* Creators and destructor. */ -STORE *STORE_new_method(const STORE_METHOD *method); -STORE *STORE_new_engine(ENGINE *engine); -void STORE_free(STORE *ui); - - -/* Give a user interface parametrised control commands. This can be used to - send down an integer, a data pointer or a function pointer, as well as - be used to get information from a STORE. */ -int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); - -/* A control to set the directory with keys and certificates. Used by the - built-in directory level method. */ -#define STORE_CTRL_SET_DIRECTORY 0x0001 -/* A control to set a file to load. Used by the built-in file level method. */ -#define STORE_CTRL_SET_FILE 0x0002 -/* A control to set a configuration file to load. Can be used by any method - that wishes to load a configuration file. */ -#define STORE_CTRL_SET_CONF_FILE 0x0003 -/* A control to set a the section of the loaded configuration file. Can be - used by any method that wishes to load a configuration file. */ -#define STORE_CTRL_SET_CONF_SECTION 0x0004 - - -/* Some methods may use extra data */ -#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) -#define STORE_get_app_data(s) STORE_get_ex_data(s,0) -int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); -int STORE_set_ex_data(STORE *r,int idx,void *arg); -void *STORE_get_ex_data(STORE *r, int idx); - -/* Use specific methods instead of the built-in one */ -const STORE_METHOD *STORE_get_method(STORE *store); -const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); - -/* The standard OpenSSL methods. */ -/* This is the in-memory method. It does everything except revoking and updating, - and is of course volatile. It's used by other methods that have an in-memory - cache. */ -const STORE_METHOD *STORE_Memory(void); -#if 0 /* Not yet implemented */ -/* This is the directory store. It does everything except revoking and updating, - and uses STORE_Memory() to cache things in memory. */ -const STORE_METHOD *STORE_Directory(void); -/* This is the file store. It does everything except revoking and updating, - and uses STORE_Memory() to cache things in memory. Certificates are added - to it with the store operation, and it will only get cached certificates. */ -const STORE_METHOD *STORE_File(void); -#endif - -/* Store functions take a type code for the type of data they should store - or fetch */ -typedef enum STORE_object_types - { - STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ - STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ - STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ - STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ - STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ - STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ - STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known - object types */ - } STORE_OBJECT_TYPES; -/* List of text strings corresponding to the object types. */ -extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; - -/* Some store functions take a parameter list. Those parameters come with - one of the following codes. The comments following the codes below indicate - what type the value should be a pointer to. */ -typedef enum STORE_params - { - STORE_PARAM_EVP_TYPE= 0x01, /* int */ - STORE_PARAM_BITS= 0x02, /* size_t */ - STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ - STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ - STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ - STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ - STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known - parameter types */ - } STORE_PARAM_TYPES; -/* Parameter value sizes. -1 means unknown, anything else is the required size. */ -extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; - -/* Store functions take attribute lists. Those attributes come with codes. - The comments following the codes below indicate what type the value should - be a pointer to. */ -typedef enum STORE_attribs - { - STORE_ATTR_END= 0x00, - STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ - STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ - STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ - STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ - STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ - STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ - STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ - STORE_ATTR_EMAIL= 0x0a, /* C string */ - STORE_ATTR_FILENAME= 0x0b, /* C string */ - STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known - attribute types */ - STORE_ATTR_OR= 0xff /* This is a special - separator, which - expresses the OR - operation. */ - } STORE_ATTR_TYPES; -/* Attribute value sizes. -1 means unknown, anything else is the required size. */ -extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; - -typedef enum STORE_certificate_status - { - STORE_X509_VALID= 0x00, - STORE_X509_EXPIRED= 0x01, - STORE_X509_SUSPENDED= 0x02, - STORE_X509_REVOKED= 0x03 - } STORE_CERTIFICATE_STATUS; - -/* Engine store functions will return a structure that contains all the necessary - * information, including revokation status for certificates. This is really not - * needed for application authors, as the ENGINE framework functions will extract - * the OpenSSL-specific information when at all possible. However, for engine - * authors, it's crucial to know this structure. */ -typedef struct STORE_OBJECT_st - { - STORE_OBJECT_TYPES type; - union - { - struct - { - STORE_CERTIFICATE_STATUS status; - X509 *certificate; - } x509; - X509_CRL *crl; - EVP_PKEY *key; - BIGNUM *number; - BUF_MEM *arbitrary; - } data; - } STORE_OBJECT; -DECLARE_STACK_OF(STORE_OBJECT) -STORE_OBJECT *STORE_OBJECT_new(void); -void STORE_OBJECT_free(STORE_OBJECT *data); - - - -/* The following functions handle the storage. They return 0, a negative number - or NULL on error, anything else on success. */ -X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509 *STORE_list_certificate_next(STORE *e, void *handle); -int STORE_list_certificate_end(STORE *e, void *handle); -int STORE_list_certificate_endp(STORE *e, void *handle); -EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_private_key(STORE *e, EVP_PKEY *data, - OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); -int STORE_list_private_key_end(STORE *e, void *handle); -int STORE_list_private_key_endp(STORE *e, void *handle); -EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); -int STORE_list_public_key_end(STORE *e, void *handle); -int STORE_list_public_key_endp(STORE *e, void *handle); -X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -X509_CRL *STORE_list_crl_next(STORE *e, void *handle); -int STORE_list_crl_end(STORE *e, void *handle); -int STORE_list_crl_endp(STORE *e, void *handle); -int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], - OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], - OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); -int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], - OPENSSL_ITEM parameters[]); - - -/* Create and manipulate methods */ -STORE_METHOD *STORE_create_method(char *name); -void STORE_destroy_method(STORE_METHOD *store_method); - -/* These callback types are use for store handlers */ -typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); -typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); -typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); -typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); -typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); -typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); - -int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); -int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); -int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); -int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); -int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); -int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); -int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); -int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); -int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); -int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); -int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); -int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); -int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); - -STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); -STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); -STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); -STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); -STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); -STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); -STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); -STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); -STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); -STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); -STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); -STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); -STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); - -/* Method helper structures and functions. */ - -/* This structure is the result of parsing through the information in a list - of OPENSSL_ITEMs. It stores all the necessary information in a structured - way.*/ -typedef struct STORE_attr_info_st STORE_ATTR_INFO; - -/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. - Note that we do this in the list form, since the list of OPENSSL_ITEMs can - come in blocks separated with STORE_ATTR_OR. Note that the value returned - by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ -void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); -STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); -int STORE_parse_attrs_end(void *handle); -int STORE_parse_attrs_endp(void *handle); - -/* Creator and destructor */ -STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); -int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); - -/* Manipulators */ -char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, - STORE_ATTR_TYPES code); -X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); -int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - char *cstr, size_t cstr_size); -int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - unsigned char *sha1str, size_t sha1str_size); -int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - X509_NAME *dn); -int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - BIGNUM *number); -int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - char *cstr, size_t cstr_size); -int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - unsigned char *sha1str, size_t sha1str_size); -int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - X509_NAME *dn); -int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, - BIGNUM *number); - -/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values - in each contained attribute. */ -int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, - const STORE_ATTR_INFO * const *b); -/* Check if the set of attributes in a is within the range of attributes - set in b. */ -int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); -/* Check if the set of attributes in a are also set in b. */ -int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); -/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ -int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); - - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_STORE_strings(void); - -/* Error codes for the STORE functions. */ - -/* Function codes. */ -#define STORE_F_MEM_DELETE 134 -#define STORE_F_MEM_GENERATE 135 -#define STORE_F_MEM_LIST_END 168 -#define STORE_F_MEM_LIST_NEXT 136 -#define STORE_F_MEM_LIST_START 137 -#define STORE_F_MEM_MODIFY 169 -#define STORE_F_MEM_STORE 138 -#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 -#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 -#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 -#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 -#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 -#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 -#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 -#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 -#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 -#define STORE_F_STORE_ATTR_INFO_SET_DN 148 -#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 -#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 -#define STORE_F_STORE_CERTIFICATE 170 -#define STORE_F_STORE_CTRL 161 -#define STORE_F_STORE_DELETE_ARBITRARY 158 -#define STORE_F_STORE_DELETE_CERTIFICATE 102 -#define STORE_F_STORE_DELETE_CRL 103 -#define STORE_F_STORE_DELETE_NUMBER 104 -#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 -#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 -#define STORE_F_STORE_GENERATE_CRL 107 -#define STORE_F_STORE_GENERATE_KEY 108 -#define STORE_F_STORE_GET_ARBITRARY 159 -#define STORE_F_STORE_GET_CERTIFICATE 109 -#define STORE_F_STORE_GET_CRL 110 -#define STORE_F_STORE_GET_NUMBER 111 -#define STORE_F_STORE_GET_PRIVATE_KEY 112 -#define STORE_F_STORE_GET_PUBLIC_KEY 113 -#define STORE_F_STORE_LIST_CERTIFICATE_END 114 -#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 -#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 -#define STORE_F_STORE_LIST_CERTIFICATE_START 116 -#define STORE_F_STORE_LIST_CRL_END 117 -#define STORE_F_STORE_LIST_CRL_ENDP 154 -#define STORE_F_STORE_LIST_CRL_NEXT 118 -#define STORE_F_STORE_LIST_CRL_START 119 -#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 -#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 -#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 -#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 -#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 -#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 -#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 -#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 -#define STORE_F_STORE_MODIFY_ARBITRARY 162 -#define STORE_F_STORE_MODIFY_CERTIFICATE 163 -#define STORE_F_STORE_MODIFY_CRL 164 -#define STORE_F_STORE_MODIFY_NUMBER 165 -#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 -#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 -#define STORE_F_STORE_NEW_ENGINE 133 -#define STORE_F_STORE_NEW_METHOD 132 -#define STORE_F_STORE_PARSE_ATTRS_END 151 -#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 -#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 -#define STORE_F_STORE_PARSE_ATTRS_START 171 -#define STORE_F_STORE_REVOKE_CERTIFICATE 129 -#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 -#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 -#define STORE_F_STORE_STORE_ARBITRARY 157 -#define STORE_F_STORE_STORE_CERTIFICATE 100 -#define STORE_F_STORE_STORE_CRL 101 -#define STORE_F_STORE_STORE_NUMBER 126 -#define STORE_F_STORE_STORE_PRIVATE_KEY 127 -#define STORE_F_STORE_STORE_PUBLIC_KEY 128 - -/* Reason codes. */ -#define STORE_R_ALREADY_HAS_A_VALUE 127 -#define STORE_R_FAILED_DELETING_ARBITRARY 132 -#define STORE_R_FAILED_DELETING_CERTIFICATE 100 -#define STORE_R_FAILED_DELETING_KEY 101 -#define STORE_R_FAILED_DELETING_NUMBER 102 -#define STORE_R_FAILED_GENERATING_CRL 103 -#define STORE_R_FAILED_GENERATING_KEY 104 -#define STORE_R_FAILED_GETTING_ARBITRARY 133 -#define STORE_R_FAILED_GETTING_CERTIFICATE 105 -#define STORE_R_FAILED_GETTING_KEY 106 -#define STORE_R_FAILED_GETTING_NUMBER 107 -#define STORE_R_FAILED_LISTING_CERTIFICATES 108 -#define STORE_R_FAILED_LISTING_KEYS 109 -#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 -#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 -#define STORE_R_FAILED_MODIFYING_CRL 140 -#define STORE_R_FAILED_MODIFYING_NUMBER 141 -#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 -#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 -#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 -#define STORE_R_FAILED_REVOKING_KEY 111 -#define STORE_R_FAILED_STORING_ARBITRARY 134 -#define STORE_R_FAILED_STORING_CERTIFICATE 112 -#define STORE_R_FAILED_STORING_KEY 113 -#define STORE_R_FAILED_STORING_NUMBER 114 -#define STORE_R_NOT_IMPLEMENTED 128 -#define STORE_R_NO_CONTROL_FUNCTION 144 -#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 -#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 -#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 -#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 -#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 -#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 -#define STORE_R_NO_GET_OBJECT_FUNCTION 119 -#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 -#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 -#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 -#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 -#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 -#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 -#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 -#define STORE_R_NO_STORE 129 -#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 -#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 -#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 -#define STORE_R_NO_VALUE 130 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/libs/win32/openssl/include/symhacks.h b/libs/win32/openssl/include/symhacks.h index 403f592dcd..07a412f845 100644 --- a/libs/win32/openssl/include/symhacks.h +++ b/libs/win32/openssl/include/symhacks.h @@ -193,17 +193,17 @@ #undef SSL_CTX_set_srp_username_callback #define SSL_CTX_set_srp_username_callback SSL_CTX_set_srp_un_cb #undef ssl_add_clienthello_use_srtp_ext -#define ssl_add_clienthello_use_srtp_ext ssl_add_clihello_use_srtp_ext +#define ssl_add_clienthello_use_srtp_ext ssl_add_clihello_use_srtp_ext #undef ssl_add_serverhello_use_srtp_ext -#define ssl_add_serverhello_use_srtp_ext ssl_add_serhello_use_srtp_ext +#define ssl_add_serverhello_use_srtp_ext ssl_add_serhello_use_srtp_ext #undef ssl_parse_clienthello_use_srtp_ext -#define ssl_parse_clienthello_use_srtp_ext ssl_parse_clihello_use_srtp_ext +#define ssl_parse_clienthello_use_srtp_ext ssl_parse_clihello_use_srtp_ext #undef ssl_parse_serverhello_use_srtp_ext -#define ssl_parse_serverhello_use_srtp_ext ssl_parse_serhello_use_srtp_ext +#define ssl_parse_serverhello_use_srtp_ext ssl_parse_serhello_use_srtp_ext #undef SSL_CTX_set_next_protos_advertised_cb -#define SSL_CTX_set_next_protos_advertised_cb SSL_CTX_set_next_protos_adv_cb +#define SSL_CTX_set_next_protos_advertised_cb SSL_CTX_set_next_protos_adv_cb #undef SSL_CTX_set_next_proto_select_cb -#define SSL_CTX_set_next_proto_select_cb SSL_CTX_set_next_proto_sel_cb +#define SSL_CTX_set_next_proto_select_cb SSL_CTX_set_next_proto_sel_cb /* Hack some long ENGINE names */ #undef ENGINE_get_default_BN_mod_exp_crt @@ -316,8 +316,6 @@ #define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf #undef ec_GFp_simple_points_make_affine #define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine -#undef ec_GFp_simple_group_get_curve_GFp -#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp #undef ec_GFp_simple_set_Jprojective_coordinates_GFp #define ec_GFp_simple_set_Jprojective_coordinates_GFp \ ec_GFp_smp_set_Jproj_coords_GFp diff --git a/libs/win32/openssl/include/tmdiff.h b/libs/win32/openssl/include/tmdiff.h deleted file mode 100644 index 8eb8256a4f..0000000000 --- a/libs/win32/openssl/include/tmdiff.h +++ /dev/null @@ -1,2 +0,0 @@ -/* file generated by 'generate-global-headers.bat' */ -#include "..\../crypto/tmdiff.h" diff --git a/libs/win32/openssl/libeay32.2010.vcxproj b/libs/win32/openssl/libeay32.2010.vcxproj index 23119ab5c1..6cb7d673de 100644 --- a/libs/win32/openssl/libeay32.2010.vcxproj +++ b/libs/win32/openssl/libeay32.2010.vcxproj @@ -81,18 +81,18 @@ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WINDOWS;WIN32;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -107,7 +107,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX86 @@ -115,11 +115,11 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S @@ -129,7 +129,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WINDOWS;WIN32;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -143,7 +143,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX64 @@ -151,18 +151,18 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S /Gs0 %(AdditionalOptions) Full AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -177,7 +177,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX86 @@ -185,11 +185,11 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S @@ -199,7 +199,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ /Gs0 %(AdditionalOptions) Full AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -213,679 +213,679 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/win32/openssl/libeay32.2010.vcxproj.filters b/libs/win32/openssl/libeay32.2010.vcxproj.filters index 594e7558c4..b72363f920 100644 --- a/libs/win32/openssl/libeay32.2010.vcxproj.filters +++ b/libs/win32/openssl/libeay32.2010.vcxproj.filters @@ -185,1998 +185,1998 @@ - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc4 - + Source Files\crypto\rc4 - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\ripemd - + Source Files\crypto\ripemd - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\err - + Source Files\crypto\err - + Source Files\crypto\err - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\buffer - + Source Files\crypto\buffer - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\stack - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\md5 - + Source Files\crypto\md5 - + Source Files\crypto\md4 - + Source Files\crypto\md4 - + Source Files\crypto\lhash - + Source Files\crypto\lhash - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\hmac - + Source Files\crypto\hmac - + Source Files\crypto\hmac - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\whrlpool - + Source Files\crypto\whrlpool - + Source Files\crypto\mdc2 - + Source Files\crypto\mdc2 - + Source Files\crypto\krb5 - + Source Files\crypto\txt_db - + Source Files\crypto\pqueue - + Source Files\ms - + Source Files\crypto\buffer - + Source Files\crypto\camellia - + Source Files\crypto\ec - + Source Files\crypto\rc4 - + Source Files\crypto\rsa - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\cms - + Source Files\crypto\cmac - + Source Files\crypto\cmac - + Source Files\crypto\cmac - + Source Files\crypto - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\srp - + Source Files\crypto\srp - + Source Files\crypto\evp - + Source Files\crypto\bn - + Source Files\crypto - + Source Files\crypto + + Source Files\crypto\evp + - + Header Files - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto\evp - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - - Header Files\openssl - - + Header Files\bf - + Header Files\bf - + Header Files\bf - + Header Files\ms diff --git a/libs/win32/openssl/libeay32.2012.vcxproj b/libs/win32/openssl/libeay32.2012.vcxproj index 5d387c1ae0..b74e567116 100644 --- a/libs/win32/openssl/libeay32.2012.vcxproj +++ b/libs/win32/openssl/libeay32.2012.vcxproj @@ -76,8 +76,8 @@ <_ProjectFileVersion>10.0.30319.1 true true - true - true + false + false $(PlatformName)\libeay32\$(Configuration)\ $(PlatformName)\libeay32\$(Configuration)\ $(PlatformName)\libeay32\$(Configuration)\ @@ -85,18 +85,18 @@ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WINDOWS;WIN32;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -106,12 +106,12 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ Level3 true ProgramDatabase - 4996;%(DisableSpecificWarnings) + 4164;4996;4267;4244;%(DisableSpecificWarnings) false ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX86 @@ -119,11 +119,11 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S @@ -133,7 +133,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WINDOWS;WIN32;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -142,12 +142,12 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ Level3 ProgramDatabase - 4996;%(DisableSpecificWarnings) + 4164;4996;4267;4244;%(DisableSpecificWarnings) false ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX64 @@ -155,18 +155,18 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S /Gs0 %(AdditionalOptions) Full AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -176,12 +176,12 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ Level3 true ProgramDatabase - 4996;%(DisableSpecificWarnings) + 4164;4996;4267;4244;%(DisableSpecificWarnings) false ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX86 @@ -189,11 +189,11 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ - copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\opensslconf.h" -copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\applink.c" -copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1c\crypto\buildinf.h" -copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\libeay32.def" -if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\" /C /Y /S + copy /Y "$(ProjectDir)opensslconf.h" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\opensslconf.h" +copy /Y "$(ProjectDir)applink.c" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\applink.c" +copy /Y "$(ProjectDir)buildinf.h" "$(ProjectDir)..\..\openssl-1.0.1f\crypto\buildinf.h" +copy /Y "$(ProjectDir)libeay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\libeay32.def" +if not exist "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\e_os.h" xcopy "$(ProjectDir)\include\*.*" "$(ProjectDir)..\..\openssl-1.0.1f\include\openssl\" /C /Y /S @@ -203,7 +203,7 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ /Gs0 %(AdditionalOptions) Full AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c\crypto\aes;..\..\openssl-1.0.1c\crypto\asn1;..\..\openssl-1.0.1c\crypto\bf;..\..\openssl-1.0.1c\crypto\bio;..\..\openssl-1.0.1c\crypto\bn;..\..\openssl-1.0.1c\crypto\buffer;..\..\openssl-1.0.1c\crypto\camellia;..\..\openssl-1.0.1c\crypto\cast;..\..\openssl-1.0.1c\crypto\cms;..\..\openssl-1.0.1c\crypto\comp;..\..\openssl-1.0.1c\crypto\conf;..\..\openssl-1.0.1c\crypto\des;..\..\openssl-1.0.1c\crypto\dh;..\..\openssl-1.0.1c\crypto\dsa;..\..\openssl-1.0.1c\crypto\dso;..\..\openssl-1.0.1c\crypto\ec;..\..\openssl-1.0.1c\crypto\ecdh;..\..\openssl-1.0.1c\crypto\ecdsa;..\..\openssl-1.0.1c\crypto\engine;..\..\openssl-1.0.1c\crypto\err;..\..\openssl-1.0.1c\crypto\evp;..\..\openssl-1.0.1c\crypto\modes;..\..\openssl-1.0.1c\ms;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f\crypto\aes;..\..\openssl-1.0.1f\crypto\asn1;..\..\openssl-1.0.1f\crypto\bf;..\..\openssl-1.0.1f\crypto\bio;..\..\openssl-1.0.1f\crypto\bn;..\..\openssl-1.0.1f\crypto\buffer;..\..\openssl-1.0.1f\crypto\camellia;..\..\openssl-1.0.1f\crypto\cast;..\..\openssl-1.0.1f\crypto\cms;..\..\openssl-1.0.1f\crypto\comp;..\..\openssl-1.0.1f\crypto\conf;..\..\openssl-1.0.1f\crypto\des;..\..\openssl-1.0.1f\crypto\dh;..\..\openssl-1.0.1f\crypto\dsa;..\..\openssl-1.0.1f\crypto\dso;..\..\openssl-1.0.1f\crypto\ec;..\..\openssl-1.0.1f\crypto\ecdh;..\..\openssl-1.0.1f\crypto\ecdsa;..\..\openssl-1.0.1f\crypto\engine;..\..\openssl-1.0.1f\crypto\err;..\..\openssl-1.0.1f\crypto\evp;..\..\openssl-1.0.1f\crypto\modes;..\..\openssl-1.0.1f\ms;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CRT_NON_CONFORMING_SWPRINTFS;OPENSSL_THREADS;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_NO_ASM;OPENSSL_NO_GMP;OPENSSL_NO_JPAKE;OPENSSL_NO_KRB5;OPENSSL_NO_MD2;OPENSSL_NO_RFC3779;OPENSSL_NO_STORE;OPENSSL_NO_STATIC_ENGINE;OPENSSL_BUILD_SHLIBCRYPTO;MK1MF_BUILD;OPENSSL_NO_SCTP;OPENSSL_NO_EC_NISTP_64_GCC_128;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -212,683 +212,684 @@ if not exist "$(ProjectDir)..\..\openssl-1.0.1c\include\openssl\e_os.h" xcopy "$ Level3 ProgramDatabase - 4996;%(DisableSpecificWarnings) + 4164;4996;4267;4244;%(DisableSpecificWarnings) false ws2_32.lib;%(AdditionalDependencies) - $(ProjectDir)..\..\openssl-1.0.1c\libeay32.def + $(ProjectDir)..\..\openssl-1.0.1f\libeay32.def true true MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/win32/openssl/libeay32.2012.vcxproj.filters b/libs/win32/openssl/libeay32.2012.vcxproj.filters index 0ec33e602d..b72363f920 100644 --- a/libs/win32/openssl/libeay32.2012.vcxproj.filters +++ b/libs/win32/openssl/libeay32.2012.vcxproj.filters @@ -185,1995 +185,1998 @@ - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc2 - + Source Files\crypto\rc4 - + Source Files\crypto\rc4 - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\idea - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\bf - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\cast - + Source Files\crypto\ripemd - + Source Files\crypto\ripemd - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\des - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\aes - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\camellia - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\seed - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\bn - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\rsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\dsa - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\rand - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\bio - + Source Files\crypto\err - + Source Files\crypto\err - + Source Files\crypto\err - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\ui - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\x509 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\asn1 - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\objects - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\buffer - + Source Files\crypto\buffer - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\cms - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\stack - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\pkcs7 - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\dh - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\ocsp - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\x509v3 - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\ts - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\conf - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdh - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\ecdsa - + Source Files\crypto\md5 - + Source Files\crypto\md5 - + Source Files\crypto\md4 - + Source Files\crypto\md4 - + Source Files\crypto\lhash - + Source Files\crypto\lhash - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\dso - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\pkcs12 - + Source Files\crypto\hmac - + Source Files\crypto\hmac - + Source Files\crypto\hmac - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\sha - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\comp - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\pem - + Source Files\crypto\whrlpool - + Source Files\crypto\whrlpool - + Source Files\crypto\mdc2 - + Source Files\crypto\mdc2 - + Source Files\crypto\krb5 - + Source Files\crypto\txt_db - + Source Files\crypto\pqueue - + Source Files\ms - + Source Files\crypto\buffer - + Source Files\crypto\camellia - + Source Files\crypto\ec - + Source Files\crypto\rc4 - + Source Files\crypto\rsa - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\evp - + Source Files\crypto\evp - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\modes - + Source Files\crypto\engine - + Source Files\crypto\engine - + Source Files\crypto\cms - + Source Files\crypto\cmac - + Source Files\crypto\cmac - + Source Files\crypto\cmac - + Source Files\crypto - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\ec - + Source Files\crypto\srp - + Source Files\crypto\srp - + Source Files\crypto\evp - + Source Files\crypto\bn - + Source Files\crypto - + Source Files\crypto + + Source Files\crypto\evp + - + Header Files - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto\evp - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\openssl - + Header Files\bf - + Header Files\bf - + Header Files\bf - + Header Files\ms diff --git a/libs/win32/openssl/libeay32.def b/libs/win32/openssl/libeay32.def index f98701635b..a6ddea5fe6 100644 --- a/libs/win32/openssl/libeay32.def +++ b/libs/win32/openssl/libeay32.def @@ -745,6 +745,7 @@ EXPORTS CRYPTO_mem_leaks @190 CRYPTO_mem_leaks_cb @191 CRYPTO_mem_leaks_fp @192 + CRYPTO_memcmp @3906 CRYPTO_new_ex_data @1027 CRYPTO_nistcts128_decrypt @4645 CRYPTO_nistcts128_decrypt_block @4634 @@ -1467,6 +1468,7 @@ EXPORTS EVP_SealInit @288 EVP_SignFinal @289 EVP_VerifyFinal @290 + EVP_add_alg_module @4077 EVP_add_cipher @292 EVP_add_digest @293 EVP_aes_128_cbc @2927 diff --git a/libs/win32/openssl/openssl.2010.vcxproj b/libs/win32/openssl/openssl.2010.vcxproj index fcc3f9e41c..800b451809 100644 --- a/libs/win32/openssl/openssl.2010.vcxproj +++ b/libs/win32/openssl/openssl.2010.vcxproj @@ -75,7 +75,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -103,7 +103,7 @@ MaxSpeed AnySuitable true - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -135,7 +135,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -165,7 +165,7 @@ MaxSpeed AnySuitable true - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -189,61 +189,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/libs/win32/openssl/openssl.2010.vcxproj.filters b/libs/win32/openssl/openssl.2010.vcxproj.filters index 293b866e4b..f415047bdc 100644 --- a/libs/win32/openssl/openssl.2010.vcxproj.filters +++ b/libs/win32/openssl/openssl.2010.vcxproj.filters @@ -17,165 +17,165 @@ - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Header Files\apps diff --git a/libs/win32/openssl/openssl.2012.vcxproj b/libs/win32/openssl/openssl.2012.vcxproj index 3c1fc97a01..d19f0a88ab 100644 --- a/libs/win32/openssl/openssl.2012.vcxproj +++ b/libs/win32/openssl/openssl.2012.vcxproj @@ -70,16 +70,16 @@ <_ProjectFileVersion>10.0.30319.1 true - true + false true - true + false /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -91,7 +91,7 @@ Level3 true ProgramDatabase - 4996;4133;%(DisableSpecificWarnings) + 4996;4133;4267;4244;%(DisableSpecificWarnings) ws2_32.lib;%(AdditionalDependencies) @@ -107,7 +107,7 @@ MaxSpeed AnySuitable true - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -119,7 +119,7 @@ Level3 true ProgramDatabase - 4996;4133;%(DisableSpecificWarnings) + 4996;4133;4267;4244;%(DisableSpecificWarnings) ws2_32.lib;%(AdditionalDependencies) @@ -139,7 +139,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -150,7 +150,7 @@ Level3 ProgramDatabase - 4996;4133;%(DisableSpecificWarnings) + 4996;4133;4267;4244;%(DisableSpecificWarnings) ws2_32.lib;%(AdditionalDependencies) @@ -169,7 +169,7 @@ MaxSpeed AnySuitable true - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;_CONSOLE;OPENSSL_THREADS;MONOLITH;DSO_WIN32;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;%(PreprocessorDefinitions) true true @@ -180,7 +180,7 @@ Level3 ProgramDatabase - 4996;4133;%(DisableSpecificWarnings) + 4996;4133;4267;4244;%(DisableSpecificWarnings) ws2_32.lib;%(AdditionalDependencies) @@ -193,61 +193,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/libs/win32/openssl/openssl.2012.vcxproj.filters b/libs/win32/openssl/openssl.2012.vcxproj.filters index 293b866e4b..f415047bdc 100644 --- a/libs/win32/openssl/openssl.2012.vcxproj.filters +++ b/libs/win32/openssl/openssl.2012.vcxproj.filters @@ -17,165 +17,165 @@ - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Source Files\apps - + Header Files\apps diff --git a/libs/win32/openssl/ssleay32.2010.vcxproj b/libs/win32/openssl/ssleay32.2010.vcxproj index 18b05a6d66..7c16015d6d 100644 --- a/libs/win32/openssl/ssleay32.2010.vcxproj +++ b/libs/win32/openssl/ssleay32.2010.vcxproj @@ -80,13 +80,13 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -96,6 +96,7 @@ Level3 true ProgramDatabase + 4244 $(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories) @@ -107,13 +108,13 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -123,6 +124,7 @@ Level3 true ProgramDatabase + 4244 $(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories) @@ -134,7 +136,7 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" X64 @@ -143,7 +145,7 @@ /Gs0 %(AdditionalOptions) Disabled AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -164,7 +166,7 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" X64 @@ -173,7 +175,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -193,57 +195,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/libs/win32/openssl/ssleay32.2010.vcxproj.filters b/libs/win32/openssl/ssleay32.2010.vcxproj.filters index 5c2e2bfdd9..527c3a58fc 100644 --- a/libs/win32/openssl/ssleay32.2010.vcxproj.filters +++ b/libs/win32/openssl/ssleay32.2010.vcxproj.filters @@ -20,153 +20,156 @@ - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + + Source Files\ssl + + Source Files\ssl - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto\evp diff --git a/libs/win32/openssl/ssleay32.2012.vcxproj b/libs/win32/openssl/ssleay32.2012.vcxproj index f362ef2d8b..310a8691ff 100644 --- a/libs/win32/openssl/ssleay32.2012.vcxproj +++ b/libs/win32/openssl/ssleay32.2012.vcxproj @@ -74,9 +74,9 @@ <_ProjectFileVersion>10.0.30319.1 true - true + false true - true + false $(PlatformName)\ssleay32\$(Configuration)\ $(PlatformName)\ssleay32\$(Configuration)\ $(PlatformName)\ssleay32\$(Configuration)\ @@ -84,13 +84,13 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -100,6 +100,7 @@ Level3 true ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) $(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories) @@ -111,13 +112,13 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -127,6 +128,7 @@ Level3 true ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) $(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories) @@ -138,7 +140,7 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" X64 @@ -147,7 +149,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;_DEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -156,6 +158,7 @@ Level3 ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) %(AdditionalDependencies) @@ -168,7 +171,7 @@ - copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1c\ssleay32.def" + copy /Y "$(ProjectDir)ssleay32.def" "$(ProjectDir)..\..\openssl-1.0.1f\ssleay32.def" X64 @@ -177,7 +180,7 @@ /Gs0 %(AdditionalOptions) MaxSpeed AnySuitable - ..\..\openssl-1.0.1c\include;..\..\openssl-1.0.1c\crypto;..\..\openssl-1.0.1c;%(AdditionalIncludeDirectories) + ..\..\openssl-1.0.1f\include;..\..\openssl-1.0.1f\crypto;..\..\openssl-1.0.1f;%(AdditionalIncludeDirectories) WIN32;NDEBUG;DSO_WIN32;OPENSSL_THREADS;OPENSSL_SYSNAME_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;_CRT_SECURE_NO_DEPRECATE;OPENSSL_USE_APPLINK;OPENSSL_NO_RC5;OPENSSL_NO_MD2;OPENSSL_NO_KRB5;OPENSSL_NO_JPAKE;OPENSSL_NO_STATIC_ENGINE;_WINDLL;OPENSSL_BUILD_SHLIBSSL;OPENSSL_NO_SCTP;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -186,6 +189,7 @@ Level3 ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) %(AdditionalDependencies) @@ -197,57 +201,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/libs/win32/openssl/ssleay32.2012.vcxproj.filters b/libs/win32/openssl/ssleay32.2012.vcxproj.filters index 3b97d043dd..527c3a58fc 100644 --- a/libs/win32/openssl/ssleay32.2012.vcxproj.filters +++ b/libs/win32/openssl/ssleay32.2012.vcxproj.filters @@ -20,153 +20,156 @@ - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + Source Files\ssl - + + Source Files\ssl + + Source Files\ssl - + Header Files\crypto - + Header Files\crypto - + Header Files\crypto\evp diff --git a/libs/win32/opus/opus.2010.vcxproj b/libs/win32/opus/opus.2010.vcxproj new file mode 100644 index 0000000000..7dc9cd19e4 --- /dev/null +++ b/libs/win32/opus/opus.2010.vcxproj @@ -0,0 +1,250 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Win32Proj + opus + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} + + + + StaticLibrary + true + + + StaticLibrary + true + + + false + StaticLibrary + true + + + StaticLibrary + false + + + + + + + + + + + + + + + + + + + true + opus + + + true + opus + + + false + opus + + + false + + + opus + + + + HAVE_CONFIG_H;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + MachineX86 + true + Console + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + true + Console + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + HAVE_CONFIG_H;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + true + + + MachineX86 + false + Console + true + true + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + false + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + + + false + Console + true + true + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + false + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + false + false + false + false + false + + + {245603e3-f580-41a5-9632-b25fe3372cbf} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {8484c90d-1561-402f-a91d-2db10f8c5171} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + + + + diff --git a/libs/win32/opus/opus.2010.vcxproj.filters b/libs/win32/opus/opus.2010.vcxproj.filters new file mode 100644 index 0000000000..80b78c2044 --- /dev/null +++ b/libs/win32/opus/opus.2010.vcxproj.filters @@ -0,0 +1,93 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.2012.vcxproj b/libs/win32/opus/opus.2012.vcxproj new file mode 100644 index 0000000000..85a42fc893 --- /dev/null +++ b/libs/win32/opus/opus.2012.vcxproj @@ -0,0 +1,262 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Win32Proj + opus + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} + + + + StaticLibrary + true + v110 + + + StaticLibrary + true + v110 + + + false + StaticLibrary + true + v110 + + + StaticLibrary + false + v110 + + + + + + + + + + + + + + + + + + + true + opus + $(Platform)\$(Configuration)\opus\ + + + true + opus + $(Platform)\$(Configuration)\opus\ + + + false + opus + $(Platform)\$(Configuration)\opus\ + + + false + + + opus + $(Platform)\$(Configuration)\opus\ + + + + _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + 4334;4244;%(DisableSpecificWarnings) + + + MachineX86 + true + Console + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + 4334;4244;%(DisableSpecificWarnings) + + + true + Console + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + true + 4334;4244;%(DisableSpecificWarnings) + + + MachineX86 + false + Console + true + true + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + false + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\celt;..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + 4334;4244;%(DisableSpecificWarnings) + + + false + Console + true + true + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories) + false + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + false + false + false + false + false + + + {245603e3-f580-41a5-9632-b25fe3372cbf} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {8484c90d-1561-402f-a91d-2db10f8c5171} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + + + + diff --git a/libs/win32/opus/opus.2012.vcxproj.filters b/libs/win32/opus/opus.2012.vcxproj.filters new file mode 100644 index 0000000000..80b78c2044 --- /dev/null +++ b/libs/win32/opus/opus.2012.vcxproj.filters @@ -0,0 +1,93 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.celt.2010.vcxproj b/libs/win32/opus/opus.celt.2010.vcxproj new file mode 100644 index 0000000000..f722cb0a0d --- /dev/null +++ b/libs/win32/opus/opus.celt.2010.vcxproj @@ -0,0 +1,252 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {245603E3-F580-41A5-9632-B25FE3372CBF} + Win32Proj + opus.celt + opus.celt + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + celt + + + + celt + + + + celt + + + celt + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + + + + diff --git a/libs/win32/opus/opus.celt.2010.vcxproj.filters b/libs/win32/opus/opus.celt.2010.vcxproj.filters new file mode 100644 index 0000000000..9cdc36139e --- /dev/null +++ b/libs/win32/opus/opus.celt.2010.vcxproj.filters @@ -0,0 +1,147 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/libs/win32/opus/opus.celt.2012.vcxproj b/libs/win32/opus/opus.celt.2012.vcxproj new file mode 100644 index 0000000000..bf9051e833 --- /dev/null +++ b/libs/win32/opus/opus.celt.2012.vcxproj @@ -0,0 +1,260 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {245603E3-F580-41A5-9632-B25FE3372CBF} + Win32Proj + opus.celt + opus.celt + + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + + + + + + + + + + + + + + + + + + + + celt + $(Platform)\$(Configuration)\opus.celt\ + + + + celt + $(Platform)\$(Configuration)\opus.celt\ + + + + celt + $(Platform)\$(Configuration)\opus.celt\ + + + celt + $(Platform)\$(Configuration)\opus.celt\ + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\win32;..\..\opus-1.1\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + + + + diff --git a/libs/win32/opus/opus.celt.2012.vcxproj.filters b/libs/win32/opus/opus.celt.2012.vcxproj.filters new file mode 100644 index 0000000000..9cdc36139e --- /dev/null +++ b/libs/win32/opus/opus.celt.2012.vcxproj.filters @@ -0,0 +1,147 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/libs/win32/opus/opus.silk_common.2010.vcxproj b/libs/win32/opus/opus.silk_common.2010.vcxproj new file mode 100644 index 0000000000..6e17e5cdc7 --- /dev/null +++ b/libs/win32/opus/opus.silk_common.2010.vcxproj @@ -0,0 +1,307 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + Win32Proj + src_common + opus.silk_common + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + silk_common + + + silk_common + + + silk_common + + + + + silk_common + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + Fast + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + Fast + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + + + + diff --git a/libs/win32/opus/opus.silk_common.2010.vcxproj.filters b/libs/win32/opus/opus.silk_common.2010.vcxproj.filters new file mode 100644 index 0000000000..000040c0ca --- /dev/null +++ b/libs/win32/opus/opus.silk_common.2010.vcxproj.filters @@ -0,0 +1,315 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.silk_common.2012.vcxproj b/libs/win32/opus/opus.silk_common.2012.vcxproj new file mode 100644 index 0000000000..1798f8498f --- /dev/null +++ b/libs/win32/opus/opus.silk_common.2012.vcxproj @@ -0,0 +1,315 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + Win32Proj + src_common + opus.silk_common + + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + + + + + + + + + + + + + + + + + silk_common + $(Platform)\$(Configuration)\opus.silk_common\ + + + silk_common + $(Platform)\$(Configuration)\opus.silk_common\ + + + silk_common + $(Platform)\$(Configuration)\opus.silk_common\ + + + + + silk_common + $(Platform)\$(Configuration)\opus.silk_common\ + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + Fast + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\fixed;..\..\opus-1.1\silk\float;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + Fast + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + + + + diff --git a/libs/win32/opus/opus.silk_common.2012.vcxproj.filters b/libs/win32/opus/opus.silk_common.2012.vcxproj.filters new file mode 100644 index 0000000000..000040c0ca --- /dev/null +++ b/libs/win32/opus/opus.silk_common.2012.vcxproj.filters @@ -0,0 +1,315 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.silk_fixed.2010.vcxproj b/libs/win32/opus/opus.silk_fixed.2010.vcxproj new file mode 100644 index 0000000000..33a7f5a065 --- /dev/null +++ b/libs/win32/opus/opus.silk_fixed.2010.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {8484C90D-1561-402F-A91D-2DB10F8C5171} + Win32Proj + src_FIX + opus.silk_fixed + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + silk_fixed + + + silk_fixed + + + silk_fixed + + + silk_fixed + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + + + + diff --git a/libs/win32/opus/opus.silk_fixed.2010.vcxproj.filters b/libs/win32/opus/opus.silk_fixed.2010.vcxproj.filters new file mode 100644 index 0000000000..d4c0785df5 --- /dev/null +++ b/libs/win32/opus/opus.silk_fixed.2010.vcxproj.filters @@ -0,0 +1,111 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.silk_fixed.2012.vcxproj b/libs/win32/opus/opus.silk_fixed.2012.vcxproj new file mode 100644 index 0000000000..a8be2de5b8 --- /dev/null +++ b/libs/win32/opus/opus.silk_fixed.2012.vcxproj @@ -0,0 +1,205 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {8484C90D-1561-402F-A91D-2DB10F8C5171} + Win32Proj + src_FIX + opus.silk_fixed + + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + + + + + + + + + + + + + + + + + silk_fixed + $(Platform)\$(Configuration)\silk_fixed\ + + + silk_fixed + $(Platform)\$(Configuration)\silk_fixed\ + + + silk_fixed + $(Platform)\$(Configuration)\silk_fixed\ + + + silk_fixed + $(Platform)\$(Configuration)\silk_fixed\ + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + 4244;4133;%(DisableSpecificWarnings) + + + Windows + true + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + 4244;4133;%(DisableSpecificWarnings) + + + Windows + true + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + 4244;4133;%(DisableSpecificWarnings) + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk\;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + 4244;4133;%(DisableSpecificWarnings) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + + + + diff --git a/libs/win32/opus/opus.silk_fixed.2012.vcxproj.filters b/libs/win32/opus/opus.silk_fixed.2012.vcxproj.filters new file mode 100644 index 0000000000..d4c0785df5 --- /dev/null +++ b/libs/win32/opus/opus.silk_fixed.2012.vcxproj.filters @@ -0,0 +1,111 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.silk_float.2010.vcxproj b/libs/win32/opus/opus.silk_float.2010.vcxproj new file mode 100644 index 0000000000..85be5aad3e --- /dev/null +++ b/libs/win32/opus/opus.silk_float.2010.vcxproj @@ -0,0 +1,245 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} + Win32Proj + src_FLP + opus.silk_float + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + silk_float + + + silk_float + + + silk_float + + + Compile + silk_float + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + + + + diff --git a/libs/win32/opus/opus.silk_float.2010.vcxproj.filters b/libs/win32/opus/opus.silk_float.2010.vcxproj.filters new file mode 100644 index 0000000000..4e132e1222 --- /dev/null +++ b/libs/win32/opus/opus.silk_float.2010.vcxproj.filters @@ -0,0 +1,129 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/opus/opus.silk_float.2012.vcxproj b/libs/win32/opus/opus.silk_float.2012.vcxproj new file mode 100644 index 0000000000..2cd54a22c1 --- /dev/null +++ b/libs/win32/opus/opus.silk_float.2012.vcxproj @@ -0,0 +1,253 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} + Win32Proj + src_FLP + opus.silk_float + + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + StaticLibrary + false + true + Unicode + v110 + + + + + + + + + + + + + + + + + + + silk_float + $(Platform)\$(Configuration)\silk_float\ + + + silk_float + $(Platform)\$(Configuration)\silk_float\ + + + silk_float + $(Platform)\$(Configuration)\silk_float\ + + + Compile + silk_float + $(Platform)\$(Configuration)\silk_float\ + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDebugDLL + + + Windows + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\opus-1.1\silk;..\..\opus-1.1\silk\fixed;..\..\opus-1.1\win32;..\..\opus-1.1\celt;..\..\opus-1.1\include + MultiThreadedDLL + + + Windows + true + true + true + + + "$(ProjectDir)..\..\opus-1.1\win32\genversion.bat" "$(ProjectDir)..\..\opus-1.1\win32\version.h" OPUS_VERSION + Generating version.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {092124c9-09ed-43c7-bd6d-4ae5d6b3c547} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + + + + diff --git a/libs/win32/opus/opus.silk_float.2012.vcxproj.filters b/libs/win32/opus/opus.silk_float.2012.vcxproj.filters new file mode 100644 index 0000000000..4e132e1222 --- /dev/null +++ b/libs/win32/opus/opus.silk_float.2012.vcxproj.filters @@ -0,0 +1,129 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + diff --git a/libs/win32/pcre/libpcre.2012.vcxproj b/libs/win32/pcre/libpcre.2012.vcxproj index fdd48188de..ad55fa5db5 100644 --- a/libs/win32/pcre/libpcre.2012.vcxproj +++ b/libs/win32/pcre/libpcre.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -137,6 +137,7 @@ MultiThreadedDebugDLL Level3 true + 4267;4244;%(DisableSpecificWarnings) true @@ -152,6 +153,7 @@ MultiThreadedDebugDLL Level3 true + 4267;4244;%(DisableSpecificWarnings) @@ -165,6 +167,7 @@ true Level3 true + 4267;4244;%(DisableSpecificWarnings) true @@ -181,6 +184,7 @@ true Level3 true + 4267;4244;%(DisableSpecificWarnings) true @@ -222,6 +226,7 @@ Level3 true ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -284,6 +289,7 @@ Level3 true ProgramDatabase + 4267;4244;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -346,6 +352,7 @@ $(IntDir) Level3 true + 4267;4244;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -407,6 +414,7 @@ $(IntDir) Level3 true + 4267;4244;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj index 041ff68ec6..1bd39b525c 100644 --- a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj +++ b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj @@ -78,7 +78,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Disabled - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true EnableFastChecks @@ -114,7 +114,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Disabled - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) _WIN64;WIN32;_DEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true EnableFastChecks @@ -148,7 +148,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" MaxSpeed OnlyExplicitInline - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -185,7 +185,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" MaxSpeed OnlyExplicitInline - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) _WIN64;WIN32;NDEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true MultiThreadedDLL diff --git a/libs/win32/sofia/libsofia_sip_ua_static.2012.vcxproj b/libs/win32/sofia/libsofia_sip_ua_static.2012.vcxproj index a5d64ced41..fbc38c2692 100644 --- a/libs/win32/sofia/libsofia_sip_ua_static.2012.vcxproj +++ b/libs/win32/sofia/libsofia_sip_ua_static.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -82,7 +82,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Disabled - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true EnableFastChecks @@ -91,6 +91,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Level4 true true + 4244;4267;4306;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -118,7 +119,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Disabled - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) _WIN64;WIN32;_DEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true EnableFastChecks @@ -127,6 +128,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Level4 false true + 4244;4267;4306;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -152,7 +154,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" MaxSpeed OnlyExplicitInline - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -161,6 +163,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Level4 true true + 4244;4267;4306;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -189,7 +192,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" MaxSpeed OnlyExplicitInline - ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1c\include;%(AdditionalIncludeDirectories) + ..\..\sofia-sip\win32;..\..\sofia-sip\libsofia-sip-ua\su;..\..\sofia-sip\libsofia-sip-ua\ipt;..\..\sofia-sip\libsofia-sip-ua\sresolv;..\..\sofia-sip\libsofia-sip-ua\bnf;..\..\sofia-sip\libsofia-sip-ua\url;..\..\sofia-sip\libsofia-sip-ua\msg;..\..\sofia-sip\libsofia-sip-ua\sip;..\..\sofia-sip\libsofia-sip-ua\nta;..\..\sofia-sip\libsofia-sip-ua\nua;..\..\sofia-sip\libsofia-sip-ua\iptsec;..\..\sofia-sip\libsofia-sip-ua\http;..\..\sofia-sip\libsofia-sip-ua\nth;..\..\sofia-sip\libsofia-sip-ua\nea;..\..\sofia-sip\libsofia-sip-ua\sdp;..\..\sofia-sip\libsofia-sip-ua\soa;..\..\sofia-sip\libsofia-sip-ua\stun;..\..\sofia-sip\libsofia-sip-ua\tport;..\..\sofia-sip\libsofia-sip-ua\features;..\..\pthreads-w32-2-9-1;.;..\..\openssl-1.0.1f\include;%(AdditionalIncludeDirectories) _WIN64;WIN32;NDEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC;PTW32_STATIC_LIB;HAVE_IPHLPAPI_H;SU_DEBUG=0;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -198,6 +201,7 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd" Level4 false true + 4244;4267;4306;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/libs/win32/v8/build-v8.bat b/libs/win32/v8/build-v8.bat new file mode 100644 index 0000000000..c0184d7b5e --- /dev/null +++ b/libs/win32/v8/build-v8.bat @@ -0,0 +1,88 @@ +@ECHO OFF + +REM First argument is the target architecture +REM Second argument is "Debug" or "Release" mode +REM Third argument is the V8 root directory path +REM Fourth argument is the version of Visual Studio (optional) + +IF "%1" == "" GOTO Fail +IF "%2" == "" GOTO Fail +IF "%3" == "" GOTO Fail + +REM Go into the V8 lib directory +cd "%3" + +REM Check the last build info, so we know if we're supposed to build again or not +SET /P LAST_BUILD_INFO= last_build + +exit + +:Fail +REM Delete the last_build info if this build failed! +@del /Q last_build +exit /b 1 diff --git a/libs/win32/v8/libv8.2010.vcxproj b/libs/win32/v8/libv8.2010.vcxproj new file mode 100644 index 0000000000..b76c35969b --- /dev/null +++ b/libs/win32/v8/libv8.2010.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + libv8 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} + libv8 + Win32Proj + + + + Utility + MultiByte + + + Utility + MultiByte + + + Utility + MultiByte + + + Utility + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + X64 + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + X64 + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Building Google V8 + $(ProjectDir)build-v8.bat x86 Release "$(ProjectDir)..\..\v8-$(V8Version)" 2010 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x86 Debug "$(ProjectDir)..\..\v8-$(V8Version)" 2010 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x64 Release "$(ProjectDir)..\..\v8-$(V8Version)" 2010 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x64 Debug "$(ProjectDir)..\..\v8-$(V8Version)" 2010 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + + + + + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} + false + + + + + + diff --git a/libs/win32/v8/libv8.2012.vcxproj b/libs/win32/v8/libv8.2012.vcxproj new file mode 100644 index 0000000000..0a9f09ea8d --- /dev/null +++ b/libs/win32/v8/libv8.2012.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + libv8 + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} + libv8 + Win32Proj + + + + Utility + MultiByte + v110 + + + Utility + MultiByte + v110 + + + Utility + MultiByte + v110 + + + Utility + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + $(PlatformName)\V8\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + X64 + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + X64 + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + Document + Building Google V8 + $(ProjectDir)build-v8.bat x86 Release "$(ProjectDir)..\..\v8-$(V8Version)" 2012 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x86 Debug "$(ProjectDir)..\..\v8-$(V8Version)" 2012 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x64 Release "$(ProjectDir)..\..\v8-$(V8Version)" 2012 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + Building Google V8 + $(ProjectDir)build-v8.bat x64 Debug "$(ProjectDir)..\..\v8-$(V8Version)" 2012 + + $(ProjectDir)..\..\v8-$(V8Version);%(Outputs) + + + + + {13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF} + false + + + + + + diff --git a/libs/win32/xmlrpc-c/abyss.2012.vcxproj b/libs/win32/xmlrpc-c/abyss.2012.vcxproj index 3c75e4c41a..22dc1562d5 100644 --- a/libs/win32/xmlrpc-c/abyss.2012.vcxproj +++ b/libs/win32/xmlrpc-c/abyss.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -89,6 +89,7 @@ MultiThreadedDebugDLL Level3 true + 4267;4244;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -114,6 +115,7 @@ MultiThreadedDebugDLL Level3 true + 4267;4244;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -137,6 +139,7 @@ true Level3 true + 4267;4244;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -163,6 +166,7 @@ true Level3 true + 4267;4244;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/libs/win32/xmlrpc-c/gennmtab.2012.vcxproj b/libs/win32/xmlrpc-c/gennmtab.2012.vcxproj index 41a93ea7e4..88ef30278c 100644 --- a/libs/win32/xmlrpc-c/gennmtab.2012.vcxproj +++ b/libs/win32/xmlrpc-c/gennmtab.2012.vcxproj @@ -132,6 +132,7 @@ MachineX86 + false true @@ -181,6 +182,7 @@ false + false true diff --git a/libs/win32/xmlrpc-c/xmlparse.2012.vcxproj b/libs/win32/xmlrpc-c/xmlparse.2012.vcxproj index dc790fccf6..8dc7a0d927 100644 --- a/libs/win32/xmlrpc-c/xmlparse.2012.vcxproj +++ b/libs/win32/xmlrpc-c/xmlparse.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -95,10 +95,11 @@ $(XMLRPCDir)lib\expat\xmltok;$(XMLRPCDir)lib\expat\xmlwf;%(AdditionalIncludeDirectories) NDEBUG;WIN32;_WINDOWS;XML_DTD;_LIB;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -136,10 +137,11 @@ popd $(XMLRPCDir)lib\expat\xmltok;$(XMLRPCDir)lib\expat\xmlwf;%(AdditionalIncludeDirectories) NDEBUG;WIN32;_WINDOWS;XML_DTD;_LIB;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -178,6 +180,7 @@ popd Level3 true ProgramDatabase + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -219,6 +222,7 @@ popd Level3 true ProgramDatabase + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) diff --git a/libs/win32/xmlrpc-c/xmlrpc.2012.vcxproj b/libs/win32/xmlrpc-c/xmlrpc.2012.vcxproj index 6f4d7a4031..b5c2998870 100644 --- a/libs/win32/xmlrpc-c/xmlrpc.2012.vcxproj +++ b/libs/win32/xmlrpc-c/xmlrpc.2012.vcxproj @@ -91,6 +91,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -120,6 +121,7 @@ MultiThreadedDebugDLL Level3 true + 4267;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -148,6 +150,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -178,6 +181,7 @@ true Level3 true + 4267;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/libs/win32/xmlrpc-c/xmltok.2012.vcxproj b/libs/win32/xmlrpc-c/xmltok.2012.vcxproj index 79592f57b4..fa8186cfbb 100644 --- a/libs/win32/xmlrpc-c/xmltok.2012.vcxproj +++ b/libs/win32/xmlrpc-c/xmltok.2012.vcxproj @@ -139,7 +139,7 @@ %(AdditionalIncludeDirectories) NDEBUG;XML_NS;WIN32;_WINDOWS;XML_DTD;_LIB;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Level3 true @@ -166,7 +166,7 @@ %(AdditionalIncludeDirectories) NDEBUG;XML_NS;WIN32;_WINDOWS;XML_DTD;_LIB;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Level3 true diff --git a/libs/xmlrpc-c/include/xmlrpc-c/util_int.h b/libs/xmlrpc-c/include/xmlrpc-c/util_int.h index db5c5e9114..5596eed244 100644 --- a/libs/xmlrpc-c/include/xmlrpc-c/util_int.h +++ b/libs/xmlrpc-c/include/xmlrpc-c/util_int.h @@ -12,8 +12,12 @@ #include "util.h" +#ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif /* When we deallocate a pointer in a struct, we often replace it with ** this and throw in a few assertions here and there. */ diff --git a/patches/FS-2746.diff b/patches/FS-2746.diff index c62f40dc2c..ce22bcfb57 100644 --- a/patches/FS-2746.diff +++ b/patches/FS-2746.diff @@ -73573,7 +73573,7 @@ index 679f29b..df87773 100644 -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * @@ -22,7 +22,7 @@ * the Initial Developer. All Rights Reserved. @@ -75445,7 +75445,7 @@ index 9b20546..4489cfc 100644 -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * @@ -22,13 +22,38 @@ * the Initial Developer. All Rights Reserved. diff --git a/scripts/backtrace-from-core b/scripts/backtrace-from-core new file mode 100755 index 0000000000..342bcc71bc --- /dev/null +++ b/scripts/backtrace-from-core @@ -0,0 +1,91 @@ +#!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- +##### Author: Travis Cross + +log1 () { printf '%s' "$1">&2; } +log () { printf '%s\n' "$1">&2; } +err () { log "$1"; exit 1; } + +usage () { + local opt="$1" bs="" be="" + $opt && { bs="[ "; be=" ]"; } + log "usage: $0 ${bs}${be}" +} + +while getopts "h" o; do + case "$o" in + h) usage true; exit 0; ;; + esac +done +shift $(($OPTIND-1)) + + +if [ $# -lt 1 ]; then + usage true; exit 1 +fi +core="$1" +if ! [ $# -lt 2 ]; then + fspath="$2" + [ -x "$fspath" ] || err "Not executable: $fspath" +fi +btpath="/tmp/$(date -u +%Y%m%dT%H%M%SZ)-bt.txt" +if [ -z "$fspath" ]; then + for x in "$(which freeswitch)" \ + /usr/bin/freeswitch /usr/sbin/freeswitch \ + /usr/local/bin/freeswitch /usr/local/sbin/freeswitch \ + /opt/freeswitch/bin/freeswitch; do + ! [ -x "$x" ] || { fspath="$x"; break; } + done +fi +if [ -z "$fspath" ]; then + log "Couldn't find FS binary" + usage false; exit 1 +fi +if test $(id -u) = 0 && test -f /etc/debian_version; then + cat >&2 <<'EOF' +### You're running on Debian. Please make sure you have appropriate +### freeswitch-*-dbg packages installed so we get as many symbols in +### this backtrace as possible. I won't install these for you. If +### you're running the freeswitch-all package, then you should install +### freeswitch-all-dbg. +EOF +log '' +fi + +log1 'Generating backtrace...' +gdb "$fspath" "$core" > $btpath <<'EOF' +set prompt +set pagination off +printf "\n\n" +printf "================================================================================\n" +printf "# GDB session generated by FS backtrace-from-core\n" +printf "# FreeSWITCH version: %s\n", switch_version_full_str +printf "# FreeSWITCH version (human): %s\n", switch_version_full_human_str +printf "================================================================================\n" +printf "\n\n" +printf "================================================================================\n" +printf "# info threads\n" +printf "================================================================================\n" +info threads +printf "================================================================================\n" +printf "# bt\n" +printf "================================================================================\n" +bt +printf "================================================================================\n" +printf "# bt full\n" +printf "================================================================================\n" +bt full +printf "================================================================================\n" +printf "# thread apply all bt\n" +printf "================================================================================\n" +thread apply all bt +printf "================================================================================\n" +printf "# thread apply all bt full\n" +printf "================================================================================\n" +thread apply all bt full +quit +EOF +log 'done' +log '' +log "Please attach the backtrace here:" +log "$btpath" diff --git a/scripts/build_freeswitch_svn b/scripts/build_freeswitch_svn deleted file mode 100755 index 1cc303858a..0000000000 --- a/scripts/build_freeswitch_svn +++ /dev/null @@ -1,23 +0,0 @@ -# FreeSWITCH auto-build Makefile -# http://www.freeswitch.org - -cat << EOF | make -f - -freeswitch: freeswitch.trunk/Makefile - cd freeswitch.trunk && make - -freeswitch.trunk/Makefile: freeswitch.trunk/configure - cd freeswitch.trunk && ./configure - -freeswitch.trunk/configure: freeswitch.trunk/bootstrap.sh - cd freeswitch.trunk && sh bootstrap.sh - -freeswitch.trunk/bootstrap.sh: - @echo 'Downloading FreeSWITCH please wait....(a while)' - svn co -q http://svn.freeswitch.org:/svn/freeswitch/trunk freeswitch.trunk - - -install: - cd freeswitch.trunk && make install - -all: freeswitch -EOF diff --git a/scripts/c/socket2me/socket2me.c b/scripts/c/socket2me/socket2me.c index 9bb9551742..88f809c9e3 100644 --- a/scripts/c/socket2me/socket2me.c +++ b/scripts/c/socket2me/socket2me.c @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * - * Copyright (C) 2007-2012, Anthony Minessale II + * Copyright (C) 2007-2014, Anthony Minessale II */ #include diff --git a/scripts/ci/common.sh b/scripts/ci/common.sh index a1e97c6064..adb8d56d80 100755 --- a/scripts/ci/common.sh +++ b/scripts/ci/common.sh @@ -108,7 +108,7 @@ set_fs_ver () { if [ -n "$rev" ]; then [ -n "$hrev" ] || hrev="$rev" sed -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION, \[\).*\(\])\)|\1$rev\2|" \ - -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, \[\).*\(\])\)|\1$hrev\2|" \ + -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, \[\).*\(\])\)|\1'$hrev'\2|" \ -e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION\)|\1|" \ -e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN\)|\1|" \ configure.in > configure.in.$$ diff --git a/scripts/ci/config-rayo.sh b/scripts/ci/config-rayo.sh new file mode 100755 index 0000000000..119e01ea96 --- /dev/null +++ b/scripts/ci/config-rayo.sh @@ -0,0 +1,26 @@ +#!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- + +src_repo="$(pwd)" + +if [ ! -d .git ]; then + echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2 + exit 1; +fi + +rpmbuild --define "VERSION_NUMBER $1" \ + --define "BUILD_NUMBER $2" \ + --define "_topdir %(pwd)/rpmbuild" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + -ba freeswitch-config-rayo.spec + +mkdir -p $src_repo/RPMS +mv $src_repo/rpmbuild/*/freeswitch-config-rayo*.rpm $src_repo/RPMS/. + +cat 1>&2 < .version -cd libs -getlib () { - f="${1##*/}" - echo "fetching: $1 to $f" >&2 - wget -N "$1" \ - && tar -xv --no-same-owner --no-same-permissions -f "$f" \ - && rm -f "$f" \ - && mkdir -p $f -} -getlib http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-v1.8-latest.tgz -getlib http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz -getlib http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz -getlib http://files.freeswitch.org/downloads/libs/soundtouch-1.6.0.tar.gz -getlib http://files.freeswitch.org/downloads/libs/flite-1.5.4-current.tar.bz2 -getlib http://files.freeswitch.org/downloads/libs/sphinxbase-0.7.tar.gz -getlib http://files.freeswitch.org/downloads/libs/pocketsphinx-0.7.tar.gz -getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz -getlib http://files.freeswitch.org/downloads/libs/celt-0.10.0.tar.gz -getlib http://files.freeswitch.org/downloads/libs/opus-0.9.0.tar.gz -getlib http://files.freeswitch.org/downloads/libs/openldap-2.4.19.tar.gz -getlib http://download.zeromq.org/zeromq-2.1.9.tar.gz \ - || getlib http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz -getlib http://files.freeswitch.org/downloads/libs/freeradius-client-1.1.6.tar.gz -getlib http://files.freeswitch.org/downloads/libs/lame-3.98.4.tar.gz -getlib http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz -getlib http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz -cd mongo-cxx-driver-v1.8 -rm -rf config.log .sconf_temp *Test *Example -find . -name "*.o" -exec rm -f {} \; -cd $ddir -tar -c --exclude=.git -vf $orig.tar $fname -echo "Compressing $orig.tar with xz -6..." >&2 -xz -6 $orig.tar - -cd $bdir -(cd debian && ./bootstrap.sh -c "$codename") -# dch can't handle comments in control file -(cd debian; \ - mv control control.orig; \ - grep -e '^#' -v control.orig > control) -# dependency: libparse-debcontrol-perl -dch -b -v "${fver}-1~${codename}+1" \ - -M --force-distribution -D "$distro" \ - "Nightly build at ${datestamp}." -# dependency: fakeroot -dpkg-buildpackage -S -rfakeroot -uc -us -i\.git -I.git -Zxz -z9 || exit ? - -cat 1>&2 < $dst_name.tar.gz || echo "gzip not available" +gzip -9 -c ${dst_name}.tar > $dst_name.tar.gz || echo "gzip not available" bzip2 -z -k ${dst_name}.tar || echo "bzip2 not available" -# xz -z -9 -k ${dst_name}.tar || echo "xz / xz-utils not available" +xz -z -9 -k ${dst_name}.tar || echo "xz / xz-utils not available" +zip -r $dst_name.zip $dst_name rm -rf ${dst_name}.tar $dst_dir mkdir -p ${src_repo}/src_dist mv -f ${dst_name}.tar.* ${src_repo}/src_dist +mv -f $dst_name.zip ${src_repo}/src_dist cat 1>&2 < + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/javascript/pizza.js b/scripts/javascript/pizza.js index 57c8f2b116..9cd3f0d60a 100644 --- a/scripts/javascript/pizza.js +++ b/scripts/javascript/pizza.js @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/javascript/ps_pizza.js b/scripts/javascript/ps_pizza.js index 646128e308..1b58ab5b84 100644 --- a/scripts/javascript/ps_pizza.js +++ b/scripts/javascript/ps_pizza.js @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/perl/f-off-friendly-scanner.pl b/scripts/perl/f-off-friendly-scanner.pl new file mode 100644 index 0000000000..48c0b75083 --- /dev/null +++ b/scripts/perl/f-off-friendly-scanner.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +# Fsck Friendly Scanner +# +use Data::Dumper; +require ESL; +$| = 1; +my $c = new ESL::ESLconnection("localhost", "8021", "ClueCon"); +$c->events("plain", "CUSTOM sofia::register"); + +while ($c->connected()) { + my $event = $c->recvEvent(); + + my $user_agent = $event->getHeader('user-agent'); + my $network_ip = $event->getHeader('network-ip'); + + if ($user_agent =~ m/friendly-scanner/) { + system("/sbin/iptables -I INPUT -s $network_ip -j DROP"); + } +} diff --git a/scripts/perl/perltidyrc b/scripts/perl/perltidyrc new file mode 100644 index 0000000000..59bcb55450 --- /dev/null +++ b/scripts/perl/perltidyrc @@ -0,0 +1,42 @@ +-l=120 +# Max line width is 120 cols + +-i=4 +# Indent level is 4 cols + +-ci=4 +# Continuation indent is 4 cols + +-st +# Output to STDOUT + +-se +# Errors to STDERR + +-vt=2 +# Maximal vertical tightness + +-cti=0 +# No extra indentation for closing brackets + +-pt=1 +# Medium parenthesis tightness + +-bt=1 +# Medium brace tightness + +-sbt=1 +# Medium square bracket tightness + +-bbt=1 +# Medium block brace tightness + +-nsfs +# No space before semicolons + +-nolq +# Don't outdent long +# quoted strings + +-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= ><<= &&= -= /= |= >>= ||= .= %= ^= x=" +# Break before all operators diff --git a/scripts/perl/timezone-gen.pl b/scripts/perl/timezone-gen.pl new file mode 100755 index 0000000000..682964d77d --- /dev/null +++ b/scripts/perl/timezone-gen.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl + +use strict; +use Getopt::Long; + +my $base = "/usr/share/zoneinfo"; +my $output = "timezones.conf.xml"; +my $debug; +my $help; + +my %zones = (); +my %name_to_file = (); + +my $res = GetOptions( + "base=s" => \$base, + "debug+" => \$debug, + "help" => \$help, + "output" => \$output +); +if ( !$res || $help ) { + print "$0 [--base=/usr/share/zoneinfo] [--output=timezones.conf.xml] [--debug] [--help]\n"; + exit; +} + +my @dirs = ($base); + +while (@dirs) { + my $dir = shift @dirs; + + opendir( my $top, $dir ); + while ( my $file = readdir($top) ) { + next if ( $file eq "." || $file eq ".." ); + + if ( -f "$dir/$file" ) { + $debug && print "Found $dir/$file\n"; + + my $name = "$dir/$file"; + $name =~ s|^${base}/||o; + + $name_to_file{$name} = "$dir/$file"; + } + elsif ( -d "$dir/$file" ) { + $debug && print "Found subdir $dir/$file\n"; + push( @dirs, "$dir/$file" ); + } + } + closedir($top); +} + +foreach my $name ( sort( keys(%name_to_file) ) ) { + my $file = $name_to_file{$name}; + $debug && print "Processing $file...\n"; + + open( my $in, "<$file" ); + my $data = join( "", <$in> ); + close($in); + + if ( $data !~ /^TZif2/o ) { + $debug && print "Skipped $file\n"; + next; + } + + my $tmp = $data; + $tmp =~ s/\n$//s; + $tmp =~ s/.*\n//sgmo; + + $zones{$name} = $tmp; +} + +open( my $out, ">$output" ); +print $out "\n"; +print $out " " x 4, "\n"; + +my $lastprefix = ""; +foreach my $zone ( sort( keys(%zones) ) ) { + my $str = $zones{$zone}; + next if ( !$str ); + + my $newprefix = $zone; + $newprefix =~ s|/.*||go; + if ( $newprefix ne $lastprefix && $lastprefix ne "" ) { + print $out "\n"; + } + $lastprefix = $newprefix; + + print $out "\t\n"; +} +print $out " " x 4, "\n"; +print $out "\n"; +close($out); diff --git a/scripts/python/freepy/__init__.py b/scripts/python/freepy/__init__.py index 2274cdc474..4e871fe532 100644 --- a/scripts/python/freepy/__init__.py +++ b/scripts/python/freepy/__init__.py @@ -1,6 +1,6 @@ """ FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -Copyright (C) 2005-2012, Anthony Minessale II +Copyright (C) 2005-2014, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/fseventlistener.py b/scripts/python/freepy/fseventlistener.py index fb1b430f5d..f65f966429 100644 --- a/scripts/python/freepy/fseventlistener.py +++ b/scripts/python/freepy/fseventlistener.py @@ -1,6 +1,6 @@ """ FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -Copyright (C) 2005-2012, Anthony Minessale II +Copyright (C) 2005-2014, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/fshelper.py b/scripts/python/freepy/fshelper.py index d258461629..bd2ccb4c13 100644 --- a/scripts/python/freepy/fshelper.py +++ b/scripts/python/freepy/fshelper.py @@ -2,7 +2,7 @@ """ FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -Copyright (C) 2005-2012, Anthony Minessale II +Copyright (C) 2005-2014, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/models.py b/scripts/python/freepy/models.py index 37e595946f..89955abb8e 100644 --- a/scripts/python/freepy/models.py +++ b/scripts/python/freepy/models.py @@ -1,6 +1,6 @@ """ FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -Copyright (C) 2005-2012, Anthony Minessale II +Copyright (C) 2005-2014, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/request.py b/scripts/python/freepy/request.py index 787482be3a..cb6e7ad489 100644 --- a/scripts/python/freepy/request.py +++ b/scripts/python/freepy/request.py @@ -1,6 +1,6 @@ """ FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -Copyright (C) 2005-2012, Anthony Minessale II +Copyright (C) 2005-2014, Anthony Minessale II Version: MPL 1.1 diff --git a/src/fs_encode.c b/src/fs_encode.c index 417ff7dc2f..d3052a98d6 100644 --- a/src/fs_encode.c +++ b/src/fs_encode.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -40,8 +40,6 @@ #endif #include -#include - /* Picky compiler */ #ifdef __ICC @@ -130,6 +128,7 @@ int main(int argc, char *argv[]) switch_loadable_module_init(SWITCH_FALSE); switch_loadable_module_load_module("", "CORE_PCM_MODULE", SWITCH_TRUE, &err); + switch_loadable_module_load_module("", "CORE_SPEEX_MODULE", SWITCH_TRUE, &err); for (i = 0; i < extra_modules_count; i++) { if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) extra_modules[i], SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index bff9b72a78..e344489917 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -178,6 +178,7 @@ struct switch_core_session { switch_size_t recur_buffer_len; switch_media_handle_t *media_handle; + uint32_t decoder_errors; }; struct switch_media_bug { @@ -276,6 +277,7 @@ struct switch_runtime { char *core_db_inner_pre_trans_execute; char *core_db_inner_post_trans_execute; int events_use_dispatch; + uint32_t port_alloc_flags; }; extern struct switch_runtime runtime; diff --git a/src/include/switch.h b/src/include/switch.h index a637dc62d4..72b93cea25 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 923d60d985..dc6769d267 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1304,6 +1304,7 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_ SWITCH_DECLARE(switch_status_t) switch_mcast_hops(switch_socket_t *sock, uint8_t ttl); SWITCH_DECLARE(switch_status_t) switch_mcast_loopback(switch_socket_t *sock, uint8_t opt); +SWITCH_DECLARE(switch_status_t) switch_mcast_interface(switch_socket_t *sock, switch_sockaddr_t *iface); /** @} */ diff --git a/src/include/switch_bitpack.h b/src/include/switch_bitpack.h index 91cc33d8a2..612d6b5c50 100644 --- a/src/include/switch_bitpack.h +++ b/src/include/switch_bitpack.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_buffer.h b/src/include/switch_buffer.h index 4fe9a8f738..e6cc2ad7d5 100644 --- a/src/include/switch_buffer.h +++ b/src/include/switch_buffer.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index f0dc1c76fe..54fbcc062c 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -127,6 +127,7 @@ typedef struct profile_node_s { switch_memory_pool_t *pool; struct switch_caller_profile *next; switch_call_direction_t direction; + switch_call_direction_t logical_direction; profile_node_t *soft; char *uuid_str; char *clone_of; diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 234b692114..aea8c217d2 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -633,6 +633,7 @@ SWITCH_DECLARE(int) switch_channel_test_app_flag_key(const char *app, switch_cha SWITCH_DECLARE(void) switch_channel_set_bridge_time(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel); SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel); +SWITCH_DECLARE(switch_call_direction_t) switch_channel_logical_direction(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_set_direction(switch_channel_t *channel, switch_call_direction_t direction); SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel); @@ -652,7 +653,7 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_ SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix); SWITCH_DECLARE(switch_status_t) switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix); - +SWITCH_DECLARE(void) switch_channel_process_device_hangup(switch_channel_t *channel); SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_queued_extension(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension); SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *channel); diff --git a/src/include/switch_config.h b/src/include/switch_config.h index e35620721a..c0f5bbfa46 100644 --- a/src/include/switch_config.h +++ b/src/include/switch_config.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_console.h b/src/include/switch_console.h index 73410bd248..bcf956e2e9 100644 --- a/src/include/switch_console.h +++ b/src/include/switch_console.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_core.h b/src/include/switch_core.h index c203f84dbc..db4c4f34ca 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -109,6 +109,7 @@ typedef struct switch_device_stats_s { uint32_t early; uint32_t early_in; uint32_t early_out; + uint32_t ring_wait; } switch_device_stats_t; @@ -414,7 +415,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_set_pre_buffer_framecount( \param new_allocator new pointer for the return value \return SWITCH_STATUS_SUCCESS if the operation was a success */ -SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ switch_port_t start, +SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ const char *ip, + _In_ switch_port_t start, _In_ switch_port_t end, _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator); @@ -2311,7 +2313,7 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload); SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token); #define switch_check_network_list_ip(_ip_str, _list_name) switch_check_network_list_ip_token(_ip_str, _list_name, NULL) SWITCH_DECLARE(void) switch_time_set_monotonic(switch_bool_t enable); -SWITCH_DECLARE(void) switch_time_set_timerfd(switch_bool_t enable); +SWITCH_DECLARE(void) switch_time_set_timerfd(int enable); SWITCH_DECLARE(void) switch_time_set_nanosleep(switch_bool_t enable); SWITCH_DECLARE(void) switch_time_set_matrix(switch_bool_t enable); SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable); @@ -2600,6 +2602,16 @@ SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_han SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream); SWITCH_DECLARE(switch_call_direction_t) switch_ice_direction(switch_core_session_t *session); +SWITCH_DECLARE(void) switch_core_session_debug_pool(switch_stream_handle_t *stream); + +SWITCH_DECLARE(const char *)switch_version_major(void); +SWITCH_DECLARE(const char *)switch_version_minor(void); +SWITCH_DECLARE(const char *)switch_version_micro(void); + +SWITCH_DECLARE(const char *)switch_version_revision(void); +SWITCH_DECLARE(const char *)switch_version_revision_human(void); +SWITCH_DECLARE(const char *)switch_version_full(void); +SWITCH_DECLARE(const char *)switch_version_full_human(void); SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_core_db.h b/src/include/switch_core_db.h index 081b09ea8a..53e0625b07 100644 --- a/src/include/switch_core_db.h +++ b/src/include/switch_core_db.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_core_event_hook.h b/src/include/switch_core_event_hook.h index f6ff99823b..26dfb0c87d 100644 --- a/src/include/switch_core_event_hook.h +++ b/src/include/switch_core_event_hook.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 9641718f07..37e8df8484 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -68,7 +68,6 @@ typedef enum { SCMF_RUNNING, SCMF_DISABLE_TRANSCODING, SCMF_AUTOFIX_TIMING, - SCMF_AUTOFIX_PT, SCMF_CODEC_GREEDY, SCMF_CODEC_SCROOGE, SCMF_DISABLE_HOLD, @@ -81,6 +80,8 @@ typedef enum { SCMF_AUTOFLUSH, SCMF_REWRITE_TIMESTAMPS, SCMF_RTP_AUTOFLUSH_DURING_BRIDGE, + SCMF_MULTI_ANSWER_AUDIO, + SCMF_MULTI_ANSWER_VIDEO, SCMF_MAX } switch_core_media_flag_t; @@ -156,6 +157,41 @@ typedef struct switch_core_media_params_s { } switch_core_media_params_t; +typedef struct payload_map_s { + switch_media_type_t type; + switch_sdp_type_t sdp_type; + uint32_t ptime; + uint32_t rate; + uint8_t allocated; + uint8_t negotiated; + uint8_t current; + unsigned long hash; + + char *rm_encoding; + char *iananame; + switch_payload_t pt; + unsigned long rm_rate; + unsigned long adv_rm_rate; + uint32_t codec_ms; + uint32_t bitrate; + + char *rm_fmtp; + + switch_payload_t agreed_pt; + switch_payload_t recv_pt; + + char *fmtp_out; + + char *remote_sdp_ip; + switch_port_t remote_sdp_port; + + int channels; + int adv_channels; + + struct payload_map_s *next; + +} payload_map_t; + static inline const char *switch_media_type2str(switch_media_type_t type) { switch(type) { @@ -216,7 +252,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi SWITCH_DECLARE(switch_status_t) switch_core_media_ext_address_lookup(switch_core_session_t *session, char **ip, switch_port_t *port, const char *sourceip); SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session, switch_core_session_t *other_session, switch_t38_options_t *t38_options); -SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force); +SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, switch_sdp_type_t sdp_type, + const char *ip, switch_port_t port, const char *sr, int force); SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *session, const char *sdp_str, switch_bool_t dup); SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t *session, switch_t38_options_t *t38_options, int insist); @@ -232,7 +269,6 @@ SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_core_session_t *sessio SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf); SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf); SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_core_session_t *session, switch_media_type_t type); -SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_core_session_t *session, switch_media_type_t type, switch_payload_t pt); SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te); SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te); SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool); @@ -244,7 +280,7 @@ SWITCH_DECLARE(stfu_instance_t *) switch_core_media_get_jb(switch_core_session_t SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool); -SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp); +SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp, switch_sdp_type_t sdp_type); SWITCH_DECLARE(void) switch_core_media_reset_autofix(switch_core_session_t *session, switch_media_type_t type); SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session); SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t media); @@ -258,6 +294,23 @@ SWITCH_DECLARE(void) switch_core_media_set_stats(switch_core_session_t *session) SWITCH_DECLARE(void) switch_core_session_wake_video_thread(switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_session_clear_crypto(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core_session_t *session, + switch_media_type_t type, + const char *iananame, + switch_payload_t *ptP, + switch_payload_t *recv_ptP, + char **fmtpP); + +SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session, + switch_media_type_t type, + const char *name, + const char *fmtp, + switch_sdp_type_t sdp_type, + uint32_t pt, + uint32_t rate, + uint32_t ptime, + uint8_t negotiated); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 57d122b79b..5a372c3cdb 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -398,7 +398,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod SWITCH_DECLARE(void) console_log(char *level_str, char *msg); SWITCH_DECLARE(void) console_clean_log(char *msg); -SWITCH_DECLARE(void) msleep(unsigned ms); +SWITCH_DECLARE(void) switch_msleep(unsigned ms); /** \brief bridge the audio of session_b into session_a * diff --git a/src/include/switch_curl.h b/src/include/switch_curl.h index dc31269465..b8c7b9e67a 100644 --- a/src/include/switch_curl.h +++ b/src/include/switch_curl.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -32,6 +32,7 @@ #define __SWITCH_CURL_H #include "curl/curl.h" +SWITCH_BEGIN_EXTERN_C typedef void switch_CURL; typedef struct curl_slist switch_curl_slist_t; @@ -50,6 +51,8 @@ SWITCH_DECLARE(const char *) switch_curl_easy_strerror(switch_CURLcode errornum SWITCH_DECLARE(void) switch_curl_init(void); SWITCH_DECLARE(void) switch_curl_destroy(void); SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp); + +SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_dso.h b/src/include/switch_dso.h index 7f9e2dfa53..1e89bcd4a5 100644 --- a/src/include/switch_dso.h +++ b/src/include/switch_dso.h @@ -21,6 +21,8 @@ #ifndef FREESWITCH_DSO_H #define FREESWITCH_DSO_H +SWITCH_BEGIN_EXTERN_C + typedef int (*switch_dso_func_t) (void); #ifdef WIN32 typedef HINSTANCE switch_dso_lib_t; @@ -35,6 +37,7 @@ SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(const char *path, int global, c SWITCH_DECLARE(switch_dso_func_t) switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err); SWITCH_DECLARE(void *) switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err); +SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_event.h b/src/include/switch_event.h index 28e805658f..12f18a9b94 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index 39ffb9ca6b..a15ef34c8a 100644 --- a/src/include/switch_frame.h +++ b/src/include/switch_frame.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -37,6 +37,7 @@ #define SWITCH_FRAME_H #include +#include SWITCH_BEGIN_EXTERN_C /*! \brief An abstraction of a data frame */ @@ -71,6 +72,7 @@ SWITCH_BEGIN_EXTERN_C /*! frame flags */ switch_frame_flag_t flags; void *user_data; + payload_map_t *pmap; }; SWITCH_END_EXTERN_C diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index c0ba440c99..01c82f4f31 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_json.h b/src/include/switch_json.h old mode 100755 new mode 100644 diff --git a/src/include/switch_limit.h b/src/include/switch_limit.h index 3ae606be19..7999c85a02 100644 --- a/src/include/switch_limit.h +++ b/src/include/switch_limit.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index e76e0e5ab1..ef27e75758 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_log.h b/src/include/switch_log.h index b7c3997a06..e2244ac51e 100644 --- a/src/include/switch_log.h +++ b/src/include/switch_log.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index ad6b4aefd4..62fea0b3f7 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_nat.h b/src/include/switch_nat.h index 8865218133..fbf7ee2090 100644 --- a/src/include/switch_nat.h +++ b/src/include/switch_nat.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_odbc.h b/src/include/switch_odbc.h index 1f5c2c81eb..94f1806156 100644 --- a/src/include/switch_odbc.h +++ b/src/include/switch_odbc.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_pgsql.h b/src/include/switch_pgsql.h index 110c5364a8..e09bcab743 100644 --- a/src/include/switch_pgsql.h +++ b/src/include/switch_pgsql.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index dfd8c012bc..501dfbab31 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -227,9 +227,10 @@ typedef intptr_t switch_ssize_t; #ifdef WIN32 -#ifdef WIN64 +#ifdef _WIN64 #define SWITCH_SSIZE_T_FMT "lld" #define SWITCH_SIZE_T_FMT "lld" +#define FS_64BIT 1 #else #define SWITCH_SSIZE_T_FMT "d" #define SWITCH_SIZE_T_FMT "d" @@ -274,7 +275,11 @@ typedef intptr_t switch_ssize_t; #endif +#ifdef __sun +#define SWITCH_TIME_T_FMT SWITCH_SIZE_T_FMT +#else #define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT +#endif SWITCH_END_EXTERN_C /* these includes must be outside the extern "C" block on windows or it will break compatibility with c++ modules*/ diff --git a/src/include/switch_regex.h b/src/include/switch_regex.h index 9317a5fbb4..05971b607d 100644 --- a/src/include/switch_regex.h +++ b/src/include/switch_regex.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index ee1de4e2c7..bc1677079f 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -39,7 +39,7 @@ */ #define switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4; -#define switch_normalize_volume_granular(x) if (x > 12) x = 12; if (x < -12) x = -12; +#define switch_normalize_volume_granular(x) if (x > 13) x = 13; if (x < -13) x = -13; #ifndef SWITCH_RESAMPLE_H #define SWITCH_RESAMPLE_H diff --git a/src/include/switch_rtcp_frame.h b/src/include/switch_rtcp_frame.h index b9ae200b57..b0b52134e3 100644 --- a/src/include/switch_rtcp_frame.h +++ b/src/include/switch_rtcp_frame.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index bd509cc29a..489d6a3a13 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -50,6 +50,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_RTP_KEY_LEN 30 #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" +#define SWITCH_RTP_CRYPTO_KEY_8 "AES_GCM_128_8" typedef enum { SWITCH_RTP_CRYPTO_SEND, SWITCH_RTP_CRYPTO_RECV, @@ -63,6 +64,9 @@ typedef enum { AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_CM_256_HMAC_SHA1_80, + AES_CM_192_HMAC_SHA1_80, + AES_GCM_256_8, + AES_GCM_128_8, AES_CM_128_NULL_AUTH } switch_rtp_crypto_key_type_t; @@ -96,7 +100,7 @@ typedef struct icand_s { uint8_t ready; } icand_t; -#define MAX_CAND 25 +#define MAX_CAND 50 typedef struct ice_s { icand_t cands[MAX_CAND][2]; @@ -485,7 +489,6 @@ SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *pri */ SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te); SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te); -SWITCH_DECLARE(void) switch_rtp_set_recv_pt(switch_rtp_t *rtp_session, switch_payload_t pt); /*! \brief Set the payload type for comfort noise @@ -500,7 +503,7 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay \return the pointer to the private data */ SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session); - +SWITCH_DECLARE(switch_status_t) switch_rtp_set_payload_map(switch_rtp_t *rtp_session, payload_map_t **pmap); SWITCH_DECLARE(void) switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs); SWITCH_DECLARE(switch_rtp_stats_t *) switch_rtp_get_stats(switch_rtp_t *rtp_session, switch_memory_pool_t *pool); diff --git a/src/include/switch_scheduler.h b/src/include/switch_scheduler.h index 59997a006d..dc23e9f87e 100644 --- a/src/include/switch_scheduler.h +++ b/src/include/switch_scheduler.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -47,6 +47,7 @@ SWITCH_BEGIN_EXTERN_C char *group; void *cmd_arg; uint32_t task_id; + unsigned long hash; }; diff --git a/src/include/switch_ssl.h b/src/include/switch_ssl.h index ee8bd8d479..3f4d6d696e 100644 --- a/src/include/switch_ssl.h +++ b/src/include/switch_ssl.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index b6de510159..579c6f1bbd 100644 --- a/src/include/switch_stun.h +++ b/src/include/switch_stun.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 5c049ddd0a..beb26fc370 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -227,6 +227,15 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_MAX_TRANS 2000 #define SWITCH_CORE_SESSION_MAX_PRIVATES 2 +/* Jitter */ +#define JITTER_VARIANCE_THRESHOLD 400.0 +/* IPDV */ +#define IPDV_THRESHOLD 1.0 +/* Burst and Lost Rate */ +#define LOST_BURST_ANALYZE 500 +/* Burst */ +#define LOST_BURST_CAPTURE 1024 + typedef uint8_t switch_byte_t; typedef enum { @@ -311,7 +320,9 @@ typedef uint32_t switch_originate_flag_t; typedef enum { SPF_NONE = 0, SPF_ODD = (1 << 0), - SPF_EVEN = (1 << 1) + SPF_EVEN = (1 << 1), + SPF_ROBUST_TCP = (1 << 2), + SPF_ROBUST_UDP = (1 << 3) } switch_port_flag_enum_t; typedef uint32_t switch_port_flag_t; @@ -421,7 +432,8 @@ typedef enum { typedef enum { SSG_MASCULINE, SSG_FEMININE, - SSG_NEUTER + SSG_NEUTER, + SSG_UTRUM } switch_say_gender_t; typedef enum { @@ -589,6 +601,29 @@ typedef struct { switch_size_t cng_packet_count; switch_size_t flush_packet_count; switch_size_t largest_jb_size; + /* Jitter */ + int64_t last_proc_time; + int64_t jitter_n; + int64_t jitter_add; + int64_t jitter_addsq; + + double variance; + double min_variance; + double max_variance; + double std_deviation; + + /* Burst and Packet Loss */ + double lossrate; + double burstrate; + double mean_interval; + int loss[LOST_BURST_CAPTURE]; + int last_loss; + int recved; + int last_processed_seq; + switch_size_t flaws; + switch_size_t last_flaw; + double R; + double mos; } switch_rtp_numbers_t; @@ -634,6 +669,7 @@ typedef enum { */ typedef enum { SWITCH_RTP_FLAG_NOBLOCK = 0, + SWITCH_RTP_FLAG_DTMF_ON, SWITCH_RTP_FLAG_IO, SWITCH_RTP_FLAG_USE_TIMER, SWITCH_RTP_FLAG_RTCP_PASSTHRU, @@ -668,6 +704,8 @@ typedef enum { SWITCH_RTP_FLAG_KILL_JB, SWITCH_RTP_FLAG_VIDEO_BREAK, SWITCH_RTP_FLAG_PAUSE, + SWITCH_RTP_FLAG_FIR, + SWITCH_RTP_FLAG_PLI, SWITCH_RTP_FLAG_INVALID } switch_rtp_flag_t; @@ -1140,6 +1178,7 @@ typedef enum { CCS_EARLY, CCS_ACTIVE, CCS_HELD, + CCS_RING_WAIT, CCS_HANGUP, CCS_UNHOLD } switch_channel_callstate_t; @@ -1359,6 +1398,8 @@ typedef enum { CF_VIDEO_ECHO, CF_SLA_INTERCEPT, CF_VIDEO_BREAK, + CF_MEDIA_PAUSE, + CF_BYPASS_MEDIA_AFTER_HOLD, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */ CF_FLAG_MAX diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 971a915bad..55071e72d1 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -434,6 +434,11 @@ static inline int switch_true(const char *expr) (switch_is_number(expr) && atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE); } +static inline switch_byte_t switch_true_byte(const char *expr) +{ + return (switch_byte_t)switch_true(expr); +} + #define switch_true_buf(expr)\ ((( !strcasecmp(expr, "yes") ||\ !strcasecmp(expr, "on") ||\ @@ -1019,7 +1024,11 @@ SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domai #ifdef NDEBUG #define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr ) #define switch_zmalloc(ptr, len) (void)( (!!(ptr = calloc(1, (len)))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#if (_MSC_VER >= 1500) // VC9+ +#define switch_strdup(ptr, s) (void)( (!!(ptr = _strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#else #define switch_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#endif #else #if (_MSC_VER >= 1500) // VC9+ #define switch_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr);__analysis_assume( ptr ) diff --git a/src/include/switch_version.h.template b/src/include/switch_version.h.template index 06169d603f..61ebca8a98 100644 --- a/src/include/switch_version.h.template +++ b/src/include/switch_version.h.template @@ -37,7 +37,7 @@ extern "C" { #endif -#if UINTPTR_MAX == 0xffffffffffffffff +#if UINTPTR_MAX == 0xffffffffffffffff || defined(_WIN64) #define _fs__bits "64bit" #else #define _fs__bits "32bit" diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index fc8505f167..23596aedc6 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_xml_config.h b/src/include/switch_xml_config.h index 8d688ee696..eea4dfe0a9 100644 --- a/src/include/switch_xml_config.h +++ b/src/include/switch_xml_config.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/timerfd_wrap.h b/src/include/timerfd_wrap.h index 7196a6c1e0..bdcd11b4f1 100644 --- a/src/include/timerfd_wrap.h +++ b/src/include/timerfd_wrap.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_abstraction/mod_abstraction.c b/src/mod/applications/mod_abstraction/mod_abstraction.c index 11515048ca..a232848fe4 100644 --- a/src/mod/applications/mod_abstraction/mod_abstraction.c +++ b/src/mod/applications/mod_abstraction/mod_abstraction.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index 5d76a28c2e..dffa78cd73 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -98,28 +98,28 @@ SWITCH_STANDARD_APP(avmd_start_function); /*! Status of the beep detection */ typedef enum { - BEEP_DETECTED, - BEEP_NOTDETECTED + BEEP_DETECTED, + BEEP_NOTDETECTED } avmd_beep_state_t; /*! Data related to the current status of the beep */ typedef struct { - avmd_beep_state_t beep_state; - size_t last_beep; + avmd_beep_state_t beep_state; + size_t last_beep; } avmd_state_t; /*! Type that holds session information pertinent to the avmd module. */ typedef struct { - /*! Internal FreeSWITCH session. */ - switch_core_session_t *session; - uint32_t rate; - circ_buffer_t b; - sma_buffer_t sma_b; - sma_buffer_t sqa_b; - size_t pos; - double f; - /* freq_table_t ft; */ - avmd_state_t state; + /*! Internal FreeSWITCH session. */ + switch_core_session_t *session; + uint32_t rate; + circ_buffer_t b; + sma_buffer_t sma_b; + sma_buffer_t sqa_b; + size_t pos; + double f; + /* freq_table_t ft; */ + avmd_state_t state; } avmd_session_t; static void avmd_process(avmd_session_t *session, switch_frame_t *frame); @@ -135,26 +135,26 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_session_t *fs_session) { /*! This is a worst case sample rate estimate */ - avmd_session->rate = 48000; - INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate), fs_session); + avmd_session->rate = 48000; + INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate), fs_session); - avmd_session->session = fs_session; - avmd_session->pos = 0; - avmd_session->f = 0.0; - avmd_session->state.last_beep = 0; - avmd_session->state.beep_state = BEEP_NOTDETECTED; + avmd_session->session = fs_session; + avmd_session->pos = 0; + avmd_session->f = 0.0; + avmd_session->state.last_beep = 0; + avmd_session->state.beep_state = BEEP_NOTDETECTED; - INIT_SMA_BUFFER( - &avmd_session->sma_b, - BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), - fs_session - ); + INIT_SMA_BUFFER( + &avmd_session->sma_b, + BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), + fs_session + ); - INIT_SMA_BUFFER( - &avmd_session->sqa_b, - BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), - fs_session - ); + INIT_SMA_BUFFER( + &avmd_session->sqa_b, + BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), + fs_session + ); } @@ -168,42 +168,42 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se */ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type) { - avmd_session_t *avmd_session; - switch_codec_t *read_codec; - switch_frame_t *frame; + avmd_session_t *avmd_session; + switch_codec_t *read_codec; + switch_frame_t *frame; - avmd_session = (avmd_session_t *) user_data; - if (avmd_session == NULL) { - return SWITCH_FALSE; - } + avmd_session = (avmd_session_t *) user_data; + if (avmd_session == NULL) { + return SWITCH_FALSE; + } - switch (type) { + switch (type) { - case SWITCH_ABC_TYPE_INIT: - read_codec = switch_core_session_get_read_codec(avmd_session->session); - avmd_session->rate = read_codec->implementation->samples_per_second; - /* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */ - break; + case SWITCH_ABC_TYPE_INIT: + read_codec = switch_core_session_get_read_codec(avmd_session->session); + avmd_session->rate = read_codec->implementation->samples_per_second; + /* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */ + break; - case SWITCH_ABC_TYPE_READ_PING: - case SWITCH_ABC_TYPE_CLOSE: - case SWITCH_ABC_TYPE_READ: - case SWITCH_ABC_TYPE_WRITE: - case SWITCH_ABC_TYPE_TAP_NATIVE_READ: - case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE: - break; + case SWITCH_ABC_TYPE_READ_PING: + case SWITCH_ABC_TYPE_CLOSE: + case SWITCH_ABC_TYPE_READ: + case SWITCH_ABC_TYPE_WRITE: + case SWITCH_ABC_TYPE_TAP_NATIVE_READ: + case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE: + break; - case SWITCH_ABC_TYPE_READ_REPLACE: - frame = switch_core_media_bug_get_read_replace_frame(bug); - avmd_process(avmd_session, frame); - return SWITCH_TRUE; + case SWITCH_ABC_TYPE_READ_REPLACE: + frame = switch_core_media_bug_get_read_replace_frame(bug); + avmd_process(avmd_session, frame); + return SWITCH_TRUE; - case SWITCH_ABC_TYPE_WRITE_REPLACE: - break; - } + case SWITCH_ABC_TYPE_WRITE_REPLACE: + break; + } - return SWITCH_TRUE; + return SWITCH_TRUE; } /*! \brief FreeSWITCH module loading function @@ -214,40 +214,40 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) { - switch_application_interface_t *app_interface; - switch_api_interface_t *api_interface; - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(pool, modname); + switch_application_interface_t *app_interface; + switch_api_interface_t *api_interface; + /* connect my internal structure to the blank pointer passed to me */ + *module_interface = switch_loadable_module_create_module_interface(pool, modname); - switch_log_printf( - SWITCH_CHANNEL_LOG, - SWITCH_LOG_NOTICE, - "Advanced Voicemail detection enabled\n" - ); + switch_log_printf( + SWITCH_CHANNEL_LOG, + SWITCH_LOG_NOTICE, + "Advanced Voicemail detection enabled\n" + ); #ifdef FASTMATH - init_fast_acosf(); - switch_log_printf( - SWITCH_CHANNEL_LOG, - SWITCH_LOG_NOTICE, - "Advanced Voicemail detection: fast math enabled\n" - ); + init_fast_acosf(); + switch_log_printf( + SWITCH_CHANNEL_LOG, + SWITCH_LOG_NOTICE, + "Advanced Voicemail detection: fast math enabled\n" + ); #endif - SWITCH_ADD_APP( - app_interface, - "avmd", - "Beep detection", - "Advanced detection of voicemail beeps", - avmd_start_function, - "[start] [stop]", - SAF_NONE - ); + SWITCH_ADD_APP( + app_interface, + "avmd", + "Beep detection", + "Advanced detection of voicemail beeps", + avmd_start_function, + "[start] [stop]", + SAF_NONE + ); - SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection", avmd_api_main, AVMD_SYNTAX); + SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection", avmd_api_main, AVMD_SYNTAX); - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; } /*! \brief FreeSWITCH application handler function. @@ -258,63 +258,63 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) */ SWITCH_STANDARD_APP(avmd_start_function) { - switch_media_bug_t *bug; - switch_status_t status; - switch_channel_t *channel; - avmd_session_t *avmd_session; + switch_media_bug_t *bug; + switch_status_t status; + switch_channel_t *channel; + avmd_session_t *avmd_session; - if (session == NULL) - return; + if (session == NULL) + return; - channel = switch_core_session_get_channel(session); + channel = switch_core_session_get_channel(session); - /* Is this channel already using avmd ? */ - bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); - /* If it is using avmd */ - if (bug != NULL) { - /* If we have a stop remove audio bug */ - if (strcasecmp(data, "stop") == 0) { - switch_channel_set_private(channel, "_avmd_", NULL); - switch_core_media_bug_remove(session, &bug); - return; - } + /* Is this channel already using avmd ? */ + bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); + /* If it is using avmd */ + if (bug != NULL) { + /* If we have a stop remove audio bug */ + if (strcasecmp(data, "stop") == 0) { + switch_channel_set_private(channel, "_avmd_", NULL); + switch_core_media_bug_remove(session, &bug); + return; + } - /* We have already started */ - switch_log_printf( - SWITCH_CHANNEL_SESSION_LOG(session), - SWITCH_LOG_WARNING, - "Cannot run 2 at once on the same channel!\n" - ); + /* We have already started */ + switch_log_printf( + SWITCH_CHANNEL_SESSION_LOG(session), + SWITCH_LOG_WARNING, + "Cannot run 2 at once on the same channel!\n" + ); - return; - } + return; + } - avmd_session = (avmd_session_t *)switch_core_session_alloc(session, sizeof(avmd_session_t)); + avmd_session = (avmd_session_t *)switch_core_session_alloc(session, sizeof(avmd_session_t)); - init_avmd_session_data(avmd_session, session); + init_avmd_session_data(avmd_session, session); - status = switch_core_media_bug_add( - session, - "avmd", - NULL, - avmd_callback, - avmd_session, - 0, - SMBF_READ_REPLACE, - &bug - ); + status = switch_core_media_bug_add( + session, + "avmd", + NULL, + avmd_callback, + avmd_session, + 0, + SMBF_READ_REPLACE, + &bug + ); - if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf( - SWITCH_CHANNEL_SESSION_LOG(session), - SWITCH_LOG_ERROR, - "Failure hooking to stream\n" - ); + if (status != SWITCH_STATUS_SUCCESS) { + switch_log_printf( + SWITCH_CHANNEL_SESSION_LOG(session), + SWITCH_LOG_ERROR, + "Failure hooking to stream\n" + ); - return; - } + return; + } - switch_channel_set_private(channel, "_avmd_", bug); + switch_channel_set_private(channel, "_avmd_", bug); } /*! \brief Called when the module shuts down @@ -326,16 +326,16 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { #ifdef FASTMATH - destroy_fast_acosf(); + destroy_fast_acosf(); #endif - switch_log_printf( - SWITCH_CHANNEL_LOG, - SWITCH_LOG_NOTICE, - "Advanced Voicemail detection disabled\n" - ); + switch_log_printf( + SWITCH_CHANNEL_LOG, + SWITCH_LOG_NOTICE, + "Advanced Voicemail detection disabled\n" + ); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } /*! \brief FreeSWITCH API handler function. @@ -347,127 +347,127 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) */ SWITCH_STANDARD_API(avmd_api_main) { - switch_core_session_t *fs_session = NULL; - switch_media_bug_t *bug; - avmd_session_t *avmd_session; - switch_channel_t *channel; - switch_status_t status; - int argc; - char *argv[AVMD_PARAMS]; - char *ccmd = NULL; - char *uuid; - char *command; + switch_core_session_t *fs_session = NULL; + switch_media_bug_t *bug; + avmd_session_t *avmd_session; + switch_channel_t *channel; + switch_status_t status; + int argc; + char *argv[AVMD_PARAMS]; + char *ccmd = NULL; + char *uuid; + char *command; - /* No command? Display usage */ - if (zstr(cmd)) { - stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); - return SWITCH_STATUS_SUCCESS; - } + /* No command? Display usage */ + if (zstr(cmd)) { + stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); + return SWITCH_STATUS_SUCCESS; + } - /* Duplicated contents of original string */ - ccmd = strdup(cmd); - /* Separate the arguments */ - argc = switch_separate_string(ccmd, ' ', argv, AVMD_PARAMS); + /* Duplicated contents of original string */ + ccmd = strdup(cmd); + /* Separate the arguments */ + argc = switch_separate_string(ccmd, ' ', argv, AVMD_PARAMS); - /* If we don't have the expected number of parameters - * display usage */ - if (argc != AVMD_PARAMS) { - stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); - goto end; - } + /* If we don't have the expected number of parameters + * display usage */ + if (argc != AVMD_PARAMS) { + stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); + goto end; + } - uuid = argv[0]; - command = argv[1]; + uuid = argv[0]; + command = argv[1]; - /* using uuid locate a reference to the FreeSWITCH session */ - fs_session = switch_core_session_locate(uuid); + /* using uuid locate a reference to the FreeSWITCH session */ + fs_session = switch_core_session_locate(uuid); - /* If the session was not found exit */ - if (fs_session == NULL) { - stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); - goto end; - } + /* If the session was not found exit */ + if (fs_session == NULL) { + stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); + goto end; + } - /* Get current channel of the session to tag the session - * This indicates that our module is present */ - channel = switch_core_session_get_channel(fs_session); + /* Get current channel of the session to tag the session + * This indicates that our module is present */ + channel = switch_core_session_get_channel(fs_session); - /* Is this channel already set? */ - bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); - /* If yes */ - if (bug != NULL) { - /* If we have a stop remove audio bug */ - if (strcasecmp(command, "stop") == 0) { - switch_channel_set_private(channel, "_avmd_", NULL); - switch_core_media_bug_remove(fs_session, &bug); - switch_safe_free(ccmd); - stream->write_function(stream, "+OK\n"); - goto end; - } + /* Is this channel already set? */ + bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); + /* If yes */ + if (bug != NULL) { + /* If we have a stop remove audio bug */ + if (strcasecmp(command, "stop") == 0) { + switch_channel_set_private(channel, "_avmd_", NULL); + switch_core_media_bug_remove(fs_session, &bug); + switch_safe_free(ccmd); + stream->write_function(stream, "+OK\n"); + goto end; + } - /* We have already started */ - switch_log_printf( - SWITCH_CHANNEL_SESSION_LOG(session), - SWITCH_LOG_WARNING, - "Cannot run 2 at once on the same channel!\n" - ); + /* We have already started */ + switch_log_printf( + SWITCH_CHANNEL_SESSION_LOG(session), + SWITCH_LOG_WARNING, + "Cannot run 2 at once on the same channel!\n" + ); - goto end; - } + goto end; + } - /* If we don't see the expected start exit */ - if (strcasecmp(command, "start") != 0) { - stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); - goto end; - } + /* If we don't see the expected start exit */ + if (strcasecmp(command, "start") != 0) { + stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); + goto end; + } - /* Allocate memory attached to this FreeSWITCH session for - * use in the callback routine and to store state information */ - avmd_session = (avmd_session_t *) switch_core_session_alloc(fs_session, sizeof(avmd_session_t)); + /* Allocate memory attached to this FreeSWITCH session for + * use in the callback routine and to store state information */ + avmd_session = (avmd_session_t *) switch_core_session_alloc(fs_session, sizeof(avmd_session_t)); - init_avmd_session_data(avmd_session, fs_session); + init_avmd_session_data(avmd_session, fs_session); - /* Add a media bug that allows me to intercept the - * reading leg of the audio stream */ - status = switch_core_media_bug_add( - fs_session, - "avmd", - NULL, - avmd_callback, - avmd_session, - 0, - SMBF_READ_REPLACE, - &bug - ); + /* Add a media bug that allows me to intercept the + * reading leg of the audio stream */ + status = switch_core_media_bug_add( + fs_session, + "avmd", + NULL, + avmd_callback, + avmd_session, + 0, + SMBF_READ_REPLACE, + &bug + ); - /* If adding a media bug fails exit */ - if (status != SWITCH_STATUS_SUCCESS) { + /* If adding a media bug fails exit */ + if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf( - SWITCH_CHANNEL_SESSION_LOG(session), - SWITCH_LOG_ERROR, - "Failure hooking to stream\n" - ); + switch_log_printf( + SWITCH_CHANNEL_SESSION_LOG(session), + SWITCH_LOG_ERROR, + "Failure hooking to stream\n" + ); - goto end; - } + goto end; + } - /* Set the vmd tag to detect an existing vmd media bug */ - switch_channel_set_private(channel, "_avmd_", bug); + /* Set the vmd tag to detect an existing vmd media bug */ + switch_channel_set_private(channel, "_avmd_", bug); - /* Everything went according to plan! Notify the user */ - stream->write_function(stream, "+OK\n"); + /* Everything went according to plan! Notify the user */ + stream->write_function(stream, "+OK\n"); end: - if (fs_session) { - switch_core_session_rwunlock(fs_session); - } + if (fs_session) { + switch_core_session_rwunlock(fs_session); + } - switch_safe_free(ccmd); + switch_safe_free(ccmd); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } /*! \brief Process one frame of data with avmd algorithm @@ -477,100 +477,102 @@ end: */ static void avmd_process(avmd_session_t *session, switch_frame_t *frame) { - switch_event_t *event; - switch_status_t status; - switch_event_t *event_copy; - switch_channel_t *channel; + switch_event_t *event; + switch_status_t status; + switch_event_t *event_copy; + switch_channel_t *channel; - circ_buffer_t *b; - size_t pos; - double f; - double v; -// double error = 0.0; -// double success = 0.0; -// double amp = 0.0; -// double s_rate; -// double e_rate; -// double avg_a; - //double sine_len; - uint32_t sine_len_i; - //uint32_t beep_len_i; -// int valid; + circ_buffer_t *b; + size_t pos; + double f; + double v; + // double error = 0.0; + // double success = 0.0; + // double amp = 0.0; + // double s_rate; + // double e_rate; + // double avg_a; + //double sine_len; + uint32_t sine_len_i; + //uint32_t beep_len_i; + // int valid; b = &session->b; /*! If beep has already been detected skip the CPU heavy stuff */ - if(session->state.beep_state == BEEP_DETECTED){ - return; - } + if(session->state.beep_state == BEEP_DETECTED){ + return; + } /*! Precompute values used heavily in the inner loop */ - sine_len_i = SINE_LEN(session->rate); - //sine_len = (double)sine_len_i; - //beep_len_i = BEEP_LEN(session->rate); - - channel = switch_core_session_get_channel(session->session); + sine_len_i = SINE_LEN(session->rate); + //sine_len = (double)sine_len_i; + //beep_len_i = BEEP_LEN(session->rate); + + channel = switch_core_session_get_channel(session->session); /*! Insert frame of 16 bit samples into buffer */ - INSERT_INT16_FRAME(b, (int16_t *)(frame->data), frame->samples); + INSERT_INT16_FRAME(b, (int16_t *)(frame->data), frame->samples); - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i); + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i); - /*! INNER LOOP -- OPTIMIZATION TARGET */ - for(pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++){ - if ((pos % sine_len_i) == 0) { - /*! Get a desa2 frequency estimate every sine len */ - f = desa2(b, pos); + /*! INNER LOOP -- OPTIMIZATION TARGET */ + for(pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++){ + if ((pos % sine_len_i) == 0) { + /*! Get a desa2 frequency estimate every sine len */ + f = desa2(b, pos); - if(f < MIN_FREQUENCY_R(session->rate) || f > MAX_FREQUENCY_R(session->rate)) { - v = 99999.0; - RESET_SMA_BUFFER(&session->sma_b); - RESET_SMA_BUFFER(&session->sqa_b); - } else { - APPEND_SMA_VAL(&session->sma_b, f); - APPEND_SMA_VAL(&session->sqa_b, f * f); - - /* calculate variance */ - v = session->sqa_b.sma - (session->sma_b.sma * session->sma_b.sma); + if(f < MIN_FREQUENCY_R(session->rate) || f > MAX_FREQUENCY_R(session->rate)) { + v = 99999.0; + RESET_SMA_BUFFER(&session->sma_b); + RESET_SMA_BUFFER(&session->sqa_b); + } else { + APPEND_SMA_VAL(&session->sma_b, f); + APPEND_SMA_VAL(&session->sqa_b, f * f); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD v=%f f=%f %fHz sma=%f sqa=%f >>>\n", v, f, TO_HZ(session->rate, f), session->sma_b.sma, session->sqa_b.sma); - } + /* calculate variance */ + v = session->sqa_b.sma - (session->sma_b.sma * session->sma_b.sma); - /*! If variance is less than threshold then we have detection */ - if(v < VARIANCE_THRESHOLD){ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD v=%f f=%f %fHz sma=%f sqa=%f >>>\n", v, f, TO_HZ(session->rate, f), session->sma_b.sma, session->sqa_b.sma); + } + + /*! If variance is less than threshold then we have detection */ + if(v < VARIANCE_THRESHOLD){ + + switch_channel_execute_on(switch_core_session_get_channel(session->session), "execute_on_avmd_beep"); /*! Throw an event to FreeSWITCH */ - status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP); - if(status != SWITCH_STATUS_SUCCESS) { - return; - } + status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP); + if(status != SWITCH_STATUS_SUCCESS) { + return; + } - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session->session)); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "avmd"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session->session)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "avmd"); - if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) { - return; - } + if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) { + return; + } - switch_core_session_queue_event(session->session, &event); - switch_event_fire(&event_copy); + switch_core_session_queue_event(session->session, &event); + switch_event_fire(&event_copy); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD - Beep Detected >>>\n"); - switch_channel_set_variable(channel, "avmd_detect", "TRUE"); - RESET_SMA_BUFFER(&session->sma_b); - RESET_SMA_BUFFER(&session->sqa_b); - session->state.beep_state = BEEP_DETECTED; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD - Beep Detected >>>\n"); + switch_channel_set_variable(channel, "avmd_detect", "TRUE"); + RESET_SMA_BUFFER(&session->sma_b); + RESET_SMA_BUFFER(&session->sqa_b); + session->state.beep_state = BEEP_DETECTED; - return; - } + return; + } - //amp = 0.0; - //success = 0.0; - //error = 0.0; - } - } - session->pos = pos; + //amp = 0.0; + //success = 0.0; + //error = 0.0; + } + } + session->pos = pos; } /* For Emacs: diff --git a/src/mod/applications/mod_blacklist/mod_blacklist.2012.vcxproj b/src/mod/applications/mod_blacklist/mod_blacklist.2012.vcxproj index 6dc8684c06..adce1c84b1 100644 --- a/src/mod/applications/mod_blacklist/mod_blacklist.2012.vcxproj +++ b/src/mod/applications/mod_blacklist/mod_blacklist.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -72,6 +72,7 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -86,6 +87,7 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -98,6 +100,7 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -112,6 +115,7 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/applications/mod_blacklist/mod_blacklist.c b/src/mod/applications/mod_blacklist/mod_blacklist.c index 8b18dc001d..850be619af 100644 --- a/src/mod/applications/mod_blacklist/mod_blacklist.c +++ b/src/mod/applications/mod_blacklist/mod_blacklist.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.2012.vcxproj b/src/mod/applications/mod_callcenter/mod_callcenter.2012.vcxproj index 1f5936aaad..b7e2ed7136 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.2012.vcxproj +++ b/src/mod/applications/mod_callcenter/mod_callcenter.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -72,6 +72,7 @@ + 4127;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -86,6 +87,7 @@ + 4127;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -98,6 +100,7 @@ + 4127;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -112,6 +115,7 @@ + 4127;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 3286cea05a..3a357a10d9 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -425,6 +425,8 @@ struct cc_queue { char *strategy; char *moh; + char *announce; + uint32_t announce_freq; char *record_template; char *time_base_score; @@ -536,6 +538,8 @@ cc_queue_t *queue_set_config(cc_queue_t *queue) */ SWITCH_CONFIG_SET_ITEM(queue->config[i++], "strategy", SWITCH_CONFIG_STRING, 0, &queue->strategy, "longest-idle-agent", &queue->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(queue->config[i++], "moh-sound", SWITCH_CONFIG_STRING, 0, &queue->moh, NULL, &queue->config_str_pool, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(queue->config[i++], "announce-sound", SWITCH_CONFIG_STRING, 0, &queue->announce, NULL, &queue->config_str_pool, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(queue->config[i++], "announce-frequency", SWITCH_CONFIG_INT, 0, &queue->announce_freq, 0, &config_int_0_86400, NULL, NULL); SWITCH_CONFIG_SET_ITEM(queue->config[i++], "record-template", SWITCH_CONFIG_STRING, 0, &queue->record_template, NULL, &queue->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(queue->config[i++], "time-base-score", SWITCH_CONFIG_STRING, 0, &queue->time_base_score, "queue", &queue->config_str_pool, NULL, NULL); @@ -661,11 +665,17 @@ static cc_queue_t *load_queue(const char *queue_name) cc_queue_t *queue = NULL; switch_xml_t x_queues, x_queue, cfg, xml; switch_event_t *event = NULL; + switch_event_t *params = NULL; - if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { + switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); + switch_assert(params); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "CC-Queue", queue_name); + + if (!(xml = switch_xml_open_cfg(global_cf, &cfg, params))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); - return queue; + goto end; } + if (!(x_queues = switch_xml_child(cfg, "queues"))) { goto end; } @@ -689,7 +699,7 @@ static cc_queue_t *load_queue(const char *queue_name) queue_set_config(queue); /* Add the params to the event structure */ - count = switch_event_import_xml(switch_xml_child(x_queue, "param"), "name", "value", &event); + count = (int)switch_event_import_xml(switch_xml_child(x_queue, "param"), "name", "value", &event); if (switch_xml_config_parse_event(event, count, SWITCH_FALSE, queue->config) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to process configuration\n"); @@ -717,6 +727,9 @@ end: if (event) { switch_event_destroy(&event); } + if (params) { + switch_event_destroy(¶ms); + } return queue; } @@ -797,6 +810,7 @@ int cc_queue_count(const char *queue) cc_status_t cc_agent_add(const char *agent, const char *type) { + switch_event_t *event; cc_status_t result = CC_STATUS_SUCCESS; char *sql; @@ -818,6 +832,14 @@ cc_status_t cc_agent_add(const char *agent, const char *type) agent, type, cc_agent_status2str(CC_AGENT_STATUS_LOGGED_OUT), cc_agent_state2str(CC_AGENT_STATE_WAITING)); cc_execute_sql(NULL, sql, NULL); switch_safe_free(sql); + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CALLCENTER_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent", agent); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent-Type", type); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Action", "agent-add"); + switch_event_fire(&event); + } + } else { result = CC_STATUS_AGENT_INVALID_TYPE; goto done; @@ -986,6 +1008,13 @@ cc_status_t cc_agent_update(const char *key, const char *value, const char *agen switch_safe_free(sql); result = CC_STATUS_SUCCESS; + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CALLCENTER_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent", agent); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Action", "agent-contact-change"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent-Contact", value); + switch_event_fire(&event); + } } else if (!strcasecmp(key, "ready_time")) { sql = switch_mprintf("UPDATE agents SET ready_time = '%ld', system = 'single_box' WHERE name = '%q'", atol(value), agent); cc_execute_sql(NULL, sql, NULL); @@ -1249,13 +1278,74 @@ end: return SWITCH_STATUS_SUCCESS; } +static switch_status_t load_tier(const char *queue, const char *agent, const char *level, const char *position) +{ + /* Hack to check if an tier already exist */ + if (cc_tier_update("unknown", "unknown", queue, agent) == CC_STATUS_TIER_NOT_FOUND) { + if (level && position) { + cc_tier_add(queue, agent, cc_tier_state2str(CC_TIER_STATE_READY), atoi(level), atoi(position)); + } else { + /* default to level 1 and position 1 within the level */ + cc_tier_add(queue, agent, cc_tier_state2str(CC_TIER_STATE_READY), 0, 0); + } + } else { + if (level) { + cc_tier_update("level", level, queue, agent); + } + if (position) { + cc_tier_update("position", position, queue, agent); + } + } + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t load_tiers(switch_bool_t load_all, const char *queue_name, const char *agent_name) +{ + switch_xml_t x_tiers, x_tier, cfg, xml; + switch_status_t result = SWITCH_STATUS_FALSE; + + if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); + return SWITCH_STATUS_FALSE; + } + + if (!(x_tiers = switch_xml_child(cfg, "tiers"))) { + goto end; + } + + /* Importing from XML config Agent Tiers */ + for (x_tier = switch_xml_child(x_tiers, "tier"); x_tier; x_tier = x_tier->next) { + const char *agent = switch_xml_attr(x_tier, "agent"); + const char *queue = switch_xml_attr(x_tier, "queue"); + const char *level = switch_xml_attr(x_tier, "level"); + const char *position = switch_xml_attr(x_tier, "position"); + if (load_all == SWITCH_TRUE) { + result = load_tier(queue, agent, level, position); + } else if (!zstr(agent_name) && !zstr(queue_name) && !strcasecmp(agent, agent_name) && !strcasecmp(queue, queue_name)) { + result = load_tier(queue, agent, level, position); + } else if (zstr(agent_name) && !strcasecmp(queue, queue_name)) { + result = load_tier(queue, agent, level, position); + } else if (zstr(queue_name) && !strcasecmp(agent, agent_name)) { + result = load_tier(queue, agent, level, position); + } + } + +end: + + if (xml) { + switch_xml_free(xml); + } + + return result; +} + static switch_status_t load_config(void) { switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_xml_t cfg, xml, settings, param, x_queues, x_queue, x_agents, x_agent, x_tiers, x_tier; + switch_xml_t cfg, xml, settings, param, x_queues, x_queue, x_agents, x_agent; switch_cache_db_handle_t *dbh = NULL; char *sql = NULL; - + if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); status = SWITCH_STATUS_TERM; @@ -1323,32 +1413,7 @@ static switch_status_t load_config(void) } /* Importing from XML config Agent Tiers */ - if ((x_tiers = switch_xml_child(cfg, "tiers"))) { - for (x_tier = switch_xml_child(x_tiers, "tier"); x_tier; x_tier = x_tier->next) { - const char *agent = switch_xml_attr(x_tier, "agent"); - const char *queue_name = switch_xml_attr(x_tier, "queue"); - const char *level = switch_xml_attr(x_tier, "level"); - const char *position = switch_xml_attr(x_tier, "position"); - if (agent && queue_name) { - /* Hack to check if an tier already exist */ - if (cc_tier_update("unknown", "unknown", queue_name, agent) == CC_STATUS_TIER_NOT_FOUND) { - if (level && position) { - cc_tier_add(queue_name, agent, cc_tier_state2str(CC_TIER_STATE_READY), atoi(level), atoi(position)); - } else { - /* default to level 1 and position 1 within the level */ - cc_tier_add(queue_name, agent, cc_tier_state2str(CC_TIER_STATE_READY), 0, 0); - } - } else { - if (level) { - cc_tier_update("level", level, queue_name, agent); - } - if (position) { - cc_tier_update("position", position, queue_name, agent); - } - } - } - } - } + load_tiers(SWITCH_TRUE, NULL, NULL); end: switch_mutex_unlock(globals.mutex); @@ -1431,13 +1496,24 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa /* CallBack Mode */ if (!strcasecmp(h->agent_type, CC_AGENT_TYPE_CALLBACK)) { switch_channel_t *member_channel = switch_core_session_get_channel(member_session); - char *cid_name = NULL; + const char *cid_name = NULL; + char *cid_name_freeable = NULL; + const char *cid_number = NULL; const char *cid_name_prefix = NULL; - if ((cid_name_prefix = switch_channel_get_variable(member_channel, "cc_outbound_cid_name_prefix"))) { - cid_name = switch_mprintf("%s%s", cid_name_prefix, h->member_cid_name); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Setting outbound caller_id_name to: %s\n", cid_name); - } + if ((cid_name_prefix = switch_channel_get_variable(member_channel, "cc_outbound_cid_name_prefix"))) { + cid_name_freeable = switch_mprintf("%s%s", cid_name_prefix, h->member_cid_name); + cid_name = cid_name_freeable; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Setting outbound caller_id_name to: %s\n", cid_name); + } else { + if (!(cid_name = switch_channel_get_variable(member_channel, "effective_caller_id_name"))) { + cid_name = h->member_cid_name; + } + + if (!(cid_number = switch_channel_get_variable(member_channel, "effective_caller_id_number"))) { + cid_number = h->member_cid_number; + } + } switch_event_create(&ovars, SWITCH_EVENT_REQUEST_PARAMS); switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "cc_queue", "%s", h->queue_name); switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "cc_member_uuid", "%s", h->member_uuid); @@ -1455,11 +1531,11 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa t_agent_called = local_epoch_time_now(NULL); dialstr = switch_channel_expand_variables(member_channel, h->originate_string); - status = switch_ivr_originate(NULL, &agent_session, &cause, dialstr, 60, NULL, cid_name ? cid_name : h->member_cid_name, h->member_cid_number, NULL, ovars, SOF_NONE, NULL); + status = switch_ivr_originate(NULL, &agent_session, &cause, dialstr, 60, NULL, cid_name ? cid_name : h->member_cid_name, cid_number ? cid_number : h->member_cid_number, NULL, ovars, SOF_NONE, NULL); if (dialstr != h->originate_string) { switch_safe_free(dialstr); } - switch_safe_free(cid_name); + switch_safe_free(cid_name_freeable); switch_event_destroy(&ovars); /* UUID Standby Mode */ @@ -1584,7 +1660,7 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa if (atoi(res) == 0) { goto done; } - switch_core_session_hupall_matching_var("cc_member_pre_answer_uuid", h->member_uuid, SWITCH_CAUSE_ORIGINATOR_CANCEL); + switch_core_session_hupall_matching_var("cc_member_pre_answer_uuid", h->member_uuid, SWITCH_CAUSE_LOSE_RACE); } t_agent_answered = local_epoch_time_now(NULL); @@ -1877,11 +1953,11 @@ static int agents_callback(void *pArg, int argc, char **argv, char **columnNames if (cbt->tier_rule_no_agent_no_wait == SWITCH_TRUE && cbt->tier_agent_available == 0) { cbt->tier = atoi(agent_tier_level); /* Multiple the tier level by the tier wait time */ - } else if (cbt->tier_rule_wait_multiply_level == SWITCH_TRUE && (long) local_epoch_time_now(NULL) - atol(cbt->member_joined_epoch) >= atoi(agent_tier_level) * cbt->tier_rule_wait_second) { + } else if (cbt->tier_rule_wait_multiply_level == SWITCH_TRUE && (long) local_epoch_time_now(NULL) - atol(cbt->member_joined_epoch) >= atoi(agent_tier_level) * (int)cbt->tier_rule_wait_second) { cbt->tier = atoi(agent_tier_level); cbt->tier_agent_available = 0; /* Just check if joined is bigger than next tier wait time */ - } else if (cbt->tier_rule_wait_multiply_level == SWITCH_FALSE && (long) local_epoch_time_now(NULL) - atol(cbt->member_joined_epoch) >= cbt->tier_rule_wait_second) { + } else if (cbt->tier_rule_wait_multiply_level == SWITCH_FALSE && (long) local_epoch_time_now(NULL) - atol(cbt->member_joined_epoch) >= (int)cbt->tier_rule_wait_second) { cbt->tier = atoi(agent_tier_level); cbt->tier_agent_available = 0; } else { @@ -2008,8 +2084,6 @@ static int agents_callback(void *pArg, int argc, char **argv, char **columnNames return 1; } } - - return 0; } static int members_callback(void *pArg, int argc, char **argv, char **columnNames) @@ -2292,6 +2366,8 @@ void *SWITCH_THREAD_FUNC cc_member_thread_run(switch_thread_t *thread, void *obj struct member_thread_helper *m = (struct member_thread_helper *) obj; switch_core_session_t *member_session = switch_core_session_locate(m->member_session_uuid); switch_channel_t *member_channel = NULL; + switch_time_t last_announce = local_epoch_time_now(NULL); + switch_bool_t announce_valid = SWITCH_TRUE; if (member_session) { member_channel = switch_core_session_get_channel(member_session); @@ -2306,22 +2382,27 @@ void *SWITCH_THREAD_FUNC cc_member_thread_run(switch_thread_t *thread, void *obj while(switch_channel_ready(member_channel) && m->running && globals.running) { cc_queue_t *queue = NULL; + switch_time_t time_now = local_epoch_time_now(NULL); if (!m->queue_name || !(queue = get_queue(m->queue_name))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_WARNING, "Queue %s not found\n", m->queue_name); break; } /* Make the Caller Leave if he went over his max wait time */ - if (queue->max_wait_time > 0 && queue->max_wait_time <= local_epoch_time_now(NULL) - m->t_member_called) { + if (queue->max_wait_time > 0 && queue->max_wait_time <= time_now - m->t_member_called) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Member %s <%s> in queue '%s' reached max wait time\n", m->member_cid_name, m->member_cid_number, m->queue_name); m->member_cancel_reason = CC_MEMBER_CANCEL_REASON_TIMEOUT; switch_channel_set_flag_value(member_channel, CF_BREAK, 2); } - if (queue->max_wait_time_with_no_agent > 0 && queue->last_agent_exist_check > queue->last_agent_exist) { + /* Check if max wait time no agent is Active AND if there is no Agent AND if the last agent check was after the member join */ + if (queue->max_wait_time_with_no_agent > 0 && queue->last_agent_exist_check > queue->last_agent_exist && m->t_member_called <= queue->last_agent_exist_check) { + /* Check if the time without agent is bigger or equal than out threshold */ if (queue->last_agent_exist_check - queue->last_agent_exist >= queue->max_wait_time_with_no_agent) { + /* Check for grace period with no agent when member join */ if (queue->max_wait_time_with_no_agent_time_reached > 0) { - if (queue->last_agent_exist_check - m->t_member_called >= queue->max_wait_time_with_no_agent + queue->max_wait_time_with_no_agent_time_reached) { + /* Check if the last agent check was after the member join, and we waited atless the extra time */ + if (queue->last_agent_exist_check - m->t_member_called >= queue->max_wait_time_with_no_agent_time_reached + queue->max_wait_time_with_no_agent) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Member %s <%s> in queue '%s' reached max wait of %d sec. with no agent plus join grace period of %d sec.\n", m->member_cid_name, m->member_cid_number, m->queue_name, queue->max_wait_time_with_no_agent, queue->max_wait_time_with_no_agent_time_reached); m->member_cancel_reason = CC_MEMBER_CANCEL_REASON_NO_AGENT_TIMEOUT; switch_channel_set_flag_value(member_channel, CF_BREAK, 2); @@ -2349,7 +2430,24 @@ void *SWITCH_THREAD_FUNC cc_member_thread_run(switch_thread_t *thread, void *obj */ /* If Agent Logoff, we might need to recalculare score based on skill */ - /* Play Announcement in order */ + /* Play the periodic announcement if it is time to do so */ + if (announce_valid == SWITCH_TRUE && queue->announce && queue->announce_freq > 0 && + queue->announce_freq <= time_now - last_announce) { + switch_status_t status = SWITCH_STATUS_FALSE; + /* Stop previous announcement in case it's still running */ + switch_ivr_stop_displace_session(member_session, queue->announce); + /* Play the announcement */ + status = switch_ivr_displace_session(member_session, queue->announce, 0, NULL); + + if (status != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_WARNING, + "Couldn't play announcement '%s'\n", queue->announce); + announce_valid = SWITCH_FALSE; + } + else { + last_announce = time_now; + } + } queue_rwunlock(queue); @@ -2736,6 +2834,7 @@ static int list_result_callback(void *pArg, int argc, char **argv, char **column #define CC_CONFIG_API_SYNTAX "callcenter_config ,\n"\ "\tcallcenter_config agent add [name] [type] | \n" \ "\tcallcenter_config agent del [name] | \n" \ +"\tcallcenter_config agent reload [name] | \n" \ "\tcallcenter_config agent set status [agent_name] [status] | \n" \ "\tcallcenter_config agent set state [agent_name] [state] | \n" \ "\tcallcenter_config agent set contact [agent_name] [contact] | \n" \ @@ -2752,6 +2851,7 @@ static int list_result_callback(void *pArg, int argc, char **argv, char **column "\tcallcenter_config tier set level [queue_name] [agent_name] [level] | \n" \ "\tcallcenter_config tier set position [queue_name] [agent_name] [position] | \n" \ "\tcallcenter_config tier del [queue_name] [agent_name] | \n" \ +"\tcallcenter_config tier reload [queue_name] [agent_name] | \n" \ "\tcallcenter_config tier list | \n" \ "\tcallcenter_config queue load [queue_name] | \n" \ "\tcallcenter_config queue unload [queue_name] | \n" \ @@ -2837,6 +2937,22 @@ SWITCH_STANDARD_API(cc_config_api_function) } } + } else if (action && !strcasecmp(action, "reload")) { + if (argc-initial_argc < 1) { + stream->write_function(stream, "%s", "-ERR Invalid!\n"); + goto done; + } else { + const char *agent = argv[0 + initial_argc]; + switch (load_agent(agent)) { + case SWITCH_STATUS_SUCCESS: + stream->write_function(stream, "%s", "+OK\n"); + break; + default: + stream->write_function(stream, "%s", "-ERR Unknown Error!\n"); + goto done; + } + } + } else if (action && !strcasecmp(action, "set")) { if (argc-initial_argc < 3) { stream->write_function(stream, "%s", "-ERR Invalid!\n"); @@ -3002,6 +3118,28 @@ SWITCH_STANDARD_API(cc_config_api_function) } } + } else if (action && !strcasecmp(action, "reload")) { + if (argc-initial_argc < 1) { + stream->write_function(stream, "%s", "-ERR Invalid!\n"); + goto done; + } else { + const char *queue = argv[0 + initial_argc]; + const char *agent = argv[1 + initial_argc]; + switch_bool_t load_all = SWITCH_FALSE; + if (!strcasecmp(queue, "all")) { + load_all = SWITCH_TRUE; + } + switch (load_tiers(load_all, queue, agent)) { + case SWITCH_STATUS_SUCCESS: + stream->write_function(stream, "%s", "+OK\n"); + break; + default: + stream->write_function(stream, "%s", "-ERR Unknown Error!\n"); + goto done; + + } + } + } else if (action && !strcasecmp(action, "list")) { struct list_result cbt; cbt.row_process = 0; @@ -3194,6 +3332,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) switch_console_set_complete("add callcenter_config agent add"); switch_console_set_complete("add callcenter_config agent del"); + switch_console_set_complete("add callcenter_config agent reload"); switch_console_set_complete("add callcenter_config agent set status"); switch_console_set_complete("add callcenter_config agent set state"); switch_console_set_complete("add callcenter_config agent set uuid"); @@ -3207,6 +3346,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) switch_console_set_complete("add callcenter_config tier add"); switch_console_set_complete("add callcenter_config tier del"); + switch_console_set_complete("add callcenter_config tier reload"); switch_console_set_complete("add callcenter_config tier set state"); switch_console_set_complete("add callcenter_config tier set level"); switch_console_set_complete("add callcenter_config tier set position"); diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 8d4fb0b71b..34d2104d5f 100755 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -409,8 +409,8 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha if (http_data.stream.data && !zstr((char *) http_data.stream.data) && strcmp(" ", http_data.stream.data)) { - /* don't return UNKNOWN */ - if (strcmp("UNKNOWN", http_data.stream.data) || strcmp("UNAVAILABLE", http_data.stream.data)) { + /* don't return UNKNOWN or UNAVAILABLE */ + if (strcasecmp("UNKNOWN", http_data.stream.data) && strcasecmp("UNAVAILABLE", http_data.stream.data)) { *response = switch_core_strdup(pool, http_data.stream.data); } } diff --git a/src/mod/applications/mod_cluechoo/Makefile b/src/mod/applications/mod_cluechoo/Makefile index 2c35e6e98f..d96278fdcd 100644 --- a/src/mod/applications/mod_cluechoo/Makefile +++ b/src/mod/applications/mod_cluechoo/Makefile @@ -1,2 +1,3 @@ +LOCAL_LDFLAGS=-lncurses BASE=../../../.. include $(BASE)/build/modmake.rules diff --git a/src/mod/applications/mod_cluechoo/mod_cluechoo.c b/src/mod/applications/mod_cluechoo/mod_cluechoo.c index 2b2cd5482a..c1012f127b 100644 --- a/src/mod/applications/mod_cluechoo/mod_cluechoo.c +++ b/src/mod/applications/mod_cluechoo/mod_cluechoo.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_commands/mod_commands.2012.vcxproj b/src/mod/applications/mod_commands/mod_commands.2012.vcxproj index ee89aebf26..17f198ea9a 100644 --- a/src/mod/applications/mod_commands/mod_commands.2012.vcxproj +++ b/src/mod/applications/mod_commands/mod_commands.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,10 +68,27 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + false false @@ -86,6 +103,7 @@ + false false @@ -98,6 +116,7 @@ + false false @@ -112,6 +131,7 @@ + false false diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2e4259817a..d3ab138bd8 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -34,7 +34,7 @@ * Rupa Schomaker * Joseph Sullivan * Raymond Chandler - * + * Seven Du * Garmt Boekholt * * mod_commands.c -- Misc. Command Module @@ -42,7 +42,6 @@ */ #include #include -#include SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown); @@ -284,9 +283,9 @@ static void dump_user(struct user_struct *us) } if(zstr(dname)) { - apip = switch_mprintf("%s",switch_xml_attr_soft(x_user_tag, "id")); + apip = switch_mprintf("*/%s",switch_xml_attr_soft(x_user_tag, "id")); } else { - apip = switch_mprintf("%s@%s",switch_xml_attr_soft(x_user_tag, "id"), dname); + apip = switch_mprintf("*/%s@%s",switch_xml_attr_soft(x_user_tag, "id"), dname); } SWITCH_STANDARD_STREAM(apistream); @@ -518,6 +517,29 @@ SWITCH_STANDARD_API(switchname_api_function) return SWITCH_STATUS_SUCCESS; } +SWITCH_STANDARD_API(gethost_api_function) +{ + struct sockaddr_in sa; + struct hostent *he; + const char *ip; + char buf[50] = ""; + + if (!zstr(cmd)) { + he = gethostbyname(cmd); + + if (he) { + memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr)); + ip = switch_inet_ntop(AF_INET, &sa.sin_addr, buf, sizeof(buf)); + stream->write_function(stream, "%s", ip); + return SWITCH_STATUS_SUCCESS; + } + } + + stream->write_function(stream, "-ERR"); + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_STANDARD_API(shutdown_function) { @@ -536,7 +558,7 @@ SWITCH_STANDARD_API(version_function) char *mydata = NULL, *argv[2]; if (zstr(cmd)) { - stream->write_function(stream, "FreeSWITCH Version %s (%s)\n", SWITCH_VERSION_FULL, SWITCH_VERSION_REVISION_HUMAN); + stream->write_function(stream, "FreeSWITCH Version %s (%s)\n", switch_version_full(), switch_version_revision_human()); goto end; } @@ -546,9 +568,9 @@ SWITCH_STANDARD_API(version_function) argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (argc > 0 && switch_stristr("short", argv[0])) { - stream->write_function(stream, "%s.%s.%s\n", SWITCH_VERSION_MAJOR,SWITCH_VERSION_MINOR,SWITCH_VERSION_MICRO); + stream->write_function(stream, "%s.%s.%s\n", switch_version_major(),switch_version_minor(),switch_version_micro()); } else { - stream->write_function(stream, "FreeSWITCH Version %s (%s)\n", SWITCH_VERSION_FULL, SWITCH_VERSION_FULL_HUMAN); + stream->write_function(stream, "FreeSWITCH Version %s (%s)\n", switch_version_full(), switch_version_full_human()); } switch_safe_free(mydata); @@ -1108,7 +1130,7 @@ SWITCH_STANDARD_API(in_group_function) SWITCH_STANDARD_API(user_data_function) { - switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params; + switch_xml_t x_user = NULL, x_param, x_params; int argc; char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain, *dup_domain = NULL; char delim = ' '; @@ -1143,7 +1165,7 @@ SWITCH_STANDARD_API(user_data_function) switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "type", type); - if (key && type && switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, &x_group, params) == SWITCH_STATUS_SUCCESS) { + if (key && type && switch_xml_locate_user_merged("id:number-alias", user, domain, NULL, &x_user, params) == SWITCH_STATUS_SUCCESS) { if (!strcmp(type, "attr")) { const char *attr = switch_xml_attr_soft(x_user, key); result = attr; @@ -1155,29 +1177,6 @@ SWITCH_STANDARD_API(user_data_function) elem = "variable"; } - if ((x_params = switch_xml_child(x_domain, container))) { - for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) { - const char *var = switch_xml_attr(x_param, "name"); - const char *val = switch_xml_attr(x_param, "value"); - - if (var && val && !strcasecmp(var, key)) { - result = val; - } - - } - } - - if (x_group && (x_params = switch_xml_child(x_group, container))) { - for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) { - const char *var = switch_xml_attr(x_param, "name"); - const char *val = switch_xml_attr(x_param, "value"); - - if (var && val && !strcasecmp(var, key)) { - result = val; - } - } - } - if ((x_params = switch_xml_child(x_user, container))) { for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) { const char *var = switch_xml_attr(x_param, "name"); @@ -1194,7 +1193,7 @@ SWITCH_STANDARD_API(user_data_function) if (result) { stream->write_function(stream, "%s", result); } - switch_xml_free(xml); + switch_xml_free(x_user); switch_safe_free(mydata); switch_safe_free(dup_domain); switch_event_destroy(¶ms); @@ -1204,7 +1203,7 @@ SWITCH_STANDARD_API(user_data_function) static switch_status_t _find_user(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream, switch_bool_t tf) { - switch_xml_t x_domain = NULL, x_user = NULL, xml = NULL; + switch_xml_t x_user = NULL; int argc; char *mydata = NULL, *argv[3]; char *key, *user, *domain; @@ -1244,7 +1243,7 @@ static switch_status_t _find_user(const char *cmd, switch_core_session_t *sessio goto end; } - if (switch_xml_locate_user(key, user, domain, NULL, &xml, &x_domain, &x_user, NULL, NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_xml_locate_user_merged(key, user, domain, NULL, &x_user, NULL) != SWITCH_STATUS_SUCCESS) { err = "can't find user"; goto end; } @@ -1274,7 +1273,7 @@ static switch_status_t _find_user(const char *cmd, switch_core_session_t *sessio } } - switch_xml_free(xml); + switch_xml_free(x_user); switch_safe_free(mydata); return SWITCH_STATUS_SUCCESS; } @@ -1397,7 +1396,7 @@ SWITCH_STANDARD_API(expand_function) { char *expanded; char *dup; - char *arg; + char *arg = NULL; char *mycmd; switch_status_t status; const char *p; @@ -1431,7 +1430,7 @@ SWITCH_STANDARD_API(expand_function) } } - if ((arg = strchr(mycmd, ' '))) { + if (mycmd && (arg = strchr(mycmd, ' '))) { *arg++ = '\0'; } @@ -1929,40 +1928,101 @@ SWITCH_STANDARD_API(cond_function) } a = argv[0]; + while(*a == ' ' || *a == '\t') a++; - if ((expr = strchr(a, '!'))) { - *expr++ = '\0'; - if (*expr == '=') { - o = O_NE; - } - } else if ((expr = strchr(a, '>'))) { - if (*(expr + 1) == '=') { + if (*a == '\'') { + if ((expr = switch_find_end_paren(a, '\'', '\''))) { + a++; *expr++ = '\0'; - o = O_GE; } else { - o = O_GT; + goto error; } - } else if ((expr = strchr(a, '<'))) { - if (*(expr + 1) == '=') { + } else { + if ((expr = strchr(a, ' '))) { *expr++ = '\0'; - o = O_LE; } else { - o = O_LT; - } - } else if ((expr = strchr(a, '='))) { - *expr++ = '\0'; - if (*expr == '=') { - o = O_EQ; + expr = a; } } + if (strspn(a, "!<>=")) { + expr = a; + } + + if (expr == a) { + a = ""; + } + + while (*expr == ' ') expr++; + + while(expr && *expr) { + switch(*expr) { + case '!': + case '<': + case '>': + case '=': + goto done; + default: + expr++; + break; + } + } + + done: + + switch(*expr) { + case '!': + *expr++ = '\0'; + if (*expr == '=') { + o = O_NE; + *expr++ = '\0'; + } + break; + + case '>': + *expr++ = '\0'; + if (*expr == '=') { + o = O_GE; + *expr++ = '\0'; + } else { + o = O_GT; + } + break; + + case '<': + *expr++ = '\0'; + if (*expr == '=') { + o = O_LE; + *expr++ = '\0'; + } else { + o = O_LT; + } + break; + + case '=': + *expr++ = '\0'; + if (*expr == '=') { + o = O_EQ; + *expr++ = '\0'; + } + break; + + default: + goto error; + } + + if (o) { char *s_a = NULL, *s_b = NULL; int a_is_num, b_is_num; - *expr++ = '\0'; + + expr++; b = expr; + s_a = switch_strip_spaces(a, SWITCH_TRUE); s_b = switch_strip_spaces(b, SWITCH_TRUE); + + a_is_num = switch_is_number(s_a); b_is_num = switch_is_number(s_b); @@ -2068,7 +2128,7 @@ SWITCH_STANDARD_API(status_function) duration.sec, duration.sec == 1 ? "" : "s", duration.ms , duration.ms == 1 ? "" : "s", duration.mms, duration.mms == 1 ? "" : "s", nl); - stream->write_function(stream, "FreeSWITCH (Version %s) is %s%s", SWITCH_VERSION_FULL_HUMAN, + stream->write_function(stream, "FreeSWITCH (Version %s) is %s%s", switch_version_full_human(), switch_core_ready() ? "ready" : "not ready", nl); stream->write_function(stream, "%" SWITCH_SIZE_T_FMT " session(s) since startup%s", switch_core_session_id() - 1, nl); @@ -2225,6 +2285,9 @@ SWITCH_STANDARD_API(ctl_function) switch_core_session_ctl(command, &arg); stream->write_function(stream, "+OK\n"); + } else if (!strcasecmp(argv[0], "debug_pool")) { + switch_core_session_debug_pool(stream); + } else if (!strcasecmp(argv[0], "debug_sql")) { int x = 0; switch_core_session_ctl(SCSC_DEBUG_SQL, &x); @@ -2888,6 +2951,130 @@ SWITCH_STANDARD_API(uuid_deflect) return SWITCH_STATUS_SUCCESS; } + +#define UUID_MEDIA_STATS_SYNTAX "" +SWITCH_STANDARD_API(uuid_set_media_stats) +{ + switch_core_session_t *tsession = NULL; + const char *uuid = cmd; + + if (zstr(uuid)) { + stream->write_function(stream, "-USAGE: %s\n", UUID_MEDIA_STATS_SYNTAX); + } else { + if ((tsession = switch_core_session_locate(uuid))) { + switch_core_media_set_stats(tsession); + stream->write_function(stream, "+OK:\n"); + switch_core_session_rwunlock(tsession); + } else { + stream->write_function(stream, "-ERR No such channel %s!\n", uuid); + } + } + + return SWITCH_STATUS_SUCCESS; +} + +#define add_stat(_i, _s) cJSON_AddItemToObject(jstats, _s, cJSON_CreateNumber(((double)_i))) + +static void jsonify_stats(cJSON *json, const char *name, switch_rtp_stats_t *stats) +{ + cJSON *jstats = cJSON_CreateObject(); + cJSON_AddItemToObject(json, name, jstats); + + stats->inbound.std_deviation = sqrt(stats->inbound.variance); + + add_stat(stats->inbound.raw_bytes, "in_raw_bytes"); + add_stat(stats->inbound.media_bytes, "in_media_bytes"); + add_stat(stats->inbound.packet_count, "in_packet_count"); + add_stat(stats->inbound.media_packet_count, "in_media_packet_count"); + add_stat(stats->inbound.skip_packet_count, "in_skip_packet_count"); + add_stat(stats->inbound.jb_packet_count, "in_jitter_packet_count"); + add_stat(stats->inbound.dtmf_packet_count, "in_dtmf_packet_count"); + add_stat(stats->inbound.cng_packet_count, "in_cng_packet_count"); + add_stat(stats->inbound.flush_packet_count, "in_flush_packet_count"); + add_stat(stats->inbound.largest_jb_size, "in_largest_jb_size"); + + add_stat (stats->inbound.min_variance, "in_jitter_min_variance"); + add_stat (stats->inbound.max_variance, "in_jitter_max_variance"); + add_stat (stats->inbound.lossrate, "in_jitter_loss_rate"); + add_stat (stats->inbound.burstrate, "in_jitter_burst_rate"); + add_stat (stats->inbound.mean_interval, "in_mean_interval"); + + add_stat(stats->inbound.flaws, "in_flaw_total"); + + add_stat (stats->inbound.R, "in_quality_percentage"); + add_stat (stats->inbound.mos, "in_mos"); + + + add_stat(stats->outbound.raw_bytes, "out_raw_bytes"); + add_stat(stats->outbound.media_bytes, "out_media_bytes"); + add_stat(stats->outbound.packet_count, "out_packet_count"); + add_stat(stats->outbound.media_packet_count, "out_media_packet_count"); + add_stat(stats->outbound.skip_packet_count, "out_skip_packet_count"); + add_stat(stats->outbound.dtmf_packet_count, "out_dtmf_packet_count"); + add_stat(stats->outbound.cng_packet_count, "out_cng_packet_count"); + + add_stat(stats->rtcp.packet_count, "rtcp_packet_count"); + add_stat(stats->rtcp.octet_count, "rtcp_octet_count"); + +} + +static switch_bool_t true_enough(cJSON *json) +{ + if (json && (json->type == cJSON_True || json->valueint || json->valuedouble || json->valuestring)) { + return SWITCH_TRUE; + } + + return SWITCH_FALSE; +} + +SWITCH_STANDARD_JSON_API(json_stats_function) +{ + cJSON *reply, *data = cJSON_GetObjectItem(json, "data"); + switch_status_t status = SWITCH_STATUS_FALSE; + const char *uuid = cJSON_GetObjectCstr(data, "uuid"); + cJSON *cdata = cJSON_GetObjectItem(data, "channelData"); + + switch_core_session_t *tsession; + + reply = cJSON_CreateObject(); + *json_reply = reply; + + if (zstr(uuid)) { + cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT")); + goto end; + } + + + if ((tsession = switch_core_session_locate(uuid))) { + cJSON *jevent; + switch_rtp_stats_t *audio_stats = NULL, *video_stats = NULL; + + switch_core_media_set_stats(tsession); + + audio_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(tsession)); + video_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_VIDEO, switch_core_session_get_pool(tsession)); + + jsonify_stats(reply, "audio", audio_stats); + jsonify_stats(reply, "video", video_stats); + + if (true_enough(cdata) && switch_ivr_generate_json_cdr(tsession, &jevent, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { + cJSON_AddItemToObject(reply, "channelData", jevent); + } + + switch_core_session_rwunlock(tsession); + + status = SWITCH_STATUS_SUCCESS; + } else { + cJSON_AddItemToObject(reply, "response", cJSON_CreateString("Session does not exist")); + goto end; + } + + end: + + return status; +} + + #define UUID_RECOVERY_REFRESH_SYNTAX " " SWITCH_STANDARD_API(uuid_recovery_refresh) { @@ -3123,8 +3310,13 @@ SWITCH_STANDARD_API(uuid_answer_function) if (uuid && (xsession = switch_core_session_locate(uuid))) { switch_channel_t *channel = switch_core_session_get_channel(xsession); - switch_channel_answer(channel); + switch_status_t status = switch_channel_answer(channel); switch_core_session_rwunlock(xsession); + if (status == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK\n"); + } else { + stream->write_function(stream, "-ERROR\n"); + } } else { stream->write_function(stream, "-ERROR\n"); } @@ -3602,7 +3794,7 @@ SWITCH_STANDARD_API(uuid_video_refresh_function) } -#define DEBUG_MEDIA_SYNTAX " " +#define DEBUG_MEDIA_SYNTAX " " SWITCH_STANDARD_API(uuid_debug_media_function) { char *mycmd = NULL, *argv[3] = { 0 }; @@ -3626,7 +3818,18 @@ SWITCH_STANDARD_API(uuid_debug_media_function) msg.from = __FILE__; if ((lsession = switch_core_session_locate(argv[0]))) { + if (!strcasecmp(argv[1], "all")) { + msg.string_array_arg[0] = "both"; + } + + again: status = switch_core_session_receive_message(lsession, &msg); + + if (status == SWITCH_STATUS_SUCCESS && !strcasecmp(argv[1], "all") && !strcmp(msg.string_array_arg[0], "both")) { + msg.string_array_arg[0] = "vboth"; + goto again; + } + switch_core_session_rwunlock(lsession); } } @@ -6211,7 +6414,7 @@ SWITCH_STANDARD_JSON_API(json_api_function) } -#include + SWITCH_STANDARD_JSON_API(json_status_function) { cJSON *o, *oo, *reply = cJSON_CreateObject(); @@ -6241,7 +6444,7 @@ SWITCH_STANDARD_JSON_API(json_status_function) cJSON_AddItemToObject(o, "microseconds", cJSON_CreateNumber(duration.mms)); cJSON_AddItemToObject(reply, "uptime", o); - cJSON_AddItemToObject(reply, "version", cJSON_CreateString(SWITCH_VERSION_FULL_HUMAN)); + cJSON_AddItemToObject(reply, "version", cJSON_CreateString(switch_version_full_human())); o = cJSON_CreateObject(); cJSON_AddItemToObject(reply, "sessions", o); @@ -6249,7 +6452,7 @@ SWITCH_STANDARD_JSON_API(json_status_function) oo = cJSON_CreateObject(); cJSON_AddItemToObject(o, "count", oo); - cJSON_AddItemToObject(oo, "total", cJSON_CreateNumber(switch_core_session_id() - 1)); + cJSON_AddItemToObject(oo, "total", cJSON_CreateNumber((double)(switch_core_session_id() - 1))); cJSON_AddItemToObject(oo, "active", cJSON_CreateNumber(switch_core_session_count())); cJSON_AddItemToObject(oo, "peak", cJSON_CreateNumber(sessions_peak)); cJSON_AddItemToObject(oo, "peak5Min", cJSON_CreateNumber(sessions_peak_fivemin)); @@ -6276,8 +6479,8 @@ SWITCH_STANDARD_JSON_API(json_status_function) o = cJSON_CreateObject(); cJSON_AddItemToObject(reply, "stackSizeKB", o); - cJSON_AddItemToObject(o, "current", cJSON_CreateNumber(cur / 1024)); - cJSON_AddItemToObject(o, "max", cJSON_CreateNumber(max / 1024)); + cJSON_AddItemToObject(o, "current", cJSON_CreateNumber((double)(cur / 1024))); + cJSON_AddItemToObject(o, "max", cJSON_CreateNumber((double)(max / 1024))); } @@ -6372,6 +6575,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "hostname", "Return the system hostname", hostname_api_function, ""); SWITCH_ADD_API(commands_api_interface, "interface_ip", "Return the primary IP of an interface", interface_ip_function, INTERFACE_IP_SYNTAX); SWITCH_ADD_API(commands_api_interface, "switchname", "Return the switch name", switchname_api_function, ""); + SWITCH_ADD_API(commands_api_interface, "gethost", "gethostbyname", gethost_api_function, ""); SWITCH_ADD_API(commands_api_interface, "hupall", "hupall", hupall_api_function, " [ ]"); SWITCH_ADD_API(commands_api_interface, "in_group", "Determine if a user is in a group", in_group_function, "[@] "); SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "See if an ip is a lan addr", lan_addr_function, ""); @@ -6438,6 +6642,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill channel", kill_function, KILL_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_send_message", "Send MESSAGE to the endpoint", uuid_send_message_function, SEND_MESSAGE_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_send_info", "Send info to the endpoint", uuid_send_info_function, INFO_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "uuid_set_media_stats", "Set media stats", uuid_set_media_stats, UUID_MEDIA_STATS_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_video_refresh", "Send video refresh.", uuid_video_refresh_function, VIDEO_REFRESH_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_outgoing_answer", "Answer outgoing channel", outgoing_answer_function, OUTGOING_ANSWER_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_limit", "Increase limit resource", uuid_limit_function, LIMIT_SYNTAX); @@ -6469,6 +6674,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "file_exists", "Check if a file exists on server", file_exists_function, ""); SWITCH_ADD_API(commands_api_interface, "json", "JSON API", json_function, "JSON"); + SWITCH_ADD_JSON_API(json_api_interface, "mediaStats", "JSON Media Stats", json_stats_function, ""); SWITCH_ADD_JSON_API(json_api_interface, "status", "JSON status API", json_status_function, ""); SWITCH_ADD_JSON_API(json_api_interface, "fsapi", "JSON FSAPI Gateway", json_api_function, ""); @@ -6478,12 +6684,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add alias add"); + switch_console_set_complete("add alias stickyadd"); switch_console_set_complete("add alias del"); switch_console_set_complete("add coalesce"); switch_console_set_complete("add complete add"); switch_console_set_complete("add complete del"); switch_console_set_complete("add db_cache status"); switch_console_set_complete("add fsctl debug_level"); + switch_console_set_complete("add fsctl debug_pool"); switch_console_set_complete("add fsctl debug_sql"); switch_console_set_complete("add fsctl last_sps"); switch_console_set_complete("add fsctl default_dtmf_duration"); diff --git a/src/mod/applications/mod_conference/mod_conference.2012.vcxproj b/src/mod/applications/mod_conference/mod_conference.2012.vcxproj index 8c27c204e3..cf6308fb22 100644 --- a/src/mod/applications/mod_conference/mod_conference.2012.vcxproj +++ b/src/mod/applications/mod_conference/mod_conference.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,10 +68,27 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + false false @@ -86,6 +103,7 @@ + false false @@ -98,6 +116,7 @@ + false false @@ -112,6 +131,7 @@ + false false diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 863e4c727b..54f19f4bc6 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -32,7 +32,9 @@ * David Weekly * Joao Mesquita * Raymond Chandler + * Ken Rice * Seven Du + * Emmanuel Schmidbauer * * mod_conference.c -- Software Conference Bridge * @@ -183,7 +185,9 @@ typedef enum { MFLAG_NOMOH = (1 << 19), MFLAG_VIDEO_BRIDGE = (1 << 20), MFLAG_INDICATE_MUTE_DETECT = (1 << 21), - MFLAG_PAUSE_RECORDING = (1 << 22) + MFLAG_PAUSE_RECORDING = (1 << 22), + MFLAG_ACK_VIDEO = (1 << 23), + MFLAG_TOOL = (1 << 24) } member_flag_t; typedef enum { @@ -208,7 +212,8 @@ typedef enum { CFLAG_FLOOR_CHANGE = (1 << 18), CFLAG_VID_FLOOR_LOCK = (1 << 19), CFLAG_JSON_EVENTS = (1 << 20), - CFLAG_LIVEARRAY_SYNC = (1 << 21) + CFLAG_LIVEARRAY_SYNC = (1 << 21), + CFLAG_CONF_RESTART_AUTO_RECORD = (1 << 22) } conf_flag_t; typedef enum { @@ -270,6 +275,8 @@ typedef struct conference_file_node { uint32_t leadin; struct conference_file_node *next; char *file; + switch_bool_t mux; + uint32_t member_id; } conference_file_node_t; typedef enum { @@ -372,6 +379,7 @@ typedef struct conference_obj { int comfort_noise_level; int auto_recording; int record_count; + int min_recording_participants; int video_running; int ivr_dtmf_timeout; int ivr_input_timeout; @@ -537,7 +545,7 @@ static void launch_conference_video_thread(conference_obj_t *conference); static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj); static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf, uint32_t buflen); -static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin); +static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin, switch_bool_t mux); static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin); static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop); static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_core_session_t *session, switch_memory_pool_t *pool); @@ -555,6 +563,8 @@ static void conference_member_itterator(conference_obj_t *conference, switch_str static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data); static switch_status_t conf_api_sub_tmute(conference_member_t *member, switch_stream_handle_t *stream, void *data); static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_tool(conference_member_t *member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_untool(conference_member_t *member, switch_stream_handle_t *stream, void *data); static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data); static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data); static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event); @@ -1455,7 +1465,7 @@ static switch_status_t conference_record_stop(conference_obj_t *conference, swit switch_mutex_lock(conference->member_mutex); for (member = conference->members; member; member = member->next) { if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) { - if (member->rec && member->rec->autorec) { + if (!switch_test_flag(conference, CFLAG_CONF_RESTART_AUTO_RECORD) && member->rec && member->rec->autorec) { stream->write_function(stream, "Stopped AUTO recording file %s (Auto Recording Now Disabled)\n", member->rec_path); conference->auto_record = 0; } else { @@ -1795,6 +1805,10 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe channel = switch_core_session_get_channel(member->session); + if (switch_channel_test_flag(channel, CF_VIDEO)) { + switch_set_flag_locked(member, MFLAG_ACK_VIDEO); + } + switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id); switch_channel_set_variable_printf(channel, "conference_moderator", "%s", switch_test_flag(member, MFLAG_MOD) ? "true" : "false"); switch_channel_set_variable(channel, "conference_recording", conference->record_filename); @@ -1914,7 +1928,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe if (conference->la && member->channel) { member->json = cJSON_CreateArray(); - cJSON_AddItemToArray(member->json, cJSON_CreateStringPrintf("%0.8d", member->id)); + cJSON_AddItemToArray(member->json, cJSON_CreateStringPrintf("%0.4d", member->id)); cJSON_AddItemToArray(member->json, cJSON_CreateString(switch_channel_get_variable(member->channel, "caller_id_number"))); cJSON_AddItemToArray(member->json, cJSON_CreateString(switch_channel_get_variable(member->channel, "caller_id_name"))); @@ -2100,6 +2114,48 @@ static void conference_set_floor_holder(conference_obj_t *conference, conference } +static switch_status_t conference_file_close(conference_obj_t *conference, conference_file_node_t *node) +{ + switch_event_t *event; + conference_member_t *member = NULL; + + if (test_eflag(conference, EFLAG_PLAY_FILE_DONE) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + + conference_add_event_data(conference, event); + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "seconds", "%ld", (long) node->fh.samples_in / node->fh.native_rate); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "milliseconds", "%ld", (long) node->fh.samples_in / (node->fh.native_rate / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "samples", "%ld", (long) node->fh.samples_in); + + if (node->fh.params) { + switch_event_merge(event, node->fh.params); + } + + if (node->member_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member-done"); + + if ((member = conference_member_get(conference, node->member_id))) { + conference_add_event_member_data(member, event); + switch_thread_rwlock_unlock(member->rwlock); + } + + } else { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-done"); + } + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", node->file); + + if (node->async) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Async", "true"); + } + + switch_event_fire(&event); + } + + return switch_core_file_close(&node->fh); +} + /* Gain exclusive access and remove the member from the list */ static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member) { @@ -2169,7 +2225,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe fnode = fnode->next; if (cur->type != NODE_TYPE_SPEECH) { - switch_core_file_close(&cur->fh); + conference_file_close(conference, cur); } pool = cur->pool; @@ -2314,7 +2370,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr { conference_obj_t *conference = (conference_obj_t *) obj; conference_member_t *imember; - switch_frame_t *vid_frame; + switch_frame_t *vid_frame = NULL; switch_status_t status; int want_refresh = 0; int yield = 0; @@ -2584,8 +2640,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } } - /* Start recording if there's more than one participant. */ - if (conference->auto_record && !conference->auto_recording && conference->count > 1) { + /* Start auto recording if there's the minimum number of required participants. */ + if (conference->auto_record && !conference->auto_recording && (conference->count >= conference->min_recording_participants)) { conference->auto_recording++; conference->record_count++; imember = conference->members; @@ -2594,6 +2650,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v char *rfile = switch_channel_expand_variables(channel, conference->auto_record); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto recording file: %s\n", rfile); launch_conference_record_thread(conference, rfile, SWITCH_TRUE); + if (rfile != conference->auto_record) { conference->record_filename = switch_core_strdup(conference->pool, rfile); switch_safe_free(rfile); @@ -2653,18 +2710,12 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } } else if (conference->fnode->type == NODE_TYPE_FILE) { switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len); + if (conference->fnode->fh.vol) { + switch_change_sln_volume_granular((void *)file_frame, (uint32_t)file_sample_len, conference->fnode->fh.vol); + } } if (file_sample_len <= 0) { - if (test_eflag(conference, EFLAG_PLAY_FILE_DONE) && - switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { - conference_add_event_data(conference, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-done"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", conference->fnode->file); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Async", "true"); - switch_event_fire(&event); - } - conference->fnode->done++; } else { has_file_data = 1; @@ -2681,14 +2732,6 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len); if (file_sample_len <= 0) { - if (test_eflag(conference, EFLAG_PLAY_FILE) && - switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { - conference_add_event_data(conference, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-done"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", conference->async_fnode->file); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Async", "true"); - switch_event_fire(&event); - } conference->async_fnode->done++; } else { if (has_file_data) { @@ -2743,6 +2786,10 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v continue; } + if (switch_test_flag(omember, MFLAG_TOOL) && (rand() % 20) > 9){ + continue; + } + if (conference->agc_level) { if (switch_test_flag(omember, MFLAG_TALKING) && switch_test_flag(omember, MFLAG_CAN_SPEAK)) { member_score_sum += omember->score; @@ -2788,6 +2835,11 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v continue; } + if (switch_test_flag(omember, MFLAG_TOOL) && (rand() % 20) > 9) { + continue; + } + + bptr = (int16_t *) omember->frame; for (x = 0; x < bytes / 2; x++) { z = main_frame[x]; @@ -2843,7 +2895,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (conference->async_fnode && conference->async_fnode->done) { switch_memory_pool_t *pool; - switch_core_file_close(&conference->async_fnode->fh); + conference_file_close(conference, conference->async_fnode); pool = conference->async_fnode->pool; conference->async_fnode = NULL; switch_core_destroy_memory_pool(&pool); @@ -2854,7 +2906,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_memory_pool_t *pool; if (conference->fnode->type != NODE_TYPE_SPEECH) { - switch_core_file_close(&conference->fnode->fh); + conference_file_close(conference, conference->fnode); } fnode = conference->fnode; @@ -2909,7 +2961,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v fnode = fnode->next; if (cur->type != NODE_TYPE_SPEECH) { - switch_core_file_close(&cur->fh); + conference_file_close(conference, cur); } pool = cur->pool; @@ -2920,7 +2972,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (conference->async_fnode) { switch_memory_pool_t *pool; - switch_core_file_close(&conference->async_fnode->fh); + conference_file_close(conference, conference->async_fnode); pool = conference->async_fnode->pool; conference->async_fnode = NULL; switch_core_destroy_memory_pool(&pool); @@ -3152,7 +3204,7 @@ static void conference_loop_fn_energy_up(conference_member_t *member, caller_con switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); for (p = str; p && *p; p++) { switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } @@ -3184,7 +3236,7 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t *member, call switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); for (p = str; p && *p; p++) { switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } } @@ -3216,7 +3268,7 @@ static void conference_loop_fn_energy_dn(conference_member_t *member, caller_con switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); for (p = str; p && *p; p++) { switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } } @@ -3245,11 +3297,11 @@ static void conference_loop_fn_volume_talk_up(conference_member_t *member, calle if (member->volume_out_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } @@ -3277,11 +3329,11 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t *member, cal if (member->volume_out_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action) @@ -3308,11 +3360,11 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t *member, calle if (member->volume_out_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action) @@ -3339,11 +3391,11 @@ static void conference_loop_fn_volume_listen_up(conference_member_t *member, cal if (member->volume_in_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } @@ -3370,11 +3422,11 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t *member, c if (member->volume_in_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } @@ -3402,11 +3454,11 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t *member, cal if (member->volume_in_level < 0) { switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); - conference_member_play_file(member, msg, 0); + conference_member_play_file(member, msg, 0, SWITCH_TRUE); } static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action) @@ -3545,10 +3597,10 @@ static int noise_gate_check(conference_member_t *member) if (target_score < 0) target_score = 0; - r = member->score > target_score; + r = (int)member->score > target_score; } else { - r = member->score > member->energy_level; + r = (int32_t)member->score > member->energy_level; } return r; @@ -3569,11 +3621,11 @@ static void check_agc_levels(conference_member_t *member) if (!member->avg_score) return; - if (member->avg_score < member->conference->agc_level - 100) { + if ((int)member->avg_score < member->conference->agc_level - 100) { member->agc_volume_in_level++; switch_normalize_volume_granular(member->agc_volume_in_level); x = 1; - } else if (member->avg_score > member->conference->agc_level + 100) { + } else if ((int)member->avg_score > member->conference->agc_level + 100) { member->agc_volume_in_level--; switch_normalize_volume_granular(member->agc_volume_in_level); x = -1; @@ -3603,7 +3655,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_frame_t *read_frame = NULL; uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400; switch_core_session_t *session = member->session; - + uint32_t flush_len; if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { goto end; @@ -3617,6 +3669,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_core_session_get_read_impl(session, &member->read_impl); + switch_channel_audio_sync(channel); + + flush_len = switch_samples_per_packet(member->conference->rate, member->conference->interval) * 6; + /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it and mux it with any audio from other channels. */ @@ -3638,6 +3694,13 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v break; } + if (switch_channel_test_flag(channel, CF_VIDEO) && !switch_test_flag(member, MFLAG_ACK_VIDEO)) { + switch_set_flag_locked(member, MFLAG_ACK_VIDEO); + switch_channel_clear_flag(channel, CF_VIDEO_ECHO); + switch_core_session_refresh_video(member->session); + conference_set_video_floor_holder(member->conference, member, SWITCH_FALSE); + } + /* if we have caller digits, feed them to the parser to find an action */ if (switch_channel_has_dtmf(channel)) { char dtmf[128] = ""; @@ -3698,7 +3761,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v goto do_continue; } - if (member->nt_tally > (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { + if (member->nt_tally > (int32_t)(member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { member->agc_volume_in_level = 0; clear_avg(member); } @@ -3857,7 +3920,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v /* skip frames that are not actual media or when we are muted or silent */ if ((switch_test_flag(member, MFLAG_TALKING) || member->energy_level == 0 || switch_test_flag(member->conference, CFLAG_AUDIO_ALWAYS)) - && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD) && member->conference->count > 1) { + && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD) + && (member->conference->count > 1 || (member->conference->record_count && member->conference->count >= member->conference->min_recording_participants))) { switch_audio_resampler_t *read_resampler = member->read_resampler; void *data; uint32_t datalen; @@ -3882,6 +3946,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v /* Write the audio into the input buffer */ switch_mutex_lock(member->audio_in_mutex); + if (switch_buffer_inuse(member->audio_buffer) > flush_len) { + switch_buffer_zero(member->audio_buffer); + switch_channel_audio_sync(channel); + } ok = switch_buffer_write(member->audio_buffer, data, datalen); switch_mutex_unlock(member->audio_in_mutex); if (!ok) { @@ -3937,7 +4005,7 @@ static void member_add_file_data(conference_member_t *member, int16_t *data, swi switch_memory_pool_t *pool; if (member->fnode->type != NODE_TYPE_SPEECH) { - switch_core_file_close(&member->fnode->fh); + conference_file_close(member->conference, member->fnode); } fnode = member->fnode; @@ -3965,29 +4033,23 @@ static void member_add_file_data(conference_member_t *member, int16_t *data, swi } if (file_sample_len <= 0) { - switch_event_t *event; member->fnode->done++; - - if (test_eflag(member->conference, EFLAG_PLAY_FILE) && - switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { - conference_add_event_data(member->conference, event); - conference_add_event_member_data(member, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member-done"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", member->fnode->file); - switch_event_fire(&event); - } } else { /* there is file node data to mix into the frame */ int32_t i, sample; /* Check for output volume adjustments */ if (member->volume_out_level) { - switch_change_sln_volume(file_frame, file_sample_len, member->volume_out_level); + switch_change_sln_volume(file_frame, (uint32_t)file_sample_len, member->volume_out_level); } - for (i = 0; i < file_sample_len; i++) { - sample = data[i] + file_frame[i]; - switch_normalize_to_16bit(sample); - data[i] = sample; + for (i = 0; i < (int)file_sample_len; i++) { + if (member->fnode->mux) { + sample = data[i] + file_frame[i]; + switch_normalize_to_16bit(sample); + data[i] = (int16_t)sample; + } else { + data[i] = file_frame[i]; + } } } @@ -4083,6 +4145,7 @@ static void conference_loop_output(conference_member_t *member) const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce"); const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix"); const char *maxwait = switch_channel_get_variable(channel, "conference_auto_outcall_maxwait"); + const char *delimiter_val = switch_channel_get_variable(channel, "conference_auto_outcall_delimiter"); int to = 60; int wait_sec = 2; int loops = 0; @@ -4109,7 +4172,12 @@ static void conference_loop_output(conference_member_t *member) int x = 0; switch_assert(cpstr); - argc = switch_separate_string(cpstr, ',', argv, (sizeof(argv) / sizeof(argv[0]))); + if (!zstr(delimiter_val) && strlen(delimiter_val) == 1) { + char delimiter = *delimiter_val; + argc = switch_separate_string(cpstr, delimiter, argv, (sizeof(argv) / sizeof(argv[0]))); + } else { + argc = switch_separate_string(cpstr, ',', argv, (sizeof(argv) / sizeof(argv[0]))); + } for (x = 0; x < argc; x++) { char *dial_str = switch_mprintf("%s%s", switch_str_nil(prefix), argv[x]); switch_assert(dial_str); @@ -4141,7 +4209,7 @@ static void conference_loop_output(conference_member_t *member) goto end; } - conference_member_play_file(member, "tone_stream://%(500,0,640)", 0); + conference_member_play_file(member, "tone_stream://%(500,0,640)", 0, SWITCH_TRUE); } if (!switch_test_flag(member->conference, CFLAG_ANSWERED)) { @@ -4303,7 +4371,7 @@ static void conference_loop_output(conference_member_t *member) if (switch_test_flag(member, MFLAG_INDICATE_MUTE)) { if (!zstr(member->conference->muted_sound)) { - conference_member_play_file(member, member->conference->muted_sound, 0); + conference_member_play_file(member, member->conference->muted_sound, 0, SWITCH_TRUE); } else { char msg[512]; @@ -4315,7 +4383,7 @@ static void conference_loop_output(conference_member_t *member) if (switch_test_flag(member, MFLAG_INDICATE_MUTE_DETECT)) { if (!zstr(member->conference->mute_detect_sound)) { - conference_member_play_file(member, member->conference->mute_detect_sound, 0); + conference_member_play_file(member, member->conference->mute_detect_sound, 0, SWITCH_TRUE); } else { char msg[512]; @@ -4327,7 +4395,7 @@ static void conference_loop_output(conference_member_t *member) if (switch_test_flag(member, MFLAG_INDICATE_UNMUTE)) { if (!zstr(member->conference->unmuted_sound)) { - conference_member_play_file(member, member->conference->unmuted_sound, 0); + conference_member_play_file(member, member->conference->unmuted_sound, 0, SWITCH_TRUE); } else { char msg[512]; @@ -4456,6 +4524,17 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th rec->path, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, rec->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path); + + + if (test_eflag(conference, EFLAG_RECORD) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + conference_add_event_data(conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "start-recording"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Path", rec->path); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Error", "File could not be opened for recording"); + switch_event_fire(&event); + } + goto end; } @@ -4577,6 +4656,9 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th conference_add_event_data(conference, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "stop-recording"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Path", rec->path); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Samples-Out", "%ld", (long) fh.samples_out); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Samplerate", "%ld", (long) fh.samplerate); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Milliseconds-Elapsed", "%ld", (long) fh.samples_out / (fh.samplerate / 1000)); switch_event_fire(&event); } @@ -4727,8 +4809,9 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->mutex); - if (!count) + if (!count) { return SWITCH_STATUS_FALSE; + } if (channel) { if ((expanded = switch_channel_expand_variables(channel, file)) != file) { @@ -4783,11 +4866,36 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * fnode->fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN; if (switch_core_file_open(&fnode->fh, file, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) { + switch_event_t *event; + + if (test_eflag(conference, EFLAG_PLAY_FILE) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + conference_add_event_data(conference, event); + + if (fnode->fh.params) { + switch_event_merge(event, conference->fnode->fh.params); + } + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", file); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Async", async ? "true" : "false"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Error", "File could not be played"); + switch_event_fire(&event); + } + switch_core_destroy_memory_pool(&pool); status = SWITCH_STATUS_NOTFOUND; goto done; } + if (fnode->fh.params) { + const char *vol = switch_event_get_header(fnode->fh.params, "vol"); + + if (!zstr(vol)) { + fnode->fh.vol = atoi(vol); + } + } + fnode->pool = pool; fnode->async = async; fnode->file = switch_core_strdup(fnode->pool, file); @@ -4803,7 +4911,7 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * if (nptr) { switch_memory_pool_t *tmppool; - switch_core_file_close(&nptr->fh); + conference_file_close(conference, nptr); tmppool = nptr->pool; switch_core_destroy_memory_pool(&tmppool); } @@ -4829,7 +4937,7 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * } /* Play a file in the conference room to a member */ -static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin) +static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin, switch_bool_t mux) { switch_status_t status = SWITCH_STATUS_FALSE; char *dfile = NULL, *expanded = NULL; @@ -4876,6 +4984,9 @@ static switch_status_t conference_member_play_file(conference_member_t *member, } fnode->type = NODE_TYPE_FILE; fnode->leadin = leadin; + fnode->mux = mux; + fnode->member_id = member->id; + /* Open the file */ fnode->fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN; if (switch_core_file_open(&fnode->fh, @@ -5252,6 +5363,34 @@ static void conference_list_count_only(conference_obj_t *conference, switch_stre stream->write_function(stream, "%d", conference->count); } +static switch_status_t conf_api_sub_untool(conference_member_t *member, switch_stream_handle_t *stream, void *data) +{ + if (member == NULL) + return SWITCH_STATUS_GENERR; + + switch_clear_flag_locked(member, MFLAG_TOOL); + + if (stream != NULL) { + stream->write_function(stream, "OK untooled %u\n", member->id); + } + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t conf_api_sub_tool(conference_member_t *member, switch_stream_handle_t *stream, void *data) +{ + if (member == NULL) + return SWITCH_STATUS_GENERR; + + switch_set_flag_locked(member, MFLAG_TOOL); + + if (stream != NULL) { + stream->write_function(stream, "OK tooled %u\n", member->id); + } + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data) { switch_event_t *event; @@ -6160,7 +6299,7 @@ static switch_status_t conf_api_sub_file_seek(conference_obj_t *conference, swit step = 1000; } - samps = step * (conference->rate / 1000); + samps = step * (conference->fnode->fh.native_rate / 1000); target = (int32_t)conference->fnode->fh.pos + samps; if (target < 0) { @@ -6171,7 +6310,7 @@ static switch_status_t conf_api_sub_file_seek(conference_obj_t *conference, swit switch_core_file_seek(&conference->fnode->fh, &pos, target, SEEK_SET); } else { - samps = switch_atoui(argv[2]) * (conference->rate / 1000); + samps = switch_atoui(argv[2]) * (conference->fnode->fh.native_rate / 1000); stream->write_function(stream, "+OK seek to position %d\n", samps); switch_core_file_seek(&conference->fnode->fh, &pos, samps, SEEK_SET); } @@ -6204,6 +6343,11 @@ static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_st if (test_eflag(conference, EFLAG_PLAY_FILE) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_data(conference, event); + + if (conference->fnode && conference->fnode->fh.params) { + switch_event_merge(event, conference->fnode->fh.params); + } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", argv[2]); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Async", async ? "true" : "false"); @@ -6213,16 +6357,26 @@ static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_st stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)"); } ret_status = SWITCH_STATUS_SUCCESS; - } else if (argc == 4) { + } else if (argc >= 4) { uint32_t id = atoi(argv[3]); conference_member_t *member; + switch_bool_t mux = SWITCH_TRUE; + + if (argc > 4 && !strcasecmp(argv[4], "nomux")) { + mux = SWITCH_FALSE; + } if ((member = conference_member_get(conference, id))) { - if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) { + if (conference_member_play_file(member, argv[2], 0, mux) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id); if (test_eflag(conference, EFLAG_PLAY_FILE_MEMBER) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); + + if (member->fnode->fh.params) { + switch_event_merge(event, member->fnode->fh.params); + } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", argv[2]); switch_event_fire(&event); @@ -6864,6 +7018,54 @@ static switch_status_t conf_api_sub_recording(conference_obj_t *conference, swit } } +static switch_status_t conf_api_sub_file_vol(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + if (argc >= 1) { + conference_file_node_t *fnode; + int vol = 0; + int ok = 0; + + if (argc < 2) { + stream->write_function(stream, "missing args\n"); + return SWITCH_STATUS_GENERR; + } + + switch_mutex_lock(conference->mutex); + + fnode = conference->fnode; + + vol = atoi(argv[2]); + + if (argc > 3) { + if (strcasecmp(argv[3], "async")) { + fnode = conference->async_fnode; + } + } + + printf("WTF %p %p\n", (void *) conference, (void *) fnode); + + if (fnode && fnode->type == NODE_TYPE_FILE) { + fnode->fh.vol = vol; + ok = 1; + } + switch_mutex_unlock(conference->mutex); + + + if (ok) { + stream->write_function(stream, "volume changed\n"); + return SWITCH_STATUS_SUCCESS; + } else { + stream->write_function(stream, "File not playing\n"); + return SWITCH_STATUS_GENERR; + } + + + } else { + stream->write_function(stream, "Invalid parameters:\n"); + return SWITCH_STATUS_GENERR; + } +} + static switch_status_t conf_api_sub_pin(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { switch_assert(conference != NULL); @@ -7019,7 +7221,7 @@ static api_command_t conf_api_sub_commands[] = { {"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, "energy", " []"}, {"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, "volume_in", " []"}, {"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, "volume_out", " []"}, - {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "play", " [async|]"}, + {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "play", " [async| [nomux]]"}, {"pause_play", (void_fn_t) & conf_api_sub_pause_play, CONF_API_SUB_ARGS_SPLIT, "pause", ""}, {"file_seek", (void_fn_t) & conf_api_sub_file_seek, CONF_API_SUB_ARGS_SPLIT, "file_seek", "[+-]"}, {"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "say", ""}, @@ -7033,6 +7235,8 @@ static api_command_t conf_api_sub_commands[] = { {"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, "unmute", "<[member_id|all]|last|non_moderator>"}, {"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "deaf", "<[member_id|all]|last|non_moderator>"}, {"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "undeaf", "<[member_id|all]|last|non_moderator>"}, + {"tool", (void_fn_t) & conf_api_sub_tool, CONF_API_SUB_MEMBER_TARGET, "", ""}, + {"untool", (void_fn_t) & conf_api_sub_untool, CONF_API_SUB_MEMBER_TARGET, "", ""}, {"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "relate", " [nospeak|nohear|clear]"}, {"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "lock", ""}, {"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "unlock", ""}, @@ -7052,6 +7256,7 @@ static api_command_t conf_api_sub_commands[] = { {"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "nopin", ""}, {"get", (void_fn_t) & conf_api_sub_get, CONF_API_SUB_ARGS_SPLIT, "get", ""}, {"set", (void_fn_t) & conf_api_sub_set, CONF_API_SUB_ARGS_SPLIT, "set", " "}, + {"file-vol", (void_fn_t) & conf_api_sub_file_vol, CONF_API_SUB_ARGS_SPLIT, "file-vol", ""}, {"floor", (void_fn_t) & conf_api_sub_floor, CONF_API_SUB_MEMBER_TARGET, "floor", ""}, {"vid-floor", (void_fn_t) & conf_api_sub_vid_floor, CONF_API_SUB_MEMBER_TARGET, "vid-floor", " [force]"}, {"clear-vid-floor", (void_fn_t) & conf_api_sub_clear_vid_floor, CONF_API_SUB_ARGS_AS_ONE, "clear-vid-floor", ""} @@ -7247,7 +7452,9 @@ SWITCH_STANDARD_API(conf_api_main) int i; for (i = 0; i < CONFFUNCAPISIZE; i++) { - stream->write_function(stream, " %s %s\n", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); + if (!switch_strlen_zero(conf_api_sub_commands[i].psyntax)) { + stream->write_function(stream, " %s %s\n", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); + } } } @@ -7676,6 +7883,8 @@ static void set_cflags(const char *flags, uint32_t *f) *f |= CFLAG_VIDEO_BRIDGE; } else if (!strcasecmp(argv[i], "audio-always")) { *f |= CFLAG_AUDIO_ALWAYS; + } else if (!strcasecmp(argv[i], "restart-auto-record")) { + *f |= CFLAG_CONF_RESTART_AUTO_RECORD; } else if (!strcasecmp(argv[i], "json-events")) { *f |= CFLAG_JSON_EVENTS; } else if (!strcasecmp(argv[i], "livearray-sync")) { @@ -7965,8 +8174,6 @@ SWITCH_STANDARD_APP(conference_function) goto end; } - - if ((flags_str = strstr(mydata, flags_prefix))) { char *p; *((char *) flags_str) = '\0'; @@ -8244,7 +8451,7 @@ SWITCH_STANDARD_APP(conference_function) while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) { size_t dpin_length = dpin ? strlen(dpin) : 0; size_t mdpin_length = mdpin ? strlen(mdpin) : 0; - int maxpin = dpin_length > mdpin_length ? dpin_length : mdpin_length; + int maxpin = dpin_length > mdpin_length ? (int)dpin_length : (int)mdpin_length; switch_status_t pstatus = SWITCH_STATUS_FALSE; /* be friendly */ @@ -8263,7 +8470,7 @@ SWITCH_STANDARD_APP(conference_function) } /* wait for them if neccessary */ - if (strlen(pin_buf) < maxpin) { + if ((int)strlen(pin_buf) < maxpin) { char *buf = pin_buf + strlen(pin_buf); char term = '\0'; @@ -8748,6 +8955,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c char *suppress_events = NULL; char *verbose_events = NULL; char *auto_record = NULL; + int min_recording_participants = 2; char *conference_log_dir = NULL; char *cdr_event_mode = NULL; char *terminate_on_silence = NULL; @@ -8967,6 +9175,14 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c verbose_events = val; } else if (!strcasecmp(var, "auto-record") && !zstr(val)) { auto_record = val; + } else if (!strcasecmp(var, "min-required-recording-participants") && !zstr(val)) { + if (!strcmp(val, "1")) { + min_recording_participants = 1; + } else if (!strcmp(val, "2")) { + min_recording_participants = 2; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "min-required-recording-participants is invalid, leaving set to %d\n", min_recording_participants); + } } else if (!strcasecmp(var, "terminate-on-silence") && !zstr(val)) { terminate_on_silence = val; } else if (!strcasecmp(var, "endconf-grace-time") && !zstr(val)) { @@ -9173,7 +9389,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c if (!zstr(auto_gain_level)) { int level = 0; - if (switch_true(auto_gain_level)) { + if (switch_true(auto_gain_level) && !switch_is_number(auto_gain_level)) { level = DEFAULT_AGC_LEVEL; } else { level = atoi(auto_gain_level); @@ -9219,6 +9435,8 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c conference->auto_record = switch_core_strdup(conference->pool, auto_record); } + conference->min_recording_participants = min_recording_participants; + if (!zstr(desc)) { conference->desc = switch_core_strdup(conference->pool, desc); } @@ -9737,7 +9955,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) nl = strlen(conf_api_sub_commands[i].pcommand) + strlen(conf_api_sub_commands[i].psyntax) + 5; switch_snprintf(cmd_str, sizeof(cmd_str), "add conference ::conference::list_conferences %s", conf_api_sub_commands[i].pcommand); - switch_console_set_complete(cmd_str); if (p != NULL) { diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 7d62342c4a..5c99ded50d 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -583,7 +583,7 @@ http_sendfile_app_done: #define HTTP_SENDFILE_SYNTAX " [nopost|postparam1=foo&postparam2=bar... [event|stream|both|none [identifier ]]]" SWITCH_STANDARD_API(http_sendfile_function) { - switch_status_t status; + switch_status_t status = SWITCH_STATUS_FALSE; switch_bool_t new_memory_pool = SWITCH_FALSE; char *argv[10] = { 0 }, *argv2[10] = { 0 }; int argc = 0, argc2 = 0; diff --git a/src/mod/applications/mod_db/mod_db.c b/src/mod/applications/mod_db/mod_db.c index ed9a8cf877..46eee6b36d 100644 --- a/src/mod/applications/mod_db/mod_db.c +++ b/src/mod/applications/mod_db/mod_db.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_directory/mod_directory.2012.vcxproj b/src/mod/applications/mod_directory/mod_directory.2012.vcxproj index 0f969cf130..6e3f7a4a49 100644 --- a/src/mod/applications/mod_directory/mod_directory.2012.vcxproj +++ b/src/mod/applications/mod_directory/mod_directory.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,10 +68,28 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -86,6 +104,8 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -98,6 +118,8 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -112,6 +134,8 @@ + 4306;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false diff --git a/src/mod/applications/mod_directory/mod_directory.c b/src/mod/applications/mod_directory/mod_directory.c index 50c4701364..22768bcf5f 100644 --- a/src/mod/applications/mod_directory/mod_directory.c +++ b/src/mod/applications/mod_directory/mod_directory.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -24,6 +24,7 @@ * Contributor(s): * * Marc Olivier Chouinard + * Emmanuel Schmidbauer * * * mod_directory.c -- Search by Name Directory IVR @@ -95,6 +96,7 @@ struct dir_profile { uint32_t max_menu_attempt; uint32_t digit_timeout; uint32_t max_result; + switch_bool_t use_number_alias; switch_mutex_t *mutex; switch_thread_rwlock_t *rwlock; @@ -177,7 +179,7 @@ char *string_to_keypad_digit(const char *in) while (*s) { char c; - if ((c = digit_matching_keypad(*s++)) > 0) { + if ((c = (char)digit_matching_keypad(*s++)) > 0) { *d++ = c + 48; } } @@ -385,6 +387,8 @@ dir_profile_t *profile_set_config(dir_profile_t *profile) &profile->max_menu_attempt, 3, &config_int_ht_0, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-result", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &profile->max_result, 5, &config_int_ht_0, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(profile->config[i++], "use-number-alias", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, + &profile->use_number_alias, SWITCH_FALSE, NULL, NULL, NULL); return profile; @@ -555,6 +559,8 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro int exten_visible = 1; const char *type = switch_xml_attr_soft(ut, "type"); const char *id = switch_xml_attr_soft(ut, "id"); + const char *number_alias = switch_xml_attr_soft(ut, "number-alias"); + const char *extension = NULL; char *fullName = NULL; char *caller_name = NULL; char *caller_name_override = NULL; @@ -612,6 +618,13 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "FullName %s firstName [%s] lastName [%s]\n", fullName, firstName, lastName); */ + /* user number-alias instead of id if profile allows it */ + if (profile->use_number_alias == SWITCH_TRUE && !zstr(number_alias)) { + extension = number_alias; + } else { + extension = id; + } + /* Generate Digits key mapping */ fullNameDigit = string_to_keypad_digit(fullName); lastNameDigit = string_to_keypad_digit(lastName); @@ -619,7 +632,7 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro /* add user into DB */ sql = switch_mprintf("insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')", - globals.hostname, switch_core_session_get_uuid(session), id, fullName, fullNameDigit, firstName, firstNameDigit, + globals.hostname, switch_core_session_get_uuid(session), extension, fullName, fullNameDigit, firstName, firstNameDigit, lastName, lastNameDigit, name_visible, exten_visible); if (sqlvalues) { @@ -843,7 +856,7 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p params->try_again = 1; status = SWITCH_STATUS_BREAK; goto end; - } else if (profile->max_result != 0 && result_count > profile->max_result) { + } else if (profile->max_result != 0 && (uint32_t)result_count > profile->max_result) { switch_ivr_phrase_macro(session, DIR_RESULT_COUNT_TOO_LARGE, NULL, NULL, NULL); params->try_again = 1; status = SWITCH_STATUS_BREAK; diff --git a/src/mod/applications/mod_distributor/mod_distributor.c b/src/mod/applications/mod_distributor/mod_distributor.c index 841faceb4f..feef887345 100644 --- a/src/mod/applications/mod_distributor/mod_distributor.c +++ b/src/mod/applications/mod_distributor/mod_distributor.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -47,6 +47,7 @@ struct dist_node { char *name; int weight; int cur_weight; + int wval; struct dist_node *next; }; @@ -96,6 +97,21 @@ static struct { } globals; +static void calc_weight(struct dist_list *lp) +{ + struct dist_node *np; + + lp->target_weight = 0; + + for (np = lp->nodes; np; np = np->next) { + lp->target_weight += np->wval; + } + + for (np = lp->nodes; np; np = np->next) { + np->weight = np->cur_weight = (lp->target_weight - np->wval); + } +} + static int load_config(int reloading) { @@ -121,8 +137,6 @@ static int load_config(int reloading) const char *name = switch_xml_attr(list, "name"); const char *tweight = switch_xml_attr(list, "total-weight"); struct dist_node *node, *np = NULL; - int target_weight = 10; - int accum = 0; if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing NAME!\n"); @@ -130,14 +144,13 @@ static int load_config(int reloading) } if (!zstr(tweight)) { - target_weight = atoi(tweight); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "The total-weight attribute is no longer necessary.\n"); } switch_zmalloc(new_list, sizeof(*new_list)); new_list->name = strdup(name); new_list->last = -1; - new_list->target_weight = target_weight; if (lp) { lp->next = new_list; @@ -150,39 +163,17 @@ static int load_config(int reloading) for (param = switch_xml_child(list, "node"); param; param = param->next) { char *name = (char *) switch_xml_attr_soft(param, "name"); char *weight_val = (char *) switch_xml_attr_soft(param, "weight"); - int weight = 0, tmp; + int tmp; if ((tmp = atoi(weight_val)) < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be > 0\n", tmp); continue; } - if (tmp >= lp->target_weight && (lp->target_weight == 1 && tmp != 1)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be less than %d\n", tmp, lp->target_weight); - continue; - } - - if (accum + tmp > lp->target_weight) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Target Weight %d already met, ignoring subsequent entries.\n", - lp->target_weight); - continue; - } - - accum += tmp; - - weight = lp->target_weight - tmp; - - if (weight < 0 || weight > lp->target_weight) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be between 1 and %d\n", weight, - lp->target_weight); - continue; - } - switch_zmalloc(node, sizeof(*node)); node->name = strdup(name); - node->weight = node->cur_weight = weight; - - + node->wval = tmp; + if (np) { np->next = node; } else { @@ -193,18 +184,7 @@ static int load_config(int reloading) lp->node_count++; } - if (accum < lp->target_weight) { - struct dist_node *np1; - int remain = lp->target_weight - accum; - int ea = remain / (lp->node_count ? lp->node_count : 1); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Total weight does not add up to total weight %d\n", lp->target_weight); - - for (np1 = lp->nodes; np1; np1 = np1->next) { - np1->weight += lp->target_weight - ea; - } - - } + calc_weight(lp); } @@ -369,18 +349,142 @@ SWITCH_STANDARD_API(distributor_function) } +static struct dist_list *find_list(const char *name) +{ + struct dist_list *lp = NULL; + + switch_mutex_lock(globals.mod_lock); + for (lp = globals.list; lp; lp = lp->next) { + if (!strcasecmp(name, lp->name)) { + break; + } + } + switch_mutex_unlock(globals.mod_lock); + + return lp; +} + + +static struct dist_node *find_node(struct dist_list *list, const char *name) +{ + struct dist_node *np; + + switch_mutex_lock(globals.mod_lock); + for (np = list->nodes; np; np = np->next) { + if (!strcasecmp(name, np->name)) { + break; + } + } + switch_mutex_unlock(globals.mod_lock); + + return np; +} + +#define MAX 50 SWITCH_STANDARD_API(distributor_ctl_function) { + int argc = 0; + char *argv[MAX] = { 0 }; + const char *err = "-error"; + char *dup = NULL; - if (!zstr(cmd) && !strcasecmp(cmd, "reload")) { - if (load_config(SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "+ok reloaded.\n"); - return SWITCH_STATUS_SUCCESS; - } + switch_mutex_lock(globals.mod_lock); + + if (zstr(cmd)) { + goto err; } - stream->write_function(stream, "-error!\n"); + dup = strdup(cmd); + argc = switch_split(dup, ' ', argv); + + if (argc > 0) { + if (!strcasecmp(argv[0], "reload")) { + if (load_config(SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+ok reloaded.\n"); + err = NULL; + } + } else if (!strcasecmp(argv[0], "dump")) { + if (argc > 1) { + const char *listname = argv[1]; + struct dist_list *list = find_list(listname); + + if (!list) { + err = "cannot find list"; + } else { + struct dist_node *np; + stream->write_function(stream, "list: name=%s\n", list->name); + + for (np = list->nodes; np; np = np->next) { + stream->write_function(stream, "node: name=%s weight=%d\n", np->name, np->wval); + } + + err = NULL; + } + + } else { + err = "missing list name"; + } + } else if (!strcasecmp(argv[0], "modify")) { + if (argc > 1) { + const char *listname = argv[1]; + struct dist_list *list = find_list(listname); + + if (!list) { + err = "cannot find list"; + } else { + struct dist_node *np; + int i = 2; + char *e; + + for(i = 2; i < argc; i++) { + if ((e = strchr(argv[i], '='))) { + *e++ = '\0'; + if ((np = find_node(list, argv[i]))) { + int tmp = -1; + + if (e) { + tmp = atoi(e); + } + + if (tmp > 0) { + np->wval = tmp; + } else { + stream->write_function(stream, "error: name=%s, specified weight invalid\n", np->name); + } + } else { + stream->write_function(stream, "error: node %s not found\n", argv[i]); + } + } + } + + calc_weight(list); + reset_list(list); + + stream->write_function(stream, "list: name=%s\n", list->name); + + for (np = list->nodes; np; np = np->next) { + stream->write_function(stream, "node: name=%s weight=%d\n", np->name, np->wval); + } + + err = NULL; + } + + } else { + err = "missing list name"; + } + } + } + + err: + + if (err) { + stream->write_function(stream, "%s\n", err); + } + + switch_safe_free(dup); + + switch_mutex_unlock(globals.mod_lock); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_dptools/mod_dptools.2012.vcxproj b/src/mod/applications/mod_dptools/mod_dptools.2012.vcxproj index ac01f587d7..84df98e1ad 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.2012.vcxproj +++ b/src/mod/applications/mod_dptools/mod_dptools.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,10 +68,27 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + false false @@ -86,6 +103,7 @@ + false false @@ -98,6 +116,7 @@ + false false @@ -112,6 +131,7 @@ + false false diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 8d7b5c6f37..2311633c55 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1175,6 +1175,13 @@ SWITCH_STANDARD_APP(eval_function) return; } +SWITCH_STANDARD_APP(set_media_stats_function) +{ + switch_core_media_set_stats(session); + + return; +} + SWITCH_STANDARD_APP(zombie_function) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -3622,6 +3629,9 @@ static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *sessio switch_core_session_set_private(nsession, tech_pvt); nchannel = switch_core_session_get_channel(nsession); + switch_channel_set_cap(nchannel, CC_PROXY_MEDIA); + switch_channel_set_cap(nchannel, CC_BYPASS_MEDIA); + caller_profile = switch_caller_profile_clone(nsession, outbound_profile); switch_channel_set_caller_profile(nchannel, caller_profile); @@ -4746,7 +4756,7 @@ SWITCH_STANDARD_APP(blind_transfer_ack_function) switch_bool_t val = 0; if (data) { - val = switch_true((char *) val); + val = (switch_bool_t)switch_true((char *) data); } switch_ivr_blind_transfer_ack(session, val); @@ -5230,7 +5240,7 @@ void *SWITCH_THREAD_FUNC call_monitor_thread(switch_thread_t *thread, void *obj) switch_mutex_t *mutex; uint32_t counter = 0; switch_memory_pool_t *pool = cm->pool; - int size; + unsigned int size; char *argv[512] = { 0 }; int busy = 0; switch_event_t *var_event = NULL; @@ -5683,6 +5693,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "strftime", "strftime", "strftime", strftime_function, "[|]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "phrase", "Say a Phrase", "Say a Phrase", phrase_function, ",", SAF_NONE); SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "set_media_stats", "Set Media Stats", "Set Media Stats", set_media_stats_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "stop", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution", zombie_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); diff --git a/src/mod/applications/mod_easyroute/mod_easyroute.c b/src/mod/applications/mod_easyroute/mod_easyroute.c index f343955cc6..5fdbf3abb2 100644 --- a/src/mod/applications/mod_easyroute/mod_easyroute.c +++ b/src/mod/applications/mod_easyroute/mod_easyroute.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_enum/mod_enum.2012.vcxproj b/src/mod/applications/mod_enum/mod_enum.2012.vcxproj index baa419c4eb..b809a069a4 100644 --- a/src/mod/applications/mod_enum/mod_enum.2012.vcxproj +++ b/src/mod/applications/mod_enum/mod_enum.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,11 +68,28 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + %(RootDir)%(Directory)..\..\..\..\libs\ldns;%(AdditionalIncludeDirectories) + false ws2_32.lib;%(AdditionalDependencies) @@ -89,6 +106,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\ldns;%(AdditionalIncludeDirectories) + false ws2_32.lib;%(AdditionalDependencies) @@ -103,6 +121,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\ldns;%(AdditionalIncludeDirectories) + false ws2_32.lib;%(AdditionalDependencies) @@ -119,6 +138,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\ldns;%(AdditionalIncludeDirectories) + false ws2_32.lib;%(AdditionalDependencies) diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index 2328c12772..60cbad7184 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index bc04991bee..82e50c21c0 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -30,10 +30,50 @@ * */ #include +#include SWITCH_MODULE_LOAD_FUNCTION(mod_esf_load); SWITCH_MODULE_DEFINITION(mod_esf, mod_esf_load, NULL, NULL); + + +#ifdef _MSC_VER +#pragma pack(push, r1, 1) +#else +#pragma pack(1) +#endif + + +struct polycom_packet { + switch_byte_t op; + switch_byte_t channel; + uint32_t serno; + uint8_t cid_len; + unsigned char cid[13]; +}; + +typedef struct polycom_packet polycom_packet_t; + +typedef struct { + switch_byte_t codec; + switch_byte_t flags; + uint32_t seq; +} polycom_audio_header_t; + + +typedef struct polycom_alert_packet { + polycom_packet_t header; + polycom_audio_header_t audio_header; + uint8_t data[]; +} polycom_alert_packet_t; + + +#ifdef _MSC_VER +#pragma pack(pop, r1) +#else +#pragma pack() +#endif + struct ls_control_packet { uint32_t unique_id; uint32_t command; @@ -51,35 +91,82 @@ typedef enum { typedef enum { SEND_TYPE_UNKNOWN = 0, SEND_TYPE_RTP = 1, - SEND_TYPE_RAW = 2, - SEND_TYPE_NOMEDIA = 3 + SEND_TYPE_NOMEDIA = 2 } ls_how_t; +static uint32_t SERNO = 0; + +switch_mutex_t *MUTEX = NULL; + +uint32_t get_serno(void) +{ + uint32_t r = 0; + + switch_mutex_lock(MUTEX); + r = SERNO; + switch_mutex_unlock(MUTEX); + + return r; +} + + +void inc_serno(void) +{ + switch_mutex_lock(MUTEX); + SERNO++; + switch_mutex_unlock(MUTEX); + +} + +void dec_serno(void) +{ + switch_mutex_lock(MUTEX); + SERNO--; + switch_mutex_unlock(MUTEX); + +} + + SWITCH_STANDARD_APP(bcast_function) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_socket_t *socket; - switch_sockaddr_t *audio_addr = NULL, *control_packet_addr; + switch_socket_t *socket = NULL, *polycom_socket = NULL; + switch_sockaddr_t *audio_addr = NULL, *control_packet_addr = NULL, *polycom_addr = NULL, *local_addr = NULL; switch_frame_t *read_frame = NULL; switch_status_t status; switch_size_t bytes; ls_control_packet_t control_packet; + unsigned char polycom_buf[1024] = { 0 }; + unsigned char last_polycom_buf[1024] = { 0 }; + uint32_t last_polycom_len = 0; + polycom_packet_t *polycom_packet = (polycom_packet_t *) polycom_buf; + polycom_alert_packet_t *alert_packet = (polycom_alert_packet_t *) polycom_buf; switch_codec_t codec = { 0 }; + switch_codec_t write_codec = { 0 }; switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0}; const char *err; switch_rtp_t *rtp_session = NULL; - switch_port_t rtp_port; - char guess_ip[25]; + switch_port_t rtp_port = 0; ls_how_t ready = SEND_TYPE_UNKNOWN; - //int argc; char *mydata, *argv[5]; char *mcast_ip = "224.168.168.168"; switch_port_t mcast_port = 34567; switch_port_t mcast_control_port = 6061; char *mcast_port_str = "34567"; - const char *esf_broadcast_ip = NULL, *var; + char *polycom_ip = "224.0.1.116"; + const char *source_ip = NULL; + switch_port_t polycom_port = 5001; + const char *var; switch_codec_implementation_t read_impl = { 0 }; int mcast_ttl = 1; + const char *caller_id_name = NULL; + int x = 0; + uint32_t seq = 0; + const char *codec_name = "PCMU"; + int read_rate = 8000; + int need_transcode = 0; + + inc_serno(); switch_core_session_get_read_impl(session, &read_impl); @@ -114,6 +201,9 @@ SWITCH_STANDARD_APP(bcast_function) } } + switch_channel_set_variable_printf(channel, "multicast_ttl", "%d", mcast_ttl); + + if (switch_true(switch_channel_get_variable(channel, SWITCH_BYPASS_MEDIA_VARIABLE))) { switch_core_session_message_t msg = { 0 }; @@ -131,13 +221,27 @@ SWITCH_STANDARD_APP(bcast_function) switch_channel_answer(channel); } + if (!(source_ip = switch_channel_get_variable(channel, "esf_multicast_bind_ip"))) { + if (!(source_ip = switch_channel_get_variable(channel, "local_ip_v4"))) { + source_ip = "127.0.0.1"; + } + } + + /* everyone */ + + if (switch_sockaddr_info_get(&local_addr, source_ip, SWITCH_UNSPEC, + 0, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "address Error\n"); + goto fail; + } + if (switch_socket_create(&socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error 1\n"); goto fail; } - if (switch_mcast_hops(socket, (uint8_t) mcast_ttl) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Mutlicast TTL set failed\n"); + if (switch_socket_opt_set(socket, SWITCH_SO_REUSEADDR, 1) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Option Error\n"); goto fail; } @@ -147,28 +251,120 @@ SWITCH_STANDARD_APP(bcast_function) goto fail; } + if (switch_socket_bind(socket, local_addr) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket bind Error\n"); + goto fail; + } + if (switch_mcast_interface(socket, local_addr) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket interface Error\n"); + goto fail; + } + + if (switch_mcast_join(socket, control_packet_addr, NULL, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Multicast Error\n"); + goto fail; + } + + + if (switch_mcast_hops(socket, (uint8_t) mcast_ttl) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Mutlicast TTL set failed\n"); + goto fail; + } + + /* polycom */ + + + if (switch_sockaddr_info_get(&polycom_addr, polycom_ip, SWITCH_UNSPEC, + polycom_port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error 3\n"); + goto fail; + } + + if (switch_socket_create(&polycom_socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error 1\n"); + goto fail; + } + + if (switch_socket_opt_set(polycom_socket, SWITCH_SO_REUSEADDR, 1) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Option Error\n"); + goto fail; + } + + if (switch_socket_bind(polycom_socket, local_addr) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket bind Error\n"); + goto fail; + } + + + if (switch_mcast_interface(polycom_socket, local_addr) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket interface Error\n"); + goto fail; + } + + if (switch_mcast_join(polycom_socket, polycom_addr, NULL, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Multicast Error\n"); + goto fail; + } + + + if (switch_mcast_hops(polycom_socket, (uint8_t) mcast_ttl) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Mutlicast TTL set failed\n"); + goto fail; + } + + while (!ready) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - if (read_frame && switch_test_flag(read_frame, SFF_CNG)) { - continue; - } if (!SWITCH_READ_ACCEPTABLE(status) || !read_frame) { goto fail; } - if (read_frame->packet && read_frame->packetlen && read_impl.ianacode == 0) { - ready = SEND_TYPE_RAW; - } else { - ready = SEND_TYPE_RTP; + + if (switch_test_flag(read_frame, SFF_CNG)) { + continue; + } + + + ready = SEND_TYPE_RTP; + } + + + alert_packet->audio_header.codec = 0x00; + alert_packet->audio_header.flags = 0; + + if ((var = switch_channel_get_variable(channel, "esf_multicast_write_codec"))) { + if (!strcasecmp(var, "PCMU")) { + codec_name = var; + } else if (!strcasecmp(var, "G722")) { + codec_name = var; + read_rate = 16000; + alert_packet->audio_header.codec = 0x09; } } + if (ready == SEND_TYPE_RTP) { - if (read_impl.ianacode != 0) { + if (strcasecmp(read_impl.iananame, codec_name)) { + need_transcode = 1; + if (switch_core_codec_init(&codec, - "PCMU", + "L16", + NULL, + read_rate, + 20, + 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { + switch_core_session_set_read_codec(session, &codec); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activation Success\n"); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Activation Fail\n"); + goto fail; + } + + if (switch_core_codec_init(&write_codec, + codec_name, NULL, 8000, 20, @@ -181,39 +377,28 @@ SWITCH_STANDARD_APP(bcast_function) goto fail; } } + - if ((var = switch_channel_get_variable(channel, "esf_broadcast_ip"))) { - esf_broadcast_ip = switch_core_session_strdup(session, var); - } else { - switch_find_local_ip(guess_ip, sizeof(guess_ip), NULL, AF_INET); - esf_broadcast_ip = guess_ip; - } - - - if (!(rtp_port = switch_rtp_request_port(esf_broadcast_ip))) { + if (!(rtp_port = switch_rtp_request_port(source_ip))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Port Error\n"); goto fail; } - rtp_session = switch_rtp_new(esf_broadcast_ip, + rtp_session = switch_rtp_new(source_ip, rtp_port, mcast_ip, mcast_port, - 0, - 8000, - 20, flags, "soft", &err, switch_core_session_get_pool(session)); - + alert_packet->audio_header.codec, + 160, + 20000, flags, "soft", &err, switch_core_session_get_pool(session)); + if (!switch_rtp_ready(rtp_session)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error\n"); goto fail; } + } else if (ready == SEND_TYPE_NOMEDIA) { switch_yield(10000); - } else if (ready == SEND_TYPE_RAW) { - if (switch_sockaddr_info_get(&audio_addr, mcast_ip, SWITCH_UNSPEC, mcast_port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error 2\n"); - goto fail; - } } control_packet.unique_id = htonl((u_long) switch_epoch_time_now(NULL)); @@ -226,6 +411,38 @@ SWITCH_STANDARD_APP(bcast_function) bytes = 16; switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes); + + if (!(caller_id_name = switch_channel_get_variable(channel, "caller_id_name"))) { + caller_id_name = "FreeSWITCH"; + } + + strncpy((char *)polycom_packet->cid, caller_id_name, sizeof(polycom_packet->cid)); + polycom_packet->cid_len = 13; + + polycom_packet->op = 0x0F; + polycom_packet->channel = 0x1a; + polycom_packet->serno = htonl(get_serno()); + + if ((var = switch_channel_get_variable(channel, "esf_multicast_channel"))) { + int channel_no = atoi(var); + + if (channel_no > 0 && channel_no < 255) { + polycom_packet->channel = (uint8_t) channel_no; + } + } + + for (x = 0; x < 32; x++) { + bytes = sizeof(polycom_packet_t); + switch_socket_sendto(socket, polycom_addr, 0, (void *) polycom_packet, &bytes); + //switch_yield(30000); + } + + polycom_packet->op = 0x10; + + if ((var = switch_channel_get_variable(channel, "esf_multicast_alert_sound"))) { + switch_ivr_displace_session(session, var, 0, "mr"); + } + while (switch_channel_ready(channel)) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); @@ -233,11 +450,57 @@ SWITCH_STANDARD_APP(bcast_function) if (!SWITCH_READ_ACCEPTABLE(status)) { break; } + if (switch_test_flag(read_frame, SFF_CNG)) { continue; } + if (ready == SEND_TYPE_RTP) { + unsigned char *ebuf; + unsigned char encoded_data[4192]; + uint32_t encoded_datalen = sizeof(encoded_data); + + if (need_transcode) { + uint32_t rate = codec.implementation->actual_samples_per_second; + uint32_t flag = 0; + + ebuf = encoded_data; + + switch_core_codec_encode(&write_codec, + &codec, + read_frame->data, + read_frame->datalen, + read_impl.actual_samples_per_second, + ebuf, &encoded_datalen, &rate, &flag); + + read_frame->data = encoded_data; + read_frame->datalen = encoded_datalen; + + } else { + ebuf = read_frame->data; + encoded_datalen = read_frame->datalen; + } + switch_rtp_write_frame(rtp_session, read_frame); + + seq += 160; + + alert_packet->audio_header.seq = htonl(seq); + + if (last_polycom_len) { + memcpy(alert_packet->data, last_polycom_buf, last_polycom_len); + memcpy(alert_packet->data + last_polycom_len, ebuf, encoded_datalen); + } else { + memcpy(alert_packet->data, ebuf, encoded_datalen); + } + + bytes = sizeof(*alert_packet) + encoded_datalen + last_polycom_len; + + switch_socket_sendto(socket, polycom_addr, 0, (void *) polycom_buf, &bytes); + + last_polycom_len = encoded_datalen; + memcpy((void *)last_polycom_buf, (void *)ebuf, last_polycom_len); + } else { bytes = read_frame->packetlen; switch_socket_sendto(socket, audio_addr, 0, read_frame->packet, &bytes); @@ -251,6 +514,16 @@ SWITCH_STANDARD_APP(bcast_function) bytes = 8; switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes); + + polycom_packet->op = 0xFF; + //switch_yield(50000); + + for (x = 0; x < 12; x++) { + bytes = sizeof(*polycom_packet); + switch_socket_sendto(socket, polycom_addr, 0, (void *) polycom_packet, &bytes); + //switch_yield(30000); + } + fail: switch_core_session_set_read_codec(session, NULL); @@ -265,6 +538,16 @@ SWITCH_STANDARD_APP(bcast_function) if (socket) { switch_socket_close(socket); } + + if (polycom_socket) { + switch_socket_close(polycom_socket); + } + + if (rtp_port) { + switch_rtp_release_port(source_ip, rtp_port); + } + + dec_serno(); return; } @@ -273,6 +556,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_esf_load) { switch_application_interface_t *app_interface; + switch_mutex_init(&MUTEX, SWITCH_MUTEX_NESTED, pool); + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_APP(app_interface, "esf_page_group", NULL, NULL, bcast_function, NULL, SAF_NONE); diff --git a/src/mod/applications/mod_esl/mod_esl.c b/src/mod/applications/mod_esl/mod_esl.c index 2a37c3ab7e..eced37f48c 100644 --- a/src/mod/applications/mod_esl/mod_esl.c +++ b/src/mod/applications/mod_esl/mod_esl.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_expr/mod_expr.c b/src/mod/applications/mod_expr/mod_expr.c index 5f578319fc..c2f94b4d2f 100644 --- a/src/mod/applications/mod_expr/mod_expr.c +++ b/src/mod/applications/mod_expr/mod_expr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 3c6bc7a169..7408c74444 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -313,6 +313,7 @@ struct fifo_node { int ring_timeout; int default_lag; char *domain_name; + int retry_delay; struct fifo_node *next; }; @@ -1067,7 +1068,7 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses switch_channel_event_set_data(consumer_channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", MANUAL_QUEUE_NAME); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer-stop"); - if (use_count) { + if (outbound_id) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", use_count); } @@ -1307,6 +1308,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *rows[MAX_ROWS] = { 0 }; int rowcount = 0; switch_memory_pool_t *pool; + char *export = NULL; switch_mutex_lock(globals.mutex); globals.threads++; @@ -1379,12 +1381,14 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *h = cbh->rows[i]; char *parsed = NULL; int use_ent = 0; + char *expanded_originate_string = switch_event_expand_headers(ovars, h->originate_string); - if (strstr(h->originate_string, "user/")) { - switch_event_create_brackets(h->originate_string, '<', '>', ',', &ovars, &parsed, SWITCH_TRUE); + + if (strstr(expanded_originate_string, "user/")) { + switch_event_create_brackets(expanded_originate_string, '<', '>', ',', &ovars, &parsed, SWITCH_TRUE); use_ent = 1; } else { - switch_event_create_brackets(h->originate_string, '{', '}', ',', &ovars, &parsed, SWITCH_TRUE); + switch_event_create_brackets(expanded_originate_string, '{', '}', ',', &ovars, &parsed, SWITCH_TRUE); } switch_event_del_header(ovars, "fifo_outbound_uuid"); @@ -1395,15 +1399,19 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void if (use_ent) { stream.write_function(&stream, "{ignore_early_media=true,outbound_redirect_fatal=true,leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s}%s%s", h->timeout, h->uuid, node->name, - parsed ? parsed : h->originate_string, (i == cbh->rowcount - 1) ? "" : SWITCH_ENT_ORIGINATE_DELIM); + parsed ? parsed : expanded_originate_string, (i == cbh->rowcount - 1) ? "" : SWITCH_ENT_ORIGINATE_DELIM); } else { stream.write_function(&stream, "[leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s]%s,", - h->timeout, h->uuid, node->name, parsed ? parsed : h->originate_string); + h->timeout, h->uuid, node->name, parsed ? parsed : expanded_originate_string); } stream2.write_function(&stream2, "%s,", h->uuid); switch_safe_free(parsed); + if (expanded_originate_string && expanded_originate_string != h->originate_string) { + switch_safe_free(expanded_originate_string); + } + } originate_string = (char *) stream.data; @@ -1467,6 +1475,28 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "fifo_originate_uuid", uuid_str); + if ((export = switch_event_get_header(pop, "variable_fifo_export"))) { + int argc; + char *argv[100] = { 0 }; + char *mydata = strdup(export); + char *tmp; + + argc = switch_split(mydata, ',', argv); + + for (x = 0; x < argc; x++) { + char *name = switch_mprintf("variable_%s", argv[x]); + + if ((tmp = switch_event_get_header(pop, name))) { + switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, argv[x], tmp); + } + + free(name); + } + + switch_safe_free(mydata); + } + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_core_session_t *session; if (id && (session = switch_core_session_locate(id))) { @@ -1547,7 +1577,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void "outbound_fail_count=outbound_fail_count+1, " "outbound_fail_total_count = outbound_fail_total_count+1, " "next_avail=%ld + lag + 1 where uuid='%q' and ring_count > 0", - (long) switch_epoch_time_now(NULL), h->uuid); + (long) switch_epoch_time_now(NULL) + node->retry_delay, h->uuid); fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } @@ -1664,6 +1694,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_status_t status = SWITCH_STATUS_FALSE; switch_event_t *event = NULL; char *sql = NULL; + char *expanded_originate_string = NULL; if (!globals.running) return NULL; @@ -1688,24 +1719,26 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_assert(ovars); switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "originate_timeout", "%d", h->timeout); - if (switch_stristr("origination_caller", h->originate_string)) { + expanded_originate_string = switch_event_expand_headers(ovars, h->originate_string); + + if (node && switch_stristr("origination_caller", expanded_originate_string)) { originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_name='%q',fifo_hangup_check='%q'}%s", - node->name, node->name, h->originate_string); + node->name, node->name, expanded_originate_string); } else { - if (!zstr(node->outbound_name)) { + if (node && !zstr(node->outbound_name)) { originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_name='%q',fifo_hangup_check='%q'," "origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s", - node->name, node->name, node->outbound_name, h->originate_string); - } else { + node->name, node->name, node->outbound_name, expanded_originate_string); + } else if (node) { originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_name='%q',fifo_hangup_check='%q'," "origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s", - node->name, node->name, node->name, h->originate_string); + node->name, node->name, node->name, expanded_originate_string); } } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node ? node->name : ""); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "pre-dial"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); @@ -1723,11 +1756,11 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1, " "outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag + 1 where uuid='%q'", - (long) switch_epoch_time_now(NULL), h->uuid); + (long) switch_epoch_time_now(NULL) + (node ? node->retry_delay : 0), h->uuid); fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node ? node->name : ""); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); @@ -1744,7 +1777,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node ? node->name : ""); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); @@ -1778,6 +1811,10 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_safe_free(originate_string); } + if (expanded_originate_string && expanded_originate_string != h->originate_string) { + switch_safe_free(expanded_originate_string); + } + switch_event_destroy(&ovars); if (node) { switch_mutex_lock(node->update_mutex); @@ -2218,7 +2255,7 @@ SWITCH_STANDARD_API(fifo_add_outbound_function) } -static void dec_use_count(switch_core_session_t *session, switch_bool_t send_event) +static void dec_use_count(switch_core_session_t *session, const char *type) { char *sql; const char *outbound_id = NULL; @@ -2226,8 +2263,6 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve long now = (long) switch_epoch_time_now(NULL); switch_channel_t *channel = switch_core_session_get_channel(session); - do_unbridge(session, NULL); - if ((outbound_id = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s untracking call on uuid %s!\n", switch_channel_get_name(channel), outbound_id); @@ -2242,15 +2277,34 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve fifo_dec_use_count(outbound_id); } - if (send_event) { + do_unbridge(session, NULL); + + if (type) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + uint64_t hold_usec = 0, tt_usec = 0; + switch_caller_profile_t *originator_cp = NULL; + + originator_cp = switch_channel_get_caller_profile(channel); switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", MANUAL_QUEUE_NAME); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "channel-consumer-stop"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Type", type); if (outbound_id) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); } + hold_usec = originator_cp->times->hold_accum; + tt_usec = (switch_micro_time_now() - originator_cp->times->bridged) - hold_usec; + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-us", "%"SWITCH_TIME_T_FMT, originator_cp->times->bridged); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(originator_cp->times->bridged / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(originator_cp->times->bridged / 1000000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-us", "%"SWITCH_TIME_T_FMT, tt_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-us", "%"SWITCH_TIME_T_FMT, hold_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000000)); + switch_event_fire(&event); } } @@ -2262,7 +2316,7 @@ static switch_status_t hanguphook(switch_core_session_t *session) switch_channel_state_t state = switch_channel_get_state(channel); if (state >= CS_HANGUP && !switch_channel_test_app_flag_key(FIFO_APP_KEY, channel, FIFO_APP_DID_HOOK)) { - dec_use_count(session, SWITCH_TRUE); + dec_use_count(session, "manual"); switch_core_event_hook_remove_state_change(session, hanguphook); switch_channel_set_app_flag_key(FIFO_APP_KEY, channel, FIFO_APP_DID_HOOK); } @@ -2325,6 +2379,9 @@ SWITCH_STANDARD_APP(fifo_track_call_function) switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", MANUAL_QUEUE_NAME); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "channel-consumer-start"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", data); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(data)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Type", "manual"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Name", cid_name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Number", cid_number); switch_event_fire(&event); @@ -2729,16 +2786,33 @@ SWITCH_STANDARD_APP(fifo_function) const char *url = NULL; const char *caller_uuid = NULL; const char *outbound_id = switch_channel_get_variable(channel, "fifo_outbound_uuid"); + switch_event_t *event; + const char *cid_name = NULL, *cid_number = NULL; //const char *track_use_count = switch_channel_get_variable(channel, "fifo_track_use_count"); //int do_track = switch_true(track_use_count); if (switch_core_event_hook_remove_receive_message(session, messagehook) == SWITCH_STATUS_SUCCESS) { - dec_use_count(session, SWITCH_FALSE); + dec_use_count(session, NULL); switch_core_event_hook_remove_state_change(session, hanguphook); switch_channel_clear_app_flag_key(FIFO_APP_KEY, channel, FIFO_APP_TRACKING); } + if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { + cid_name = switch_channel_get_variable(channel, "callee_id_name"); + cid_number = switch_channel_get_variable(channel, "callee_id_number"); + + if (!cid_name) { + cid_name = switch_channel_get_variable(channel, "destination_number"); + } + if (!cid_number) { + cid_number = cid_name; + } + } else { + cid_name = switch_channel_get_variable(channel, "caller_id_name"); + cid_number = switch_channel_get_variable(channel, "caller_id_number"); + } + if (!zstr(strat_str)) { if (!strcasecmp(strat_str, "more_ppl")) { strat = STRAT_MORE_PPL; @@ -3148,6 +3222,22 @@ SWITCH_STANDARD_APP(fifo_function) } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "channel-consumer-start"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Type", "onhook"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Name", cid_name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-CID-Number", cid_number); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } + switch_event_fire(&event); + } + + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); @@ -3221,6 +3311,32 @@ SWITCH_STANDARD_APP(fifo_function) } + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + uint64_t hold_usec = 0, tt_usec = 0; + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", arg_fifo_name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "channel-consumer-stop"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Type", "onhook"); + if (outbound_id) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id)); + } + hold_usec = originator_cp->times->hold_accum; + tt_usec = (switch_micro_time_now() - originator_cp->times->bridged) - hold_usec; + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-us", "%"SWITCH_TIME_T_FMT, originator_cp->times->bridged); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(originator_cp->times->bridged / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Bridge-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(originator_cp->times->bridged / 1000000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-us", "%"SWITCH_TIME_T_FMT, tt_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Talk-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-us", "%"SWITCH_TIME_T_FMT, hold_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000000)); + + switch_event_fire(&event); + } + del_bridge_call(switch_core_session_get_uuid(session)); del_bridge_call(switch_core_session_get_uuid(other_session)); @@ -3236,9 +3352,18 @@ SWITCH_STANDARD_APP(fifo_function) switch_event_fire(&event); } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + uint64_t hold_usec = 0, tt_usec = 0; switch_channel_event_set_data(other_channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-caller-stop"); + hold_usec = originatee_cp->times->hold_accum; + tt_usec = (switch_micro_time_now() - originatee_cp->times->bridged) - hold_usec; + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Talk-Time-us", "%"SWITCH_TIME_T_FMT, tt_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Talk-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Talk-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(tt_usec / 1000000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Hold-Time-us", "%"SWITCH_TIME_T_FMT, hold_usec); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Hold-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Caller-Hold-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000000)); switch_event_fire(&event); } @@ -4313,6 +4438,16 @@ static switch_status_t load_config(int reload, int del_all) node->has_outbound = 1; } + if ((val = switch_xml_attr(fifo, "retry_delay"))) { + int tmp; + + if ((tmp = atoi(val)) < 0) { + tmp = 0; + } + + node->retry_delay = tmp; + } + if ((val = switch_xml_attr(fifo, "outbound_priority"))) { outbound_priority = atoi(val); diff --git a/src/mod/applications/mod_fsk/fsk_callerid.c b/src/mod/applications/mod_fsk/fsk_callerid.c index 9c99650f3d..24acb75d90 100644 --- a/src/mod/applications/mod_fsk/fsk_callerid.c +++ b/src/mod/applications/mod_fsk/fsk_callerid.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_fsk/fsk_callerid.h b/src/mod/applications/mod_fsk/fsk_callerid.h index 59f6cc5e52..0813ba18b3 100644 --- a/src/mod/applications/mod_fsk/fsk_callerid.h +++ b/src/mod/applications/mod_fsk/fsk_callerid.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_fsk/mod_fsk.c b/src/mod/applications/mod_fsk/mod_fsk.c index 970bc867b0..9695a9af14 100644 --- a/src/mod/applications/mod_fsk/mod_fsk.c +++ b/src/mod/applications/mod_fsk/mod_fsk.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_fsv/mod_fsv.c b/src/mod/applications/mod_fsv/mod_fsv.c index 67acca7a7a..f95db036a2 100644 --- a/src/mod/applications/mod_fsv/mod_fsv.c +++ b/src/mod/applications/mod_fsv/mod_fsv.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -690,7 +690,7 @@ end: static switch_status_t fsv_file_write(switch_file_handle_t *handle, void *data, size_t *len) { - uint32_t datalen = *len * 2; + size_t datalen = *len * 2; size_t size; switch_status_t status; @@ -720,7 +720,7 @@ static switch_status_t fsv_file_write(switch_file_handle_t *handle, void *data, static switch_status_t fsv_file_write_video(switch_file_handle_t *handle, void *data, size_t *len) { - uint32_t datalen = *len; + uint32_t datalen = (uint32_t)*len; uint32_t bytes = datalen | VID_BIT; size_t size; switch_status_t status = SWITCH_STATUS_SUCCESS; diff --git a/src/mod/applications/mod_hash/mod_hash.2012.vcxproj b/src/mod/applications/mod_hash/mod_hash.2012.vcxproj index a017d805c8..f376d6244f 100644 --- a/src/mod/applications/mod_hash/mod_hash.2012.vcxproj +++ b/src/mod/applications/mod_hash/mod_hash.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,12 +68,29 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + ..\..\..\..\libs\esl\src\include;%(AdditionalIncludeDirectories) ESL_DECLARE_STATIC;%(PreprocessorDefinitions) + false false @@ -90,6 +107,7 @@ ..\..\..\..\libs\esl\src\include;%(AdditionalIncludeDirectories) ESL_DECLARE_STATIC;%(PreprocessorDefinitions) + false false @@ -104,6 +122,7 @@ ..\..\..\..\libs\esl\src\include;%(AdditionalIncludeDirectories) ESL_DECLARE_STATIC;%(PreprocessorDefinitions) + false false @@ -120,6 +139,7 @@ ..\..\..\..\libs\esl\src\include;%(AdditionalIncludeDirectories) ESL_DECLARE_STATIC;%(PreprocessorDefinitions) + false false diff --git a/src/mod/applications/mod_hash/mod_hash.c b/src/mod/applications/mod_hash/mod_hash.c index 87c2f0521b..5b5020181e 100644 --- a/src/mod/applications/mod_hash/mod_hash.c +++ b/src/mod/applications/mod_hash/mod_hash.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -58,7 +58,7 @@ typedef struct { uint32_t rate_usage; /* < Current rate usage */ time_t last_check; /* < Last rate check */ uint32_t interval; /* < Interval used on last rate check */ - uint32_t last_update; /* < Last updated timestamp (rate or total) */ + switch_time_t last_update; /* < Last updated timestamp (rate or total) */ } limit_hash_item_t; struct callback { @@ -837,7 +837,7 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi limit_remote_t *remote = (limit_remote_t*)obj; while (remote->state > REMOTE_OFF) { if (remote->state != REMOTE_UP) { - if (esl_connect_timeout(&remote->handle, remote->host, remote->port, remote->username, remote->password, 5000) == ESL_SUCCESS) { + if (esl_connect_timeout(&remote->handle, remote->host, (esl_port_t)remote->port, remote->username, remote->password, 5000) == ESL_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to remote FreeSWITCH (%s) at %s:%d\n", remote->name, remote->host, remote->port); diff --git a/src/mod/applications/mod_httapi/mod_httapi.2012.vcxproj b/src/mod/applications/mod_httapi/mod_httapi.2012.vcxproj index 6a35c17ac1..0efd86736f 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.2012.vcxproj +++ b/src/mod/applications/mod_httapi/mod_httapi.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -72,6 +72,7 @@ + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -86,6 +87,7 @@ + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -98,6 +100,7 @@ + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -112,6 +115,7 @@ + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 6ae3001804..2c025b521c 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1283,16 +1283,18 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data) { register unsigned int realsize = (unsigned int) (size * nmemb); client_t *client = data; + char *zero = "\0"; client->bytes += realsize; - if (client->bytes > client->max_bytes) { + if (client->bytes > client->max_bytes - 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) client->bytes); client->err = 1; return 0; } switch_buffer_write(client->buffer, ptr, realsize); + switch_buffer_write(client->buffer, zero, 1); return realsize; } @@ -1473,7 +1475,6 @@ static switch_status_t httapi_sync(client_t *client) if (!put_file) { switch_curl_process_form_post_params(client->params, curl_handle, &formpost); - get_style_method = 1; } if (formpost) { @@ -1893,15 +1894,15 @@ static switch_status_t do_config(void) char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "all")) { - switch_byte_t all = switch_true(val); + switch_byte_t all = switch_true_byte(val); memset(&profile->perms, all, sizeof(profile->perms)); } else if (!strcasecmp(var, "none")) { - switch_byte_t none = switch_true(val); + switch_byte_t none = switch_true_byte(val); memset(&profile->perms, none, sizeof(profile->perms)); } else if (!strcasecmp(var, "set-params")) { - profile->perms.set_params = switch_true(val); + profile->perms.set_params = switch_true_byte(val); } else if (!strcasecmp(var, "set-vars")) { - profile->perms.set_vars = switch_true(val); + profile->perms.set_vars = switch_true_byte(val); if (profile->perms.set_vars) { switch_xml_t x_list, x_var; @@ -1929,7 +1930,7 @@ static switch_status_t do_config(void) } } } else if (!strcasecmp(var, "get-vars")) { - profile->perms.get_vars = switch_true(val); + profile->perms.get_vars = switch_true_byte(val); if (profile->perms.get_vars) { switch_xml_t x_list, x_var; @@ -1957,9 +1958,9 @@ static switch_status_t do_config(void) } } } else if (!strcasecmp(var, "extended-data")) { - profile->perms.extended_data = switch_true(val); + profile->perms.extended_data = switch_true_byte(val); } else if (!strcasecmp(var, "execute-apps")) { - profile->perms.execute_apps = switch_true(val); + profile->perms.execute_apps = switch_true_byte(val); if (profile->perms.execute_apps) { switch_xml_t x_list, x_app; @@ -1988,7 +1989,7 @@ static switch_status_t do_config(void) } } else if (!strcasecmp(var, "expand-vars")) { - profile->perms.expand_vars = switch_true(val); + profile->perms.expand_vars = switch_true_byte(val); if (profile->perms.expand_vars) { switch_xml_t x_list, x_var, x_api; @@ -2040,27 +2041,27 @@ static switch_status_t do_config(void) } } else if (!strcasecmp(var, "dial")) { - profile->perms.dial.enabled = switch_true(val); + profile->perms.dial.enabled = switch_true_byte(val); } else if (!strcasecmp(var, "dial-set-context")) { if (switch_true(val)) profile->perms.dial.enabled = SWITCH_TRUE; - profile->perms.dial.set_context = switch_true(val); + profile->perms.dial.set_context = switch_true_byte(val); } else if (!strcasecmp(var, "dial-set-dialplan")) { if (switch_true(val)) profile->perms.dial.enabled = SWITCH_TRUE; - profile->perms.dial.set_dp = switch_true(val); + profile->perms.dial.set_dp = switch_true_byte(val); } else if (!strcasecmp(var, "dial-set-cid-name")) { if (switch_true(val)) profile->perms.dial.enabled = SWITCH_TRUE; - profile->perms.dial.set_cid_name = switch_true(val); + profile->perms.dial.set_cid_name = switch_true_byte(val); } else if (!strcasecmp(var, "dial-set-cid-number")) { if (switch_true(val)) profile->perms.dial.enabled = SWITCH_TRUE; - profile->perms.dial.set_cid_number = switch_true(val); + profile->perms.dial.set_cid_number = switch_true_byte(val); } else if (!strcasecmp(var, "dial-full-originate")) { if (switch_true(val)) profile->perms.dial.enabled = SWITCH_TRUE; - profile->perms.dial.full_originate = switch_true(val); + profile->perms.dial.full_originate = switch_true_byte(val); } else if (!strcasecmp(var, "conference")) { - profile->perms.conference.enabled = switch_true(val); + profile->perms.conference.enabled = switch_true_byte(val); } else if (!strcasecmp(var, "conference-set-profile")) { if (switch_true(val)) profile->perms.conference.enabled = SWITCH_TRUE; - profile->perms.conference.set_profile = switch_true(val); + profile->perms.conference.set_profile = switch_true_byte(val); } } @@ -2578,7 +2579,7 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char data); - status = write(fd, write_data, strlen(write_data) + 1) > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; + status = write(fd, write_data, (int)strlen(write_data) + 1) > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; } close(fd); @@ -2948,7 +2949,7 @@ static switch_status_t http_file_file_read(switch_file_handle_t *handle, void *d *len = context->samples; } - context->samples -= *len; + context->samples -= (int)*len; memset(data, 255, *len *2); status = SWITCH_STATUS_SUCCESS; } else { diff --git a/src/mod/applications/mod_http_cache/aws.c b/src/mod/applications/mod_http_cache/aws.c index 17d6a233ab..4d446d5857 100644 --- a/src/mod/applications/mod_http_cache/aws.c +++ b/src/mod/applications/mod_http_cache/aws.c @@ -44,7 +44,7 @@ int aws_s3_is_s3_url(const char *url) { /* AWS bucket naming rules are complex... this match only supports virtual hosting of buckets */ - return !zstr(url) && switch_regex_match(url, "^https?://[a-z0-9][-a-z0-9.]{1,61}[a-z0-9]\\.s3\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS; + return !zstr(url) && switch_regex_match(url, "^https?://\\w[-\\w.]{1,61}\\w\\.s3([-\\w]+)?\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS; } /** diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index 24ea2aa76c..3648f97e80 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -331,7 +331,7 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes); switch_curl_easy_cleanup(curl_handle); - if (httpRes == 200 || httpRes == 201 || httpRes == 204) { + if (httpRes == 200 || httpRes == 201 || httpRes == 202 || httpRes == 204) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s saved to %s\n", filename, url); if (cache_local_file) { cached_url_t *u = NULL; diff --git a/src/mod/applications/mod_http_cache/test_aws/main.c b/src/mod/applications/mod_http_cache/test_aws/main.c index 8610127bbe..c29f1364ec 100644 --- a/src/mod/applications/mod_http_cache/test_aws/main.c +++ b/src/mod/applications/mod_http_cache/test_aws/main.c @@ -41,6 +41,9 @@ static void test_signature(void) */ static void test_check_url(void) { + ASSERT_TRUE(aws_s3_is_s3_url("http://bucket.s3-us-west-1.amazonaws.com/object.ext")); + ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3-us-west-1.amazonaws.com/object.ext")); + ASSERT_TRUE(aws_s3_is_s3_url("http://bucket.s3.amazonaws.com/object.ext")); ASSERT_TRUE(aws_s3_is_s3_url("http://bucket.s3.amazonaws.com/object.ext")); ASSERT_TRUE(aws_s3_is_s3_url("http://bucket.s3.amazonaws.com/object")); ASSERT_TRUE(aws_s3_is_s3_url("http://red.bucket.s3.amazonaws.com/object.ext")); @@ -48,6 +51,7 @@ static void test_check_url(void) ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/object")); ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/recordings/1240fwjf8we.mp3")); ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/en/us/8000/1232345.mp3")); + ASSERT_TRUE(aws_s3_is_s3_url("https://bucket_with_underscore.s3.amazonaws.com/en/us/8000/1232345.mp3")); ASSERT_FALSE(aws_s3_is_s3_url("bucket.s3.amazonaws.com/object.ext")); ASSERT_FALSE(aws_s3_is_s3_url("https://s3.amazonaws.com/bucket/object")); ASSERT_FALSE(aws_s3_is_s3_url("http://s3.amazonaws.com/bucket/object")); @@ -103,6 +107,10 @@ static void test_parse_url(void) aws_s3_parse_url(strdup("http://bucket.s3.amazonaws.com/voicemails/recording.wav"), &bucket, &object); ASSERT_STRING_EQUALS("bucket", bucket); ASSERT_STRING_EQUALS("voicemails/recording.wav", object); + + aws_s3_parse_url(strdup("https://my-bucket-with-dash.s3-us-west-2.amazonaws.com/greeting/file/1002/Lumino.mp3"), &bucket, &object); + ASSERT_STRING_EQUALS("my-bucket-with-dash", bucket); + ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object); } /** diff --git a/src/mod/applications/mod_ladspa/mod_ladspa.c b/src/mod/applications/mod_ladspa/mod_ladspa.c index 7102ddfe81..e540dc9d53 100644 --- a/src/mod/applications/mod_ladspa/mod_ladspa.c +++ b/src/mod/applications/mod_ladspa/mod_ladspa.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_lcr/mod_lcr.c b/src/mod/applications/mod_lcr/mod_lcr.c index 7755eadb5a..362fb54ff6 100644 --- a/src/mod/applications/mod_lcr/mod_lcr.c +++ b/src/mod/applications/mod_lcr/mod_lcr.c @@ -1,6 +1,6 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -22,7 +22,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * + * * Raymond Chandler * Rupa Schomaker * Emmanuel Schmidbauer @@ -114,7 +114,7 @@ struct profile_obj { switch_bool_t profile_has_intrastate; switch_bool_t profile_has_intralata; switch_bool_t profile_has_npanxx; - + switch_bool_t reorder_by_rate; switch_bool_t quote_in_list; switch_bool_t single_bridge; @@ -175,25 +175,29 @@ static const char *do_cid(switch_memory_pool_t *pool, const char *cid, const cha char *src_regex = NULL; char *dst_regex = NULL; switch_channel_t *channel = NULL; - + if (!zstr(cid)) { len = (uint32_t)strlen(cid); } else { goto done; } - + src = switch_core_strdup(pool, cid); /* check that this is a valid regexp and split the string */ - + if ((src[0] == '/') && src[len-1] == '/') { /* strip leading / trailing slashes */ src[len-1] = '\0'; src++; - + /* break on first / */ - dst = strchr(src, '/'); - *dst = '\0'; - dst++; + if((dst = strchr(src, '/'))) { + *dst = '\0'; + dst++; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid destination part in regexp: %s\n", src); + goto done; + } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "src: %s, dst: %s\n", src, dst); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Not a valid regexp: %s\n", src); @@ -218,10 +222,10 @@ static const char *do_cid(switch_memory_pool_t *pool, const char *cid, const cha switch_safe_free(tmp_regex); dst = dst_regex; } - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "expanded src: %s, dst: %s\n", src, dst); } - + if ((proceed = switch_regex_perform(number, src, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { len = (uint32_t) (strlen(src) + strlen(dst) + 10) * proceed; /* guestimate size */ if (!(substituted = switch_core_alloc(pool, len))) { @@ -235,19 +239,19 @@ static const char *do_cid(switch_memory_pool_t *pool, const char *cid, const cha } switch_regex_safe_free(re); - + return substituted; - + done: switch_regex_safe_free(re); + switch_safe_free(tmp_regex); return number; } -static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile, switch_core_session_t *session) +static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile, switch_core_session_t *session, char *data) { size_t lstrip; size_t tstrip; - char *data = NULL; char *destination_number = NULL; char *codec = NULL; char *cid = NULL; @@ -256,18 +260,18 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch char *export_fields = NULL; destination_number = switch_core_strdup(pool, dialed_number); - + tstrip = ((cur_route->digit_len - cur_route->tstrip) + 1); lstrip = cur_route->lstrip; - + if (cur_route->tstrip > 0) { if (strlen(destination_number) > tstrip) { destination_number[tstrip] = '\0'; } else { destination_number[0] = '\0'; - } - } + } + } if (cur_route->lstrip > 0) { if (strlen(destination_number) > lstrip) { destination_number += lstrip; @@ -275,31 +279,31 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch else { destination_number[0] = '\0'; } - } + } codec = ""; if (!zstr(cur_route->codec)) { codec = switch_core_sprintf(pool, ",absolute_codec_string=%s", cur_route->codec); } - + cid = ""; if (!zstr(cur_route->cid)) { - cid = switch_core_sprintf(pool, ",origination_caller_id_number=%s", + cid = switch_core_sprintf(pool, ",origination_caller_id_number=%s", do_cid(pool, cur_route->cid, caller_id, session)); } - + header = ""; if (profile->info_in_headers) { header = switch_core_sprintf(pool, ",sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s", - cur_route->rate_str, + cur_route->rate_str, cur_route->carrier_name); } - + if (zstr(cur_route->user_rate_str)) { user_rate = ""; } else { user_rate = switch_core_sprintf(pool, ",lcr_user_rate=%s", cur_route->user_rate_str); } - + export_fields = ""; if (profile->export_fields_cnt > 0) { int i = 0; @@ -307,14 +311,14 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch for (i = 0; i < profile->export_fields_cnt; i++) { val = switch_event_get_header(cur_route->fields, profile->export_fields[i]); if (val) { - export_fields = switch_core_sprintf(pool, "%s,%s=%s", + export_fields = switch_core_sprintf(pool, "%s,%s=%s", export_fields, - profile->export_fields[i], + profile->export_fields[i], val); } } } - + if (profile->enable_sip_redir) { data = switch_core_sprintf(pool, "%s%s%s%s%s" , cur_route->gw_prefix, cur_route->prefix @@ -326,7 +330,7 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch , cur_route->gw_prefix, cur_route->prefix , destination_number, cur_route->suffix, cur_route->gw_suffix); } - + if (session && (switch_string_var_check_const(data) || switch_string_has_escaped_data(data))) { data = switch_channel_expand_variables(switch_core_session_get_channel(session), data); } @@ -336,6 +340,7 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Returning Dialstring %s\n", data); + return data; } @@ -354,7 +359,7 @@ static profile_t *locate_profile(const char *profile_name) } else if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); } - + return profile; } @@ -403,7 +408,7 @@ static switch_status_t process_max_lengths(max_obj_t *maxes, lcr_route routes, c if (current->digit_str) { if (current->digit_len > maxes->digit_str) { maxes->digit_str = current->digit_len; - } + } } if (current->rate_str) { this_len = strlen(current->rate_str); @@ -438,7 +443,7 @@ static switch_cache_db_handle_t *lcr_get_db_handle(void) { switch_cache_db_handle_t *dbh = NULL; char *dsn; - + if (!zstr(globals.odbc_dsn)) { dsn = globals.odbc_dsn; } else { @@ -448,7 +453,7 @@ static switch_cache_db_handle_t *lcr_get_db_handle(void) if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) { dbh = NULL; } - + return dbh; } @@ -478,12 +483,12 @@ static switch_bool_t set_db_random() db_random = "random()"; return SWITCH_TRUE; } - + return SWITCH_FALSE; } /* make a new string with digits only */ -static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) +static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) { char *p, *np, *newstr; size_t len; @@ -493,7 +498,7 @@ static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) len = strlen(str); newstr = switch_core_alloc(pool, len+1); np = newstr; - + while(*p) { if (switch_isdigit(*p)) { *np = *p; @@ -526,11 +531,11 @@ static char *expand_digits(switch_memory_pool_t *pool, char *digits, switch_bool digit_len = (int)strlen(digits); digits_copy = switch_core_strdup(pool, digits); - + for (n = digit_len; n > 0; n--) { digits_copy[n] = '\0'; - dig_stream.write_function(&dig_stream, "%s%s%s%s", - (n==digit_len ? "" : ", "), + dig_stream.write_function(&dig_stream, "%s%s%s%s", + (n==digit_len ? "" : ", "), (quote ? "'" : ""), digits_copy, (quote ? "'" : "")); @@ -544,54 +549,42 @@ static char *expand_digits(switch_memory_pool_t *pool, char *digits, switch_bool /* format the custom sql */ static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, const char *digits) { - char * tmpSQL = NULL; char * newSQL = NULL; switch_channel_t *channel; - + /* first replace %s with digits to maintain backward compat */ if (cb_struct->profile->custom_sql_has_percent == SWITCH_TRUE) { - tmpSQL = switch_string_replace(custom_sql, "%q", digits); - newSQL = tmpSQL; + newSQL = switch_string_replace(custom_sql, "%q", digits); } - + /* expand the vars */ if (cb_struct->profile->custom_sql_has_vars == SWITCH_TRUE) { if (cb_struct->session) { channel = switch_core_session_get_channel(cb_struct->session); switch_assert(channel); - /* - newSQL = switch_channel_expand_variables_escape(channel, - tmpSQL ? tmpSQL : custom_sql, - escape_sql); - */ - newSQL = switch_channel_expand_variables(channel, - tmpSQL ? tmpSQL : custom_sql); + newSQL = switch_channel_expand_variables(channel, newSQL ? newSQL : custom_sql); + custom_sql = newSQL; } else if (cb_struct->event) { /* use event system to expand vars */ - newSQL = switch_event_expand_headers(cb_struct->event, tmpSQL ? tmpSQL : custom_sql); - + newSQL = switch_event_expand_headers(cb_struct->event, newSQL ? newSQL : custom_sql); + custom_sql = newSQL; } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_CRIT, "mod_lcr called without a valid session while using a custom_sql that has channel variables.\n"); } } - - if (tmpSQL != newSQL) { - switch_safe_free(tmpSQL); - } - + if (newSQL == NULL) { - return (char *) custom_sql; - } else { - return newSQL; + switch_safe_free(newSQL); } + return (char *) custom_sql; } static switch_bool_t lcr_execute_sql_callback(char *sql, switch_core_db_callback_func_t callback, void *pdata) { switch_bool_t retval = SWITCH_FALSE; switch_cache_db_handle_t *dbh = NULL; - + if (globals.odbc_dsn && (dbh = lcr_get_db_handle())) { if (switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, NULL) != SWITCH_STATUS_SUCCESS) { retval = SWITCH_FALSE; @@ -615,10 +608,11 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa char *key2 = NULL; int i = 0; int r = 0; + char *data = NULL; switch_bool_t lcr_skipped = SWITCH_TRUE; /* assume we'll throw it away, paranoid about leak */ switch_memory_pool_t *pool = cbt->pool; - + additional = switch_core_alloc(pool, sizeof(lcr_obj_t)); switch_event_create(&additional->fields, SWITCH_EVENT_REQUEST_PARAMS); @@ -662,20 +656,20 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa } else if (CF("lcr_limit_id")) { additional->limit_id = switch_core_strdup(pool, switch_str_nil(argv[i])); } else if (CF("lcr_limit_max")) { - additional->limit_max = (float)atof(switch_str_nil(argv[i])); + additional->limit_max = (int)(float)atof(switch_str_nil(argv[i])); } - + /* add all fields to the fields event */ switch_event_add_header_string(additional->fields, SWITCH_STACK_BOTTOM, columnNames[i], argv[i]); } - + cbt->matches++; - - additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile, cbt->session); + + additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile, cbt->session, data); if (cbt->head == NULL) { if (cbt->max_rate && (cbt->max_rate < additional->rate)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Skipping [%s] because [%f] is higher than the max_rate of [%f]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Skipping [%s] because [%f] is higher than the max_rate of [%f]\n", additional->carrier_name, additional->rate, cbt->max_rate); lcr_skipped = SWITCH_FALSE; r = 0; goto end; @@ -704,11 +698,11 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa for (current = cbt->head; current; current = current->next) { if (cbt->max_rate && (cbt->max_rate < additional->rate)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Skipping [%s] because [%f] is higher than the max_rate of [%f]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Skipping [%s] because [%f] is higher than the max_rate of [%f]\n", additional->carrier_name, additional->rate, cbt->max_rate); break; } - + key = switch_core_sprintf(pool, "%s:%s", additional->gw_prefix, additional->gw_suffix); if (switch_core_hash_find(cbt->dedup_hash, key)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, @@ -750,12 +744,12 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa if (current->rate > additional->rate) { /* insert myself here */ if (current->prev != NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s before %s\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s before %s\n", additional->carrier_name, current->carrier_name); current->prev->next = additional; } else { /* put this one at the head */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Inserting %s to list head before %s\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Inserting %s to list head before %s\n", additional->carrier_name, current->carrier_name); cbt->head = additional; } @@ -801,16 +795,18 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa /* complain loudly if we're asked to destroy a route that is added to the route list */ if (additional && additional->prev != NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "additional->prev != NULL\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "additional->prev != NULL\n"); } if (current && current->next == additional) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "current->next == additional\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "current->next == additional\n"); } lcr_destroy(additional); } - + + switch_safe_free(data); + return r; } @@ -819,7 +815,7 @@ static int intrastatelata_callback(void *pArg, int argc, char **argv, char **col { int count = 0; callback_t *cbt = (callback_t *) pArg; - + count = atoi(argv[1]); if (count == 1) { if (!strcmp(argv[0], "state")) { @@ -829,33 +825,33 @@ static int intrastatelata_callback(void *pArg, int argc, char **argv, char **col } } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Type: %s, Count: %d\n", argv[0], count); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Type: %s, Count: %d\n", argv[0], count); + return SWITCH_STATUS_SUCCESS; } static switch_status_t is_intrastatelata(callback_t *cb_struct) { char *sql = NULL; - + /* extract npa nxx - make some assumptions about format: e164 format without the + NANP only (so 11 digits starting with 1) */ - if (!cb_struct->lookup_number || strlen(cb_struct->lookup_number) != 11 || *cb_struct->lookup_number != '1' || + if (!cb_struct->lookup_number || strlen(cb_struct->lookup_number) != 11 || *cb_struct->lookup_number != '1' || !switch_is_number(cb_struct->lookup_number)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "%s doesn't appear to be a NANP number\n", cb_struct->lookup_number); /* dest doesn't appear to be NANP number */ return SWITCH_STATUS_GENERR; } if (!cb_struct->cid || strlen(cb_struct->cid) != 11 || *cb_struct->cid != '1' || !switch_is_number(cb_struct->cid)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "%s doesn't appear to be a NANP number\n", cb_struct->cid); /* cid not NANP */ return SWITCH_STATUS_GENERR; } - + /* assume that if the area code (plus leading 1) are the same we're intrastate */ /* probably a bad assumption */ /* @@ -864,7 +860,7 @@ static switch_status_t is_intrastatelata(callback_t *cb_struct) return SWITCH_STATUS_SUCCESS; } */ - + sql = switch_core_sprintf(cb_struct->pool, "SELECT 'state', count(DISTINCT state) FROM npa_nxx_company_ocn WHERE (npa=%3.3s AND nxx=%3.3s) OR (npa=%3.3s AND nxx=%3.3s)" " UNION " @@ -877,7 +873,7 @@ static switch_status_t is_intrastatelata(callback_t *cb_struct) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", sql); return(lcr_execute_sql_callback(sql, intrastatelata_callback, cb_struct)); - + } static switch_status_t lcr_do_lookup(callback_t *cb_struct) @@ -894,32 +890,32 @@ static switch_status_t lcr_do_lookup(callback_t *cb_struct) char *safe_sql = NULL; char *rate_field = NULL; char *user_rate_field = NULL; - + switch_assert(cb_struct->lookup_number != NULL); digits_copy = string_digitsonly(cb_struct->pool, digits); if (zstr(digits_copy)) { return SWITCH_STATUS_GENERR; } - + /* allocate the dedup hash */ if (switch_core_hash_init(&cb_struct->dedup_hash, cb_struct->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_ERROR, "Error initializing the dedup hash\n"); return SWITCH_STATUS_GENERR; } - + digits_expanded = expand_digits(cb_struct->pool, digits_copy, cb_struct->profile->quote_in_list); if (cb_struct->lrn_number) { lrn_digits_expanded = expand_digits(cb_struct->pool, cb_struct->lrn_number, cb_struct->profile->quote_in_list); } else { lrn_digits_expanded = switch_core_strdup(cb_struct->pool, digits_expanded); } - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "Has NPA NXX: [%u == %u]\n", profile->profile_has_npanxx, SWITCH_TRUE); if (profile->profile_has_npanxx == SWITCH_TRUE) { is_intrastatelata(cb_struct); } - + /* set our rate field based on env and profile */ if (cb_struct->intralata == SWITCH_TRUE && profile->profile_has_intralata == SWITCH_TRUE) { rate_field = switch_core_strdup(cb_struct->pool, "intralata_rate"); @@ -933,14 +929,14 @@ static switch_status_t lcr_do_lookup(callback_t *cb_struct) } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "intra routing [state:%d lata:%d] so rate field is [%s]\n", cb_struct->intrastate, cb_struct->intralata, rate_field); - + /* set some channel vars if we have a session */ if (cb_struct->session) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "we have a session\n"); if ((channel = switch_core_session_get_channel(cb_struct->session))) { const char *max_rate = switch_channel_get_variable(channel, "max_rate"); if (!zstr(max_rate)) { - cb_struct->max_rate = atof(max_rate); + cb_struct->max_rate = (float)atof(max_rate); } switch_channel_set_variable_var_check(channel, "lcr_rate_field", rate_field, SWITCH_FALSE); switch_channel_set_variable_var_check(channel, "lcr_user_rate_field", user_rate_field, SWITCH_FALSE); @@ -982,9 +978,9 @@ static switch_status_t lcr_do_lookup(callback_t *cb_struct) /* channel_expand_variables returned the same string to us, no need to free */ switch_safe_free(safe_sql); } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", (char *)sql_stream.data); - + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", (char *)sql_stream.data); + lookup_status = lcr_execute_sql_callback((char *)sql_stream.data, route_add_callback, cb_struct); switch_safe_free(sql_stream.data); @@ -1008,12 +1004,12 @@ static switch_bool_t test_profile(char *lcr_profile) switch_event_create(&event, SWITCH_EVENT_MESSAGE); routes.event = event; routes.pool = pool; - + if (!(routes.profile = locate_profile(lcr_profile))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown profile: %s\n", lcr_profile); return SWITCH_FALSE; } - + routes.lookup_number = "15555551212"; routes.cid = "18005551212"; lcr_destroy(routes.head); @@ -1051,7 +1047,7 @@ static switch_status_t lcr_load_config() } } } - + /* initialize sql here, 'cause we need to verify custom_sql for each profile below */ if (globals.odbc_dsn) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG @@ -1063,7 +1059,7 @@ static switch_status_t lcr_load_config() switch_goto_status(SWITCH_STATUS_FALSE, done); } } - + if (set_db_random() == SWITCH_TRUE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Database RANDOM function set to %s\n", db_random); } else { @@ -1088,7 +1084,7 @@ static switch_status_t lcr_load_config() char *limit_type = NULL; int argc, x = 0; char *argv[32] = { 0 }; - + SWITCH_STANDARD_STREAM(order_by); for (param = switch_xml_child(x_profile, "param"); param; param = param->next) { @@ -1096,7 +1092,7 @@ static switch_status_t lcr_load_config() var = (char *) switch_xml_attr_soft(param, "name"); val = (char *) switch_xml_attr_soft(param, "value"); - + if (!strcasecmp(var, "order_by") && !zstr(val)) { thisorder = &order_by; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param val is %s\n", val); @@ -1147,14 +1143,14 @@ static switch_status_t lcr_load_config() enable_sip_redir = val; } } - + if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n"); } else { profile = switch_core_alloc(globals.pool, sizeof(*profile)); memset(profile, 0, sizeof(profile_t)); profile->name = switch_core_strdup(globals.pool, name); - + if (!zstr((char *)order_by.data)) { profile->order_by = switch_core_strdup(globals.pool, (char *)order_by.data); } else { @@ -1165,7 +1161,7 @@ static switch_status_t lcr_load_config() if (!zstr(id_s)) { profile->id = (uint16_t)atoi(id_s); } - + /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */ SWITCH_STANDARD_STREAM(sql_stream); if (zstr(custom_sql)) { @@ -1201,49 +1197,49 @@ static switch_status_t lcr_load_config() } } - sql_stream.write_function(&sql_stream, + sql_stream.write_function(&sql_stream, "SELECT l.digits AS lcr_digits, c.carrier_name AS lcr_carrier_name, l.${lcr_rate_field} AS lcr_rate_field, \ - cg.prefix AS lcr_gw_prefix, cg.suffix AS lcr_gw_suffix, l.lead_strip AS lcr_lead_strip, \ - l.trail_strip AS lcr_trail_strip, l.prefix AS lcr_prefix, l.suffix AS lcr_suffix, \ - cg.codec AS lcr_codec, l.cid AS lcr_cid "); + cg.prefix AS lcr_gw_prefix, cg.suffix AS lcr_gw_suffix, l.lead_strip AS lcr_lead_strip, \ + l.trail_strip AS lcr_trail_strip, l.prefix AS lcr_prefix, l.suffix AS lcr_suffix, \ + cg.codec AS lcr_codec, l.cid AS lcr_cid "); sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id \ - JOIN carrier_gateway cg ON c.id=cg.carrier_id \ - WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND (\ - (digits IN (${lcr_query_expanded_digits}) AND lrn = false) OR \ - (digits IN (${lcr_query_expanded_lrn_digits}) AND lrn = true)"); + JOIN carrier_gateway cg ON c.id=cg.carrier_id \ + WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND (\ + (digits IN (${lcr_query_expanded_digits}) AND lrn = false) OR \ + (digits IN (${lcr_query_expanded_lrn_digits}) AND lrn = true)"); sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end "); if (profile->id > 0) { sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id); } - sql_stream.write_function(&sql_stream, "ORDER BY digits DESC%s", + sql_stream.write_function(&sql_stream, "ORDER BY digits DESC%s", profile->order_by); if (db_random) { sql_stream.write_function(&sql_stream, ", %s", db_random); } sql_stream.write_function(&sql_stream, ";"); - + custom_sql = sql_stream.data; } - - + + profile->profile_has_intralata = db_check("SELECT intralata_rate FROM lcr LIMIT 1"); if (profile->profile_has_intralata != SWITCH_TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no \"intralata_rate\" field found in the \"lcr\" table, routing by intralata rates will be disabled until the field is added and mod_lcr is reloaded\n" ); } profile->profile_has_intrastate = db_check("SELECT intrastate_rate FROM lcr LIMIT 1"); if (profile->profile_has_intrastate != SWITCH_TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no \"intrastate_rate\" field found in the \"lcr\" table, routing by intrastate rates will be disabled until the field is added and mod_lcr is reloaded\n" ); } - + profile->profile_has_npanxx = db_check("SELECT npa, nxx, state FROM npa_nxx_company_ocn LIMIT 1"); if (profile->profile_has_npanxx != SWITCH_TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no \"npa_nxx_company_ocn\" table found in the \"lcr\" database, automatic intrastate detection will be disabled until the table is added and mod_lcr is reloaded\n" ); } @@ -1255,11 +1251,11 @@ static switch_status_t lcr_load_config() profile->custom_sql_has_percent = SWITCH_TRUE; } profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql); - + if (!zstr(reorder_by_rate)) { profile->reorder_by_rate = switch_true(reorder_by_rate); } - + if (!zstr(info_in_headers)) { profile->info_in_headers = switch_true(info_in_headers); } @@ -1288,7 +1284,7 @@ static switch_status_t lcr_load_config() memcpy(argvdup, argv2, sizeof(argv2)); profile->export_fields = argvdup; } - + if (!zstr(limit_type)) { if (!strcasecmp(limit_type, "hash")) { profile->limit_type = "hash"; @@ -1298,7 +1294,7 @@ static switch_status_t lcr_load_config() } else { profile->limit_type = "db"; } - + switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name); /* test the profile */ @@ -1317,7 +1313,7 @@ static switch_status_t lcr_load_config() switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Removing INVALID Profile %s.\n", profile->name); switch_core_hash_delete(globals.profile_hash, profile->name); } - + } switch_safe_free(order_by.data); switch_safe_free(sql_stream.data); @@ -1325,7 +1321,7 @@ static switch_status_t lcr_load_config() } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No lcr profiles defined.\n"); } - + /* define default profile */ if (!globals.default_profile) { profile = switch_core_alloc(globals.pool, sizeof(*profile)); @@ -1380,7 +1376,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, int argc; char *argv[32] = { 0 }; char *mydata = NULL; - + switch_core_new_memory_pool(&pool); routes.pool = pool; @@ -1445,7 +1441,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(var); } - + intrastate = switch_event_get_header(var_event, "intrastate"); intralata = switch_event_get_header(var_event, "intralata"); //switch_event_dup(&event, var_event); @@ -1456,7 +1452,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, } routes.lookup_number = dest; routes.cid = (char *) cid_num_override; - + if ((flags & SOF_FORKED_DIAL)) { myflags |= SOF_NOBLOCK; } @@ -1476,7 +1472,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Select routes based on interstate rates\n"); routes.intrastate = SWITCH_FALSE; } - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "LCR Lookup on %s\n", dest); if (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) { @@ -1517,7 +1513,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, switch_core_session_rwunlock(*new_session); break; } - + /* did not connect, release limit */ if (pop_limit) { switch_limit_release(routes.profile->limit_type, mysession, cur_route->limit_realm, cur_route->limit_id); @@ -1543,7 +1539,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session, if (cause == SWITCH_CAUSE_NONE) { cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - + return cause; } @@ -1587,7 +1583,7 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on interstate rates\n"); routes.intrastate = SWITCH_FALSE; } - + if (!caller_profile) { caller_profile = switch_channel_get_caller_profile(channel); } @@ -1607,7 +1603,7 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt) } } - if (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) { + if (caller_profile && lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) { if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "memory error!\n"); goto end; @@ -1642,7 +1638,7 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt) switch_caller_extension_add_application(session, extension, app, argc); } } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s using profile %s\n", caller_profile->destination_number, caller_profile->context); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s using profile %s\n", caller_profile ? caller_profile->destination_number : "unknown", caller_profile ? caller_profile->context : "unknown"); } end: @@ -1661,7 +1657,7 @@ void str_repeat(size_t how_many, char *what, switch_stream_handle_t *str_stream) size_t i; /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "repeating %d of '%s'\n", (int)how_many, what);*/ - + for (i=0; iwrite_function(str_stream, "%s", what); } @@ -1722,11 +1718,11 @@ SWITCH_STANDARD_APP(lcr_app_function) if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { dest = argv[0]; - + if (argc > 1) { lcr_profile = argv[1]; } - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "LCR Lookup on %s using profile %s\n", dest, lcr_profile); routes.lookup_number = dest; if (caller_profile) { @@ -1736,14 +1732,14 @@ SWITCH_STANDARD_APP(lcr_app_function) } } - + if (!(routes.profile = locate_profile(lcr_profile))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unknown profile: %s\n", lcr_profile); goto end; } if (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) { switch_stream_handle_t dig_stream = { 0 }; - + SWITCH_STANDARD_STREAM(dig_stream); for (cur_route = routes.head; cur_route; cur_route = cur_route->next) { @@ -1766,7 +1762,7 @@ SWITCH_STANDARD_APP(lcr_app_function) } cnt++; } - + switch_snprintf(vbuf, sizeof(vbuf), "%d", cnt - 1); switch_channel_set_variable(channel, "lcr_route_count", vbuf); switch_channel_set_variable(channel, "lcr_auto_route", (char *)dig_stream.data); @@ -1783,7 +1779,7 @@ SWITCH_STANDARD_APP(lcr_app_function) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s\n", dest); } } - + end: lcr_destroy(routes.head); if (routes.event) { @@ -1823,6 +1819,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) char *event_str = NULL; switch_xml_t event_xml = NULL; int rowcount = 0; + char *data = NULL; if (zstr(cmd)) { goto usage; @@ -1841,7 +1838,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) cb_struct.event = event; } cb_struct.pool = pool; - + mydata = switch_core_strdup(pool, cmd); if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { @@ -1877,7 +1874,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) cb_struct.cid = switch_core_strdup(pool, argv[i]); } } - } + } if (zstr(cb_struct.cid)) { cb_struct.cid = "18005551212"; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING @@ -1930,7 +1927,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) if ((len = (maximum_lengths.limit - strlen(headers[LCR_HEADERS_LIMIT]))) > 0) { str_repeat(len, " ", stream); } - + stream->write_function(stream, " | %s", headers[LCR_HEADERS_DIALSTRING]); if ((len = (maximum_lengths.dialstring - strlen(headers[LCR_HEADERS_DIALSTRING]))) > 0) { str_repeat(len, " ", stream); @@ -1941,39 +1938,39 @@ SWITCH_STANDARD_API(dialplan_lcr_function) current = cb_struct.head; while (current) { - //dialstring = - get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current, cb_struct.profile, cb_struct.session); + //dialstring = + get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current, cb_struct.profile, cb_struct.session, data); rowcount++; if (as_xml) { stream->write_function(stream, " \n", rowcount); } - - write_data(stream, as_xml, "prefix", current->digit_str, 2, maximum_lengths.digit_str); - write_data(stream, as_xml, "carrier_name", current->carrier_name, 2, maximum_lengths.carrier_name); - write_data(stream, as_xml, "rate", current->rate_str, 2, maximum_lengths.rate); + + write_data(stream, as_xml, "prefix", current->digit_str, 2, (int)maximum_lengths.digit_str); + write_data(stream, as_xml, "carrier_name", current->carrier_name, 2, (int)maximum_lengths.carrier_name); + write_data(stream, as_xml, "rate", current->rate_str, 2, (int)maximum_lengths.rate); if (current->codec) { - write_data(stream, as_xml, "codec", current->codec, 2, maximum_lengths.codec); + write_data(stream, as_xml, "codec", current->codec, 2, (int)maximum_lengths.codec); } else { - write_data(stream, as_xml, "codec", "", 2, maximum_lengths.codec); + write_data(stream, as_xml, "codec", "", 2, (int)maximum_lengths.codec); } if (current->cid) { - write_data(stream, as_xml, "cid", current->cid, 2, maximum_lengths.cid); + write_data(stream, as_xml, "cid", current->cid, 2, (int)maximum_lengths.cid); } else { - write_data(stream, as_xml, "cid", "", 2, maximum_lengths.cid); + write_data(stream, as_xml, "cid", "", 2, (int)maximum_lengths.cid); } - + if (current->limit_realm && current->limit_id) { char *str = NULL; str = switch_core_sprintf(pool, "%s %s %d", current->limit_realm, current->limit_id, current->limit_max); - - write_data(stream, as_xml, "limit", str, 2, maximum_lengths.limit); + + write_data(stream, as_xml, "limit", str, 2, (int)maximum_lengths.limit); } else { - write_data(stream, as_xml, "limit", "", 2, maximum_lengths.limit); + write_data(stream, as_xml, "limit", "", 2, (int)maximum_lengths.limit); } - - write_data(stream, as_xml, "dialstring", current->dialstring, 2, maximum_lengths.dialstring); + + write_data(stream, as_xml, "dialstring", current->dialstring, 2, (int)maximum_lengths.dialstring); if (as_xml) { event_xml = switch_event_xmlize(current->fields, SWITCH_VA_NONE); event_str = switch_xml_toxml(event_xml, SWITCH_FALSE); @@ -1981,7 +1978,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) switch_xml_free(event_xml); switch_safe_free(event_str); } - + if (as_xml) { stream->write_function(stream, " \n"); } else { @@ -2006,6 +2003,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) } end: + switch_safe_free(data); lcr_destroy(cb_struct.head); if (!session) { if (pool) { @@ -2042,7 +2040,7 @@ SWITCH_STANDARD_API(dialplan_lcr_admin_function) for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); profile = (profile_t *) val; - + stream->write_function(stream, "Name:\t\t%s\n", profile->name); if (zstr(profile->custom_sql)) { stream->write_function(stream, " ID:\t\t%d\n", profile->id); @@ -2074,16 +2072,16 @@ usage: switch_safe_free(mydata); stream->write_function(stream, "-ERR %s\n", LCR_ADMIN_SYNTAX); return SWITCH_STATUS_SUCCESS; - + } - + SWITCH_MODULE_LOAD_FUNCTION(mod_lcr_load) { switch_api_interface_t *dialplan_lcr_api_interface; switch_api_interface_t *dialplan_lcr_api_admin_interface; switch_application_interface_t *app_interface; switch_dialplan_interface_t *dp_interface; - + *module_interface = switch_loadable_module_create_module_interface(pool, modname); globals.pool = pool; @@ -2105,7 +2103,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lcr_load) lcr_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); lcr_endpoint_interface->interface_name = "lcr"; lcr_endpoint_interface->io_routines = &lcr_io_routines; - + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_limit/mod_limit.c b/src/mod/applications/mod_limit/mod_limit.c index 93bb93fc7b..b4adf36fdf 100644 --- a/src/mod/applications/mod_limit/mod_limit.c +++ b/src/mod/applications/mod_limit/mod_limit.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_memcache/mod_memcache.c b/src/mod/applications/mod_memcache/mod_memcache.c index 740fe54954..0fed4cc516 100755 --- a/src/mod/applications/mod_memcache/mod_memcache.c +++ b/src/mod/applications/mod_memcache/mod_memcache.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_mongo/Makefile b/src/mod/applications/mod_mongo/Makefile index 9ce16b1171..aa696cb6b0 100644 --- a/src/mod/applications/mod_mongo/Makefile +++ b/src/mod/applications/mod_mongo/Makefile @@ -1,17 +1,18 @@ BASE=../../../.. -MONGO_CXX_DRIVER_VERSION=v1.8 +MONGO_CXX_DRIVER_VERSION=v2.4 MONGO_CXX_DRIVER_URL=http://downloads.mongodb.org/cxx-driver MONGO_CXX_DRIVER_TARBALL=mongodb-linux-x86_64-$(MONGO_CXX_DRIVER_VERSION)-latest.tgz MONGO_CXX_DRIVER_SRC=$(BASE)/libs/mongo-cxx-driver-$(MONGO_CXX_DRIVER_VERSION) LIBMONGOCLIENT_A =$(MONGO_CXX_DRIVER_SRC)/libmongoclient.a -LOCAL_SOURCES=mongo_conn.cpp -LOCAL_OBJS=mongo_conn.o +LOCAL_SOURCES= +LOCAL_OBJS= -LOCAL_CFLAGS=-I$(MONGO_CXX_DRIVER_SRC)/mongo +LOCAL_CFLAGS=-I$(MONGO_CXX_DRIVER_SRC)/src LOCAL_LIBADD=$(LIBMONGOCLIENT_A) LOCAL_LDFLAGS=-lboost_thread -lboost_filesystem-mt -lboost_system-mt +#LOCAL_LDFLAGS=-lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt MODDIR=$(shell pwd) diff --git a/src/mod/applications/mod_mongo/conf/autoload_configs/mongo.conf.xml b/src/mod/applications/mod_mongo/conf/autoload_configs/mongo.conf.xml index 8423645e95..72fffafbb7 100644 --- a/src/mod/applications/mod_mongo/conf/autoload_configs/mongo.conf.xml +++ b/src/mod/applications/mod_mongo/conf/autoload_configs/mongo.conf.xml @@ -7,8 +7,9 @@ foo/server:port,server:port SET --> - + + - - + + diff --git a/src/mod/applications/mod_nibblebill/mod_nibblebill.2012.vcxproj b/src/mod/applications/mod_nibblebill/mod_nibblebill.2012.vcxproj index 85df16fec1..3589f64957 100644 --- a/src/mod/applications/mod_nibblebill/mod_nibblebill.2012.vcxproj +++ b/src/mod/applications/mod_nibblebill/mod_nibblebill.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,6 +68,10 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + %(PreprocessorDefinitions) @@ -101,7 +105,7 @@ %(PreprocessorDefinitions) - true + false false diff --git a/src/mod/applications/mod_nibblebill/mod_nibblebill.c b/src/mod/applications/mod_nibblebill/mod_nibblebill.c index fff12336f1..1390e0ef0a 100755 --- a/src/mod/applications/mod_nibblebill/mod_nibblebill.c +++ b/src/mod/applications/mod_nibblebill/mod_nibblebill.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,9 +28,10 @@ * Contributor(s): * Darren Schreiber * Rupa Schomaker + * Emmanuel Schmidbauer * * mod_nibblebill.c - Nibble Billing - * Purpose is to allow real-time debiting of credit or cash from a database while calls are in progress. I had the following goals: + * Purpose is to allow real-time debiting of credit or cash from a database while calls are in progress. I had the following goals: * * Debit credit/cash from accounts real-time * Allow for billing at different rates during a single call @@ -91,6 +92,10 @@ static struct { /* Other options */ int global_heartbeat; /* Supervise and bill every X seconds, 0 means off */ + /* Channel variable name options */ + char *var_name_rate; + char *var_name_account; + /* Database settings */ char *dbname; char *odbc_dsn; @@ -125,6 +130,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_custom_sql_lookup, globals.custom_s SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_percall_action, globals.percall_action); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_lowbal_action, globals.lowbal_action); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_nobal_action, globals.nobal_action); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_var_name_rate, globals.var_name_rate); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_var_name_account, globals.var_name_account); static switch_cache_db_handle_t *nibblebill_get_db_handle(void) { @@ -242,6 +249,10 @@ static switch_status_t nibblebill_load_config(void) set_global_nobal_action(val); } else if (!strcasecmp(var, "nobal_amt")) { globals.nobal_amt = atof(val); + } else if (!strcasecmp(var, "var_name_rate")) { + set_global_var_name_rate(val); + } else if (!strcasecmp(var, "var_name_account")) { + set_global_var_name_account(val); } else if (!strcasecmp(var, "global_heartbeat")) { globals.global_heartbeat = atoi(val); } @@ -260,6 +271,12 @@ static switch_status_t nibblebill_load_config(void) if (zstr(globals.nobal_action)) { set_global_nobal_action("hangup"); } + if (zstr(globals.var_name_rate)) { + set_global_var_name_rate("nibble_rate"); + } + if (zstr(globals.var_name_account)) { + set_global_var_name_account("nibble_account"); + } if (globals.odbc_dsn) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG @@ -449,10 +466,10 @@ static switch_status_t do_billing(switch_core_session_t *session) } /* Variables kept in FS but relevant only to this module */ - billrate = switch_channel_get_variable(channel, "nibble_rate"); + billrate = switch_channel_get_variable(channel, globals.var_name_rate); billincrement = switch_channel_get_variable(channel, "nibble_increment"); - billaccount = switch_channel_get_variable(channel, "nibble_account"); - + billaccount = switch_channel_get_variable(channel, globals.var_name_account); + if (!zstr(switch_channel_get_variable(channel, "nobal_amt"))) { nobal_amt = atof(switch_channel_get_variable(channel, "nobal_amt")); } @@ -707,7 +724,7 @@ static void nibblebill_resume(switch_core_session_t *session) switch_mutex_lock(globals.mutex); } - billrate = switch_channel_get_variable(channel, "nibble_rate"); + billrate = switch_channel_get_variable(channel, globals.var_name_rate); /* Calculate how much was "lost" to billings during pause - we do this here because you never know when the billrate may change during a call */ nibble_data->bill_adjustments += (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets)); @@ -800,7 +817,7 @@ static void nibblebill_adjust(switch_core_session_t *session, double amount) /* Variables kept in FS but relevant only to this module */ - billaccount = switch_channel_get_variable(channel, "nibble_account"); + billaccount = switch_channel_get_variable(channel, globals.var_name_account); /* Return if there's no billing information on this session */ if (!billaccount) { @@ -900,9 +917,9 @@ static switch_status_t sched_billing(switch_core_session_t *session) } /* Variables kept in FS but relevant only to this module */ - billrate = switch_channel_get_variable(channel, "nibble_rate"); - billaccount = switch_channel_get_variable(channel, "nibble_account"); - + billrate = switch_channel_get_variable(channel, globals.var_name_rate); + billaccount = switch_channel_get_variable(channel, globals.var_name_account); + /* Return if there's no billing information on this session */ if (!billrate || !billaccount) { return SWITCH_STATUS_SUCCESS; @@ -930,7 +947,7 @@ static switch_status_t process_hangup(switch_core_session_t *session) /* Now go handle like normal billing */ do_billing(session); - billaccount = switch_channel_get_variable(channel, "nibble_account"); + billaccount = switch_channel_get_variable(channel, globals.var_name_account); if (billaccount) { switch_channel_set_variable_printf(channel, "nibble_current_balance", "%f", get_balance(billaccount, channel)); } @@ -1012,6 +1029,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_nibblebill_shutdown) switch_safe_free(globals.percall_action); switch_safe_free(globals.lowbal_action); switch_safe_free(globals.nobal_action); + switch_safe_free(globals.var_name_rate); + switch_safe_free(globals.var_name_account); return SWITCH_STATUS_UNLOAD; } diff --git a/src/mod/applications/mod_osp/mod_osp.c b/src/mod/applications/mod_osp/mod_osp.c index b63d9d91b6..19ea56e399 100644 --- a/src/mod/applications/mod_osp/mod_osp.c +++ b/src/mod/applications/mod_osp/mod_osp.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_rad_auth/Makefile b/src/mod/applications/mod_rad_auth/Makefile index c00bce2cc2..63542dff47 100644 --- a/src/mod/applications/mod_rad_auth/Makefile +++ b/src/mod/applications/mod_rad_auth/Makefile @@ -1,7 +1,26 @@ -switch_srcdir=../../../.. +RADCLIENT_VERSION=1.1.6 +RADCLIENT=freeradius-client-$(RADCLIENT_VERSION) +RADCLIENT_DIR=$(switch_srcdir)/libs/$(RADCLIENT) +RADCLIENT_BUILDDIR=$(switch_builddir)/libs/$(RADCLIENT) +RADCLIENT_LIBDIR=$(RADCLIENT_BUILDDIR)/lib +RADCLIENT_LA=${RADCLIENT_LIBDIR}/libfreeradius-client.la -FREERADIUSLA=/usr/local/lib/libfreeradius-client.so -LOCAL_LIBADD=$(FREERADIUSLA) +LOCAL_CFLAGS=-I$(RADCLIENT_DIR)/include +LOCAL_LIBADD=$(RADCLIENT_LA) + +BASE=../../../.. +include $(BASE)/build/modmake.rules + +$(RADCLIENT_DIR): + $(GETLIB) $(RADCLIENT).tar.gz + +$(RADCLIENT_BUILDDIR)/Makefile: $(RADCLIENT_DIR) + mkdir -p $(RADCLIENT_BUILDDIR) + cd $(RADCLIENT_BUILDDIR) && $(DEFAULT_VARS) $(RADCLIENT_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(RADCLIENT_DIR) + $(TOUCH_TARGET) + +$(RADCLIENT_LA): $(RADCLIENT_BUILDDIR)/Makefile + cd $(RADCLIENT_BUILDDIR) && CFLAGS="$(CFLAGS)" $(MAKE) + $(TOUCH_TARGET) -include $(switch_srcdir)/build/modmake.rules diff --git a/src/mod/applications/mod_rad_auth/mod_rad_auth.c b/src/mod/applications/mod_rad_auth/mod_rad_auth.c index 4f66608814..7d4d76f148 100644 --- a/src/mod/applications/mod_rad_auth/mod_rad_auth.c +++ b/src/mod/applications/mod_rad_auth/mod_rad_auth.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -* Copyright (C) 2005-2012, Anthony Minessale II +* Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_random/mod_random.c b/src/mod/applications/mod_random/mod_random.c index 190015d676..c4ffa25af0 100644 --- a/src/mod/applications/mod_random/mod_random.c +++ b/src/mod/applications/mod_random/mod_random.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_redis/credis.c b/src/mod/applications/mod_redis/credis.c index d25756fc3a..a76cbedf49 100644 --- a/src/mod/applications/mod_redis/credis.c +++ b/src/mod/applications/mod_redis/credis.c @@ -341,8 +341,8 @@ static int cr_readln(REDIS rhnd, int start, char **line, int *idx) *line = buf->data + buf->idx; if (idx) *idx = buf->idx; - len = nl - *line; - buf->idx = (nl - buf->data) + 2; /* skip "\r\n" */ + len = (int)(nl - *line); + buf->idx = (int)((nl - buf->data) + 2); /* skip "\r\n" */ DEBUG("size=%d, len=%d, idx=%d, start=%d, line=%s", buf->size, buf->len, buf->idx, start, *line); diff --git a/src/mod/applications/mod_redis/mod_redis.2012.vcxproj b/src/mod/applications/mod_redis/mod_redis.2012.vcxproj index 6302be92af..08127494ae 100644 --- a/src/mod/applications/mod_redis/mod_redis.2012.vcxproj +++ b/src/mod/applications/mod_redis/mod_redis.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,6 +68,22 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + @@ -75,6 +91,11 @@ + + _CRT_SECURE_NO_WARNINGS;_DEBUG;DEBUG;%(PreprocessorDefinitions) + 4706;4306;4996;6340;6246;6011;6387;%(DisableSpecificWarnings) + false + @@ -87,6 +108,11 @@ MachineX64 + + _CRT_SECURE_NO_WARNINGS;_DEBUG;DEBUG;%(PreprocessorDefinitions) + 4706;4306;4996;6340;6246;6011;6387;%(DisableSpecificWarnings) + false + @@ -95,6 +121,11 @@ + + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4389;4706;4306;4996;6340;6246;6011;6387;%(DisableSpecificWarnings) + false + @@ -107,6 +138,11 @@ MachineX64 + + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4706;4306;4996;6340;6246;6011;6387;%(DisableSpecificWarnings) + false + diff --git a/src/mod/applications/mod_redis/mod_redis.c b/src/mod/applications/mod_redis/mod_redis.c index 48b27d503b..b7038a6878 100755 --- a/src/mod/applications/mod_redis/mod_redis.c +++ b/src/mod/applications/mod_redis/mod_redis.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -260,13 +260,13 @@ SWITCH_LIMIT_RESET(limit_reset_redis) if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) { int i = 0; - int hostnamelen = strlen(switch_core_get_switchname())+1; + int hostnamelen = (int)strlen(switch_core_get_switchname())+1; for (i = 0; i < keyc && uuids[i]; i++){ const char *key = uuids[i] + hostnamelen; char *value; - if (strlen(uuids[i]) <= hostnamelen) { + if ((int)strlen(uuids[i]) <= hostnamelen) { continue; /* Sanity check */ } diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index 10920e2e9f..a48e6226c5 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_skel/mod_skel.c b/src/mod/applications/mod_skel/mod_skel.c index 37f155aef6..38bf4ac099 100644 --- a/src/mod/applications/mod_skel/mod_skel.c +++ b/src/mod/applications/mod_skel/mod_skel.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 49037f24d9..856029b7ce 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -76,7 +76,7 @@ typedef enum { #define check_tz() \ do { \ tzoff = switch_event_get_header(event, "tod_tz_offset"); \ - tzname = switch_event_get_header(event, "timezone"); \ + tzname_ = switch_event_get_header(event, "timezone"); \ if (!zstr(tzoff) && switch_is_number(tzoff)) { \ offset = atoi(tzoff); \ break; \ @@ -93,7 +93,7 @@ static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_ char *expression_expanded = NULL, *field_expanded = NULL; switch_regex_t *re = NULL; const char *to = switch_event_get_header(event, "to"); - const char *tzoff = NULL, *tzname = NULL; + const char *tzoff = NULL, *tzname_ = NULL; int offset = 0; check_tz(); @@ -117,7 +117,7 @@ static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_ int time_match; check_tz(); - time_match = switch_xml_std_datetime_check(xcond, tzoff ? &offset : NULL, tzname); + time_match = switch_xml_std_datetime_check(xcond, tzoff ? &offset : NULL, tzname_); switch_safe_free(field_expanded); switch_safe_free(expression_expanded); diff --git a/src/mod/applications/mod_snapshot/mod_snapshot.c b/src/mod/applications/mod_snapshot/mod_snapshot.c index 5bc8a05798..adc900ea3d 100644 --- a/src/mod/applications/mod_snapshot/mod_snapshot.c +++ b/src/mod/applications/mod_snapshot/mod_snapshot.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c b/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c index 244842c5eb..2e4fc2973b 100644 --- a/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c +++ b/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_snom/mod_snom.2012.vcxproj b/src/mod/applications/mod_snom/mod_snom.2012.vcxproj index 1908fff11f..623dc138b9 100644 --- a/src/mod/applications/mod_snom/mod_snom.2012.vcxproj +++ b/src/mod/applications/mod_snom/mod_snom.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -73,6 +73,7 @@ WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + 6385;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -88,6 +89,7 @@ WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) + 6385;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -100,6 +102,7 @@ + 6385;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -114,6 +117,7 @@ + 6385;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/applications/mod_snom/mod_snom.c b/src/mod/applications/mod_snom/mod_snom.c index a024479012..36bc438ce1 100644 --- a/src/mod/applications/mod_snom/mod_snom.c +++ b/src/mod/applications/mod_snom/mod_snom.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_sonar/mod_sonar.c b/src/mod/applications/mod_sonar/mod_sonar.c index 446319b2a8..30aa6f22a1 100644 --- a/src/mod/applications/mod_sonar/mod_sonar.c +++ b/src/mod/applications/mod_sonar/mod_sonar.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_soundtouch/Makefile b/src/mod/applications/mod_soundtouch/Makefile index 33d3e2b227..0afa65ca69 100644 --- a/src/mod/applications/mod_soundtouch/Makefile +++ b/src/mod/applications/mod_soundtouch/Makefile @@ -1,5 +1,5 @@ BASE=../../../.. -VERSION=soundtouch-1.6.0 +VERSION=soundtouch-1.7.1 SNDT_SRC=$(switch_srcdir)/libs/soundtouch SNDT_BUILD=$(switch_builddir)/libs/soundtouch LA=$(SNDT_BUILD)/source/SoundTouch/.libs/libSoundTouch.a diff --git a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp index 69ba4878d6..e6cfb2a148 100644 --- a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp +++ b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.2012.vcxproj b/src/mod/applications/mod_spandsp/mod_spandsp.2012.vcxproj index 351ef2cf78..223bb55100 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.2012.vcxproj +++ b/src/mod/applications/mod_spandsp/mod_spandsp.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,11 +68,29 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4024;4047;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + false ws2_32.lib;%(AdditionalDependencies) @@ -89,6 +107,8 @@ %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4024;4047;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + false ws2_32.lib;%(AdditionalDependencies) @@ -103,6 +123,8 @@ %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4024;4047;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + false ws2_32.lib;%(AdditionalDependencies) @@ -119,6 +141,8 @@ %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4024;4047;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + false ws2_32.lib;%(AdditionalDependencies) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index b6ff1771de..41d7212601 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -64,6 +64,11 @@ SWITCH_STANDARD_APP(spanfax_rx_function) mod_spandsp_fax_process_fax(session, data, FUNCTION_RX); } +SWITCH_STANDARD_APP(spanfax_stop_function) +{ + mod_spandsp_fax_stop_fax(session); +} + SWITCH_STANDARD_APP(dtmf_session_function) { spandsp_inband_dtmf_session(session); @@ -740,6 +745,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK); SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE, SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK); + SWITCH_ADD_APP(app_interface, "stopfax", "Stop FAX Application", "Stop FAX Application", spanfax_stop_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP); @@ -795,8 +801,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); } - +#if defined(MODEM_SUPPORT) modem_global_init(module_interface, pool); +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_spandsp loaded, using spandsp library version [%s]\n", SPANDSP_RELEASE_DATETIME_STRING); @@ -811,7 +818,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown) mod_spandsp_fax_shutdown(); mod_spandsp_dsp_shutdown(); +#if defined(MODEM_SUPPORT) modem_global_shutdown(); +#endif if (spandsp_globals.tones) { switch_core_hash_destroy(&spandsp_globals.tones); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 5f5a038c43..ca4aa84060 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -132,6 +132,7 @@ void mod_spandsp_dsp_shutdown(void); void mod_spandsp_fax_event_handler(switch_event_t *event); void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *data, mod_spandsp_fax_application_mode_t app_mode); +void mod_spandsp_fax_stop_fax(switch_core_session_t *session); switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app, const char *data); switch_status_t spandsp_stop_inband_dtmf_session(switch_core_session_t *session); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_codecs.c b/src/mod/applications/mod_spandsp/mod_spandsp_codecs.c index b44daa6172..0f5c316667 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_codecs.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_codecs.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 42e31d1ef5..b2fb98313a 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -399,7 +399,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da if (pvt->verbose) { span_log_set_level(dtmf_rx_get_logging_state(pvt->dtmf_detect), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); } - dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, pvt->twist, pvt->reverse_twist, pvt->threshold); + dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, (float)pvt->twist, (float)pvt->reverse_twist, (float)pvt->threshold); dtmf_rx_set_realtime_callback(pvt->dtmf_detect, spandsp_dtmf_rx_realtime_callback, pvt); break; } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index c76fda6637..82edadbbf4 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1347,6 +1347,14 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati return pvt; } +void mod_spandsp_fax_stop_fax(switch_core_session_t *session) +{ + pvt_t *pvt = switch_channel_get_private(switch_core_session_get_channel(session), "_fax_pvt"); + if (pvt) { + pvt->done = 1; + } +} + void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *data, mod_spandsp_fax_application_mode_t app_mode) { pvt_t *pvt; @@ -1365,7 +1373,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat pvt = pvt_init(session, app_mode); - + switch_channel_set_private(channel, "_fax_pvt", pvt); buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); @@ -1478,6 +1486,8 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat int tx = 0; switch_status_t status; + switch_ivr_parse_all_events(session); + /* if we are in T.38 mode, we should: 1- initialize the ptv->t38_state stuff, if not done and then set some callbacks when reading frames. diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index 7c43577427..ee7405f90a 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -81,7 +81,7 @@ static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uin return 0; } -static int t31_at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len) +static int t31_at_tx_handler(void *user_data, const uint8_t *buf, size_t len) { modem_t *modem = user_data; @@ -1024,7 +1024,6 @@ static void wake_modem_thread(modem_t *modem) static int control_handler(modem_t *modem, const char *num, int op) { switch_core_session_t *session = NULL; - at_state_t *at_state; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s\n", op, modem_state2name(modem_get_state(modem)), modem->devlink); @@ -1103,16 +1102,14 @@ static int control_handler(modem_t *modem, const char *num, int op) u_char x[1]; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Modem %s [%s] - CTS %s\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num ? "XON" : "XOFF"); - - at_state = t31_get_at_state(modem->t31_state); if (num) { x[0] = 0x11; - t31_at_tx_handler(at_state, modem, x, 1); + t31_at_tx_handler(modem, x, 1); switch_clear_flag(modem, MODEM_FLAG_XOFF); wake_modem_thread(modem); } else { x[0] = 0x13; - t31_at_tx_handler(at_state, modem, x, 1); + t31_at_tx_handler(modem, x, 1); switch_set_flag(modem, MODEM_FLAG_XOFF); } } @@ -1238,7 +1235,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj) DWORD readBytes; OVERLAPPED o; #endif - char buf[T31_TX_BUF_LEN], tmp[80]; + char buf[T31_TX_BUF_LEN]; switch_mutex_lock(globals.mutex); modem_init(modem, control_handler); @@ -1298,18 +1295,8 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj) #endif t31_at_rx(modem->t31_state, buf, r); - memset(tmp, 0, sizeof(tmp)); if (!strncasecmp(buf, "AT", 2)) { - int x; - - strncpy(tmp, buf, r); - for (x = 0; x < r; x++) { - if (tmp[x] == '\r' || tmp[x] == '\n') { - tmp[x] = '\0'; - } - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Command on %s [%s]\n", modem->devlink, tmp); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Command on %s [%s]\n", modem->devlink, buf); } } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.h b/src/mod/applications/mod_spandsp/mod_spandsp_modem.h index 147e823496..80efefd8b7 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -35,7 +35,7 @@ #undef HAVE_STDLIB_H #include "switch_private.h" #endif -#if defined(HAVE_OPENPTY) || defined(HAVE_DEV_PTMX) || defined(HAVE_POSIX_OPENPT) || WIN32 +#if !defined(__OpenBSD__) && !defined(__DragonFly__) && (defined(HAVE_OPENPTY) || defined(HAVE_DEV_PTMX) || defined(HAVE_POSIX_OPENPT) || WIN32) #define MODEM_SUPPORT 1 #if !defined(HAVE_POSIX_OPENPT) && !defined(HAVE_DEV_PTMX) && !defined(WIN32) #define USE_OPENPTY 1 @@ -55,6 +55,7 @@ #include #elif defined(__SunOS) #include +#elif defined(__OpenBSD__) #else #include #endif diff --git a/src/mod/applications/mod_spandsp/udptl.c b/src/mod/applications/mod_spandsp/udptl.c index 45fa6b6ffc..d1e21d648d 100644 --- a/src/mod/applications/mod_spandsp/udptl.c +++ b/src/mod/applications/mod_spandsp/udptl.c @@ -28,7 +28,9 @@ #include "udptl.h" #define FALSE 0 +#ifndef TRUE #define TRUE (!FALSE) +#endif static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue) { @@ -170,8 +172,8 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len) int count; int total_count; int seq_no; - const uint8_t *msg; - const uint8_t *data; + const uint8_t *msg = NULL; + const uint8_t *data = NULL; int msg_len; int repaired[16]; const uint8_t *bufs[16] = {0}; diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c index 5e92272163..80cacec402 100644 --- a/src/mod/applications/mod_spy/mod_spy.c +++ b/src/mod/applications/mod_spy/mod_spy.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_stress/mod_stress.cpp b/src/mod/applications/mod_stress/mod_stress.cpp index 52b187074c..c16efde095 100644 --- a/src/mod/applications/mod_stress/mod_stress.cpp +++ b/src/mod/applications/mod_stress/mod_stress.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_translate/mod_translate.c b/src/mod/applications/mod_translate/mod_translate.c index 6b8b225d34..87f0a14e3d 100644 --- a/src/mod/applications/mod_translate/mod_translate.c +++ b/src/mod/applications/mod_translate/mod_translate.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_valet_parking/mod_valet_parking.c b/src/mod/applications/mod_valet_parking/mod_valet_parking.c index f14c81c3bf..2ead3186c9 100644 --- a/src/mod/applications/mod_valet_parking/mod_valet_parking.c +++ b/src/mod/applications/mod_valet_parking/mod_valet_parking.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -162,7 +162,8 @@ static int find_longest(valet_lot_t *lot, int min, int max) const void *i_var; void *i_val; valet_token_t *token; - int longest = 0, cur = 0, longest_ext = 0; + int longest_ext = 0; + time_t longest = 0, cur = 0; time_t now = switch_epoch_time_now(NULL); switch_mutex_lock(lot->mutex); @@ -607,7 +608,7 @@ SWITCH_STANDARD_APP(valet_parking_function) } dest = switch_core_session_sprintf(session, "%s%s%s%s" - "set:valet_ticket=%s,set:valet_hold_music=%s,sleep:1000,valet_park:%s %s", + "set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s", timeout_str, orbit_exten_str, orbit_dialplan_str, @@ -805,24 +806,22 @@ static void pres_event_handler(switch_event_t *event) if (count) { if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { - if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); - switch_event_fire(&event); - } - found++; + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); + switch_event_fire(&event); } + found++; } else { if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO); diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.2012.vcxproj b/src/mod/applications/mod_voicemail/mod_voicemail.2012.vcxproj index cdce7e6b31..51a18f8e5e 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.2012.vcxproj +++ b/src/mod/applications/mod_voicemail/mod_voicemail.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -72,6 +72,7 @@ + 6385;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -86,6 +87,7 @@ + 6385;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -98,6 +100,7 @@ + 6385;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -112,6 +115,7 @@ + 6385;4306;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 07d4d2fe95..7b19974bcb 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,6 +28,7 @@ * John Wehle (john@feith.com) * Raymond Chandler * Kristin King + * Emmanuel Schmidbauer * * mod_voicemail.c -- Voicemail Module * @@ -40,6 +41,9 @@ #define TRY_CODE(code) do { status = code; if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { goto end; } break;} while(status) #endif + +#define xml_safe_free(_x) if (_x) switch_xml_free(_x); _x = NULL + SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_voicemail_shutdown); SWITCH_MODULE_DEFINITION(mod_voicemail, mod_voicemail_load, mod_voicemail_shutdown, NULL); @@ -151,6 +155,7 @@ struct vm_profile { char *vmain_ext; char *tone_spec; char *storage_dir; + switch_bool_t storage_dir_shared; char *callback_dialplan; char *callback_context; char *email_body; @@ -625,6 +630,8 @@ vm_profile_t *profile_set_config(vm_profile_t *profile) &profile->tone_spec, "%(1000, 0, 640)", &profile->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->storage_dir, "", &profile->config_str_pool, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir-shared", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, + &profile->storage_dir_shared, SWITCH_FALSE, NULL, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-dialplan", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->callback_dialplan, "XML", &profile->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-context", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, @@ -706,7 +713,8 @@ static vm_profile_t *load_profile(const char *profile_name) if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) { switch_memory_pool_t *pool; - int x, count; + int x; + switch_size_t count; char *errmsg; if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { @@ -747,7 +755,7 @@ static vm_profile_t *load_profile(const char *profile_name) } - if (switch_xml_config_parse_event(event, count, SWITCH_FALSE, profile->config) != SWITCH_STATUS_SUCCESS) { + if (switch_xml_config_parse_event(event, (int)count, SWITCH_FALSE, profile->config) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to process configuration\n"); switch_core_destroy_memory_pool(&pool); goto end; @@ -1345,16 +1353,16 @@ static int listen_callback(void *pArg, int argc, char **argv, char **columnNames static char *resolve_id(const char *myid, const char *domain_name, const char *action) { - switch_xml_t xx_user, xx_domain, xx_domain_root; + switch_xml_t xx_user; switch_event_t *params; char *ret = (char *) myid; switch_event_create(¶ms, SWITCH_EVENT_GENERAL); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", action); - if (switch_xml_locate_user("id", myid, domain_name, NULL, &xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) { + if (switch_xml_locate_user_merged("id:number-alias", myid, domain_name, NULL, &xx_user, params) == SWITCH_STATUS_SUCCESS) { ret = strdup(switch_xml_attr(xx_user, "id")); - switch_xml_free(xx_domain_root); + switch_xml_free(xx_user); } switch_event_destroy(¶ms); @@ -1707,9 +1715,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t while (!ok) { - if (x_user) { - switch_xml_free(x_user); - } + xml_safe_free(x_user); switch_snprintf(macro_buf, sizeof(macro_buf), "phrase:%s:%s", VM_FORWARD_MESSAGE_ENTER_EXTENSION_MACRO, profile->terminator_key); vm_cc[0] = '\0'; @@ -1723,7 +1729,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(my_params); - status = switch_xml_locate_user_merged("id", vm_cc, cbt->domain, NULL, &x_user, my_params); + status = switch_xml_locate_user_merged("id:number-alias", vm_cc, cbt->domain, NULL, &x_user, my_params); switch_event_destroy(&my_params); if (status != SWITCH_STATUS_SUCCESS) { @@ -1762,8 +1768,9 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t } } } - - switch_xml_free(x_user); + + xml_safe_free(x_user); + break; } @@ -1952,9 +1959,6 @@ static void update_mwi(vm_profile_t *profile, const char *id, const char *domain switch_event_fire(&message_event); } - -#define FREE_DOMAIN_ROOT() if (x_user) switch_xml_free(x_user); x_user = NULL - static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id, int auth, const char *uuid_in) { vm_check_state_t vm_check_state = VM_CHECK_START; @@ -2025,7 +2029,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p mypass = NULL; myfolder = "inbox"; vm_check_state = VM_CHECK_AUTH; - FREE_DOMAIN_ROOT(); + xml_safe_free(x_user); } break; case VM_CHECK_FOLDER_SUMMARY: @@ -2439,7 +2443,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_id_number); - if (switch_xml_locate_user_merged("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"), + if (switch_xml_locate_user_merged("id:number-alias", myid, domain_name, switch_channel_get_variable(channel, "network_addr"), &x_user, params) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", myid, domain_name); ok = 0; @@ -2523,9 +2527,11 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p convert_ext = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "vm-storage-dir")) { vm_storage_dir = switch_core_session_strdup(session, val); + } else if (!strcasecmp(var, "vm-domain-storage-dir")) { + storage_dir = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "storage-dir")) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "Using deprecated 'storage-dir' directory variable: Please use 'vm-storage-dir'.\n"); + "Using deprecated 'storage-dir' directory variable: Please use 'vm-domain-storage-dir'.\n"); storage_dir = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "timezone")) { switch_channel_set_variable(channel, var, val); @@ -2590,7 +2596,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p switch_channel_event_set_data(channel, event); switch_event_fire(&event); - FREE_DOMAIN_ROOT(); + xml_safe_free(x_user); if (auth) { if (!dir_path) { @@ -2605,9 +2611,16 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p } else if (!zstr(storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, myid); } else if (!zstr(profile->storage_dir)) { - dir_path = - switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, - SWITCH_PATH_SEPARATOR, myid); + if (profile->storage_dir_shared) { + dir_path = + switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, + SWITCH_PATH_SEPARATOR, "voicemail", + SWITCH_PATH_SEPARATOR, myid); + } else { + dir_path = + switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, + SWITCH_PATH_SEPARATOR, myid); + } } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR, @@ -2634,7 +2647,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p failed: - FREE_DOMAIN_ROOT(); + xml_safe_free(x_user); status = switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL); myid = id; @@ -2677,11 +2690,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p } } - if (x_user) { - switch_xml_free(x_user); - x_user = NULL; - } - + xml_safe_free(x_user); } @@ -2777,9 +2786,11 @@ static switch_status_t deliver_vm(vm_profile_t *profile, send_mail++; } else if (!strcasecmp(var, "vm-storage-dir")) { vm_storage_dir = switch_core_strdup(pool, val); + } else if (!strcasecmp(var, "vm-domain-storage-dir")) { + storage_dir = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "storage-dir")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Using deprecated 'storage-dir' directory variable: Please use 'vm-storage-dir'.\n"); + "Using deprecated 'storage-dir' directory variable: Please use 'vm-domain-storage-dir'.\n"); storage_dir = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "vm-notify-email-all-messages") && (send_notify = switch_true(val))) { send_mail++; @@ -2810,7 +2821,11 @@ static switch_status_t deliver_vm(vm_profile_t *profile, } else if (!zstr(storage_dir)) { dir_path = switch_mprintf("%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, myid); } else if (!zstr(profile->storage_dir)) { - dir_path = switch_mprintf("%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); + if (profile->storage_dir_shared) { + dir_path = switch_mprintf("%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, "voicemail", SWITCH_PATH_SEPARATOR, myid); + } else { + dir_path = switch_mprintf("%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); + } } else { dir_path = switch_mprintf("%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR, @@ -2849,7 +2864,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, if (!message_len) { size_t len = 0; if (measure_file_len(file_path, &len) == SWITCH_STATUS_SUCCESS) { - message_len = len; + message_len = (uint32_t)len; } } @@ -2866,6 +2881,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-File-Path", file_path); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Flags", read_flags); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Folder", myfolder); + switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-UUID", use_uuid); switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Message-Len", "%u", message_len); switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Timestamp", "%lu", (unsigned long) switch_epoch_time_now(NULL)); @@ -3345,7 +3361,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p int send_mail = 0; cc_t cc = { 0 }; char *read_flags = NORMAL_FLAG_STRING; - char *operator_ext = NULL; + const char *operator_ext = switch_channel_get_variable(channel, "vm_operator_extension"); char buf[2]; char key_buf[80]; char *greet_path = NULL; @@ -3387,7 +3403,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p switch_assert(locate_params); switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "action", "voicemail-lookup"); - if (switch_xml_locate_user_merged("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"), + if (switch_xml_locate_user_merged("id:number-alias", id, domain_name, switch_channel_get_variable(channel, "network_addr"), &x_user, locate_params) == SWITCH_STATUS_SUCCESS) { id = switch_core_session_strdup(session, switch_xml_attr(x_user, "id")); @@ -3408,9 +3424,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p send_mail++; } else if (!strcasecmp(var, "vm-storage-dir")) { vm_storage_dir = switch_core_session_strdup(session, val); + } else if (!strcasecmp(var, "vm-domain-storage-dir")) { + storage_dir = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "storage-dir")) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "Using deprecated 'storage-dir' directory variable: Please use 'vm-storage-dir'.\n"); + "Using deprecated 'storage-dir' directory variable: Please use 'vm-domain-storage-dir'.\n"); storage_dir = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "vm-notify-email-all-messages") && (send_notify = switch_true(val))) { send_mail++; @@ -3422,7 +3440,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p vm_enabled = !switch_false(val); } else if (!strcasecmp(var, "vm-message-ext")) { vm_ext = switch_core_session_strdup(session, val); - } else if (!strcasecmp(var, "vm-operator-extension")) { + } else if (!strcasecmp(var, "vm-operator-extension") && (zstr(operator_ext))) { operator_ext = switch_core_session_strdup(session, val); } } @@ -3478,7 +3496,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p } else if (!zstr(storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, id); } else if (!zstr(profile->storage_dir)) { - dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id); + if (profile->storage_dir_shared) { + dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, "voicemail", SWITCH_PATH_SEPARATOR, id); + } else { + dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id); + } } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR, @@ -3662,7 +3684,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p if (x_user) { switch_channel_get_variables(channel, &vars); - status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars, + status = deliver_vm(profile, x_user, domain_name, file_path, (uint32_t)message_len, read_flags, vars, switch_core_session_get_pool(session), caller_id_name, caller_id_number, NULL, SWITCH_FALSE, session ? switch_core_session_get_uuid(session) : NULL, session); switch_event_destroy(&vars); @@ -3677,8 +3699,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", duration.hr, duration.min, duration.sec); + switch_channel_set_variable(channel, "voicemail_account", id); + switch_channel_set_variable(channel, "voicemail_domain", domain_name); + switch_channel_set_variable(channel, "voicemail_file_path", file_path); + switch_channel_set_variable(channel, "voicemail_read_flags", read_flags); switch_channel_set_variable(channel, "voicemail_message_len", duration_str); - } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to deliver message\n"); TRY_CODE(switch_ivr_phrase_macro(session, VM_ACK_MACRO, "deleted", NULL, NULL)); @@ -3688,10 +3713,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p end: - if (x_user) { - switch_xml_free(x_user); - x_user = NULL; - } + xml_safe_free(x_user); switch_safe_free(file_path); @@ -5688,7 +5710,7 @@ SWITCH_STANDARD_API(vm_fsdb_auth_login_function) } switch_event_create(¶ms, SWITCH_EVENT_GENERAL); - if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) { + if (switch_xml_locate_user_merged("id:number-alias", id, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", id, domain); stream->write_function(stream, "-ERR User not found\n"); } else { @@ -5743,7 +5765,8 @@ SWITCH_STANDARD_API(vm_fsdb_auth_login_function) } } - switch_xml_free(x_user); + xml_safe_free(x_user); + profile_rwunlock(profile); done: switch_core_destroy_memory_pool(&pool); diff --git a/src/mod/applications/mod_voicemail_ivr/config.c b/src/mod/applications/mod_voicemail_ivr/config.c index 3561c9edc5..b0cf543411 100644 --- a/src/mod/applications/mod_voicemail_ivr/config.c +++ b/src/mod/applications/mod_voicemail_ivr/config.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/config.h b/src/mod/applications/mod_voicemail_ivr/config.h index fbd5803b3b..8eb124a48b 100644 --- a/src/mod/applications/mod_voicemail_ivr/config.h +++ b/src/mod/applications/mod_voicemail_ivr/config.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/ivr.c b/src/mod/applications/mod_voicemail_ivr/ivr.c index 8f7cfb0582..a2b0af2d9e 100644 --- a/src/mod/applications/mod_voicemail_ivr/ivr.c +++ b/src/mod/applications/mod_voicemail_ivr/ivr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/ivr.h b/src/mod/applications/mod_voicemail_ivr/ivr.h index 31f95732b5..b2ad3d1ad4 100644 --- a/src/mod/applications/mod_voicemail_ivr/ivr.h +++ b/src/mod/applications/mod_voicemail_ivr/ivr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/menu.c b/src/mod/applications/mod_voicemail_ivr/menu.c index 33dde51952..54393da349 100644 --- a/src/mod/applications/mod_voicemail_ivr/menu.c +++ b/src/mod/applications/mod_voicemail_ivr/menu.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -97,6 +97,13 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) { cmd = switch_core_session_sprintf(session, "json %s %s %s %s", profile->api_profile, profile->domain, profile->id, profile->folder_name); jsonapi2event(session, menu.phrase_params, profile->api_msg_count, cmd); + /* Verify that phrases returned values, if not, exit */ + if (!switch_event_get_header(menu.phrase_params, "VM-Total-New-Messages")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Return from API is invalid. Check that the context exist on your DB backend\n"); + menu_instance_free(&menu); + break; + } + ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "msg_count"), NULL, menu.phrase_params, NULL, 0); if (atoi(switch_event_get_header(menu.phrase_params, "VM-Total-New-Messages")) > 0 && menu.ivre_d.result == RES_WAITFORMORE && !action_on_new_message_occured && action_on_new_message) { diff --git a/src/mod/applications/mod_voicemail_ivr/menu.h b/src/mod/applications/mod_voicemail_ivr/menu.h index 1f91b658f6..ff6b43c82b 100644 --- a/src/mod/applications/mod_voicemail_ivr/menu.h +++ b/src/mod/applications/mod_voicemail_ivr/menu.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c b/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c index 6ca939a4c1..006fde5fa8 100644 --- a/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c +++ b/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/utils.c b/src/mod/applications/mod_voicemail_ivr/utils.c index 1f065a55f0..73f58b84b2 100644 --- a/src/mod/applications/mod_voicemail_ivr/utils.c +++ b/src/mod/applications/mod_voicemail_ivr/utils.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/utils.h b/src/mod/applications/mod_voicemail_ivr/utils.h index c8e9ca0868..11219d1aad 100644 --- a/src/mod/applications/mod_voicemail_ivr/utils.h +++ b/src/mod/applications/mod_voicemail_ivr/utils.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c index 51b180ed88..b00b709354 100644 --- a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c +++ b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/asr_tts/mod_flite/mod_flite.c b/src/mod/asr_tts/mod_flite/mod_flite.c index a596b920f5..c9cb69f6f6 100644 --- a/src/mod/asr_tts/mod_flite/mod_flite.c +++ b/src/mod/asr_tts/mod_flite/mod_flite.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.2012.vcxproj b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.2012.vcxproj index 9b4ce7bee3..58db0d5129 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.2012.vcxproj +++ b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -92,6 +92,7 @@ true Windows MachineX86 + false if not exist "$(OutDir)grammar\model\communicator" xcopy "$(SolutionDir)libs\Communicator_semi_40.cd_semi_6000\*.*" "$(OutDir)..\grammar\model\communicator" /C /D /Y /S /I diff --git a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c index df99eed95e..f7cef99573 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c +++ b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c @@ -294,7 +294,7 @@ static switch_bool_t stop_detect(pocketsphinx_t *ps, int16_t *data, unsigned int /* Check silence timeouts */ if (ps->silence_time && switch_test_flag(ps, PSFLAG_INPUT_TIMERS)) { - int elapsed_ms = (switch_micro_time_now() - ps->silence_time) / 1000; + switch_time_t elapsed_ms = (switch_micro_time_now() - ps->silence_time) / 1000; if (switch_test_flag(ps, PSFLAG_START_OF_SPEECH)) { if (ps->speech_timeout > 0 && !switch_test_flag(ps, PSFLAG_SPEECH_TIMEOUT) && elapsed_ms >= ps->speech_timeout) { switch_set_flag_locked(ps, PSFLAG_SPEECH_TIMEOUT); diff --git a/src/mod/codecs/mod_amr/mod_amr.c b/src/mod/codecs/mod_amr/mod_amr.c index a167261df7..ec9723781a 100644 --- a/src/mod/codecs/mod_amr/mod_amr.c +++ b/src/mod/codecs/mod_amr/mod_amr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_amrwb/mod_amrwb.c b/src/mod/codecs/mod_amrwb/mod_amrwb.c index 805cf62335..082fc7f021 100644 --- a/src/mod/codecs/mod_amrwb/mod_amrwb.c +++ b/src/mod/codecs/mod_amrwb/mod_amrwb.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_b64/mod_b64.c b/src/mod/codecs/mod_b64/mod_b64.c index 8baee4a30b..a7180260af 100644 --- a/src/mod/codecs/mod_b64/mod_b64.c +++ b/src/mod/codecs/mod_b64/mod_b64.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_bv/mod_bv.c b/src/mod/codecs/mod_bv/mod_bv.c index 4ec7f16e02..352e171859 100644 --- a/src/mod/codecs/mod_bv/mod_bv.c +++ b/src/mod/codecs/mod_bv/mod_bv.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_celt/mod_celt.c b/src/mod/codecs/mod_celt/mod_celt.c index 6ba806aca0..6ca3d4a6ba 100644 --- a/src/mod/codecs/mod_celt/mod_celt.c +++ b/src/mod/codecs/mod_celt/mod_celt.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_codec2/mod_codec2.c b/src/mod/codecs/mod_codec2/mod_codec2.c index 3eb8620c9d..bb70bf8c46 100644 --- a/src/mod/codecs/mod_codec2/mod_codec2.c +++ b/src/mod/codecs/mod_codec2/mod_codec2.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c b/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c index 4b8864f2d1..5927d16ae7 100644 --- a/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c +++ b/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_g723_1/mod_g723_1.c b/src/mod/codecs/mod_g723_1/mod_g723_1.c index 62f9e2dde4..4e565a129a 100644 --- a/src/mod/codecs/mod_g723_1/mod_g723_1.c +++ b/src/mod/codecs/mod_g723_1/mod_g723_1.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_g729/mod_g729.c b/src/mod/codecs/mod_g729/mod_g729.c index 78ec62ffae..2dfb1275b0 100644 --- a/src/mod/codecs/mod_g729/mod_g729.c +++ b/src/mod/codecs/mod_g729/mod_g729.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_h26x/mod_h26x.c b/src/mod/codecs/mod_h26x/mod_h26x.c index 08aabc678e..b3ef2e55d3 100644 --- a/src/mod/codecs/mod_h26x/mod_h26x.c +++ b/src/mod/codecs/mod_h26x/mod_h26x.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_ilbc/mod_ilbc.c b/src/mod/codecs/mod_ilbc/mod_ilbc.c index 2ac024a969..f472cc46b0 100644 --- a/src/mod/codecs/mod_ilbc/mod_ilbc.c +++ b/src/mod/codecs/mod_ilbc/mod_ilbc.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_isac/isac.c b/src/mod/codecs/mod_isac/isac.c index 2199d571f9..6c03726fca 100644 --- a/src/mod/codecs/mod_isac/isac.c +++ b/src/mod/codecs/mod_isac/isac.c @@ -2636,8 +2636,8 @@ WebRtc_Word16 WebRtcIsac_SetEncSampRate( { ISACUBStruct* instUB = &(instISAC->instUB); ISACLBStruct* instLB = &(instISAC->instLB); - double bottleneckLB; - double bottleneckUB; + double bottleneckLB = 0; + double bottleneckUB = 0; WebRtc_Word32 bottleneck = instISAC->bottleneck; WebRtc_Word16 codingMode = instISAC->codingMode; WebRtc_Word16 frameSizeMs = instLB->ISACencLB_obj.new_framelength / (FS / 1000); diff --git a/src/mod/codecs/mod_isac/mod_iSAC.2012.vcxproj b/src/mod/codecs/mod_isac/mod_iSAC.2012.vcxproj index 755af1405b..3e57aaf548 100644 --- a/src/mod/codecs/mod_isac/mod_iSAC.2012.vcxproj +++ b/src/mod/codecs/mod_isac/mod_iSAC.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,10 +68,29 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + _CRT_SECURE_NO_WARNINGS;_DEBUG;DEBUG;%(PreprocessorDefinitions) + 4206;4100;4244;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -86,6 +105,9 @@ + _CRT_SECURE_NO_WARNINGS;_DEBUG;DEBUG;%(PreprocessorDefinitions) + 4206;4100;4244;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -98,6 +120,9 @@ + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4206;4100;4244;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -112,6 +137,9 @@ + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4206;4100;4244;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false diff --git a/src/mod/codecs/mod_isac/mod_isac.c b/src/mod/codecs/mod_isac/mod_isac.c index 23c90c2b15..0685878811 100644 --- a/src/mod/codecs/mod_isac/mod_isac.c +++ b/src/mod/codecs/mod_isac/mod_isac.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_mp4v/mod_mp4v.c b/src/mod/codecs/mod_mp4v/mod_mp4v.c index 338a31f2f1..cc77a3d4e8 100644 --- a/src/mod/codecs/mod_mp4v/mod_mp4v.c +++ b/src/mod/codecs/mod_mp4v/mod_mp4v.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_opus/Makefile b/src/mod/codecs/mod_opus/Makefile index 53ad7d5ffa..39284c1f8e 100644 --- a/src/mod/codecs/mod_opus/Makefile +++ b/src/mod/codecs/mod_opus/Makefile @@ -1,6 +1,6 @@ BASE=../../../.. -OPUS=opus-1.0.3 +OPUS=opus-1.1-p2 OPUS_DIR=$(switch_srcdir)/libs/$(OPUS) OPUS_BUILDDIR=$(switch_builddir)/libs/$(OPUS) diff --git a/src/mod/codecs/mod_opus/mod_opus.2010.vcxproj b/src/mod/codecs/mod_opus/mod_opus.2010.vcxproj new file mode 100644 index 0000000000..412d5c4cbf --- /dev/null +++ b/src/mod/codecs/mod_opus/mod_opus.2010.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB} + mod_opus + Win32Proj + mod_opus + + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + + + false + + + + + + + X64 + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + + + false + + + MachineX64 + + + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + + + false + + + + + + + X64 + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + + + false + + + MachineX64 + + + + + + + + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} + true + false + false + true + false + + + {245603e3-f580-41a5-9632-b25fe3372cbf} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + diff --git a/src/mod/codecs/mod_opus/mod_opus.2012.vcxproj b/src/mod/codecs/mod_opus/mod_opus.2012.vcxproj new file mode 100644 index 0000000000..097abe74ce --- /dev/null +++ b/src/mod/codecs/mod_opus/mod_opus.2012.vcxproj @@ -0,0 +1,160 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {64E99CCA-3C6F-4AEB-9FA3-CFAC711257BB} + mod_opus + Win32Proj + mod_opus + + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) + + + false + + + + + + + X64 + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) + + + false + + + MachineX64 + + + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) + + + false + + + + + + + X64 + + + ..\..\..\..\libs\opus-1.1\include;%(AdditionalIncludeDirectories) + + + 6053;6340;6246;6011;6387;%(DisableSpecificWarnings) + + + false + + + MachineX64 + + + + + + + + {FD60942F-72D6-4CA1-8B57-EA1D1B95A89E} + true + false + false + true + false + + + {245603e3-f580-41a5-9632-b25fe3372cbf} + + + {c303d2fc-ff97-49b8-9ddd-467b4c9a0b16} + + + {9c4961d2-5ddb-40c7-9be8-ca918dc4e782} + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + \ No newline at end of file diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c index b1681ea5fa..b7c3c51e12 100644 --- a/src/mod/codecs/mod_opus/mod_opus.c +++ b/src/mod/codecs/mod_opus/mod_opus.c @@ -1,6 +1,6 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -22,8 +22,9 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * + * * Brian K. West + * Noel Morgan * * mod_opus.c -- The OPUS ultra-low delay audio codec (http://www.opus-codec.org/) * @@ -36,81 +37,294 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load); SWITCH_MODULE_DEFINITION(mod_opus, mod_opus_load, NULL, NULL); +/*! \brief Various codec settings */ +struct opus_codec_settings { + int useinbandfec; + int usedtx; + int maxaveragebitrate; + int stereo; + int cbr; + int sprop_maxcapturerate; + int sprop_stereo; + int maxptime; + int minptime; + int ptime; + int samplerate; +}; +typedef struct opus_codec_settings opus_codec_settings_t; + +static opus_codec_settings_t default_codec_settings = { + /*.useinbandfec */ 1, + /*.usedtx */ 1, + /*.maxaveragebitrate */ 30000, + /*.stereo*/ 0, + /*.cbr*/ 0, + /*.sprop_maxcapturerate*/ 0, + /*.sprop_stereo*/ 0, + /*.maxptime*/ 0, + /*.minptime*/ 0, + /*.ptime*/ 0, + /*.samplerate*/ 0 +}; + struct opus_context { OpusEncoder *encoder_object; OpusDecoder *decoder_object; int frame_size; }; +struct { + int use_vbr; + int complexity; + switch_mutex_t *mutex; +} opus_prefs; + + +static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmtp_t *codec_fmtp) +{ + if (codec_fmtp) { + opus_codec_settings_t local_settings = { 0 }; + opus_codec_settings_t *codec_settings = &local_settings; + + if (codec_fmtp->private_info) { + codec_settings = codec_fmtp->private_info; + if (zstr(fmtp)) { + memcpy(codec_settings, &default_codec_settings, sizeof(*codec_settings)); + } + } + + if (fmtp) { + int x, argc; + char *argv[10]; + char *fmtp_dup = strdup(fmtp); + + switch_assert(fmtp_dup); + + argc = switch_separate_string(fmtp_dup, ';', argv, (sizeof(argv) / sizeof(argv[0]))); + for (x = 0; x < argc; x++) { + char *data = argv[x]; + char *arg; + switch_assert(data); + while (*data == ' ') { + data++; + } + + + if ((arg = strchr(data, '='))) { + *arg++ = '\0'; + + if (codec_settings) { + if (!strcasecmp(data, "useinbandfec")) { + codec_settings->useinbandfec = switch_true(arg); + } + + if (!strcasecmp(data, "usedtx")) { + codec_settings->usedtx = switch_true(arg); + } + + if (!strcasecmp(data, "sprop-maxcapturerate")) { + codec_settings->sprop_maxcapturerate = atoi(arg); + } + + if (!strcasecmp(data, "maxptime")) { + codec_settings->maxptime = atoi(arg); + } + + if (!strcasecmp(data, "minptime")) { + codec_settings->minptime = atoi(arg); + } + + if (!strcasecmp(data, "ptime")) { + codec_settings->ptime = atoi(arg); + codec_fmtp->microseconds_per_packet = codec_settings->ptime * 1000; + } + + if (!strcasecmp(data, "samplerate")) { + codec_settings->samplerate = atoi(arg); + codec_fmtp->actual_samples_per_second = codec_settings->samplerate; + } + + if (!strcasecmp(data, "maxaveragebitrate")) { + codec_settings->maxaveragebitrate = atoi(arg); + switch(codec_fmtp->actual_samples_per_second) { + case 8000: + { + if(codec_settings->maxaveragebitrate < 6000 || codec_settings->maxaveragebitrate > 20000) { + codec_settings->maxaveragebitrate = 20000; + } + break; + } + case 12000: + { + if(codec_settings->maxaveragebitrate < 7000 || codec_settings->maxaveragebitrate > 25000) { + codec_settings->maxaveragebitrate = 25000; + } + break; + } + case 16000: + { + if(codec_settings->maxaveragebitrate < 8000 || codec_settings->maxaveragebitrate > 30000) { + codec_settings->maxaveragebitrate = 30000; + } + break; + } + case 24000: + { + if(codec_settings->maxaveragebitrate < 12000 || codec_settings->maxaveragebitrate > 40000) { + codec_settings->maxaveragebitrate = 40000; + } + break; + } + + default: + /* this should never happen but 20000 is common among all rates */ + codec_settings->maxaveragebitrate = 20000; + break; + } + + + codec_fmtp->bits_per_second = codec_settings->maxaveragebitrate; + } + + } + } + } + free(fmtp_dup); + } + //codec_fmtp->bits_per_second = bit_rate; + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +static char *gen_fmtp(opus_codec_settings_t *settings, switch_memory_pool_t *pool) +{ + char buf[256] = ""; + + if (settings->useinbandfec) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "useinbandfec=1;"); + } + + if (settings->usedtx) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "usedtx=1;"); + } + + if (settings->maxaveragebitrate) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxaveragebitrate=%d;", settings->maxaveragebitrate); + + } + + if (settings->ptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "ptime=%d;", settings->ptime); + } + + if (settings->minptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "minptime=%d;", settings->minptime); + } + + if (settings->maxptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxptime=%d;", settings->maxptime); + } + + if (settings->samplerate) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "samplerate=%d;", settings->samplerate); + } + + if (end_of(buf) == ';') { + end_of(buf) = '\0'; + } + + return switch_core_strdup(pool, buf); + +} + static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) { struct opus_context *context = NULL; int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); int decoding = (flags & SWITCH_CODEC_FLAG_DECODE); - + switch_codec_fmtp_t codec_fmtp; + opus_codec_settings_t opus_codec_settings = { 0 }; + if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) { return SWITCH_STATUS_FALSE; } - + context->frame_size = codec->implementation->samples_per_packet; - + + memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp)); + codec_fmtp.private_info = &opus_codec_settings; + switch_opus_fmtp_parse(codec->fmtp_in, &codec_fmtp); + + codec->fmtp_out = gen_fmtp(&opus_codec_settings, codec->memory_pool); + if (encoding) { /* come up with a way to specify these */ - int bitrate_bps = codec->implementation->bits_per_second; - int use_vbr = 1; - int complexity = 10; - int use_inbandfec = 1; - int use_dtx = 1; - int bandwidth = OPUS_BANDWIDTH_FULLBAND; + int bitrate_bps = OPUS_AUTO; + int use_vbr = opus_prefs.use_vbr; + int complexity = opus_prefs.complexity; int err; - - context->encoder_object = opus_encoder_create(codec->implementation->actual_samples_per_second, + int samplerate = opus_codec_settings.samplerate ? opus_codec_settings.samplerate : codec->implementation->actual_samples_per_second; + + context->encoder_object = opus_encoder_create(samplerate, codec->implementation->number_of_channels, OPUS_APPLICATION_VOIP, &err); - - if (err != OPUS_OK) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create encoder: %s\n", opus_strerror(err)); - return SWITCH_STATUS_GENERR; - } - + + if (err != OPUS_OK) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create encoder: %s\n", opus_strerror(err)); + return SWITCH_STATUS_GENERR; + } + opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(bandwidth)); + + if (codec->implementation->actual_samples_per_second == 8000) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); + opus_encoder_ctl(context->encoder_object, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); + } else { + opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); + } + opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(use_vbr)); opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(use_inbandfec)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_DTX(use_dtx)); - + + if (opus_codec_settings.useinbandfec) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(opus_codec_settings.useinbandfec)); + } + + if (opus_codec_settings.usedtx) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_DTX(opus_codec_settings.usedtx)); + } } if (decoding) { int err; - - context->decoder_object = opus_decoder_create(codec->implementation->actual_samples_per_second, + + context->decoder_object = opus_decoder_create(codec->implementation->actual_samples_per_second, codec->implementation->number_of_channels, &err); - + if (err != OPUS_OK) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create decoder: %s\n", opus_strerror(err)); - + if (context->encoder_object) { opus_encoder_destroy(context->encoder_object); context->encoder_object = NULL; } - + return SWITCH_STATUS_GENERR; } - + } - + codec->private_info = context; - + return SWITCH_STATUS_SUCCESS; } static switch_status_t switch_opus_destroy(switch_codec_t *codec) { struct opus_context *context = codec->private_info; - + if (context) { if (context->decoder_object) { opus_decoder_destroy(context->decoder_object); @@ -121,7 +335,7 @@ static switch_status_t switch_opus_destroy(switch_codec_t *codec) context->encoder_object = NULL; } } - + codec->private_info = NULL; return SWITCH_STATUS_SUCCESS; } @@ -136,20 +350,20 @@ static switch_status_t switch_opus_encode(switch_codec_t *codec, struct opus_context *context = codec->private_info; int bytes = 0; int len = (int) *encoded_data_len; - + if (!context) { return SWITCH_STATUS_FALSE; } - + if (len > 1275) len = 1275; - + bytes = opus_encode(context->encoder_object, (void *) decoded_data, decoded_data_len / 2, (unsigned char *) encoded_data, len); - + if (bytes > 0) { *encoded_data_len = (uint32_t) bytes; return SWITCH_STATUS_SUCCESS; } - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoder Error!\n"); return SWITCH_STATUS_GENERR; } @@ -163,22 +377,53 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, { struct opus_context *context = codec->private_info; int samples = 0; - + if (!context) { return SWITCH_STATUS_FALSE; } samples = opus_decode(context->decoder_object, (*flag & SFF_PLC) ? NULL : encoded_data, encoded_data_len, decoded_data, *decoded_data_len, 0); - + if (samples < 0) { return SWITCH_STATUS_GENERR; } - + *decoded_data_len = samples * 2; return SWITCH_STATUS_SUCCESS; } +static switch_status_t opus_load_config(switch_bool_t reload) +{ + char *cf = "opus.conf"; + switch_xml_t cfg, xml = NULL, param, settings; + switch_status_t status = SWITCH_STATUS_SUCCESS; + + if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf); + status = SWITCH_STATUS_TERM; + } + + if ((settings = switch_xml_child(cfg, "settings"))) { + for (param = switch_xml_child(settings, "param"); param; param = param->next) { + char *key = (char *) switch_xml_attr_soft(param, "name"); + char *val = (char *) switch_xml_attr_soft(param, "value"); + + if (!strcasecmp(key, "use-vbr") && !zstr(val)) { + opus_prefs.use_vbr = atoi(val); + } else if (!strcasecmp(key, "complexity")) { + opus_prefs.complexity = atoi(val); + } + } + } + + if (xml) { + switch_xml_free(xml); + } + + return status; +} + SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) { switch_codec_interface_t *codec_interface; @@ -187,19 +432,38 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) int mss = 10000; int x = 0; int rate = 48000; - int bits = 32000; - + int bits = 0; + char *dft_fmtp = NULL; + opus_codec_settings_t settings = { 0 }; + switch_status_t status = SWITCH_FALSE; + + if ((status = opus_load_config(SWITCH_FALSE)) != SWITCH_STATUS_SUCCESS) { + return status; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); - + SWITCH_ADD_CODEC(codec_interface, "OPUS (STANDARD)"); - + + codec_interface->parse_fmtp = switch_opus_fmtp_parse; + + settings = default_codec_settings; + + for (x = 0; x < 3; x++) { + + settings.ptime = mss / 1000; + settings.maxptime = settings.ptime; + settings.minptime = settings.ptime; + settings.samplerate = rate; + dft_fmtp = gen_fmtp(&settings, pool); + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */ 116, /* the IANA code number */ "opus",/* the IANA code name */ - NULL, /* default fmtp to send (can be overridden by the init function) */ - rate, /* samples transferred per second */ + dft_fmtp, /* default fmtp to send (can be overridden by the init function) */ + 48000, /* samples transferred per second */ rate, /* actual samples transferred per second */ bits, /* bits transferred per second */ mss, /* number of microseconds per frame */ @@ -216,9 +480,47 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) bytes *= 2; samples *= 2; mss *= 2; - + } + + samples = 80; + bytes = 160; + mss = 10000; + rate = 8000; + + for (x = 0; x < 3; x++) { + + settings.ptime = mss / 1000; + settings.maxptime = settings.ptime; + settings.minptime = settings.ptime; + settings.samplerate = rate; + dft_fmtp = gen_fmtp(&settings, pool); + + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */ + 116, /* the IANA code number */ + "opus",/* the IANA code name */ + dft_fmtp, /* default fmtp to send (can be overridden by the init function) */ + 48000, /* samples transferred per second */ + rate, /* actual samples transferred per second */ + bits, /* bits transferred per second */ + mss, /* number of microseconds per frame */ + samples, /* number of samples per frame */ + bytes, /* number of bytes per frame decompressed */ + 0, /* number of bytes per frame compressed */ + 1,/* number of channels represented */ + 1, /* number of frames per network packet */ + switch_opus_init, /* function to initialize a codec handle using this implementation */ + switch_opus_encode, /* function to encode raw data into encoded data */ + switch_opus_decode, /* function to decode encoded data into raw data */ + switch_opus_destroy); /* deinitalize a codec handle using this implementation */ + + bytes += 160; + samples += 80; + mss += 10000; + + } + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/codecs/mod_silk/mod_silk.2012.vcxproj b/src/mod/codecs/mod_silk/mod_silk.2012.vcxproj index 85b6633e82..4beb873f77 100644 --- a/src/mod/codecs/mod_silk/mod_silk.2012.vcxproj +++ b/src/mod/codecs/mod_silk/mod_silk.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -73,6 +73,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\silk\interface;%(AdditionalIncludeDirectories) + /analyze:stacksize65535 false diff --git a/src/mod/codecs/mod_silk/mod_silk.c b/src/mod/codecs/mod_silk/mod_silk.c index c585548ea6..7817801741 100644 --- a/src/mod/codecs/mod_silk/mod_silk.c +++ b/src/mod/codecs/mod_silk/mod_silk.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -287,13 +287,13 @@ static switch_status_t switch_silk_encode(switch_codec_t *codec, { struct silk_context *context = codec->private_info; SKP_int16 ret; - SKP_int16 pktsz = context->encoder_object.packetSize; + SKP_int16 pktsz = (SKP_int16)context->encoder_object.packetSize; SKP_int16 nBytes = MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES; SKP_int16 *lindata = (SKP_int16 *)decoded_data; - SKP_int16 samples = decoded_data_len /sizeof(SKP_int16); + SKP_int16 samples = (SKP_int16)(decoded_data_len /sizeof(SKP_int16)); *encoded_data_len = 0; while (samples >= pktsz){ - ret = SKP_Silk_SDK_Encode(context->enc_state, + ret = (SKP_int16)SKP_Silk_SDK_Encode(context->enc_state, &context->encoder_object, lindata, pktsz, @@ -345,9 +345,9 @@ static switch_status_t switch_silk_decode(switch_codec_t *codec, } if (jb && codec && codec->cur_frame) { for (i = 1; i <= MAX_LBRR_DELAY; i++) { - found_frame = stfu_n_copy_next_frame(jb, codec->cur_frame->timestamp, codec->cur_frame->seq, i, &next_frame); + found_frame = stfu_n_copy_next_frame(jb, (uint32_t)codec->cur_frame->timestamp, codec->cur_frame->seq, (uint16_t)i, &next_frame); if (found_frame) { - SKP_Silk_SDK_search_for_LBRR(next_frame.data, next_frame.dlen, i, (SKP_uint8*) &recbuff, &reclen); + SKP_Silk_SDK_search_for_LBRR(next_frame.data, (const int)next_frame.dlen, i, (SKP_uint8*) &recbuff, &reclen); if (reclen) { encoded_data = &recbuff; encoded_data_len = reclen; @@ -361,7 +361,7 @@ static switch_status_t switch_silk_decode(switch_codec_t *codec, } do { - ret = SKP_Silk_SDK_Decode(context->dec_state, + ret = (SKP_int16)SKP_Silk_SDK_Decode(context->dec_state, &context->decoder_object, lost_flag, encoded_data, diff --git a/src/mod/codecs/mod_siren/mod_siren.c b/src/mod/codecs/mod_siren/mod_siren.c index 5f444e1001..783f47427b 100644 --- a/src/mod/codecs/mod_siren/mod_siren.c +++ b/src/mod/codecs/mod_siren/mod_siren.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_skel_codec/mod_skel_codec.c b/src/mod/codecs/mod_skel_codec/mod_skel_codec.c index 26650cd35c..e83ccc0a6e 100644 --- a/src/mod/codecs/mod_skel_codec/mod_skel_codec.c +++ b/src/mod/codecs/mod_skel_codec/mod_skel_codec.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_speex/Makefile b/src/mod/codecs/mod_speex/Makefile deleted file mode 100644 index b0cbef2909..0000000000 --- a/src/mod/codecs/mod_speex/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -BASE=../../../.. - -SPEEX_DIR=$(switch_srcdir)/libs/speex -SPEEX_BUILDDIR=$(switch_builddir)/libs/speex -SPEEXLA=$(SPEEX_BUILDDIR)/libspeex/libspeex.la -SPEEXDSPLA=$(SPEEX_BUILDDIR)/libspeex/libspeexdsp.la - -LOCAL_CFLAGS=-I$(SPEEX_DIR)/include -I$(SPEEX_BUILDDIR)/include -LOCAL_LIBADD=$(SPEEXLA) $(SPEEXDSPLA) -include $(BASE)/build/modmake.rules - -$(SPEEXLA): $(SPEEX_DIR) $(SPEEX_DIR)/.update - cd $(SPEEX_BUILDDIR)/libspeex && $(MAKE) - $(TOUCH_TARGET) - -$(SPEEXDSPLA): $(SPEEX_DIR) $(SPEEX_DIR)/.update - cd $(SPEEX_BUILDDIR)/libspeex && $(MAKE) - $(TOUCH_TARGET) - diff --git a/src/mod/codecs/mod_speex/conf/autoload_configs/speex.conf.xml b/src/mod/codecs/mod_speex/conf/autoload_configs/speex.conf.xml deleted file mode 100644 index 220229037a..0000000000 --- a/src/mod/codecs/mod_speex/conf/autoload_configs/speex.conf.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/codecs/mod_speex/mod_speex.vcproj b/src/mod/codecs/mod_speex/mod_speex.vcproj deleted file mode 100644 index 2b4eed2ac7..0000000000 --- a/src/mod/codecs/mod_speex/mod_speex.vcproj +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/codecs/mod_theora/mod_theora.c b/src/mod/codecs/mod_theora/mod_theora.c index 8d236270ca..6cc4039856 100644 --- a/src/mod/codecs/mod_theora/mod_theora.c +++ b/src/mod/codecs/mod_theora/mod_theora.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c b/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c index 23db701f92..48a8a143fd 100644 --- a/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c +++ b/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/codecs/mod_vp8/mod_vp8.c b/src/mod/codecs/mod_vp8/mod_vp8.c index 121b9ab0c9..8eb0f9630c 100644 --- a/src/mod/codecs/mod_vp8/mod_vp8.c +++ b/src/mod/codecs/mod_vp8/mod_vp8.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -83,9 +83,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vp8_load) /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_CODEC(codec_interface, "VP8 Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_VIDEO, 99, "VP8", NULL, 90000, 90000, 0, 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + + SWITCH_ADD_CODEC(codec_interface, "red Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, + SWITCH_CODEC_TYPE_VIDEO, 103, "red", NULL, 90000, 90000, 0, + 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + + SWITCH_ADD_CODEC(codec_interface, "ulpfec Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, + SWITCH_CODEC_TYPE_VIDEO, 104, "ulpfec", NULL, 90000, 90000, 0, + 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c index 4670279efe..1996168663 100644 --- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c +++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c index 65b7a47e8d..0997224dd8 100644 --- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c +++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -131,7 +131,7 @@ SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt) if ((data = strchr(app, ' ')) != 0) { *data++ = '\0'; } - switch_caller_extension_add_application(session, extension, app, data); + switch_caller_extension_add_application(session, extension, app, data ? data : ""); } } } diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c index 30bcdee997..b5ff5e63a6 100644 --- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c +++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -86,7 +86,7 @@ static switch_status_t exec_app(switch_core_session_t *session, const char *app, #define check_tz() \ do { \ tzoff = switch_channel_get_variable(channel, "tod_tz_offset"); \ - tzname = switch_channel_get_variable(channel, "timezone"); \ + tzname_ = switch_channel_get_variable(channel, "timezone"); \ if (!zstr(tzoff) && switch_is_number(tzoff)) { \ offset = atoi(tzoff); \ break; \ @@ -104,7 +104,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * char *expression_expanded = NULL, *field_expanded = NULL; switch_regex_t *re = NULL, *save_re = NULL; int offset = 0; - const char *tmp, *tzoff = NULL, *tzname = NULL, *req_nesta = NULL; + const char *tmp, *tzoff = NULL, *tzname_ = NULL, *req_nesta = NULL; char nbuf[128] = ""; int req_nest = 1; char space[MAX_RECUR_SPACE] = ""; @@ -171,7 +171,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * int time_match; check_tz(); - time_match = switch_xml_std_datetime_check(xcond, tzoff ? &offset : NULL, tzname); + time_match = switch_xml_std_datetime_check(xcond, tzoff ? &offset : NULL, tzname_); switch_safe_free(field_expanded); switch_safe_free(expression_expanded); @@ -227,7 +227,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * for (xregex = switch_xml_child(xcond, "regex"); xregex; xregex = xregex->next) { check_tz(); - time_match = switch_xml_std_datetime_check(xregex, tzoff ? &offset : NULL, tzname); + time_match = switch_xml_std_datetime_check(xregex, tzoff ? &offset : NULL, tzname_); if (time_match == 1) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, diff --git a/src/mod/directories/mod_ldap/mod_ldap.c b/src/mod/directories/mod_ldap/mod_ldap.c index 6dbf4baca4..18e06be046 100644 --- a/src/mod/directories/mod_ldap/mod_ldap.c +++ b/src/mod/directories/mod_ldap/mod_ldap.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_alsa/mod_alsa.c b/src/mod/endpoints/mod_alsa/mod_alsa.c index 55f4ca4ba3..884b5da17c 100644 --- a/src/mod/endpoints/mod_alsa/mod_alsa.c +++ b/src/mod/endpoints/mod_alsa/mod_alsa.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.2012.vcxproj b/src/mod/endpoints/mod_dingaling/mod_dingaling.2012.vcxproj index ab076891d8..4b3b2cfd6c 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.2012.vcxproj +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -121,6 +121,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\libdingaling\src;%(AdditionalIncludeDirectories) + 4718;6340;6246;6011;6387;%(DisableSpecificWarnings) $(ProjectDir)..\..\..\..\libs\libdingaling\$(OutDir);$(ProjectDir)..\..\..\..\libs\iksemel\$(OutDir);%(AdditionalLibraryDirectories) diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index e7ecaaf949..d2f6f20641 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1104,7 +1104,7 @@ static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t tty } - //if (tech_pvt->transports[ttype].crypto_type) { + if (tech_pvt->transports[ttype].crypto_type) { switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session, SWITCH_RTP_CRYPTO_SEND, 1, tech_pvt->transports[ttype].crypto_type, tech_pvt->transports[ttype].local_raw_key, SWITCH_RTP_KEY_LEN); @@ -1120,7 +1120,7 @@ static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t tty switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE, "%s %s crypto confirmed\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session)); - //} + } } @@ -1543,7 +1543,7 @@ static int do_tport_candidates(struct private_object *tech_pvt, ldl_transport_ty cand->port = tech_pvt->transports[ttype].adv_local_port; cand->address = address; - if (!strncasecmp(advip, "stun:", 5)) { + if (advip && !strncasecmp(advip, "stun:", 5)) { char *stun_ip = advip + 5; if (tech_pvt->transports[ttype].stun_ip) { @@ -1665,7 +1665,7 @@ static char *lame(char *in) static void setup_codecs(struct private_object *tech_pvt) { ldl_payload_t payloads[LDL_MAX_PAYLOADS] = { {0} }; - int idx = 0, i = 0; + unsigned int idx = 0, i = 0; int dft_audio = -1, dft_video = -1; memset(payloads, 0, sizeof(payloads)); @@ -2203,7 +2203,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch if (!switch_test_flag((&tech_pvt->transports[LDL_TPORT_RTP].read_frame), SFF_CNG)) { if ((bytes = tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->encoded_bytes_per_packet)) { - frames = (tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen / bytes); + frames = (int)(tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen / bytes); } tech_pvt->transports[LDL_TPORT_RTP].read_frame.samples = (int) (frames * tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet); } @@ -2341,7 +2341,7 @@ static switch_status_t channel_write_video_frame(switch_core_session_t *session, wrote = switch_rtp_write_frame(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, frame); } - return wrote > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR; + return wrote > -1 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR; } static switch_status_t channel_answer_channel(switch_core_session_t *session) @@ -2936,7 +2936,9 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) globals.auto_nat = 0; ip = zstr(val) ? globals.guess_ip : val; } - profile->extip = switch_core_strdup(module_pool, ip); + if (ip) { + profile->extip = switch_core_strdup(module_pool, ip); + } } else if (!strcasecmp(var, "server") && !zstr(val)) { profile->server = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "rtp-timer-name") && !zstr(val)) { @@ -4247,6 +4249,22 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi } tech_pvt->them = switch_core_session_strdup(session, ldl_session_get_callee(dlsession)); + + if (tech_pvt->them && (tmp = strdup(tech_pvt->them))) { + char *p, *q; + + if ((p = strchr(tmp, '@'))) { + *p++ = '\0'; + if ((q = strchr(p, '/'))) { + *q = '\0'; + } + switch_channel_set_variable(channel, "dl_to_user", tmp); + switch_channel_set_variable(channel, "dl_to_host", p); + } + + switch_safe_free(tmp); + } + tech_pvt->us = switch_core_session_strdup(session, ldl_session_get_caller(dlsession)); if (tech_pvt->us && (tmp = strdup(tech_pvt->us))) { diff --git a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen.h index 01388575b0..cf8561a683 100644 --- a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen.h @@ -76,7 +76,6 @@ #define GSMOPEN_ALSA #endif // NO_ALSA #include -#include #ifndef WIN32 #include #include @@ -132,7 +131,7 @@ //#define SAMPLES_PER_FRAME SAMPLERATE_GSMOPEN/50 #ifndef GSMOPEN_SVN_VERSION -#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL +#define GSMOPEN_SVN_VERSION switch_version_full() #endif /* GSMOPEN_SVN_VERSION */ typedef enum { @@ -441,6 +440,7 @@ struct private_object { char sms_message[4800]; char sms_sender[256]; char sms_date[256]; + char sms_userdataheader[256]; char sms_body[4800]; char sms_datacodingscheme[256]; char sms_servicecentreaddress[256]; diff --git a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen_protocol.c b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen_protocol.c index 00c83d0640..d8eb66aecc 100644 --- a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen_protocol.c +++ b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/gsmopen_protocol.c @@ -2095,6 +2095,8 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u DEBUGA_GSMOPEN("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str()); DEBUGA_GSMOPEN("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str()); DEBUGA_GSMOPEN("serviceCentreTimestamp=%s\n", GSMOPEN_P_LOG, sms->serviceCentreTimestamp().toString().c_str()); + DEBUGA_GSMOPEN("UserDataHeader=%s\n", GSMOPEN_P_LOG, (char *)bufToHex((unsigned char *) + ((string) sms->userDataHeader()).data(), sms->userDataHeader().length()).c_str()); DEBUGA_GSMOPEN("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType()); DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2); @@ -2105,6 +2107,9 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body)); strncpy(tech_pvt->sms_sender, sms->address().toString().c_str(), sizeof(tech_pvt->sms_sender)); strncpy(tech_pvt->sms_date, sms->serviceCentreTimestamp().toString().c_str(), sizeof(tech_pvt->sms_date)); + strncpy(tech_pvt->sms_userdataheader, (char *) + bufToHex((unsigned char *)((string) sms->userDataHeader()).data(), sms->userDataHeader().length()).c_str(), + sizeof(tech_pvt->sms_userdataheader)); strncpy(tech_pvt->sms_datacodingscheme, sms->dataCodingScheme().toString().c_str(), sizeof(tech_pvt->sms_datacodingscheme)); strncpy(tech_pvt->sms_servicecentreaddress, sms->serviceCentreAddress().toString().c_str(), sizeof(tech_pvt->sms_servicecentreaddress)); diff --git a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/mod_gsmopen.c b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/mod_gsmopen.c index f6c9605cb2..fc45ab9294 100644 --- a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/mod_gsmopen.c +++ b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/mod_gsmopen.c @@ -3307,6 +3307,7 @@ int sms_incoming(private_t * tech_pvt) //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "userdataheader", tech_pvt->sms_userdataheader); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "datacodingscheme", tech_pvt->sms_datacodingscheme); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "servicecentreaddress", tech_pvt->sms_servicecentreaddress); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "messagetype", "%d", tech_pvt->sms_messagetype); diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2012.vcxproj b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2012.vcxproj index c574a6c08e..607c07b215 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2012.vcxproj +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2012.vcxproj @@ -101,6 +101,7 @@ Level3 true /wd4290 /wd4996 %(AdditionalOptions) + 4101;4244;4554;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -108,6 +109,7 @@ true + /ignore:4221 %(AdditionalOptions) true @@ -126,6 +128,7 @@ true EditAndContinue /wd4290 /wd4996 %(AdditionalOptions) + 4101;4244;4554;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -135,6 +138,7 @@ true false %(IgnoreSpecificDefaultLibraries) + /ignore:4221 %(AdditionalOptions) true diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index b37fa77834..5aadb8a08b 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -66,7 +66,6 @@ #define SAMPLERATE_GSMOPEN 8000 #include -#include #ifndef WIN32 #include #include @@ -104,7 +103,7 @@ #endif #ifndef GSMOPEN_SVN_VERSION -#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL +#define GSMOPEN_SVN_VERSION switch_version_full() #endif /* GSMOPEN_SVN_VERSION */ #include "ctb-0.16/ctb.h" @@ -125,14 +124,14 @@ typedef enum { GFLAG_MY_CODEC_PREFS = (1 << 0) } GFLAGS; -#define DEBUGA_GSMOPEN(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][DEBUG_GSMOPEN %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "GSMOPEN_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define DEBUGA_GSMOPEN(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev %s [%p|%-7lx][DEBUG_GSMOPEN %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev %s [%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev %s [%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev %s [%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev %s [%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev %s [%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define GSMOPEN_P_LOG (void *)NULL, (unsigned long)55, __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", -1, tech_pvt ? tech_pvt->interface_state : -1, tech_pvt ? tech_pvt->phone_callflow : -1 +#define GSMOPEN_P_LOG GSMOPEN_SVN_VERSION, (void *)NULL, (unsigned long)55, __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", -1, tech_pvt ? tech_pvt->interface_state : -1, tech_pvt ? tech_pvt->phone_callflow : -1 /*********************************/ #define GSMOPEN_CAUSE_NORMAL 1 @@ -398,6 +397,7 @@ struct private_object { char sms_message[4800]; char sms_sender[256]; char sms_date[256]; + char sms_userdataheader[256]; char sms_body[4800]; char sms_datacodingscheme[256]; char sms_servicecentreaddress[256]; diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp index a52b8a1ac4..c490d36f37 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -1702,6 +1702,8 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us DEBUGA_GSMOPEN("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str()); DEBUGA_GSMOPEN("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str()); DEBUGA_GSMOPEN("serviceCentreTimestamp=%s\n", GSMOPEN_P_LOG, sms->serviceCentreTimestamp().toString().c_str()); + DEBUGA_GSMOPEN("UserDataHeader=%s\n", GSMOPEN_P_LOG, (char *)bufToHex((unsigned char *) + ((string) sms->userDataHeader()).data(), sms->userDataHeader().length()).c_str()); DEBUGA_GSMOPEN("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType()); DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2); @@ -1712,6 +1714,9 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body)); strncpy(tech_pvt->sms_sender, sms->address().toString().c_str(), sizeof(tech_pvt->sms_sender)); strncpy(tech_pvt->sms_date, sms->serviceCentreTimestamp().toString().c_str(), sizeof(tech_pvt->sms_date)); + strncpy(tech_pvt->sms_userdataheader, (char *) + bufToHex((unsigned char *)((string) sms->userDataHeader()).data(), sms->userDataHeader().length()).c_str(), + sizeof(tech_pvt->sms_userdataheader)); strncpy(tech_pvt->sms_datacodingscheme, sms->dataCodingScheme().toString().c_str(), sizeof(tech_pvt->sms_datacodingscheme)); strncpy(tech_pvt->sms_servicecentreaddress, sms->serviceCentreAddress().toString().c_str(), sizeof(tech_pvt->sms_servicecentreaddress)); diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2012.vcxproj b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2012.vcxproj index 004558e6b4..e6f6312c33 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2012.vcxproj +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2012.vcxproj @@ -73,7 +73,7 @@ false $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - AllRules.ruleset + NativeMinimumRules.ruleset AllRules.ruleset @@ -86,6 +86,9 @@ + + false + gsmlib\gsmlib-1.10-patched-13ubuntu;libctb-0.16\include;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) @@ -94,6 +97,8 @@ Level4 false + 4554;4324;4389;4244;4267;6340;6246;6011;6387;%(DisableSpecificWarnings) + false false @@ -107,6 +112,7 @@ gsmlib\gsmlib-1.10-patched-13ubuntu;libctb-0.16\include;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4554;4324;4389;4244;4267;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -126,6 +132,7 @@ Level4 false + 4554;4324;4389;4244;4267;6340;6246;6011;6387;%(DisableSpecificWarnings) false @@ -143,6 +150,7 @@ gsmlib\gsmlib-1.10-patched-13ubuntu;libctb-0.16\include;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4554;4324;4389;4244;4267;6340;6246;6011;6387;%(DisableSpecificWarnings) false diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index b3b3c1546c..881c1d8c87 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -296,9 +296,11 @@ static switch_status_t remove_interface(char *the_interface) switch_assert(the_interface); interface_id = atoi(the_interface); - if (interface_id > 0 || (interface_id == 0 && strcmp(the_interface, "0") == 0)) { - /* take a number as interface id */ - tech_pvt = &globals.GSMOPEN_INTERFACES[interface_id]; + if ((interface_id > 0 && interface_id < GSMOPEN_MAX_INTERFACES) || (interface_id == 0 && strcmp(the_interface, "0") == 0)) { + if (strlen(globals.GSMOPEN_INTERFACES[interface_id].name)) { + /* take a number as interface id */ + tech_pvt = &globals.GSMOPEN_INTERFACES[interface_id]; + } } else { for (interface_id = 0; interface_id < GSMOPEN_MAX_INTERFACES; interface_id++) { @@ -389,7 +391,6 @@ static switch_status_t remove_interface(char *the_interface) switch_mutex_unlock(globals.mutex); DEBUGA_GSMOPEN("interface '%s' deleted successfully\n", GSMOPEN_P_LOG, the_interface); - globals.GSMOPEN_INTERFACES[interface_id].running = 1; end: return SWITCH_STATUS_SUCCESS; @@ -1233,7 +1234,7 @@ static switch_status_t load_config(int reload_type) uint32_t interface_id = 0; int controldevice_speed = 115200; //FIXME TODO - int controldevice_audio_speed = 115200; //FIXME TODO + //int controldevice_audio_speed = 115200; //FIXME TODO uint32_t controldevprotocol = PROTOCOL_AT; //FIXME TODO uint32_t running = 1; //FIXME TODO const char *gsmopen_serial_sync_period = "300"; //FIXME TODO @@ -1472,7 +1473,7 @@ static switch_status_t load_config(int reload_type) if (interface_id && interface_id < GSMOPEN_MAX_INTERFACES) { private_t newconf; - int res = 0; + //int res = 0; memset(&newconf, '\0', sizeof(newconf)); globals.GSMOPEN_INTERFACES[interface_id] = newconf; @@ -1579,7 +1580,7 @@ static switch_status_t load_config(int reload_type) int res = 0; int interface_id = i; - if (strlen(globals.GSMOPEN_INTERFACES[i].name)) { + if (strlen(globals.GSMOPEN_INTERFACES[i].name) && !globals.GSMOPEN_INTERFACES[i].active) { WARNINGA("STARTING interface_id=%u\n", GSMOPEN_P_LOG, interface_id); DEBUGA_GSMOPEN("id=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].id); @@ -1680,7 +1681,7 @@ static switch_status_t load_config(int reload_type) for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) { if (strlen(globals.GSMOPEN_INTERFACES[i].name)) { /* How many real intterfaces */ - globals.real_interfaces = i + 1; + globals.real_interfaces++; tech_pvt = &globals.GSMOPEN_INTERFACES[i]; @@ -1707,7 +1708,7 @@ static switch_status_t load_config(int reload_type) static switch_status_t chat_send(switch_event_t *message_event) { - char *user, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL; + char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL; private_t *tech_pvt = NULL; int i = 0, found = 0; @@ -2225,7 +2226,7 @@ SWITCH_STANDARD_API(gsm_function) } stream->write_function(stream, "\nTotal Interfaces: %d IB Calls(Failed/Total): %u/%u OB Calls(Failed/Total): %u/%u\n", - globals.real_interfaces > 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob); + globals.real_interfaces > 0 ? globals.real_interfaces : 0, ib_failed, ib, ob_failed, ob); } else if (!strcasecmp(argv[0], "console")) { int i; @@ -2778,6 +2779,7 @@ int sms_incoming(private_t *tech_pvt) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "userdataheader", tech_pvt->sms_userdataheader); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "datacodingscheme", tech_pvt->sms_datacodingscheme); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "servicecentreaddress", tech_pvt->sms_servicecentreaddress); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "messagetype", "%d", tech_pvt->sms_messagetype); @@ -2797,6 +2799,7 @@ int sms_incoming(private_t *tech_pvt) memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message)); memset(tech_pvt->sms_sender, '\0', sizeof(tech_pvt->sms_sender)); memset(tech_pvt->sms_date, '\0', sizeof(tech_pvt->sms_date)); + memset(tech_pvt->sms_userdataheader, '\0', sizeof(tech_pvt->sms_userdataheader)); memset(tech_pvt->sms_body, '\0', sizeof(tech_pvt->sms_body)); memset(tech_pvt->sms_datacodingscheme, '\0', sizeof(tech_pvt->sms_datacodingscheme)); memset(tech_pvt->sms_servicecentreaddress, '\0', sizeof(tech_pvt->sms_servicecentreaddress)); @@ -2989,7 +2992,7 @@ void find_ttyusb_devices(private_t *tech_pvt, const char *dirname) usleep(200000); //0.2 seconds read_count = serialPort_serial_control->Read(f.answer, AT_BUFSIZ); if (read_count < 32) { - ERRORA("reading AT+GSN failed: |%s|, read_count=%d\n", GSMOPEN_P_LOG, f.answer, read_count); + ERRORA("reading AT+GSN failed: |%s|, read_count=%d, probably harmless in 'gsm reload'\n", GSMOPEN_P_LOG, f.answer, read_count); } else { strncpy(f.imei, f.answer+9, 15); sprintf(at_command, "AT\r\n"); diff --git a/src/mod/endpoints/mod_gsmopen/win_iconv.c b/src/mod/endpoints/mod_gsmopen/win_iconv.c index 94c8d4a1e7..4eb5433196 100644 --- a/src/mod/endpoints/mod_gsmopen/win_iconv.c +++ b/src/mod/endpoints/mod_gsmopen/win_iconv.c @@ -1510,7 +1510,7 @@ static int utf32_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { int codepage = cv->codepage; - uint wc; + uint wc = 0; /* swap endian: 12000 <-> 12001 */ if (cv->mode & UNICODE_MODE_SWAPPED) @@ -1752,8 +1752,8 @@ iso2022jp_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsi HRESULT hr; DWORD dummy = 0; int len; - int esc_len; - int cs; + int esc_len = 0; + int cs = 0; int shift; int i; diff --git a/src/mod/endpoints/mod_h323/mod_h323.h b/src/mod/endpoints/mod_h323/mod_h323.h index 3e046d1093..085f061d62 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.h +++ b/src/mod/endpoints/mod_h323/mod_h323.h @@ -61,7 +61,6 @@ #define HAVE_APR #include -#include #define MODNAME "mod_h323" #define OpalT38_IFP_COR GetOpalT38_IFP_COR() #define OpalT38_IFP_PRE GetOpalT38_IFP_PRE() diff --git a/src/mod/endpoints/mod_khomp/include/defs.h b/src/mod/endpoints/mod_khomp/include/defs.h index bcd5c3ce7b..5d72c95b72 100644 --- a/src/mod/endpoints/mod_khomp/include/defs.h +++ b/src/mod/endpoints/mod_khomp/include/defs.h @@ -45,7 +45,6 @@ #define _DEFS_H_ /* formatation macros */ -#include "switch_version.h" #include "revision.h" #define KHOMP_LOG __FILE__, __SWITCH_FUNC__, __LINE__ diff --git a/src/mod/endpoints/mod_khomp/mod_khomp.cpp b/src/mod/endpoints/mod_khomp/mod_khomp.cpp index f830cb5b59..5d59fc1c21 100644 --- a/src/mod/endpoints/mod_khomp/mod_khomp.cpp +++ b/src/mod/endpoints/mod_khomp/mod_khomp.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index aea8032433..8c0dd8c92e 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_opal/mod_opal.cpp b/src/mod/endpoints/mod_opal/mod_opal.cpp old mode 100644 new mode 100755 index 6f0fb3addd..7d97c29b51 --- a/src/mod/endpoints/mod_opal/mod_opal.cpp +++ b/src/mod/endpoints/mod_opal/mod_opal.cpp @@ -1031,7 +1031,7 @@ switch_status_t FSConnection::receive_message(switch_core_session_message_t *msg { PTRACE(2, "mod_opal\tRequesting switch to T.38"); PSafePtr other = GetOtherPartyConnection(); - if (other != NULL && other->SwitchT38(true)) + if (other != NULL && other->SwitchFaxMediaStreams(true)) switch_channel_set_flag(m_fsChannel, CF_REQ_MEDIA); else { PTRACE(1, "mod_opal\tMode change request to T.38 failed"); diff --git a/src/mod/endpoints/mod_opal/mod_opal.h b/src/mod/endpoints/mod_opal/mod_opal.h old mode 100644 new mode 100755 index 7b3993b0b2..4b0cd62a02 --- a/src/mod/endpoints/mod_opal/mod_opal.h +++ b/src/mod/endpoints/mod_opal/mod_opal.h @@ -32,13 +32,17 @@ #endif #include +#include -#if !defined(PTLIB_CHECK_VERSION) - #error PTLib is too old to use, must be >= 2.10.6 +#ifndef OPAL_CHECK_VERSION + #define OPAL_CHECK_VERSION(a,b,c) 0 #endif -#include -#include +#if !OPAL_CHECK_VERSION(3,12,8) + #error OPAL is too old to use, must be >= 2.12.8 +#endif + +#include #include #include @@ -53,11 +57,8 @@ #define MODNAME "mod_opal" -#ifndef OPAL_CHECK_VERSION - #define OPAL_CHECK_VERSION(a,b,c) 0 -#endif +#define HAVE_T38 OPAL_T38_CAPABILITY -#define HAVE_T38 (OPAL_CHECK_VERSION(3,11,2) && OPAL_T38_CAPABILITY) class FSEndPoint; diff --git a/src/mod/endpoints/mod_portaudio/mod_PortAudio.2012.vcxproj b/src/mod/endpoints/mod_portaudio/mod_PortAudio.2012.vcxproj index 08f20169ad..f28babf744 100644 --- a/src/mod/endpoints/mod_portaudio/mod_PortAudio.2012.vcxproj +++ b/src/mod/endpoints/mod_portaudio/mod_PortAudio.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,6 +68,22 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + %(RootDir)%(Directory)..\..\..\..\libs\portaudio\include;%(AdditionalIncludeDirectories) @@ -75,6 +91,7 @@ 4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -95,6 +112,7 @@ 4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -113,6 +131,7 @@ 4100;4101;%(DisableSpecificWarnings) + false ksuser.lib;%(AdditionalDependencies) @@ -132,6 +151,7 @@ 4100;4101;%(DisableSpecificWarnings) + false ksuser.lib;%(AdditionalDependencies) @@ -143,7 +163,12 @@ - + + 6011;4100;4101;%(DisableSpecificWarnings) + 6011;4100;4101;%(DisableSpecificWarnings) + 6011;4100;4101;%(DisableSpecificWarnings) + 6011;4100;4101;%(DisableSpecificWarnings) + diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 7f66558c61..244129117c 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_portaudio/pablio.c b/src/mod/endpoints/mod_portaudio/pablio.c index 34a52df335..0aebc7c7ab 100644 --- a/src/mod/endpoints/mod_portaudio/pablio.c +++ b/src/mod/endpoints/mod_portaudio/pablio.c @@ -88,7 +88,7 @@ static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer, if (inputBuffer != NULL) { /* retrieve the data for each channel and put it in the ring buffer */ for (c = 0; c < data->channelCount; c++) { - for (i = 0, j = c; i < framesPerBuffer; j += data->channelCount, i++) { + for (i = 0, j = c; i < (int)framesPerBuffer; j += data->channelCount, i++) { chanSamples[i] = inputSamples[j]; } if (PaUtil_WriteRingBuffer(&data->inFIFOs[c], chanSamples, numBytes) != numBytes) { @@ -114,7 +114,7 @@ static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer, for (c = 0; c < data->channelCount; c++) { int numRead = PaUtil_ReadRingBuffer(&data->outFIFOs[c], chanSamples, numBytes); numRead = numRead / sizeof(int16_t); - for (i = 0, j = c; i < framesPerBuffer; j += data->channelCount, i++) { + for (i = 0, j = c; i < (int)framesPerBuffer; j += data->channelCount, i++) { if (i < numRead) { outputSamples[j] = chanSamples[i]; } else { diff --git a/src/mod/endpoints/mod_reference/mod_reference.c b/src/mod/endpoints/mod_reference/mod_reference.c index ece46f8d63..7d1bb028e4 100644 --- a/src/mod/endpoints/mod_reference/mod_reference.c +++ b/src/mod/endpoints/mod_reference/mod_reference.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.2012.vcxproj b/src/mod/endpoints/mod_rtmp/mod_rtmp.2012.vcxproj index 2b615b19d2..f0a7f46fca 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.2012.vcxproj +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -70,13 +70,30 @@ true true + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + ./libamf/src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4221;4127;6001;6011;6385;6244;6259;4090;4306;4244;4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -92,7 +109,8 @@ _DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4221;4127;6001;6011;6385;6244;6259;4090;4306;4244;4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -108,7 +126,8 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4221;4127;6001;6011;6385;6244;6259;4090;4306;4244;4100;4101;%(DisableSpecificWarnings) + false %(AdditionalLibraryDirectories) @@ -123,7 +142,8 @@ NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4221;4127;6001;6011;6385;6244;6259;4090;4306;4244;4100;4101;%(DisableSpecificWarnings) + false %(AdditionalLibraryDirectories) diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index e25f38b861..37ebdd27f5 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -40,7 +40,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rtmp_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtmp_shutdown); -SWITCH_MODULE_DEFINITION(mod_rtmp, mod_rtmp_load, mod_rtmp_shutdown, NULL); +SWITCH_MODULE_RUNTIME_FUNCTION(mod_rtmp_runtime); +SWITCH_MODULE_DEFINITION(mod_rtmp, mod_rtmp_load, mod_rtmp_shutdown, mod_rtmp_runtime); static switch_status_t config_profile(rtmp_profile_t *profile, switch_bool_t reload); static switch_xml_config_item_t *get_instructions(rtmp_profile_t *profile); @@ -221,6 +222,9 @@ switch_status_t rtmp_on_destroy(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); if (tech_pvt) { + + rtmp_notify_call_state(session); + if (switch_core_codec_ready(&tech_pvt->read_codec)) { switch_core_codec_destroy(&tech_pvt->read_codec); } @@ -732,7 +736,7 @@ rtmp_session_t *rtmp_session_locate(const char *uuid) { rtmp_session_t *rsession = switch_core_hash_find_rdlock(rtmp_globals.session_hash, uuid, rtmp_globals.session_rwlock); - if (!rsession || rsession->state == RS_DESTROY) { + if (!rsession || rsession->state >= RS_DESTROY) { return NULL; } @@ -812,53 +816,95 @@ switch_status_t rtmp_session_request(rtmp_profile_t *profile, rtmp_session_t **n return SWITCH_STATUS_SUCCESS; } +static void rtmp_garbage_colletor(void) +{ + switch_hash_index_t *hi; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "RTMP Garbage Collection\n"); + + + switch_thread_rwlock_wrlock(rtmp_globals.session_rwlock); + + top: + + for (hi = switch_hash_first(NULL, rtmp_globals.session_hash); hi; hi = switch_hash_next(hi)) { + void *val; + const void *key; + switch_ssize_t keylen; + rtmp_session_t *rsession; + + switch_hash_this(hi, &key, &keylen, &val); + rsession = (rtmp_session_t *) val; + + if (rsession->state == RS_DESTROY) { + if (rtmp_real_session_destroy(&rsession) == SWITCH_STATUS_SUCCESS) { + goto top; + } + } + } + + switch_thread_rwlock_unlock(rtmp_globals.session_rwlock); +} + switch_status_t rtmp_session_destroy(rtmp_session_t **rsession) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + + switch_mutex_lock(rtmp_globals.mutex); + if (rsession && *rsession) { + (*rsession)->state = RS_DESTROY; + *rsession = NULL; + status = SWITCH_STATUS_SUCCESS; + } + switch_mutex_unlock(rtmp_globals.mutex); + + return status; +} + +switch_status_t rtmp_real_session_destroy(rtmp_session_t **rsession) { switch_hash_index_t *hi; switch_event_t *event; - - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, RTMP_EVENT_DISCONNECT) == SWITCH_STATUS_SUCCESS) { - rtmp_event_fill(*rsession, event); - switch_event_fire(&event); - } - - switch_core_hash_delete_wrlock(rtmp_globals.session_hash, (*rsession)->uuid, rtmp_globals.session_rwlock); - switch_core_hash_delete_wrlock((*rsession)->profile->session_hash, (*rsession)->uuid, (*rsession)->profile->session_rwlock); - rtmp_clear_registration(*rsession, NULL, NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "RTMP session ended [%s]\n", (*rsession)->uuid); - - (*rsession)->state = RS_DESTROY; + int sess = 0; switch_thread_rwlock_rdlock((*rsession)->session_rwlock); for (hi = switch_hash_first(NULL, (*rsession)->session_hash); hi; hi = switch_hash_next(hi)) { void *val; const void *key; switch_ssize_t keylen; - rtmp_private_t *tech_pvt; switch_channel_t *channel; switch_core_session_t *session; - switch_hash_this(hi, &key, &keylen, &val); - tech_pvt = (rtmp_private_t *)val; - - /* At this point we don't know if the session still exists, so request a fresh pointer to it from the core. */ - if ( (session = switch_core_session_locate((char *)key)) != NULL ) { - /* - * This is here so that if the FS session still exists and has the FS session write(or read) lock, then we won't destroy the rsession - * until the FS session is finished with it. But if the rsession is able to get the FS session - * write lock, before the FS session is hungup, then once the FS session does get the write lock - * the rsession pointer will be null, and the FS session will never try and touch the already destroyed rsession. - */ + switch_hash_this(hi, &key, &keylen, &val); + + /* If there are any sessions attached, abort the destroy operation */ + if ((session = switch_core_session_locate((char *)key)) != NULL ) { channel = switch_core_session_get_channel(session); - tech_pvt = switch_core_session_get_private(session); - if ( tech_pvt && tech_pvt->rtmp_session ) { - tech_pvt->rtmp_session = NULL; - } switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_core_session_rwunlock(session); + sess++; } } switch_thread_rwlock_unlock((*rsession)->session_rwlock); + + if (sess) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "RTMP session [%s] %p still busy.\n", (*rsession)->uuid, (void *) *rsession); + return SWITCH_STATUS_FALSE; + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "RTMP session [%s] %p will be destroyed.\n", (*rsession)->uuid, (void *) *rsession); + + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, RTMP_EVENT_DISCONNECT) == SWITCH_STATUS_SUCCESS) { + rtmp_event_fill(*rsession, event); + switch_event_fire(&event); + } + + switch_core_hash_delete(rtmp_globals.session_hash, (*rsession)->uuid); + switch_core_hash_delete_wrlock((*rsession)->profile->session_hash, (*rsession)->uuid, (*rsession)->profile->session_rwlock); + rtmp_clear_registration(*rsession, NULL, NULL); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "RTMP session ended [%s]\n", (*rsession)->uuid); + switch_mutex_lock((*rsession)->profile->mutex); if ( (*rsession)->profile->calls < 1 ) { @@ -1137,7 +1183,7 @@ static void rtmp_clear_reg_auth(rtmp_session_t *rsession, const char *auth, cons switch_thread_rwlock_wrlock(rsession->profile->reg_rwlock); if ((reg = switch_core_hash_find(rsession->profile->reg_hash, auth))) { for (; reg; reg = reg->next) { - if (!strcmp(reg->uuid, rsession->uuid) && (zstr(nickname) || !strcmp(reg->nickname, nickname))) { + if (!zstr(reg->uuid) && !strcmp(reg->uuid, rsession->uuid) && (zstr(nickname) || !strcmp(reg->nickname, nickname))) { switch_event_t *event; if (prev) { prev->next = reg->next; @@ -1495,6 +1541,20 @@ done: return SWITCH_STATUS_SUCCESS; } +static const char *state2name(int state) +{ + switch(state) { + case RS_HANDSHAKE: + return "HANDSHAKE"; + case RS_HANDSHAKE2: + return "HANDSHAKE2"; + case RS_ESTABLISHED: + return "ESTABLISHED"; + default: + return "DESTROY (PENDING)"; + } +} + #define RTMP_FUNCTION_SYNTAX "profile [profilename] [start | stop | rescan | restart]\nstatus profile [profilename]\nstatus profile [profilename] [reg | sessions]\nsession [session_id] [kill | login [user@domain] | logout [user@domain]]" SWITCH_STANDARD_API(rtmp_function) { @@ -1571,7 +1631,7 @@ SWITCH_STANDARD_API(rtmp_function) { switch_hash_index_t *hi; stream->write_function(stream, "\nSessions:\n"); - stream->write_function(stream, "uuid,address,user,domain,flashVer\n"); + stream->write_function(stream, "uuid,address,user,domain,flashVer,state\n"); switch_thread_rwlock_rdlock(profile->session_rwlock); for (hi = switch_hash_first(NULL, profile->session_hash); hi; hi = switch_hash_next(hi)) { void *val; @@ -1581,11 +1641,11 @@ SWITCH_STANDARD_API(rtmp_function) switch_hash_this(hi, &key, &keylen, &val); item = (rtmp_session_t *)val; - stream->write_function(stream, "%s,%s:%d,%s,%s,%s\n", - item->uuid, item->remote_address, item->remote_port, - item->account ? item->account->user : NULL, - item->account ? item->account->domain : NULL, - item->flashVer); + stream->write_function(stream, "%s,%s:%d,%s,%s,%s,%s\n", + item->uuid, item->remote_address, item->remote_port, + item->account ? item->account->user : NULL, + item->account ? item->account->domain : NULL, + item->flashVer, state2name(item->state)); } switch_thread_rwlock_unlock(profile->session_rwlock); @@ -1862,6 +1922,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rtmp_load) switch_xml_free(xml); } } + + rtmp_globals.running = 1; return SWITCH_STATUS_SUCCESS; } @@ -1892,9 +1954,22 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtmp_shutdown) switch_core_hash_destroy(&rtmp_globals.session_hash); switch_core_hash_destroy(&rtmp_globals.invoke_hash); + rtmp_globals.running = 0; + return SWITCH_STATUS_SUCCESS; } +SWITCH_MODULE_RUNTIME_FUNCTION(mod_rtmp_runtime) +{ + + while(rtmp_globals.running) { + rtmp_garbage_colletor(); + switch_yield(10000000); + } + + return SWITCH_STATUS_TERM; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.h b/src/mod/endpoints/mod_rtmp/mod_rtmp.h index 8a92c5b427..95eb17f017 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.h +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.h @@ -336,6 +336,7 @@ struct mod_rtmp_globals { switch_hash_t *session_hash; switch_thread_rwlock_t *session_rwlock; switch_hash_t *invoke_hash; + int running; }; extern struct mod_rtmp_globals rtmp_globals; @@ -605,6 +606,7 @@ void rtmp_profile_release(rtmp_profile_t *profile); switch_status_t rtmp_tcp_init(rtmp_profile_t *profile, const char *bindaddr, rtmp_io_t **new_io, switch_memory_pool_t *pool); switch_status_t rtmp_session_request(rtmp_profile_t *profile, rtmp_session_t **newsession); switch_status_t rtmp_session_destroy(rtmp_session_t **session); +switch_status_t rtmp_real_session_destroy(rtmp_session_t **session); /**** Protocol ****/ void rtmp_set_chunksize(rtmp_session_t *rsession, uint32_t chunksize); diff --git a/src/mod/endpoints/mod_rtmp/rtmp.c b/src/mod/endpoints/mod_rtmp/rtmp.c index 7f5db9d553..cebcec244d 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp.c +++ b/src/mod/endpoints/mod_rtmp/rtmp.c @@ -601,7 +601,7 @@ switch_status_t rtmp_send_message(rtmp_session_t *rsession, uint8_t amfnumber, u /* Find out what is the smallest header we can use */ if (!(flags & MSG_FULLHEADER) && stream_id > 0 && state->stream_id == stream_id && timestamp >= state->ts) { - if (state->type == type && state->origlen == len) { + if (state->type == type && state->origlen == (int)len) { if (state->ts == timestamp) { /* Type 3: no header! */ hdrsize = 1; @@ -930,7 +930,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) switch_mutex_lock(rsession->tech_pvt->readbuf_mutex); - if (rsession->tech_pvt->maxlen && switch_buffer_inuse(rsession->tech_pvt->readbuf) > rsession->tech_pvt->maxlen * 40) { + if (rsession->tech_pvt->maxlen && switch_buffer_inuse(rsession->tech_pvt->readbuf) > (switch_size_t)(rsession->tech_pvt->maxlen * 40)) { rsession->tech_pvt->over_size++; } else { rsession->tech_pvt->over_size = 0; diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj b/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj index 468ca02836..24ab485c82 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj +++ b/src/mod/endpoints/mod_skinny/mod_skinny.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -70,13 +70,30 @@ true true + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + %(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -92,7 +109,8 @@ WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;%(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + false /NODEFAULTLIB:LIMBCTD %(AdditionalOptions) @@ -108,7 +126,8 @@ %(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + false %(AdditionalLibraryDirectories) @@ -123,7 +142,8 @@ %(PreprocessorDefinitions) - 4100;4101;%(DisableSpecificWarnings) + 4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + false %(AdditionalLibraryDirectories) @@ -133,7 +153,12 @@ - + + 4310;4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + 4310;4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + 4310;4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + 4310;4245;4267;4389;4244;6011;4100;4101;%(DisableSpecificWarnings) + diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 0e1e700264..9ca5362b78 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -108,7 +108,7 @@ static char active_lines_sql[] = char *skinny_expand_textid(const char *str) { char *tmp; - int i; + switch_size_t i; /* Look for \200, if found, next character indicates string id */ char match = (char) 128; @@ -500,6 +500,38 @@ uint32_t skinny_line_get_state(listener_t *listener, uint32_t line_instance, uin return helper.call_state; } +struct skinny_line_count_active_helper { + uint32_t count; +}; + +int skinny_line_count_active_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + struct skinny_line_count_active_helper *helper = pArg; + helper->count++; + return 0; +} + +uint32_t skinny_line_count_active(listener_t *listener) +{ + char *sql; + struct skinny_line_count_active_helper helper = {0}; + + switch_assert(listener); + + helper.count = 0; + if ((sql = switch_mprintf( + "SELECT call_state FROM skinny_active_lines " + "WHERE device_name='%s' AND device_instance=%d " + "AND call_state != 2", + listener->device_name, listener->device_instance + ))) { + + skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_line_count_active_callback, &helper); + switch_safe_free(sql); + } + + return helper.count; +} switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force) { @@ -955,7 +987,7 @@ switch_status_t channel_on_hangup(switch_core_session_t *session) skinny_session_walk_lines(tech_pvt->profile, switch_core_session_get_uuid(session), channel_on_hangup_callback, &helper); if ((sql = switch_mprintf( - "DELETE FROM skinny_active_lines WHERE channel_uuid='%s'", + "DELETE FROM skinny_active_lines WHERE channel_uuid='%q'", switch_core_session_get_uuid(session) ))) { skinny_execute_sql(tech_pvt->profile, sql, tech_pvt->profile->sql_mutex); @@ -1405,7 +1437,7 @@ void skinny_clean_device_from_db(listener_t *listener, char *device_name) if ((sql = switch_mprintf( "DELETE FROM skinny_devices " - "WHERE name='%s'", + "WHERE name='%q'", device_name))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1413,7 +1445,7 @@ void skinny_clean_device_from_db(listener_t *listener, char *device_name) if ((sql = switch_mprintf( "DELETE FROM skinny_lines " - "WHERE device_name='%s'", + "WHERE device_name='%q'", device_name))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1421,7 +1453,7 @@ void skinny_clean_device_from_db(listener_t *listener, char *device_name) if ((sql = switch_mprintf( "DELETE FROM skinny_buttons " - "WHERE device_name='%s'", + "WHERE device_name='%q'", device_name))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1429,7 +1461,7 @@ void skinny_clean_device_from_db(listener_t *listener, char *device_name) if ((sql = switch_mprintf( "DELETE FROM skinny_active_lines " - "WHERE device_name='%s'", + "WHERE device_name='%q'", device_name))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1453,7 +1485,7 @@ void skinny_clean_listener_from_db(listener_t *listener) if ((sql = switch_mprintf( "DELETE FROM skinny_devices " - "WHERE name='%s' and instance=%d", + "WHERE name='%q' and instance=%d", listener->device_name, listener->device_instance))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1461,7 +1493,7 @@ void skinny_clean_listener_from_db(listener_t *listener) if ((sql = switch_mprintf( "DELETE FROM skinny_lines " - "WHERE device_name='%s' and device_instance=%d", + "WHERE device_name='%q' and device_instance=%d", listener->device_name, listener->device_instance))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1469,7 +1501,7 @@ void skinny_clean_listener_from_db(listener_t *listener) if ((sql = switch_mprintf( "DELETE FROM skinny_buttons " - "WHERE device_name='%s' and device_instance=%d", + "WHERE device_name='%q' and device_instance=%d", listener->device_name, listener->device_instance))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -1477,7 +1509,7 @@ void skinny_clean_listener_from_db(listener_t *listener) if ((sql = switch_mprintf( "DELETE FROM skinny_active_lines " - "WHERE device_name='%s' and device_instance=%d", + "WHERE device_name='%q' and device_instance=%d", listener->device_name, listener->device_instance))) { skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); @@ -2267,8 +2299,8 @@ static void skinny_call_state_event_handler(switch_event_t *event) if ((sql = switch_mprintf( "UPDATE skinny_active_lines " "SET call_state=%d " - "WHERE device_name='%s' AND device_instance=%d " - "AND %s AND %s", + "WHERE device_name='%q' AND device_instance=%d " + "AND %q AND %q", call_state, listener->device_name, listener->device_instance, line_instance_condition, call_id_condition diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index b252dd7e4a..a98be960a9 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -304,6 +304,7 @@ void skinny_line_perform_set_state(const char *file, const char *func, int line, #define skinny_line_set_state(listener, line_instance, call_id, call_state) skinny_line_perform_set_state(__FILE__, __SWITCH_FUNC__, __LINE__, listener, line_instance, call_id, call_state) uint32_t skinny_line_get_state(listener_t *listener, uint32_t line_instance, uint32_t call_id); +uint32_t skinny_line_count_active(listener_t *listener); switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force); void tech_init(private_t *tech_pvt, skinny_profile_t *profile, switch_core_session_t *session); diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 8a5178302e..870b4c578a 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -39,6 +39,10 @@ /*****************************************************************************/ /* SKINNY TYPES */ /*****************************************************************************/ + +/* Hardcode ptime in one place until we make it dynamic */ +#define SKINNY_PTIME 20 + typedef enum { SKINNY_CODEC_NONE = 0, SKINNY_CODEC_NONSTANDARD = 1, diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 76486633ba..e6efd6a110 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -163,9 +163,9 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l if ((sql = switch_mprintf( "INSERT INTO skinny_active_lines " "(device_name, device_instance, line_instance, channel_uuid, call_id, call_state) " - "SELECT device_name, device_instance, line_instance, '%s', %d, %d " + "SELECT device_name, device_instance, line_instance, '%q', %d, %d " "FROM skinny_lines " - "WHERE value='%s'", + "WHERE value='%q'", switch_core_session_get_uuid(nsession), tech_pvt->call_id, SKINNY_ON_HOOK, button->shortname ))) { skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex); @@ -587,6 +587,7 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN /* uint32_t call_state = atoi(argv[16]); */ listener_t *listener = NULL; + uint32_t active_calls = 0; skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener); @@ -596,9 +597,12 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN helper->lines_count++; switch_channel_set_variable(channel, "effective_callee_id_number", value); switch_channel_set_variable(channel, "effective_callee_id_name", caller_name); + + active_calls = skinny_line_count_active(listener); - skinny_log_l(listener, SWITCH_LOG_DEBUG, "Ring Lines Callback with Callee Number (%s), Caller Name (%s), Dest Number (%s)\n", - value, caller_name, helper->tech_pvt->caller_profile->destination_number); + skinny_log_l(listener, SWITCH_LOG_DEBUG, + "Ring Lines Callback with Callee Number (%s), Caller Name (%s), Dest Number (%s), Active Calls (%d)\n", + value, caller_name, helper->tech_pvt->caller_profile->destination_number, active_calls); if (helper->remote_session) { switch_core_session_message_t msg = { 0 }; @@ -630,7 +634,13 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN } skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_BLINK); - send_set_ringer(listener, SKINNY_RING_INSIDE, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id); + + if ( active_calls < 1 ) { + send_set_ringer(listener, SKINNY_RING_INSIDE, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id); + } else { + send_start_tone(listener, SKINNY_TONE_CALLWAITTONE, 0, line_instance, helper->tech_pvt->call_id); + send_stop_tone(listener, line_instance, helper->tech_pvt->call_id); + } switch_channel_ring_ready(channel); } return 0; @@ -788,7 +798,7 @@ switch_status_t skinny_session_start_media(switch_core_session_t *session, liste send_open_receive_channel(listener, tech_pvt->call_id, /* uint32_t conference_id, */ tech_pvt->call_id, /* uint32_t pass_thru_party_id, */ - 20, /* uint32_t ms_per_packet, */ + SKINNY_PTIME, /* uint32_t ms_per_packet, */ SKINNY_CODEC_ULAW_64K, /* uint32_t payload_capacity, */ 0, /* uint32_t echo_cancel_type, */ 0, /* uint32_t g723_bitrate, */ @@ -849,7 +859,25 @@ switch_status_t skinny_session_unhold_line(switch_core_session_t *session, liste send_set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, tech_pvt->call_id); send_set_speaker_mode(listener, SKINNY_SPEAKER_ON); send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_RING_OUT, 0xffff); - skinny_session_start_media(session, listener, line_instance); + + send_stop_tone(listener, line_instance, tech_pvt->call_id); + send_open_receive_channel(listener, + tech_pvt->call_id, /* uint32_t conference_id, */ + tech_pvt->call_id, /* uint32_t pass_thru_party_id, */ + SKINNY_PTIME, /* uint32_t ms_per_packet, */ + SKINNY_CODEC_ULAW_64K, /* uint32_t payload_capacity, */ + 0, /* uint32_t echo_cancel_type, */ + 0, /* uint32_t g723_bitrate, */ + 0, /* uint32_t conference_id2, */ + 0 /* uint32_t reserved[10] */ + ); + + skinny_line_set_state(listener, line_instance, tech_pvt->call_id, SKINNY_CONNECTED); + send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_CONNECTED, 0xffff); + + send_display_prompt_status_textid(listener, 0, SKINNY_TEXTID_CONNECTED, line_instance, tech_pvt->call_id); + skinny_session_send_call_info(session, listener, line_instance); + return SWITCH_STATUS_SUCCESS; } @@ -1052,7 +1080,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r if ((sql = switch_mprintf( "INSERT INTO skinny_devices " "(name, user_id, instance, ip, type, max_streams, codec_string) " - "VALUES ('%s','%d','%d', '%s', '%d', '%d', '%s')", + "VALUES ('%q','%d','%d', '%q', '%d', '%d', '%q')", request->data.reg.device_name, request->data.reg.user_id, request->data.reg.instance, @@ -1130,7 +1158,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r "label, value, caller_name, " "ring_on_idle, ring_on_active, busy_trigger, " "forward_all, forward_busy, forward_noanswer, noanswer_duration) " - "VALUES('%s', %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d)", + "VALUES('%q', %d, %d, %d, '%q', '%q', '%q', %d, %d, %d, '%q', '%q', '%q', %d)", request->data.reg.device_name, request->data.reg.instance, position, line_instance, label, value, caller_name, ring_on_idle, ring_on_active, busy_trigger, @@ -1158,7 +1186,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r if ((sql = switch_mprintf( "INSERT INTO skinny_buttons " "(device_name, device_instance, position, type, label, value, settings) " - "VALUES('%s', %d, %d, %d, '%s', '%s', '%s')", + "VALUES('%q', %d, %d, %d, '%q', '%q', '%q')", request->data.reg.device_name, request->data.reg.instance, position, @@ -1212,7 +1240,7 @@ switch_status_t skinny_handle_port_message(listener_t *listener, skinny_message_ skinny_check_data_length(request, sizeof(request->data.as_uint16)); if ((sql = switch_mprintf( - "UPDATE skinny_devices SET port=%d WHERE name='%s' and instance=%d", + "UPDATE skinny_devices SET port=%d WHERE name='%q' and instance=%d", request->data.port.port, listener->device_name, listener->device_instance @@ -1757,7 +1785,7 @@ switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny } codec_string[string_len] = '\0'; if ((sql = switch_mprintf( - "UPDATE skinny_devices SET codec_string='%s' WHERE name='%s'", + "UPDATE skinny_devices SET codec_string='%q' WHERE name='%s'", codec_string, listener->device_name ))) { @@ -1812,7 +1840,7 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste /* Codec */ tech_pvt->iananame = "PCMU"; /* TODO */ - tech_pvt->codec_ms = 20; /* TODO */ + tech_pvt->codec_ms = SKINNY_PTIME; /* TODO */ tech_pvt->rm_rate = 8000; /* TODO */ tech_pvt->rm_fmtp = NULL; /* TODO */ tech_pvt->agreed_pt = (switch_payload_t) 0; /* TODO */ @@ -1852,7 +1880,7 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste tech_pvt->read_impl.microseconds_per_packet / 1000, switch_rtp_ready(tech_pvt->rtp_session) ? "SUCCESS" : err); #ifdef WIN32 - addr.s_addr = inet_addr((uint16_t) tech_pvt->local_sdp_audio_ip); + addr.s_addr = inet_addr(tech_pvt->local_sdp_audio_ip); #else inet_aton(tech_pvt->local_sdp_audio_ip, &addr); #endif @@ -1861,7 +1889,7 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste tech_pvt->party_id, /* uint32_t pass_thru_party_id, */ addr.s_addr, /* uint32_t remote_ip, */ tech_pvt->local_sdp_audio_port, /* uint32_t remote_port, */ - 20, /* uint32_t ms_per_packet, */ + SKINNY_PTIME, /* uint32_t ms_per_packet, */ SKINNY_CODEC_ULAW_64K, /* uint32_t payload_capacity, */ 184, /* uint32_t precedence, */ 0, /* uint32_t silence_suppression, */ @@ -2083,7 +2111,7 @@ switch_status_t skinny_headset_status_message(listener_t *listener, skinny_messa skinny_check_data_length(request, sizeof(request->data.headset_status)); if ((sql = switch_mprintf( - "UPDATE skinny_devices SET headset=%d WHERE name='%s' and instance=%d", + "UPDATE skinny_devices SET headset=%d WHERE name='%q' and instance=%d", (request->data.headset_status.mode==1) ? SKINNY_ACCESSORY_STATE_OFFHOOK : SKINNY_ACCESSORY_STATE_ONHOOK, listener->device_name, listener->device_instance @@ -2245,7 +2273,7 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski switch(request->data.accessory_status.accessory_id) { case SKINNY_ACCESSORY_HEADSET: if ((sql = switch_mprintf( - "UPDATE skinny_devices SET headset=%d WHERE name='%s' and instance=%d", + "UPDATE skinny_devices SET headset=%d WHERE name='%q' and instance=%d", request->data.accessory_status.accessory_status, listener->device_name, listener->device_instance @@ -2256,7 +2284,7 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski break; case SKINNY_ACCESSORY_HANDSET: if ((sql = switch_mprintf( - "UPDATE skinny_devices SET handset=%d WHERE name='%s' and instance=%d", + "UPDATE skinny_devices SET handset=%d WHERE name='%q' and instance=%d", request->data.accessory_status.accessory_status, listener->device_name, listener->device_instance @@ -2267,7 +2295,7 @@ switch_status_t skinny_handle_accessory_status_message(listener_t *listener, ski break; case SKINNY_ACCESSORY_SPEAKER: if ((sql = switch_mprintf( - "UPDATE skinny_devices SET speaker=%d WHERE name='%s' and instance=%d", + "UPDATE skinny_devices SET speaker=%d WHERE name='%q' and instance=%d", request->data.accessory_status.accessory_status, listener->device_name, listener->device_instance @@ -2329,7 +2357,7 @@ switch_status_t skinny_handle_updatecapabilities(listener_t *listener, skinny_me } codec_string[string_len] = '\0'; if ((sql = switch_mprintf( - "UPDATE skinny_devices SET codec_string='%s' WHERE name='%s'", + "UPDATE skinny_devices SET codec_string='%q' WHERE name='%q'", codec_string, listener->device_name ))) { diff --git a/src/mod/endpoints/mod_skypopen/install/install.pl b/src/mod/endpoints/mod_skypopen/install/install.pl index 20de07e2eb..87011f96b4 100755 --- a/src/mod/endpoints/mod_skypopen/install/install.pl +++ b/src/mod/endpoints/mod_skypopen/install/install.pl @@ -1,9 +1,11 @@ #!/usr/bin/perl my $myname ; -my $skype_download_url = "http://mirrors.kernel.org/archlinux/community/os/i686/skype-oss-2.0.0.72-3-i686.pkg.tar.xz"; +#my $skype_download_url = "http://mirrors.kernel.org/archlinux/community/os/i686/skype-oss-2.0.0.72-3-i686.pkg.tar.xz"; +my $skype_download_url = "http://212.71.238.115:8080/skype-oss-2.0.0.72-3-i686.pkg.tar.xz"; my $skype_download_pkg = "skype-oss-2.0.0.72-3-i686.pkg.tar.xz"; -my $skype_binary_dir = "/usr/bin"; +#my $skype_binary_dir = "/usr/bin"; +my $skype_binary_dir = "/usr/local/freeswitch/skypopen/skype-clients-symlinks-dir"; my $skype_download_dir = "/tmp/skype_download"; my $skype_share_dir = "/usr/share/skype"; my $freeswitch_modules_config_dir = "/usr/local/freeswitch/conf/autoload_configs"; diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.2012.vcxproj b/src/mod/endpoints/mod_skypopen/mod_skypopen.2012.vcxproj index 3b45d852e3..6ce2cbb070 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.2012.vcxproj +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -75,6 +75,7 @@ Level4 false + 4324;6340;6246;6011;6387;%(DisableSpecificWarnings) rpcrt4.lib "..\..\..\..\libs\spandsp\src\Win32\Debug\libtiff.lib" "..\..\..\..\Win32\Debug\libspandsp.lib" %(AdditionalOptions) @@ -90,6 +91,7 @@ Level4 false + 4324;6340;6246;6011;6387;%(DisableSpecificWarnings) rpcrt4.lib "..\..\..\..\libs\spandsp\src\x64\Debug\libtiff.lib" "..\..\..\..\x64\Debug\libspandsp.lib" %(AdditionalOptions) @@ -103,6 +105,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4324;6340;6246;6011;6387;%(DisableSpecificWarnings) rpcrt4.lib "..\..\..\..\libs\spandsp\src\Win32\Release\libtiff.lib" "..\..\..\..\Win32\Release\libspandsp.lib" %(AdditionalOptions) @@ -116,6 +119,7 @@ %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) + 4324;6340;6246;6011;6387;%(DisableSpecificWarnings) rpcrt4.lib "..\..\..\..\libs\spandsp\src\x64\Release\libtiff.lib" "..\..\..\..\x64\Release\libspandsp.lib" %(AdditionalOptions) @@ -125,8 +129,24 @@ - - + + /analyze:stacksize65535 + /analyze:stacksize65535 + /analyze:stacksize65535 + + + + + 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) + /analyze:stacksize32768 + /analyze:stacksize32768 + /analyze:stacksize32768 + + + diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.c b/src/mod/endpoints/mod_skypopen/mod_skypopen.c index b586bd0489..8f843a0000 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.c +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.c @@ -314,7 +314,7 @@ static switch_status_t interface_exists(char *the_interface) /* CLOUDTREE (Thomas Hazel) static */ switch_status_t remove_interface(char *the_interface, /* CLOUDTREE (Thomas Hazel) */ switch_bool_t force) { int x = 10; - unsigned int howmany = 8; + switch_size_t howmany = 8; int interface_id = -1; private_t *tech_pvt = NULL; switch_status_t status; @@ -884,7 +884,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch switch_mutex_lock(tech_pvt->mutex_audio_srv); if (tech_pvt->read_buffer && switch_buffer_inuse(tech_pvt->read_buffer)) { bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, BYTES_PER_FRAME); - tech_pvt->read_frame.datalen = bytes_read; + tech_pvt->read_frame.datalen = (uint32_t)bytes_read; } switch_mutex_unlock(tech_pvt->mutex_audio_srv); @@ -2069,7 +2069,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown) int x; private_t *tech_pvt = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; - unsigned int howmany = 8; + switch_size_t howmany = 8; int interface_id; running = 0; diff --git a/src/mod/endpoints/mod_skypopen/skypopen.h b/src/mod/endpoints/mod_skypopen/skypopen.h index 69cda02b9a..87af8d9f24 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen.h +++ b/src/mod/endpoints/mod_skypopen/skypopen.h @@ -33,7 +33,6 @@ #include -#include #ifndef WIN32 #include @@ -85,7 +84,7 @@ #endif #ifndef SKYPOPEN_SVN_VERSION -#define SKYPOPEN_SVN_VERSION SWITCH_VERSION_FULL +#define SKYPOPEN_SVN_VERSION switch_version_full() #endif /* SKYPOPEN_SVN_VERSION */ typedef enum { @@ -104,14 +103,14 @@ typedef enum { GFLAG_MY_CODEC_PREFS = (1 << 0) } GFLAGS; -#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s ["SKYPOPEN_SVN_VERSION "] [DEBUG_SKYPE %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s ["SKYPOPEN_SVN_VERSION "] [DEBUG_CALL %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s ["SKYPOPEN_SVN_VERSION "] [DEBUG_PBX %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%-*s ["SKYPOPEN_SVN_VERSION "] [ERRORA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%-*s["SKYPOPEN_SVN_VERSION "] [WARNINGA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%-*s ["SKYPOPEN_SVN_VERSION "] [NOTICA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s [%s ] [DEBUG_SKYPE %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s [%s ] [DEBUG_CALL %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s [%s ] [DEBUG_PBX %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%-*s [%s ] [ERRORA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%-*s[%s ] [WARNINGA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); +#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%-*s [%s ] [NOTICA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define SKYPOPEN_P_LOG (int)((20 - (strlen(__FILE__))) + ((__LINE__ - 1000) < 0) + ((__LINE__ - 100) < 0)), " ", __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", tech_pvt ? interface_status[tech_pvt->interface_state] : "N/A", tech_pvt ? skype_callflow[tech_pvt->skype_callflow] : "N/A" +#define SKYPOPEN_P_LOG (int)((20 - (strlen(__FILE__))) + ((__LINE__ - 1000) < 0) + ((__LINE__ - 100) < 0)), " ", SKYPOPEN_SVN_VERSION, __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", tech_pvt ? interface_status[tech_pvt->interface_state] : "N/A", tech_pvt ? skype_callflow[tech_pvt->skype_callflow] : "N/A" /*********************************/ #define SKYPOPEN_CAUSE_NORMAL 1 diff --git a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c index b1542a39cc..cc6a50adfc 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c @@ -1310,7 +1310,7 @@ int skypopen_pipe_read(switch_file_t *pipe, short *buf, int howmany) switch_file_read(pipe, buf, &quantity); - howmany = quantity; + howmany = (int)quantity; return howmany; } @@ -1323,7 +1323,7 @@ int skypopen_pipe_write(switch_file_t *pipe, short *buf, int howmany) switch_file_write(pipe, buf, &quantity); - howmany = quantity; + howmany = (int)quantity; return howmany; } diff --git a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml index 1b64f63bc7..0b3c0c8da8 100644 --- a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml +++ b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml @@ -78,6 +78,8 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.2012.vcxproj b/src/mod/endpoints/mod_sofia/mod_sofia.2012.vcxproj index ba2517a24c..978e1661c9 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.2012.vcxproj +++ b/src/mod/endpoints/mod_sofia/mod_sofia.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,6 +68,22 @@ <_ProjectFileVersion>10.0.30319.1 + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + %(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\su;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\nua;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\win32;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\url;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\sip;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\msg;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\sdp;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\nta;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\nea;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\soa;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\iptsec;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\bnf;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\tport;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\sresolv;%(RootDir)%(Directory)..\..\..\..\libs\sofia-sip\libsofia-sip-ua\ipt;%(AdditionalIncludeDirectories) @@ -75,6 +91,7 @@ 4201;%(DisableSpecificWarnings) + false ws2_32.lib;advapi32.lib;iphlpapi.lib;%(AdditionalDependencies) @@ -94,6 +111,7 @@ 4201;%(DisableSpecificWarnings) + false ws2_32.lib;advapi32.lib;iphlpapi.lib;%(AdditionalDependencies) @@ -111,6 +129,7 @@ 4201;%(DisableSpecificWarnings) + false ws2_32.lib;advapi32.lib;iphlpapi.lib;%(AdditionalDependencies) @@ -130,6 +149,7 @@ 4201;%(DisableSpecificWarnings) + false ws2_32.lib;advapi32.lib;iphlpapi.lib;%(AdditionalDependencies) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7286c5de16..90aaaee1fc 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -626,13 +626,14 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY nomedia - sending ack\n"); nua_ack(tech_pvt->nh, - TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), - SOATAG_REUSE_REJECTED(1), - SOATAG_RTP_SELECT(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), - TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), - TAG_END()); + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), + SOATAG_REUSE_REJECTED(1), + SOATAG_RTP_SELECT(1), + SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), + TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), + TAG_END()); sofia_clear_flag(tech_pvt, TFLAG_3PCC_INVITE); // all done sofia_set_flag_locked(tech_pvt, TFLAG_ANS); sofia_set_flag_locked(tech_pvt, TFLAG_SDP); @@ -667,7 +668,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) tech_pvt->mparams.local_sdp_str = NULL; switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0); - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); } else { switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE); @@ -683,12 +684,14 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); if (sofia_use_soa(tech_pvt)) { + nua_respond(tech_pvt->nh, SIP_200_OK, TAG_IF(is_proxy, NUTAG_AUTOANSWER(0)), SIPTAG_CONTACT_STR(tech_pvt->profile->url), SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), - SOATAG_REUSE_REJECTED(1), TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)), + SOATAG_REUSE_REJECTED(1), + SOATAG_RTP_SELECT(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), @@ -762,7 +765,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) return status; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } @@ -834,7 +837,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), - TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)), + SOATAG_RTP_SELECT(1), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END()); @@ -1221,7 +1224,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_set_flag(tech_pvt->channel, CF_SECURE); } - if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING) || sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_PT)) { + if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) { switch_core_media_reset_autofix(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); } } @@ -1242,19 +1245,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ: { - const char *pl = ""; - time_t now = switch_epoch_time_now(NULL); + const char *pl = "\n\n\n\n\n\n\n\n"; + //time_t now = switch_epoch_time_now(NULL); - if (!tech_pvt->last_vid_info || (now - tech_pvt->last_vid_info) > 5) { - - tech_pvt->last_vid_info = now; + //if (!tech_pvt->last_vid_info || (now - tech_pvt->last_vid_info) > 5) { + + // tech_pvt->last_vid_info = now; if (!zstr(msg->string_arg)) { pl = msg->string_arg; } nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END()); - } + //} } break; @@ -1264,7 +1267,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE); port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE); if (ip && port) { - switch_core_media_gen_local_sdp(session, ip, (switch_port_t)atoi(port), msg->string_arg, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, ip, (switch_port_t)atoi(port), msg->string_arg, 1); } if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { @@ -1397,7 +1400,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi goto end_lock; } } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1); if (send_invite) { if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { @@ -1832,7 +1835,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi char ref_to[1024] = ""; const char *var; - if (!strstr(msg->string_arg, "sip:")) { + if (!strcasecmp(msg->string_arg, "sip:")) { const char *format = strchr(tech_pvt->profile->sipip, ':') ? "sip:%s@[%s]" : "sip:%s@%s"; switch_snprintf(ref_to, sizeof(ref_to), format, msg->string_arg, tech_pvt->profile->sipip); } else { @@ -2081,7 +2084,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); goto end_lock; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } @@ -2489,6 +2492,12 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url)); stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl)); } + if (profile->ws_bindurl) { + stream->write_function(stream, "WS-BIND-URL \t%s\n", switch_str_nil(profile->ws_bindurl)); + } + if (profile->wss_bindurl) { + stream->write_function(stream, "WSS-BIND-URL \t%s\n", switch_str_nil(profile->wss_bindurl)); + } stream->write_function(stream, "HOLD-MUSIC \t%s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music); stream->write_function(stream, "OUTBOUND-PROXY \t%s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); stream->write_function(stream, "CODECS IN \t%s\n", switch_str_nil(profile->inbound_codec_string)); @@ -2773,6 +2782,8 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, " %s\n", switch_str_nil(profile->bindurl)); stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_url)); stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_bindurl)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->ws_bindurl)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->wss_bindurl)); stream->write_function(stream, " %s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music); stream->write_function(stream, " %s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); @@ -2899,10 +2910,19 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl } if (sofia_test_pflag(profile, PFLAG_TLS)) { - stream->write_function(stream, - "\n%s\n%s\n%s\n%s (%u) (TLS)\n\n", - profile->name, "profile", profile->tls_url, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", - profile->inuse); + stream->write_function(stream, "\n%s\n%s\n%s\n%s (%u) (TLS)\n\n", + profile->name, "profile", profile->tls_url, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", + profile->inuse); + } + if (profile->ws_bindurl){ + stream->write_function(stream, "\n%s\n%s\n%s\n%s (%u) (WS)\n\n", + profile->name, "profile", profile->ws_bindurl, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", + profile->inuse); + } + if (profile->wss_bindurl){ + stream->write_function(stream, "\n%s\n%s\n%s\n%s (%u) (WSS)\n\n", + profile->name, "profile", profile->wss_bindurl, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", + profile->inuse); } c++; @@ -4267,12 +4287,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session if (!strchr(host, '.') || switch_true(switch_event_get_header(var_event, "sip_gethostbyname"))) { struct sockaddr_in sa; struct hostent *he = gethostbyname(host); - char *ip, *tmp; + char buf[50] = "", *tmp; + const char *ip; if (he) { memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr)); - ip = inet_ntoa(sa.sin_addr); - + ip = switch_inet_ntop(AF_INET, &sa.sin_addr, buf, sizeof(buf)); tmp = switch_string_replace(dest, host, ip); //host = switch_core_session_strdup(nsession, ip); //dest = switch_core_session_strdup(nsession, tmp); @@ -4964,17 +4984,17 @@ static void general_event_handler(switch_event_t *event) sofia_profile_t *profile; nua_handle_t *nh; - if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name); - return; - } - if (ct && user && host) { char *id = NULL; char *contact, *p; switch_console_callback_match_t *list = NULL; switch_console_callback_match_node_t *m; + if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name); + return; + } + if (!(list = sofia_reg_find_reg_url_multi(profile, user, host))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find registered user %s@%s\n", user, host); return; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 952fce2f9f..54beceb3fd 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -47,7 +47,6 @@ #define SOFIA_QUEUE_SIZE 50000 #define HAVE_APR #include -#include #define SOFIA_NAT_SESSION_TIMEOUT 90 #define SOFIA_MAX_ACL 100 #ifdef _MSC_VER @@ -96,7 +95,6 @@ typedef struct private_object private_object_t; #define MULTICAST_EVENT "multicast::event" #define SOFIA_REPLACES_HEADER "_sofia_replaces_" -#define SOFIA_USER_AGENT "FreeSWITCH-mod_sofia/" SWITCH_VERSION_FULL #define SOFIA_CHAT_PROTO "sip" #define SOFIA_MULTIPART_PREFIX "sip_mp_" #define SOFIA_MULTIPART_PREFIX_T "~sip_mp_" @@ -164,7 +162,6 @@ typedef struct sofia_dispatch_event_s { struct sofia_private { char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1]; - sofia_gateway_t *gateway; char gateway_name[256]; char auth_gateway_name[256]; char *call_id; @@ -269,9 +266,12 @@ typedef enum { PFLAG_FIRE_MESSAGE_EVENTS, PFLAG_SEND_DISPLAY_UPDATE, PFLAG_RUNNING_TRANS, + PFLAG_SOCKET_TCP_KEEPALIVE, PFLAG_TCP_KEEPALIVE, PFLAG_TCP_PINGPONG, PFLAG_TCP_PING2PONG, + PFLAG_MESSAGES_RESPOND_200_OK, + PFLAG_PARSE_ALL_INVITE_HEADERS, /* No new flags below this line */ PFLAG_MAX } PFLAGS; @@ -401,6 +401,14 @@ typedef enum { SOFIA_TRANSPORT_WSS } sofia_transport_t; +typedef enum { + SOFIA_TLS_VERSION_SSLv2 = (1 << 0), + SOFIA_TLS_VERSION_SSLv3 = (1 << 1), + SOFIA_TLS_VERSION_TLSv1 = (1 << 2), + SOFIA_TLS_VERSION_TLSv1_1 = (1 << 3), + SOFIA_TLS_VERSION_TLSv1_2 = (1 << 4), +} sofia_tls_version_t; + typedef enum { SOFIA_GATEWAY_DOWN, SOFIA_GATEWAY_UP, @@ -422,6 +430,7 @@ typedef enum { struct sofia_gateway_subscription { sofia_gateway_t *gateway; + sofia_private_t *sofia_private; nua_handle_t *nh; char *expires_str; char *event; /* eg, 'message-summary' to subscribe to MWI events */ @@ -509,7 +518,8 @@ typedef enum { typedef enum { MEDIA_OPT_NONE = 0, MEDIA_OPT_MEDIA_ON_HOLD = (1 << 0), - MEDIA_OPT_BYPASS_AFTER_ATT_XFER = (1 << 1) + MEDIA_OPT_BYPASS_AFTER_ATT_XFER = (1 << 1), + MEDIA_OPT_BYPASS_AFTER_HOLD = (1 << 2) } sofia_media_options_t; typedef enum { @@ -579,6 +589,7 @@ struct sofia_profile { switch_port_t sip_port; switch_port_t extsipport; switch_port_t tls_sip_port; + char *tls_ciphers; int tls_version; unsigned int tls_timeout; char *inbound_codec_string; @@ -675,6 +686,7 @@ struct sofia_profile { su_strlst_t *tls_verify_in_subjects; uint32_t sip_force_expires; uint32_t sip_expires_max_deviation; + uint32_t sip_expires_late_margin; uint32_t sip_subscription_max_deviation; int ireg_seconds; sofia_paid_type_t paid_type; @@ -686,6 +698,7 @@ struct sofia_profile { switch_port_t ws_port; char *wss_ip; switch_port_t wss_port; + int socket_tcp_keepalive; int tcp_keepalive; int tcp_pingpong; int tcp_ping2pong; diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c index a34b8cfd74..bbb78c88a2 100644 --- a/src/mod/endpoints/mod_sofia/rtp.c +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -170,8 +170,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi *szpt = switch_event_get_header_nil(var_event, kPT); - switch_port_t local_port = !zstr(szlocal_port) ? atoi(szlocal_port) : 0, - remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0; + switch_port_t local_port = !zstr(szlocal_port) ? (switch_port_t)atoi(szlocal_port) : 0, + remote_port = !zstr(szremote_port) ? (switch_port_t)atoi(szremote_port) : 0; int ptime = !zstr(szptime) ? atoi(szptime) : 0, //rfc2833_pt = !zstr(szrfc2833_pt) ? atoi(szrfc2833_pt) : 0, @@ -203,7 +203,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi tech_pvt->remote_address = switch_core_session_strdup(*new_session, remote_addr); tech_pvt->remote_port = remote_port; tech_pvt->ptime = ptime; - tech_pvt->agreed_pt = pt; + tech_pvt->agreed_pt = (switch_payload_t)pt; tech_pvt->dtmf_type = DTMF_2833; /* XXX */ if (zstr(local_addr) || local_port == 0) { @@ -456,7 +456,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi compare_var(event, channel, kREMOTEPORT)) { char *remote_addr = switch_event_get_header(event, kREMOTEADDR); char *szremote_port = switch_event_get_header(event, kREMOTEPORT); - switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0; + switch_port_t remote_port = !zstr(szremote_port) ? (switch_port_t)atoi(szremote_port) : 0; const char *err; @@ -512,8 +512,8 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi goto fail; } - switch_rtp_set_default_payload(tech_pvt->rtp_session, pt); - switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt); + switch_rtp_set_default_payload(tech_pvt->rtp_session, (switch_payload_t)pt); + //switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt); } if (compare_var(event, channel, kRFC2833PT)) { @@ -521,7 +521,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi int pt = !zstr(szpt) ? atoi(szpt) : 0; switch_channel_set_variable(channel, kRFC2833PT, szpt); - switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt); + switch_rtp_set_telephony_event(tech_pvt->rtp_session, (switch_payload_t)pt); } } else { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index e2207d2c6d..cf4e5a5267 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -325,7 +325,196 @@ static void extract_vars(sofia_profile_t *profile, sip_t const *sip, } } +/** + * Add a specific SIP INVITE header to the channel variables, prefixed with "sip_i_" + */ +static void sofia_add_invite_header_to_chanvars(switch_channel_t *channel, nua_handle_t *nh, void *sip_header, const char *var) +{ + switch_assert(channel); + switch_assert(nh); + switch_assert(var); + if (sip_header) { + char *full; + if ((full = sip_header_as_string(nh->nh_home, sip_header))) { + switch_channel_set_variable(channel, var, full); + su_free(nh->nh_home, full); + } + } +} + +/** + * Deep search into the SIP message to recreate the original headers, including multiple Diversions, etc. + * Finally sets the "sip_invite_headers" to a string containing the 'original' SIP headers, except that the order may have changed. + * Multiple headers will have the original internal order, though. + * + * @param sip A sip_t struct containing the parsed message + * @param session A call session + * @param nh A NUA handle for string allocation + */ +static void sofia_parse_all_invite_headers(sip_t const *sip, switch_core_session_t *session, nua_handle_t *nh) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + sip_unknown_t *un; + sip_p_asserted_identity_t *passerted; + sip_p_preferred_identity_t *ppreferred; + sip_remote_party_id_t *rpid; + sip_reply_to_t *reply_to; + sip_alert_info_t *alert_info; + + if (!sip) return; + + /* Add simple (unique) headers first */ + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_from, "sip_i_from"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_to, "sip_i_to"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_call_id, "sip_i_call_id"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_cseq, "sip_i_cseq"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_route, "sip_i_route"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_max_forwards, "sip_i_max_forwards"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_proxy_require, "sip_i_proxy_require"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_contact, "sip_i_contact"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_user_agent, "sip_i_user_agent"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_subject, "sip_i_subject"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_priority, "sip_i_priority"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_organization, "sip_i_organization"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_in_reply_to, "sip_i_in_reply_to"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_accept_encoding, "sip_i_accept_encoding"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_accept_language, "sip_i_accept_language"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_allow, "sip_i_allow"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_require, "sip_i_require"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_supported, "sip_i_supported"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_date, "sip_i_date"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_timestamp, "sip_i_timestamp"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_expires, "sip_i_expires"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_min_expires, "sip_i_min_expires"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_session_expires, "sip_i_session_expires"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_min_se, "sip_i_min_se"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_privacy, "sip_i_privacy"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_mime_version, "sip_i_mime_version"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_content_type, "sip_i_content_type"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_content_encoding, "sip_i_content_encoding"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_content_language, "sip_i_content_language"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_content_disposition, "sip_i_content_disposition"); + sofia_add_invite_header_to_chanvars(channel, nh, sip->sip_content_length, "sip_i_content_length"); + + /* Add all other headers - which might exist more than once */ + + if (sip->sip_via) { + sip_via_t *vp; + for (vp = sip->sip_via; vp; vp = vp->v_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_via", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if (sip->sip_record_route) { + sip_record_route_t *rrp; + for (rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) { + char *rr = sip_header_as_string(nh->nh_home, (void *) rrp); + switch_channel_add_variable_var_check(channel, "sip_i_record_route", rr, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, rr); + } + } + + if (sip->sip_proxy_authorization) { + sip_proxy_authorization_t *vp; + for (vp = sip->sip_proxy_authorization; vp; vp = vp->au_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_proxy_authorization", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if (sip->sip_call_info) { + sip_call_info_t *vp; + for (vp = sip->sip_call_info; vp; vp = vp->ci_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_call_info", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if (sip->sip_accept) { + sip_accept_t *vp; + for (vp = sip->sip_accept; vp; vp = vp->ac_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_accept", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if (sip->sip_authorization) { + sip_authorization_t *vp; + for (vp = sip->sip_authorization; vp; vp = vp->au_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_authorization", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if ((alert_info = sip_alert_info(sip))) { + sip_alert_info_t *vp; + for (vp = alert_info; vp; vp = vp->ai_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_alert_info", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if ((passerted = sip_p_asserted_identity(sip))) { + sip_p_asserted_identity_t *vp; + for (vp = passerted; vp; vp = vp->paid_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_p_asserted_identity", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if ((ppreferred = sip_p_preferred_identity(sip))) { + sip_p_preferred_identity_t *vp; + for (vp = ppreferred; vp; vp = vp->ppid_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_p_preferred_identity", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if ((rpid = sip_remote_party_id(sip))) { + sip_remote_party_id_t *vp; + for (vp = rpid; vp; vp = vp->rpid_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_remote_party_id", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + if ((reply_to = sip_reply_to(sip))) { + sip_reply_to_t *vp; + for (vp = reply_to; vp; vp = vp->rplyto_next) { + char *v = sip_header_as_string(nh->nh_home, (void *) vp); + switch_channel_add_variable_var_check(channel, "sip_i_reply_to", v, SWITCH_FALSE, SWITCH_STACK_PUSH); + su_free(nh->nh_home, v); + } + } + + /* Loop through the unknown headers */ + for (un = sip->sip_unknown; un; un = un->un_next) { + if (!zstr(un->un_name) && !zstr(un->un_value)) { + char *parsed_name; + if ((parsed_name = switch_mprintf("sip_i_%s", un->un_name))) { + char *p, *x = parsed_name; + switch_tolower_max(x); + while ((p = strchr(x, '-'))) { + *p = '_'; + x = ++p; + } + switch_channel_add_variable_var_check(channel, parsed_name, un->un_value, SWITCH_FALSE, SWITCH_STACK_PUSH); + free(parsed_name); + } + } + } +} void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, char const *phrase, @@ -337,6 +526,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, switch_event_t *s_event = NULL; sofia_gateway_subscription_t *gw_sub_ptr; int sub_state; + sofia_gateway_t *gateway = NULL; tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END()); @@ -445,19 +635,25 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, } } - if (!sofia_private || !sofia_private->gateway) { + if (!sofia_private || zstr(sofia_private->gateway_name)) { if (profile->debug) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Gateway information missing Subscription Event: %s\n", sip->sip_event->o_type); } goto error; } + + + if (!(gateway = sofia_reg_find_gateway(sofia_private->gateway_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n"); + goto error; + } /* find the corresponding gateway subscription (if any) */ - if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, sip->sip_event->o_type))) { + if (!(gw_sub_ptr = sofia_find_gateway_subscription(gateway, sip->sip_event->o_type))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n", - sofia_private->gateway->name, sip->sip_event->o_type); + gateway->name, sip->sip_event->o_type); goto error; } @@ -466,28 +662,39 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, goto error; } + if (sip->sip_subscription_state && sip->sip_subscription_state->ss_expires) { + int delta = atoi(sip->sip_subscription_state->ss_expires); + + delta /= 2; + + if (delta < 1) { + delta = 1; + } + gw_sub_ptr->expires = switch_epoch_time_now(NULL) + delta; + } + /* dispatch freeswitch event */ if (switch_event_create(&s_event, SWITCH_EVENT_NOTIFY_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event", sip->sip_event->o_type); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "pl_data", sip->sip_payload ? sip->sip_payload->pl_data : ""); if ( sip->sip_content_type != NULL ) switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "sip_content_type", sip->sip_content_type->c_type); - switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", sofia_private->gateway->profile->sip_port); + switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", gateway->profile->sip_port); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "module_name", "mod_sofia"); - switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_name", sofia_private->gateway->profile->name); - switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", sofia_private->gateway->profile->url); - switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "gateway_name", sofia_private->gateway->name); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_name", gateway->profile->name); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", gateway->profile->url); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "gateway_name", gateway->name); if ( sip->sip_call_info != NULL ) { sip_call_info_t *call_info = sip->sip_call_info; int cur_len = 0; char *tmp = NULL; char *hold = strdup(sip_header_as_string(nua_handle_home(nh), (void *) call_info)); - cur_len = strlen(hold); + cur_len = (int)strlen(hold); while ( call_info->ci_next != NULL) { call_info = call_info->ci_next; tmp = strdup(sip_header_as_string(nua_handle_home(nh), (void *) call_info)); - cur_len = cur_len + strlen(tmp) +2; + cur_len = cur_len + (int)strlen(tmp) +2; hold = realloc(hold, cur_len); switch_assert(hold); strcat(hold,","); @@ -565,12 +772,16 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, end: - if (sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private && + if (!gateway && sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) { sofia_private->destroy_nh = 1; sofia_private->destroy_me = 1; } + if (gateway) { + sofia_reg_release_gateway(gateway); + } + } void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, @@ -1049,9 +1260,9 @@ static void our_sofia_event_callback(nua_event_t event, if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) { - if ((gateway = sofia_private->gateway)) { - /* Released in sofia_reg_release_gateway() */ - if (sofia_reg_gateway_rdlock(gateway) != SWITCH_STATUS_SUCCESS) { + + if (!zstr(sofia_private->gateway_name)) { + if (!(gateway = sofia_reg_find_gateway(sofia_private->gateway_name))) { return; } } else if (!zstr(sofia_private->uuid)) { @@ -1492,16 +1703,21 @@ static void our_sofia_event_callback(nua_event_t event, sofia_reg_check_socket(profile, sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port); + nua_handle_destroy(nh); } - nua_handle_destroy(nh); } break; case nua_r_authenticate: if (status >= 500) { - if (sofia_private && sofia_private->gateway) { - nua_handle_destroy(sofia_private->gateway->nh); - sofia_private->gateway->nh = NULL; + if (sofia_private && !zstr(sofia_private->gateway_name)) { + sofia_gateway_t *gateway = NULL; + + if ((gateway = sofia_reg_find_gateway(sofia_private->gateway_name))) { + gateway->state = REG_STATE_FAILED; + gateway->failure_status = status; + sofia_reg_release_gateway(gateway); + } } else { nua_handle_destroy(nh); } @@ -1763,7 +1979,7 @@ void sofia_queue_message(sofia_dispatch_event_t *de) } - if ((switch_queue_size(mod_sofia_globals.msg_queue) > (SOFIA_MSG_QUEUE_SIZE * msg_queue_threads))) { + if ((switch_queue_size(mod_sofia_globals.msg_queue) > (SOFIA_MSG_QUEUE_SIZE * (unsigned int)msg_queue_threads))) { launch++; } @@ -1849,7 +2065,7 @@ void sofia_event_callback(nua_event_t event, } - if (switch_queue_size(mod_sofia_globals.msg_queue) > critical) { + if (switch_queue_size(mod_sofia_globals.msg_queue) > (unsigned int)critical) { nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END()); goto end; } @@ -2317,7 +2533,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread if (!sofia_test_pflag(profile, PFLAG_STANDBY)) { - if (++ireg_loops >= profile->ireg_seconds) { + if (++ireg_loops >= (uint32_t)profile->ireg_seconds) { time_t now = switch_epoch_time_now(NULL); sofia_reg_check_expire(profile, now, 0); ireg_loops = 0; @@ -2325,10 +2541,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread if (++gateway_loops >= GATEWAY_SECONDS) { sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL)); + sofia_sub_check_gateway(profile, switch_epoch_time_now(NULL)); gateway_loops = 0; } - - sofia_sub_check_gateway(profile, time(NULL)); } switch_yield(1000000); @@ -2458,7 +2673,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void goto end; } - supported = switch_core_sprintf(profile->pool, "%s%s%sprecondition, path, replaces", use_100rel ? "100rel, " : "", use_timer ? "timer, " : "", use_rfc_5626 ? "outbound, " : ""); + supported = switch_core_sprintf(profile->pool, "%s%s%spath, replaces", use_100rel ? "precondition, 100rel, " : "", use_timer ? "timer, " : "", use_rfc_5626 ? "outbound, " : ""); if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_nat_get_type()) { if ( (! sofia_test_pflag(profile, PFLAG_TLS) || ! profile->tls_only) && switch_nat_add_mapping(profile->sip_port, SWITCH_NAT_UDP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { @@ -2507,6 +2722,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TPTAG_TLS_VERIFY_DATE(profile->tls_verify_date)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS) && profile->tls_verify_in_subjects, TPTAG_TLS_VERIFY_SUBJECTS(profile->tls_verify_in_subjects)), + TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), + TPTAG_TLS_CIPHERS(profile->tls_ciphers)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERSION(profile->tls_version)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS) && profile->tls_timeout, @@ -2523,6 +2740,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TPTAG_PINGPONG(profile->tcp_ping2pong)), TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV503), NTATAG_SRV_503(0)), + TAG_IF(sofia_test_pflag(profile, PFLAG_SOCKET_TCP_KEEPALIVE), + TPTAG_KEEPALIVE(profile->socket_tcp_keepalive)), TAG_IF(sofia_test_pflag(profile, PFLAG_TCP_KEEPALIVE), TPTAG_KEEPALIVE(profile->tcp_keepalive)), NTATAG_DEFAULT_PROXY(profile->outbound_proxy), @@ -2602,13 +2821,13 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void for (via = vias; via; via = via->v_next) { if (sofia_test_pflag(profile, PFLAG_AUTO_ASSIGN_PORT) && !strcmp(via->v_protocol, "SIP/2.0/UDP")) { - profile->sip_port = atoi(via->v_port); + profile->sip_port = (switch_port_t)atoi(via->v_port); if (!profile->extsipport) profile->extsipport = profile->sip_port; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found auto sip port %d for %s\n", profile->sip_port, profile->name); } if (sofia_test_pflag(profile, PFLAG_AUTO_ASSIGN_TLS_PORT) && !strcmp(via->v_protocol, "SIP/2.0/TLS")) { - profile->tls_sip_port = atoi(via->v_port); + profile->tls_sip_port = (switch_port_t)atoi(via->v_port); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found auto sip port %d for %s (TLS)\n", profile->tls_sip_port, profile->name); } @@ -3452,14 +3671,15 @@ static void config_sofia_profile_urls(sofia_profile_t * profile) } if (profile->bind_params) { - char *bindurl = profile->bindurl; + char *bindurl; if (!switch_stristr("transport=", profile->bind_params)) { profile->bind_params = switch_core_sprintf(profile->pool, "%s;transport=udp,tcp", profile->bind_params); } - profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params); + bindurl = switch_core_sprintf(profile->pool, "%s;%s", profile->bindurl, profile->bind_params); + profile->bindurl = bindurl; } else { - char *bindurl = profile->bindurl; - profile->bindurl = switch_core_sprintf(profile->pool, "%s;transport=udp,tcp", bindurl); + char *bindurl = switch_core_sprintf(profile->pool, "%s;transport=udp,tcp", profile->bindurl); + profile->bindurl = bindurl; } @@ -3714,7 +3934,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833;// | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833; profile->pool = pool; - profile->user_agent = SOFIA_USER_AGENT; + + profile->user_agent = switch_core_sprintf(profile->pool, "FreeSWITCH-mod_sofia/%s", switch_version_full()); profile->name = switch_core_strdup(profile->pool, xprofilename); switch_snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename); @@ -3733,8 +3954,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->rtp_digit_delay = 40; profile->sip_force_expires = 0; profile->sip_expires_max_deviation = 0; + profile->sip_expires_late_margin = 60; profile->sip_subscription_max_deviation = 0; - profile->tls_version = 0; + profile->tls_ciphers = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"; + profile->tls_version = SOFIA_TLS_VERSION_TLSv1; + profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_1; + profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_2; profile->tls_timeout = 300; profile->mflags = MFLAG_REFER | MFLAG_REGISTER; profile->server_rport_level = 1; @@ -3743,7 +3968,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) sofia_set_pflag(profile, PFLAG_DISABLE_100REL); profile->auto_restart = 1; sofia_set_media_flag(profile, SCMF_AUTOFIX_TIMING); - sofia_set_media_flag(profile, SCMF_AUTOFIX_PT); + sofia_set_media_flag(profile, SCMF_RENEG_ON_REINVITE); sofia_set_media_flag(profile, SCMF_RTP_AUTOFLUSH_DURING_BRIDGE); profile->contact_user = SOFIA_DEFAULT_CONTACT_USER; sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID); @@ -3800,6 +4025,9 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else if (!strcasecmp(var, "sip-capture") && switch_true(val)) { sofia_set_flag(profile, TFLAG_CAPTURE); nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END()); + } else if (!strcasecmp(var, "socket-tcp-keepalive") && !zstr(val)) { + profile->socket_tcp_keepalive = atoi(val); + sofia_set_pflag(profile, PFLAG_SOCKET_TCP_KEEPALIVE); } else if (!strcasecmp(var, "tcp-keepalive") && !zstr(val)) { profile->tcp_keepalive = atoi(val); sofia_set_pflag(profile, PFLAG_TCP_KEEPALIVE); @@ -3809,6 +4037,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else if (!strcasecmp(var, "tcp-ping2pong") && !zstr(val)) { profile->tcp_ping2pong = atoi(val); sofia_set_pflag(profile, PFLAG_TCP_PING2PONG); + } else if (!strcasecmp(var, "sip-messages-respond-200-ok") && !zstr(val)) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_MESSAGES_RESPOND_200_OK); + } else { + sofia_clear_pflag(profile, PFLAG_MESSAGES_RESPOND_200_OK); + } } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { profile->odbc_dsn = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "db-pre-trans-execute") && !zstr(val)) { @@ -4181,7 +4415,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->sipip = switch_core_strdup(profile->pool, ip); } else if (!strcasecmp(var, "ext-sip-port") && val) { int tmp = atoi(val); - if (tmp > 0) profile->extsipport = tmp; + if (tmp > 0) profile->extsipport = (switch_port_t)tmp; } else if (!strcasecmp(var, "ext-sip-ip")) { if (!zstr(val)) { char *ip = mod_sofia_globals.guess_ip; @@ -4269,6 +4503,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->media_options |= MEDIA_OPT_MEDIA_ON_HOLD; } else if (!strcasecmp(val, "bypass-media-after-att-xfer")) { profile->media_options |= MEDIA_OPT_BYPASS_AFTER_ATT_XFER; + } else if (!strcasecmp(val, "bypass-media-after-hold")) { + if (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) { + profile->media_options |= MEDIA_OPT_BYPASS_AFTER_HOLD; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "bypass-media-after-hold can be set only with resume-media-on-hold media-option\n"); + } } } else if (!strcasecmp(var, "pnp-provision-url")) { profile->pnp_prov_url = switch_core_strdup(profile->pool, val); @@ -4381,12 +4622,6 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { sofia_clear_media_flag(profile, SCMF_AUTOFIX_TIMING); } - } else if (!strcasecmp(var, "rtp-autofix-pt")) { - if (switch_true(val)) { - sofia_set_media_flag(profile, SCMF_AUTOFIX_PT); - } else { - sofia_clear_media_flag(profile, SCMF_AUTOFIX_PT); - } } else if (!strcasecmp(var, "contact-user")) { profile->contact_user = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "nat-options-ping")) { @@ -4500,6 +4735,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { sofia_clear_flag(profile, TFLAG_ENABLE_SOA); } + } else if (!strcasecmp(var, "parse-all-invite-headers")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_PARSE_ALL_INVITE_HEADERS); + } else { + sofia_clear_pflag(profile, PFLAG_PARSE_ALL_INVITE_HEADERS); + } } else if (!strcasecmp(var, "bitpacking")) { if (!strcasecmp(val, "aal2")) { profile->codec_flags = SWITCH_CODEC_FLAG_AAL2; @@ -4662,12 +4903,30 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->tls_passphrase = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "tls-verify-in-subjects") && !zstr(val)) { profile->tls_verify_in_subjects_str = switch_core_strdup(profile->pool, val); + } else if (!strcasecmp(var, "tls-ciphers") && !zstr(val)) { + profile->tls_ciphers = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "tls-version") && !zstr(val)) { - - if (!strcasecmp(val, "tlsv1")) { - profile->tls_version = 1; - } else { - profile->tls_version = 0; + char *ps = val, *pe; + profile->tls_version = 0; + while (1) { + int n; + pe = strchr(ps,','); + if (!pe && !(pe = memchr(ps,0,1024))) break; + n = pe-ps; + if (n==5 && !strncasecmp(ps, "sslv2", n)) + profile->tls_version |= SOFIA_TLS_VERSION_SSLv2; + if (n==5 && !strncasecmp(ps, "sslv3", n)) + profile->tls_version |= SOFIA_TLS_VERSION_SSLv3; + if (n==6 && !strncasecmp(ps, "sslv23", n)) + profile->tls_version |= SOFIA_TLS_VERSION_SSLv2 | SOFIA_TLS_VERSION_SSLv3; + if (n==5 && !strncasecmp(ps, "tlsv1", n)) + profile->tls_version |= SOFIA_TLS_VERSION_TLSv1; + if (n==7 && !strncasecmp(ps, "tlsv1.1", n)) + profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_1; + if (n==7 && !strncasecmp(ps, "tlsv1.2", n)) + profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_2; + ps=pe+1; + if (!*pe) break; } } else if (!strcasecmp(var, "tls-timeout")) { int v = atoi(val); @@ -4706,6 +4965,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { sofia_clear_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY); } + } else if (!strcasecmp(var, "sip-expires-late-margin")) { + int32_t sip_expires_late_margin = atoi(val); + if (sip_expires_late_margin >= 0) { + profile->sip_expires_late_margin = sip_expires_late_margin; + } else { + profile->sip_expires_late_margin = 60; + } } else if (!strcasecmp(var, "sip-force-expires")) { int32_t sip_force_expires = atoi(val); if (sip_force_expires >= 0) { @@ -5124,8 +5390,12 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } tech_pvt->mparams.last_sdp_str = NULL; - if (!sofia_use_soa(tech_pvt) && sip->sip_payload && sip->sip_payload->pl_data) { - tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data); + if (sip->sip_payload && sip->sip_payload->pl_data) { + switch_core_media_set_sdp_codec_string(session, sip->sip_payload->pl_data, SDP_TYPE_RESPONSE); + + if (!sofia_use_soa(tech_pvt)) { + tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data); + } } @@ -5250,7 +5520,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status sofia_update_callee_id(session, profile, sip, SWITCH_FALSE); - if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING) || sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_PT)) { + if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) { switch_core_media_reset_autofix(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); } @@ -5424,7 +5694,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { - switch_channel_clear_flag(tech_pvt->channel, CF_T38_PASSTHRU); + switch_channel_clear_flag(channel, CF_T38_PASSTHRU); has_t38 = 0; } @@ -5476,12 +5746,13 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } else if (status > 299) { switch_channel_set_private(channel, "t38_options", NULL); switch_channel_set_private(other_channel, "t38_options", NULL); - switch_channel_clear_flag(tech_pvt->channel, CF_T38_PASSTHRU); - switch_channel_clear_flag(other_tech_pvt->channel, CF_T38_PASSTHRU); - switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); - switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ); - switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); - } else if (status == 200 && switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && has_t38 && sip->sip_payload && sip->sip_payload->pl_data) { + switch_channel_clear_flag(channel, CF_T38_PASSTHRU); + switch_channel_clear_flag(other_channel, CF_T38_PASSTHRU); + switch_channel_clear_app_flag_key("T38", channel, CF_APP_T38); + switch_channel_clear_app_flag_key("T38", channel, CF_APP_T38_REQ); + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_FAIL); + } else if (status == 200 && switch_channel_test_flag(channel, CF_T38_PASSTHRU) && + has_t38 && sip->sip_payload && sip->sip_payload->pl_data) { switch_t38_options_t *t38_options = switch_core_media_extract_t38_options(session, sip->sip_payload->pl_data); if (!t38_options) { @@ -5509,11 +5780,11 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status msg->pointer_arg_size = strlen(r_sdp); } - if (status == 200 && switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && has_t38) { - if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && - switch_core_media_ready(other_tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { - switch_channel_clear_flag(tech_pvt->channel, CF_NOTIMER_DURING_BRIDGE); - switch_core_media_udptl_mode(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); + if (status == 200 && switch_channel_test_flag(channel, CF_T38_PASSTHRU) && has_t38) { + if (switch_core_media_ready(session, SWITCH_MEDIA_TYPE_AUDIO) && + switch_core_media_ready(other_session, SWITCH_MEDIA_TYPE_AUDIO)) { + switch_channel_clear_flag(channel, CF_NOTIMER_DURING_BRIDGE); + switch_core_media_udptl_mode(session, SWITCH_MEDIA_TYPE_AUDIO); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n"); } } @@ -5873,9 +6144,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp); tech_pvt->mparams.remote_sdp_str = switch_core_session_strdup(session, r_sdp); - if ((sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND)) { - switch_core_media_set_sdp_codec_string(session, r_sdp); - } + //if ((sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND)) { + // switch_core_media_set_sdp_codec_string(session, r_sdp, status < 200 ? SDP_TYPE_REQUEST : SDP_TYPE_RESPONSE); + //} sofia_glue_pass_sdp(tech_pvt, (char *) r_sdp); sofia_set_flag(tech_pvt, TFLAG_NEW_SDP); @@ -5960,7 +6231,40 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } if (r_sdp) { - if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + if (switch_channel_test_flag(channel, CF_PROXY_MODE) && r_sdp) { + char ibuf[35] = "", pbuf[35] = ""; + const char *ptr; + + if ((ptr = switch_stristr("c=IN IP4", r_sdp))) { + int i = 0; + + ptr += 8; + + while(*ptr == ' ') { + ptr++; + } + while(*ptr && *ptr != ' ' && *ptr != '\r' && *ptr != '\n') { + ibuf[i++] = *ptr++; + } + + switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, ibuf); + } + + if ((ptr = switch_stristr("m=audio", r_sdp))) { + int i = 0; + + ptr += 7; + + while(*ptr == ' ') { + ptr++; + } + while(*ptr && *ptr != ' ' && *ptr != '\r' && *ptr != '\n') { + pbuf[i++] = *ptr++; + } + + switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, pbuf); + } + if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA"); } @@ -5985,6 +6289,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } else { if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "DELAYED NEGOTIATION"); + } else if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA"); + switch_core_media_patch_sdp(tech_pvt->session); + if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { + nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END()); + switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); + } else{ + switch_channel_mark_pre_answered(channel); + } + } else { if (sofia_media_tech_media(tech_pvt, (char *) r_sdp) != SWITCH_STATUS_SUCCESS) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR"); @@ -6171,7 +6485,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } else { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP"); switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0); - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); sofia_set_flag_locked(tech_pvt, TFLAG_3PCC); switch_channel_set_state(channel, CS_HIBERNATE); if (sofia_use_soa(tech_pvt)) { @@ -6288,7 +6602,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 1); if (sofia_use_soa(tech_pvt)) { nua_respond(tech_pvt->nh, SIP_200_OK, @@ -6394,7 +6708,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n"); @@ -6413,7 +6727,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (is_ok) { if (switch_core_session_local_crypto_key(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); } if (sofia_use_soa(tech_pvt)) { nua_respond(tech_pvt->nh, SIP_200_OK, @@ -6447,13 +6761,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_channel_set_flag(tech_pvt->channel, CF_REINVITE); if (tech_pvt->mparams.num_codecs) { - match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST); + match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_RESPONSE); } if (match) { if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) { goto done; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n"); switch_channel_set_flag(tech_pvt->channel, CF_REINVITE); @@ -7855,8 +8169,14 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia const char *from_tag = ""; char *sql = NULL; char *acl_context = NULL; + const char *r_sdp = NULL; + int broken_device = 0; + profile->ib_calls++; + if (sip->sip_payload && sip->sip_payload->pl_data) { + r_sdp = sip->sip_payload->pl_data; + } if (!session || (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING))) { nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); @@ -7877,13 +8197,30 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia goto fail; } + sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s receiving invite from %s:%d version: %s\n", + switch_channel_get_name(tech_pvt->channel), network_ip, network_port, switch_version_full_human()); + + if (sip && sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) { is_nat = "websockets"; } - if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) { + + if (r_sdp) { + switch_core_media_set_sdp_codec_string(session, r_sdp, SDP_TYPE_REQUEST); + } + + + if (profile->server_rport_level >= 2 && sip->sip_user_agent && sip->sip_user_agent->g_string && + (!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || + !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) )) { + broken_device = 1; + } + + if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) || broken_device) { if (sip && sip->sip_via) { const char *port = sip->sip_via->v_port; const char *host = sip->sip_via->v_host; @@ -8458,6 +8795,10 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia switch_channel_set_flag(channel, CF_PROXY_MODE); } + if (profile->media_options & MEDIA_OPT_BYPASS_AFTER_HOLD) { + switch_channel_set_flag(channel, CF_BYPASS_MEDIA_AFTER_HOLD); + } + if (sofia_test_flag(tech_pvt, TFLAG_PROXY_MEDIA)) { switch_channel_set_flag(channel, CF_PROXY_MEDIA); } @@ -8993,6 +9334,10 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia sofia_presence_set_chat_hash(tech_pvt, sip); } + if (sofia_test_pflag(profile, PFLAG_PARSE_ALL_INVITE_HEADERS)) { + sofia_parse_all_invite_headers(sip, session, nh); + } + if (sip->sip_to) { to = sip->sip_to->a_url; } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 833a725d44..f2cbba1173 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -288,9 +288,9 @@ enum tport_tls_verify_policy sofia_glue_str2tls_verify_policy(const char * str){ while (ptr_cur) { if ((ptr_next = strchr(ptr_cur, '|'))) { - len = ptr_next++ - ptr_cur; + len = (int)(ptr_next++ - ptr_cur); } else { - len = strlen(ptr_cur); + len = (int)strlen(ptr_cur); } if (!strncasecmp(ptr_cur, "in",len)) { ret |= TPTLS_VERIFY_IN; @@ -483,7 +483,7 @@ void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port) su_addrinfo_t *addrinfo = msg_addrinfo(msg); if (buf) { - get_addr(buf, buflen, addrinfo->ai_addr, addrinfo->ai_addrlen); + get_addr(buf, buflen, addrinfo->ai_addr, (socklen_t)addrinfo->ai_addrlen); } if (port) { @@ -752,7 +752,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } if (!switch_channel_get_private(tech_pvt->channel, "t38_options") || zstr(tech_pvt->mparams.local_sdp_str)) { - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 0); } sofia_set_flag_locked(tech_pvt, TFLAG_READY); @@ -1221,10 +1221,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) tech_pvt->session_refresher = nua_no_refresher; } - if (tech_pvt->mparams.local_sdp_str) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, - "Local SDP:\n%s\n", tech_pvt->mparams.local_sdp_str); - } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s sending invite version: %s\nLocal SDP:\n%s\n", + switch_channel_get_name(tech_pvt->channel), switch_version_full_human(), + tech_pvt->mparams.local_sdp_str ? tech_pvt->mparams.local_sdp_str : "NO SDP PRESENT\n"); if (sofia_use_soa(tech_pvt)) { @@ -1455,7 +1455,10 @@ char *sofia_glue_get_path_from_contact(char *buf) } } - if (!path) return NULL; + if (!path) { + free(contact); + return NULL; + } if ((e = strrchr(path, ';'))) { *e = '\0'; @@ -1834,14 +1837,14 @@ int sofia_recover_callback(switch_core_session_t *session) if ((tmp = switch_channel_get_variable(tech_pvt->channel, "rtp_2833_send_payload"))) { int te = atoi(tmp); if (te > 64) { - tech_pvt->te = te; + tech_pvt->te = (switch_payload_t)te; } } if ((tmp = switch_channel_get_variable(tech_pvt->channel, "rtp_2833_recv_payload"))) { int te = atoi(tmp); if (te > 64) { - tech_pvt->recv_te = te; + tech_pvt->recv_te = (switch_payload_t)te; } } @@ -1911,6 +1914,11 @@ int sofia_recover_callback(switch_core_session_t *session) r++; + if (profile) { + sofia_glue_release_profile(profile); + } + + return r; } @@ -2106,6 +2114,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) "create index sr_orig_server_host on sip_registrations (orig_server_host)", "create index sr_orig_hostname on sip_registrations (orig_hostname)", "create index ss_call_id on sip_subscriptions (call_id)", + "create index ss_multi on sip_subscriptions (call_id, profile_name, hostname)", "create index ss_hostname on sip_subscriptions (hostname)", "create index ss_network_ip on sip_subscriptions (network_ip)", "create index ss_sip_user on sip_subscriptions (sip_user)", diff --git a/src/mod/endpoints/mod_sofia/sofia_media.c b/src/mod/endpoints/mod_sofia/sofia_media.c index 363da93dfc..8bd9a589f0 100644 --- a/src/mod/endpoints/mod_sofia/sofia_media.c +++ b/src/mod/endpoints/mod_sofia/sofia_media.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index ef998c9c88..f88a6f0a99 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -693,6 +693,7 @@ static void do_normal_probe(switch_event_t *event) struct resub_helper h = { 0 }; char *to = switch_event_get_header(event, "to"); char *proto = switch_event_get_header(event, "proto"); + char *profile_name = switch_event_get_header(event, "sip_profile"); char *probe_user = NULL, *probe_euser, *probe_host, *p; struct dialog_helper dh = { { 0 } }; char *sub_call_id = switch_event_get_header(event, "sub-call-id"); @@ -716,7 +717,8 @@ static void do_normal_probe(switch_event_t *event) probe_euser = (p + 1); } - if (probe_euser && probe_host && (profile = sofia_glue_find_profile(probe_host))) { + if (probe_euser && probe_host && + ((profile = sofia_glue_find_profile(probe_host)) || (profile_name && (profile = sofia_glue_find_profile(profile_name))))) { sql = switch_mprintf("select state,status,rpid,presence_id,uuid from sip_dialogs " "where hostname='%q' and profile_name='%q' and call_info_state != 'seized' and " "((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') order by rcd desc", @@ -817,6 +819,7 @@ static void do_normal_probe(switch_event_t *event) if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", probe_euser, probe_host); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "status", "Unregistered"); switch_event_fire(&sevent); @@ -838,7 +841,6 @@ static void do_dialog_probe(switch_event_t *event) char *sql; char *to = switch_event_get_header(event, "to"); char *probe_user = NULL, *probe_euser, *probe_host, *p; - sofia_profile_t *profile; if (!to || !(probe_user = strdup(to))) { return; @@ -852,11 +854,22 @@ static void do_dialog_probe(switch_event_t *event) probe_euser = (p + 1); } - if (probe_euser && probe_host && (profile = sofia_glue_find_profile(probe_host))) { + if (probe_euser && probe_host) { char *sub_call_id = switch_event_get_header(event, "sub-call-id"); + char *profile_name = switch_event_get_header(event, "sip_profile"); + sofia_profile_t *profile = sofia_glue_find_profile(probe_host); struct rfc4235_helper *h4235 = {0}; switch_memory_pool_t *pool; + if (!profile && profile_name) { + profile = sofia_glue_find_profile(profile_name); + } + + if (!profile) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot find profile for domain %s\n", probe_host); + goto end; + } + // We need all dialogs with presence_id matching the subscription entity, // or from a registered set matching the subscription entity. // We need the "proto" of the subscription in case it is for the special "conf" or "park". @@ -936,6 +949,8 @@ static void do_dialog_probe(switch_event_t *event) switch_core_destroy_memory_pool(&pool); } + end: + switch_safe_free(probe_user); } @@ -1529,6 +1544,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", euser, host); switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", euser, host); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence"); @@ -1743,6 +1759,7 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", user, host); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_subtype", "probe"); @@ -1829,6 +1846,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char if (do_event && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", proto ? proto : SOFIA_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", user, host); @@ -3587,8 +3605,8 @@ void sofia_presence_handle_sip_i_subscribe(int status, int found_proto = 0; const char *use_to_tag; char to_tag[13] = ""; - char buf[32] = ""; - int subbed = 0; + char buf[80] = ""; + char *orig_to_user = NULL; if (!sip) { return; @@ -3714,6 +3732,8 @@ void sofia_presence_handle_sip_i_subscribe(int status, } } + orig_to_user = su_strdup(nua_handle_home(nh), to_user); + if (to_user && strchr(to_user, '+')) { char *h; if ((proto = (d_user = strdup(to_user)))) { @@ -3751,8 +3771,8 @@ void sofia_presence_handle_sip_i_subscribe(int status, } if ((sub_state != nua_substate_terminated)) { - sql = switch_mprintf("select count(*) from sip_subscriptions where call_id='%q' and hostname='%q' and profile_name='%q'", - call_id, mod_sofia_globals.hostname, profile->name); + sql = switch_mprintf("select call_id from sip_subscriptions where call_id='%q' and profile_name='%q' and hostname='%q'", + call_id, profile->name, mod_sofia_globals.hostname); sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, buf, sizeof(buf)); @@ -3763,7 +3783,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_safe_free(sql); - if ((subbed = atoi(buf)) > 0) { + if (!zstr(buf)) { sub_state = nua_substate_active; } } @@ -3771,12 +3791,15 @@ void sofia_presence_handle_sip_i_subscribe(int status, if (sub_state == nua_substate_active) { sstr = switch_mprintf("active;expires=%ld", exp_delta); - + sql = switch_mprintf("update sip_subscriptions " - "set expires=%ld " - "where hostname='%q' and profile_name='%q' and call_id='%q' and profile_name='%q'", - (long) switch_epoch_time_now(NULL) + exp_delta, mod_sofia_globals.hostname, profile->name, - call_id, profile->name); + "set expires=%ld, " + "network_ip='%q',network_port='%d',sip_user='%q',sip_host='%q',full_via='%q',full_to='%q',full_from='%q',contact='%q' " + "where call_id='%q' and profile_name='%q' and hostname='%q'", + (long) switch_epoch_time_now(NULL) + exp_delta, + np.network_ip, np.network_port, from_user, from_host, full_via, full_to, full_from, contact_str, + + call_id, profile->name, mod_sofia_globals.hostname); if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, @@ -3920,9 +3943,9 @@ void sofia_presence_handle_sip_i_subscribe(int status, if (contactstr && (p = strchr(contactstr, '@'))) { if (strrchr(p, '>')) { - new_contactstr = switch_mprintf("", to_user, p); + new_contactstr = switch_mprintf("", orig_to_user, p); } } @@ -3945,7 +3968,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending NOTIFY with Expires [0] and State [%s]\n", sstr); } - if (zstr(full_agent) || !switch_stristr("zoiper", full_agent)) { + if (zstr(full_agent) || (*full_agent != 'z' && *full_agent != 'Z')) { /* supress endless loop bug with zoiper */ nua_notify(nh, SIPTAG_EXPIRES_STR("0"), @@ -4171,6 +4194,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "orig_proto", orig_proto); } switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "rpid", "active"); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "status", "Click To Call"); @@ -4184,6 +4208,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "orig_proto", orig_proto); } switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "to", "%s%s%s@%s", proto, "+", to_user, to_host); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto-specific-event-name", event); @@ -4201,6 +4226,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "probe-type", "dialog"); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, to_host); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto-specific-event-name", event); @@ -4215,6 +4241,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name); + switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "presence-source", "subscribe"); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host); switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, to_host); @@ -4283,6 +4310,7 @@ void sofia_presence_handle_sip_r_subscribe(int status, { sip_event_t const *o = NULL; sofia_gateway_subscription_t *gw_sub_ptr; + sofia_gateway_t *gateway = NULL; if (!sip) { return; @@ -4295,18 +4323,25 @@ void sofia_presence_handle_sip_r_subscribe(int status, return; } - if (!sofia_private || !sofia_private->gateway) { + if (!sofia_private || zstr(sofia_private->gateway_name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n"); return; } - /* Find the subscription if one exists */ - if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, o->o_type))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n", - sofia_private->gateway->name, o->o_type); + + if (!(gateway = sofia_reg_find_gateway(sofia_private->gateway_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n"); return; } + + /* Find the subscription if one exists */ + if (!(gw_sub_ptr = sofia_find_gateway_subscription(gateway, o->o_type))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n", + gateway->name, o->o_type); + goto end; + } + /* Update the subscription status for the subscription */ switch (status) { case 200: @@ -4324,19 +4359,22 @@ void sofia_presence_handle_sip_r_subscribe(int status, default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status); gw_sub_ptr->state = SUB_STATE_FAILED; + gw_sub_ptr->expires = switch_epoch_time_now(NULL); + gw_sub_ptr->retry = switch_epoch_time_now(NULL); - if (sofia_private) { - if (gw_sub_ptr->nh) { - nua_handle_bind(gw_sub_ptr->nh, NULL); - nua_handle_destroy(gw_sub_ptr->nh); - gw_sub_ptr->nh = NULL; - } - } else { + if (!sofia_private) { nua_handle_destroy(nh); } - + break; } + + end: + + if (gateway) { + sofia_reg_release_gateway(gateway); + } + } @@ -4517,6 +4555,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user-agent", full_agent); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", note_txt); @@ -4613,7 +4652,7 @@ void sofia_presence_handle_sip_i_message(int status, auth_res = sofia_reg_parse_auth(profile, authorization, sip, de, (char *) sip->sip_request->rq_method_name, key, keylen, network_ip, NULL, 0, REG_INVITE, NULL, NULL, NULL, NULL); - } else if ( sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, keylen, &v_event, NULL, NULL, NULL)) { + } else if ( sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL)) { if (v_event) { switch_event_destroy(&v_event); } @@ -4770,7 +4809,11 @@ void sofia_presence_handle_sip_i_message(int status, end: - nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END()); + if (sofia_test_pflag(profile, PFLAG_MESSAGES_RESPOND_200_OK)) { + nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END()); + } else { + nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END()); + } } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 821a086880..e8682fab2a 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -56,23 +56,22 @@ static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach) NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); if (attach) { if (!gateway_ptr->sofia_private) { - gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); - switch_assert(gateway_ptr->sofia_private); + switch_zmalloc(gateway_ptr->sofia_private, sizeof(*gateway_ptr->sofia_private)); } - memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); - gateway_ptr->sofia_private->gateway = gateway_ptr; + switch_set_string(gateway_ptr->sofia_private->gateway_name, gateway_ptr->name); nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); } } -static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr, int attach) +static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr) { sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway; char *user_via = NULL; char *register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy); int ss_state = nua_callstate_authenticating; + /* check for NAT and place a Via header if necessary (hostname or non-local IP) */ if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) { user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport); @@ -82,7 +81,7 @@ static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr, i nua_handle_bind(gw_sub_ptr->nh, NULL); nua_handle_destroy(gw_sub_ptr->nh); gw_sub_ptr->nh = NULL; - sofia_private_free(gateway_ptr->sofia_private); + sofia_private_free(gw_sub_ptr->sofia_private); } gw_sub_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, @@ -90,16 +89,12 @@ static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr, i TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_TO_STR(gateway_ptr->register_to), NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); - if (attach) { - if (!gateway_ptr->sofia_private) { - gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); - switch_assert(gateway_ptr->sofia_private); - } - memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); - - gateway_ptr->sofia_private->gateway = gateway_ptr; - nua_handle_bind(gw_sub_ptr->nh, gateway_ptr->sofia_private); + if (!gw_sub_ptr->sofia_private) { + switch_zmalloc(gw_sub_ptr->sofia_private, sizeof(*gw_sub_ptr->sofia_private)); } + + switch_set_string(gw_sub_ptr->sofia_private->gateway_name, gateway_ptr->name); + nua_handle_bind(gw_sub_ptr->nh, gw_sub_ptr->sofia_private); switch_safe_free(register_host); switch_safe_free(user_via); @@ -109,6 +104,8 @@ static void sofia_reg_kill_sub(sofia_gateway_subscription_t *gw_sub_ptr) { sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway; + sofia_private_free(gw_sub_ptr->sofia_private); + if (gw_sub_ptr->nh) { nua_handle_bind(gw_sub_ptr->nh, NULL); } @@ -141,6 +138,7 @@ static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Destroying registration handle for %s\n", gateway_ptr->name); } + sofia_private_free(gateway_ptr->sofia_private); nua_handle_bind(gateway_ptr->nh, NULL); nua_handle_destroy(gateway_ptr->nh); gateway_ptr->nh = NULL; @@ -175,20 +173,18 @@ void sofia_reg_unregister(sofia_profile_t *profile) nua_handle_bind(gateway_ptr->nh, NULL); } - if (gateway_ptr->sofia_private) { - sofia_private_free(gateway_ptr->sofia_private); - } - if (gateway_ptr->state == REG_STATE_REGED) { sofia_reg_kill_reg(gateway_ptr); } for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) { + if (gw_sub_ptr->state == SUB_STATE_SUBED) { sofia_reg_kill_sub(gw_sub_ptr); } } + gateway_ptr->subscriptions = NULL; } switch_mutex_unlock(mod_sofia_globals.hash_mutex); } @@ -229,7 +225,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) break; case SUB_STATE_UNSUBED: - sofia_reg_new_sub_handle(gw_sub_ptr, 1); + sofia_reg_new_sub_handle(gw_sub_ptr); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); @@ -1071,7 +1067,8 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char int r = 0; time_t *last, now = switch_epoch_time_now(NULL); - snprintf(key, sizeof(key), "%s%s", user, host); + snprintf(key, sizeof(key)-1, "%s%s", user, host); + key[sizeof(key)-1] = '\0'; switch_mutex_lock(profile->ireg_mutex); if ((last = switch_core_hash_find(profile->mwi_debounce_hash, key))) { @@ -1335,11 +1332,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand if (sip->sip_path) { - path_val = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_path); - path_encoded_len = (int)(strlen(path_val) * 3) + 1; - switch_zmalloc(path_encoded, path_encoded_len); - switch_copy_string(path_encoded, ";fs_path=", 10); - switch_url_encode(path_val, path_encoded + 9, path_encoded_len - 9); + if ((path_val = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_path))) { + char *path_stripped = sofia_glue_get_url_from_contact(path_val, SWITCH_TRUE); + path_val = path_stripped; + path_encoded_len = (int)(strlen(path_val) * 3) + 1; + switch_zmalloc(path_encoded, path_encoded_len); + switch_copy_string(path_encoded, ";fs_path=", 10); + switch_url_encode(path_val, path_encoded + 9, path_encoded_len - 9); + } } else if (is_nat) { char my_contact_str[1024]; if (uparams) { @@ -1464,7 +1464,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand to_user = force_user; } - if (profile->server_rport_level == 3 && sip->sip_user_agent && + if (profile->server_rport_level >= 2 && sip->sip_user_agent && sip->sip_user_agent->g_string && ( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) )) { if (sip && sip->sip_via) { @@ -1731,7 +1731,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand contact = sofia_glue_get_url_from_contact(contact_str, 1); url = switch_mprintf("sofia/%q/%s:%q", profile->name, proto, sofia_glue_strip_proto(contact)); - switch_core_add_registration(to_user, reg_host, call_id, url, (long) reg_time + (long) exptime + 60, + switch_core_add_registration(to_user, reg_host, call_id, url, (long) reg_time + (long) exptime + profile->sip_expires_late_margin, network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp", reg_meta); switch_safe_free(url); @@ -1777,7 +1777,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand "mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host) " "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q')", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "", - contact_str, reg_desc, rpid, (long) reg_time + (long) exptime + 60, + contact_str, reg_desc, rpid, (long) reg_time + (long) exptime + profile->sip_expires_late_margin, agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host); } else { @@ -1789,7 +1789,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand call_id, sub_host, network_ip, network_port_c, profile->presence_hosts ? profile->presence_hosts : "", guess_ip4, guess_ip4, mod_sofia_globals.hostname, mod_sofia_globals.hostname, - (long) reg_time + (long) exptime + 60, + (long) reg_time + (long) exptime + profile->sip_expires_late_margin, to_user, username, reg_host, contact_str); } @@ -1808,9 +1808,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand if (multi_reg) { if (multi_reg_contact) { - sql = switch_mprintf("delete from sip_registrations where contact='%q' and expires!=%ld", contact_str, (long) reg_time + (long) exptime + 60); + sql = switch_mprintf("delete from sip_registrations where contact='%q' and expires!=%ld", contact_str, (long) reg_time + (long) exptime + profile->sip_expires_late_margin); } else { - sql = switch_mprintf("delete from sip_registrations where call_id='%q' and expires!=%ld", call_id, (long) reg_time + (long) exptime + 60); + sql = switch_mprintf("delete from sip_registrations where call_id='%q' and expires!=%ld", call_id, (long) reg_time + (long) exptime + profile->sip_expires_late_margin); } sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); @@ -1961,8 +1961,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } } else { const char *username = "unknown"; + const char *realm = "unknown"; + if (auth_params) { username = switch_event_get_header(auth_params, "sip_auth_username"); + realm = switch_event_get_header(auth_params, "sip_auth_realm"); } switch_core_del_registration(to_user, reg_host, call_id); @@ -1975,6 +1978,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "contact", contact_str); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "call-id", call_id); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", rpid); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "realm", realm); switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long) exptime); } } @@ -2038,6 +2042,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand switch_safe_free(display_m); switch_safe_free(dup_mwi_account); switch_safe_free(utmp); + switch_safe_free(path_val); if (auth_params) { switch_event_destroy(&auth_params); @@ -2184,17 +2189,20 @@ void sofia_reg_handle_sip_r_register(int status, sofia_dispatch_event_t *de, tagi_t tags[]) { - if (status >= 500) { - if (sofia_private && sofia_private->gateway) { - nua_handle_destroy(sofia_private->gateway->nh); - sofia_private->gateway->nh = NULL; - } else { - nua_handle_destroy(nh); - } + sofia_gateway_t *gateway = NULL; + + + if (!sofia_private) { + nua_handle_destroy(nh); + return; + } + + if (sofia_private && !zstr(sofia_private->gateway_name)) { + gateway = sofia_reg_find_gateway(sofia_private->gateway_name); } - if (sofia_private && sofia_private->gateway) { - reg_state_t ostate = sofia_private->gateway->state; + if (sofia_private && gateway) { + reg_state_t ostate = gateway->state; switch (status) { case 200: if (sip && sip->sip_contact) { @@ -2206,7 +2214,7 @@ void sofia_reg_handle_sip_r_register(int status, for (; contact; contact = contact->m_next) { if ((full = sip_header_as_string(nh->nh_home, (void *) contact))) { - if (switch_stristr(sofia_private->gateway->register_contact, full)) { + if (switch_stristr(gateway->register_contact, full)) { break; } @@ -2223,37 +2231,42 @@ void sofia_reg_handle_sip_r_register(int status, new_expires = contact->m_expires; expi = (uint32_t) atoi(new_expires); - if (expi > 0 && expi != sofia_private->gateway->freq) { - //sofia_private->gateway->freq = expi; - //sofia_private->gateway->expires_str = switch_core_sprintf(sofia_private->gateway->pool, "%d", expi); + if (expi > 0 && expi != gateway->freq) { + //gateway->freq = expi; + //gateway->expires_str = switch_core_sprintf(gateway->pool, "%d", expi); if (expi > 60) { - sofia_private->gateway->expires = switch_epoch_time_now(NULL) + (expi - 15); + gateway->expires = switch_epoch_time_now(NULL) + (expi - 15); } else { - sofia_private->gateway->expires = switch_epoch_time_now(NULL) + (expi - 2); + gateway->expires = switch_epoch_time_now(NULL) + (expi - 2); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Changing expire time to %d by request of proxy %s\n", expi, sofia_private->gateway->register_proxy); + "Changing expire time to %d by request of proxy %s\n", expi, gateway->register_proxy); } } } - sofia_private->gateway->state = REG_STATE_REGISTER; + gateway->state = REG_STATE_REGISTER; break; case 100: break; default: - sofia_private->gateway->state = REG_STATE_FAILED; - sofia_private->gateway->failure_status = status; + gateway->state = REG_STATE_FAILED; + gateway->failure_status = status; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Registration Failed with status %s [%d]. failure #%d\n", - sofia_private->gateway->name, switch_str_nil(phrase), status, ++sofia_private->gateway->failures); + gateway->name, switch_str_nil(phrase), status, ++gateway->failures); break; } - if (ostate != sofia_private->gateway->state) { - sofia_reg_fire_custom_gateway_state_event(sofia_private->gateway, status, phrase); + if (ostate != gateway->state) { + sofia_reg_fire_custom_gateway_state_event(gateway, status, phrase); } } + + if (gateway) { + sofia_reg_release_gateway(gateway); + } + } void sofia_reg_handle_sip_r_challenge(int status, @@ -2282,8 +2295,12 @@ void sofia_reg_handle_sip_r_challenge(int status, sip_auth_password = switch_channel_get_variable(channel, "sip_auth_password"); } - if (sofia_private && *sofia_private->auth_gateway_name) { - gw_name = sofia_private->auth_gateway_name; + if (sofia_private) { + if (*sofia_private->auth_gateway_name) { + gw_name = sofia_private->auth_gateway_name; + } else if (*sofia_private->gateway_name) { + gw_name = sofia_private->gateway_name; + } } if (session) { @@ -2407,7 +2424,7 @@ void sofia_reg_handle_sip_r_challenge(int status, tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), SIPTAG_WWW_AUTHENTICATE_REF(authenticate), TAG_END()); nua_authenticate(nh, - TAG_IF(sofia_private && sofia_private->gateway, SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600")), + TAG_IF(gateway, SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600")), NUTAG_AUTH(authentication), TAG_END()); goto end; diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index 4e6083086a..700fb4a9be 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c index df07c24f42..74a4c5df8e 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -69,6 +69,26 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mongodb_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_mongodb_shutdown); SWITCH_MODULE_DEFINITION(mod_cdr_mongodb, mod_cdr_mongodb_load, mod_cdr_mongodb_shutdown, NULL); +static void bson_append_value(bson *cdr, char *name, char *val) +{ + //Check the variable and insert it as int, long int or string depending on it's value + char* endptr; + long int lintValue = strtol(val, &endptr, 10); + + if (!*endptr){ + int intValue = lintValue; + if(intValue == lintValue){ + bson_append_int(cdr, name, intValue); + }else{ + bson_append_long(cdr, name, lintValue); + } + } else { + bson_append_string(cdr, name, val); + } + +} + + static void set_bson_profile_data(bson *b, switch_caller_profile_t *caller_profile) { bson_append_string(b, "username", caller_profile->username); @@ -162,7 +182,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) if ((hi = switch_channel_variable_first(channel))) { for (; hi; hi = hi->next) { if (!zstr(hi->name) && !zstr(hi->value)) { - bson_append_string(&cdr, hi->name, hi->value); + bson_append_value(&cdr, hi->name, hi->value); } } switch_channel_variable_last(channel); diff --git a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c index bf9ec59325..c80826000e 100644 --- a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c +++ b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_cdr_sqlite/mod_cdr_sqlite.c b/src/mod/event_handlers/mod_cdr_sqlite/mod_cdr_sqlite.c index c1b973bb00..44defd1805 100644 --- a/src/mod/event_handlers/mod_cdr_sqlite/mod_cdr_sqlite.c +++ b/src/mod/event_handlers/mod_cdr_sqlite/mod_cdr_sqlite.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c index c63f97cfea..3c2a128401 100644 --- a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c +++ b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index 7c3ed3a1fb..fdd0aaad26 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index e79013befe..fd248b4dc6 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h index bf2a0eef86..f4e6b2b28d 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c index 75c9f8b791..d3b0d61aad 100644 --- a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c +++ b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -412,7 +412,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load) switch_goto_status(SWITCH_STATUS_TERM, fail); } - if (switch_mcast_loopback(globals.udp_socket, globals.loopback) != SWITCH_STATUS_SUCCESS) { + if (switch_mcast_loopback(globals.udp_socket, (uint8_t)globals.loopback) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set loopback to '%d'\n", globals.loopback); switch_goto_status(SWITCH_STATUS_TERM, fail); } @@ -573,7 +573,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_multicast_runtime) char *var, *val, *term = NULL, tmpname[128]; switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes"); var = packet; - while (*var) { + while (var && *var) { if ((val = strchr(var, ':')) != 0) { *val++ = '\0'; while (*val == ' ') { diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 0c5cd880db..8ba47adfd6 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -31,7 +31,7 @@ */ #include #define CMD_BUFLEN 1024 * 1000 -#define MAX_QUEUE_LEN 25000 +#define MAX_QUEUE_LEN 100000 #define MAX_MISSED 500 SWITCH_MODULE_LOAD_FUNCTION(mod_event_socket_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown); @@ -127,6 +127,7 @@ static struct { uint32_t acl_count; uint32_t id; int nat_map; + int stop_on_bind_error; } prefs; @@ -593,9 +594,9 @@ static void send_disconnect(listener_t *listener, const char *message) if (listener->session) { switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n" "Controlled-Session-UUID: %s\n" - "Content-Disposition: disconnect\n" "Content-Length: %d\n\n", switch_core_session_get_uuid(listener->session), mlen); + "Content-Disposition: disconnect\n" "Content-Length: %d\n\n", switch_core_session_get_uuid(listener->session), (int)mlen); } else { - switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\nContent-Length: %d\n\n", mlen); + switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\nContent-Length: %d\n\n", (int)mlen); } if (!listener->sock) return; @@ -965,7 +966,7 @@ SWITCH_STANDARD_API(event_sink_function) while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_log_node_t *dnode = (switch_log_node_t *) pop; - int encode_len = (strlen(dnode->data) * 3) + 1; + size_t encode_len = (strlen(dnode->data) * 3) + 1; char *encode_buf = malloc(encode_len); switch_assert(encode_buf); @@ -1131,7 +1132,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, char *tmp; int pos; - pos = (ptr - mbuf); + pos = (int)(ptr - mbuf); buf_len += block_len; tmp = realloc(mbuf, buf_len); switch_assert(tmp); @@ -1569,12 +1570,18 @@ static switch_bool_t auth_api_command(listener_t *listener, const char *api_cmd, static switch_status_t parse_command(listener_t *listener, switch_event_t **event, char *reply, uint32_t reply_len) { switch_status_t status = SWITCH_STATUS_SUCCESS; - char *cmd = switch_event_get_header(*event, "command"); + char *cmd = NULL; char unload_cheat[] = "api bgapi unload mod_event_socket"; char reload_cheat[] = "api bgapi reload mod_event_socket"; *reply = '\0'; + if (!event || !*event || !(cmd = switch_event_get_header(*event, "command"))) { + switch_clear_flag_locked(listener, LFLAG_RUNNING); + switch_snprintf(reply, reply_len, "-ERR command parse error."); + goto done; + } + if (switch_stristr("unload", cmd) && switch_stristr("mod_event_socket", cmd)) { cmd = unload_cheat; } else if (switch_stristr("reload", cmd) && switch_stristr("mod_event_socket", cmd)) { @@ -2288,7 +2295,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even listener->linger_timeout = linger_time; switch_set_flag_locked(listener, LFLAG_LINGER); if (listener->linger_timeout != (time_t) -1) { - switch_snprintf(reply, reply_len, "+OK will linger %d seconds", linger_time); + switch_snprintf(reply, reply_len, "+OK will linger %d seconds", (int)linger_time); } else { switch_snprintf(reply, reply_len, "+OK will linger"); } @@ -2508,7 +2515,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) for (x = 0; x < prefs.acl_count; x++) { if (!switch_check_network_list_ip(listener->remote_ip, prefs.acl[x])) { const char message[] = "Access Denied, go away.\n"; - int mlen = strlen(message); + int mlen = (int)strlen(message); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", listener->remote_ip, prefs.acl[x]); @@ -2734,6 +2741,8 @@ static int config(void) } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max acl records of %d reached\n", MAX_ACL); } + } else if (!strcasecmp(var, "stop-on-bind-error")) { + prefs.stop_on_bind_error = switch_true(val) ? 1 : 0; } } } @@ -2813,6 +2822,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) break; sock_fail: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error! Could not listen on %s:%u\n", prefs.ip, prefs.port); + if (prefs.stop_on_bind_error) { + prefs.done = 1; + goto fail; + } switch_yield(100000); } diff --git a/src/mod/event_handlers/mod_event_test/mod_event_test.c b/src/mod/event_handlers/mod_event_test/mod_event_test.c index 911949c1b6..fe8e78e45e 100644 --- a/src/mod/event_handlers/mod_event_test/mod_event_test.c +++ b/src/mod/event_handlers/mod_event_test/mod_event_test.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_format_cdr/mod_format_cdr.c b/src/mod/event_handlers/mod_format_cdr/mod_format_cdr.c index 6b3ee46fc0..b59720a934 100644 --- a/src/mod/event_handlers/mod_format_cdr/mod_format_cdr.c +++ b/src/mod/event_handlers/mod_format_cdr/mod_format_cdr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c index c6dc7a6078..4c7c8eb1d7 100644 --- a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c +++ b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -603,9 +603,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_json_cdr_load) } } - if (globals.retries && globals.delay) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries set but delay 0 setting to 5000ms\n"); - globals.delay = 5000; + if (globals.retries && !globals.delay) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries set but delay 0 setting to 5 seconds\n"); + globals.delay = 5; } globals.retries++; diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c index c2dd6e103a..b2aba2f621 100644 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c +++ b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_rayo/Makefile b/src/mod/event_handlers/mod_rayo/Makefile index 6fccfdf318..070f41f98c 100644 --- a/src/mod/event_handlers/mod_rayo/Makefile +++ b/src/mod/event_handlers/mod_rayo/Makefile @@ -10,7 +10,10 @@ LOCAL_OBJS= $(IKS_LA) \ iks_helpers.o \ nlsml.o \ rayo_components.o \ + rayo_cpa_component.o \ + rayo_cpa_detector.o \ rayo_elements.o \ + rayo_fax_components.o \ rayo_input_component.o \ rayo_output_component.o \ rayo_prompt_component.o \ @@ -22,7 +25,10 @@ LOCAL_SOURCES= \ iks_helpers.c \ nlsml.c \ rayo_components.c \ + rayo_cpa_component.c \ + rayo_cpa_detector.c \ rayo_elements.c \ + rayo_fax_components.c \ rayo_input_component.c \ rayo_output_component.c \ rayo_prompt_component.c \ diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml index 35419319bc..50af0f7ecd 100644 --- a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml +++ b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml @@ -16,6 +16,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -43,20 +109,27 @@ - - + + + + ]]> + ]]> + ]]> ]]> + ]]> ]]> ]]> - ]]> - ]]> - ]]> - ]]> + ]]> + ]]> + ]]> + ]]> + ]]> ]]> + ]]> ]]> ]]> ]]> @@ -65,6 +138,8 @@ ]]> ]]> ]]> + ]]> + ]]> ]]> ]]> ]]> diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.c b/src/mod/event_handlers/mod_rayo/iks_helpers.c index 30d9d215a5..93be6db3a2 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.c +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.c @@ -522,6 +522,29 @@ char *iks_server_dialback_key(const char *secret, const char *receiving_server, return NULL; } +/** + * Print base 64 encoded SHA-1 hash + * @param sha hash to print + * @param buf to store baes 64 encoded hash + */ +void iks_sha_print_base64(iksha *sha, char *buf) +{ + int i; + char hex_digit[3] = { 0 }; + char hex_buf[SHA_1_HASH_BUF_SIZE]; + unsigned char bin_buf[SHA_1_HASH_BUF_SIZE / 2]; + iks_sha_print(sha, hex_buf); + + /* convert hex string to octets */ + for (i = 0; i < SHA_1_HASH_BUF_SIZE; i += 2) { + hex_digit[0] = hex_buf[i]; + hex_digit[1] = hex_buf[i + 1]; + bin_buf[i / 2] = strtol(hex_digit, NULL, 16); + } + + switch_b64_encode(bin_buf, SHA_1_HASH_BUF_SIZE / 2, (unsigned char *)buf, SHA_1_HASH_BUF_SIZE); +} + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/event_handlers/mod_rayo/iks_helpers.h b/src/mod/event_handlers/mod_rayo/iks_helpers.h index 3a7bae02e7..2017134713 100644 --- a/src/mod/event_handlers/mod_rayo/iks_helpers.h +++ b/src/mod/event_handlers/mod_rayo/iks_helpers.h @@ -32,6 +32,8 @@ #include #include +#define SHA_1_HASH_BUF_SIZE 40 + #define IKS_JABBER_SERVER_PORT 5269 #define IKS_NS_XMPP_DISCO "http://jabber.org/protocol/disco#info" @@ -40,6 +42,7 @@ #define IKS_NS_XMPP_STREAMS "http://etherx.jabber.org/streams" #define IKS_NS_XMPP_DIALBACK "jabber:server:dialback" #define IKS_NS_XMPP_TLS "urn:ietf:params:xml:ns:xmpp-tls" +#define IKS_NS_XMPP_ENTITY_CAPABILITIES "http://jabber.org/protocol/caps" struct xmpp_error { const char *name; @@ -53,7 +56,6 @@ struct xmpp_error { #include "xmpp_errors.def" /* See RFC-3920 XMPP core for error definitions */ - extern iks *iks_new_presence(const char *name, const char *namespace, const char *from, const char *to); extern iks *iks_new_error(iks *iq, const struct xmpp_error *err); extern iks *iks_new_error_detailed(iks *iq, const struct xmpp_error *err, const char *detail_text); @@ -70,6 +72,7 @@ extern const char *iks_net_error_to_string(int err); extern iks *iks_insert_attrib_printf(iks *xml, const char *name, const char *fmt, ...); extern char *iks_server_dialback_key(const char *secret, const char *receiving_server, const char *originating_server, const char *stream_id); +extern void iks_sha_print_base64(iksha *sha, char *buf); /** A function to validate attribute value */ typedef int (*iks_attrib_validation_function)(const char *); diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 6dd58d29c6..9b206530bb 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -126,6 +126,8 @@ struct rayo_call { switch_hash_t *pcps; /** current idle start time */ switch_time_t idle_start_time; + /** true if fax is in progress */ + int faxing; /** 1 if joined to call, 2 if joined to mixer */ int joined; /** pending join */ @@ -133,11 +135,13 @@ struct rayo_call { /** ID of joined party TODO this will be many mixers / calls */ const char *joined_id; /** set if response needs to be sent to IQ request */ - const char *dial_id; + const char *dial_request_id; /** channel destroy event */ switch_event_t *end_event; /** True if ringing event sent to client */ int ringing_sent; + /** True if request to create this call failed */ + int dial_request_failed; }; /** @@ -166,9 +170,9 @@ struct rayo_mixer_member { * A subscriber to mixer events */ struct rayo_mixer_subscriber { - /** JID of subscriber */ + /** JID of client */ const char *jid; - /** Number of controlled parties in mixer */ + /** Number of client's calls in mixer */ int ref_count; }; @@ -246,6 +250,54 @@ typedef switch_bool_t (* rayo_actor_match_fn)(struct rayo_actor *); static switch_bool_t is_call_actor(struct rayo_actor *actor); +/** + * Entity features returned by service discovery + */ +struct entity_identity { + /** identity category */ + const char *category; + /** identity type */ + const char *type; +}; + +static struct entity_identity rayo_server_identity = { "server", "im" }; +static const char *rayo_server_features[] = { IKS_NS_XMPP_ENTITY_CAPABILITIES, IKS_NS_XMPP_DISCO, RAYO_NS, RAYO_CPA_NS, RAYO_FAX_NS, 0 }; + +static struct entity_identity rayo_mixer_identity = { "client", "rayo_mixer" }; +static const char *rayo_mixer_features[] = { 0 }; + +static struct entity_identity rayo_call_identity = { "client", "rayo_call" }; +static const char *rayo_call_features[] = { 0 }; + +/** + * Calculate SHA-1 hash of entity capabilities + * @param identity of entity + * @param features of identity (NULL terminated) + * @return base64 hash (free when done) + */ +static char *calculate_entity_sha1_ver(struct entity_identity *identity, const char **features) +{ + int i; + const char *feature; + char ver[SHA_1_HASH_BUF_SIZE + 1] = { 0 }; + iksha *sha; + + sha = iks_sha_new(); + iks_sha_hash(sha, (const unsigned char *)identity->category, strlen(identity->category), 0); + iks_sha_hash(sha, (const unsigned char *)"/", 1, 0); + iks_sha_hash(sha, (const unsigned char *)identity->type, strlen(identity->type), 0); + iks_sha_hash(sha, (const unsigned char *)"//", 2, 0); + i = 0; + while ((feature = features[i++])) { + iks_sha_hash(sha, (const unsigned char *)"<", 1, 0); + iks_sha_hash(sha, (const unsigned char *)feature, strlen(feature), 0); + } + iks_sha_hash(sha, (const unsigned char *)"<", 1, 1); + iks_sha_print_base64(sha, ver); + iks_sha_delete(sha); + + return strdup(ver); +} /** * @param msg to check @@ -404,6 +456,32 @@ static void add_header(iks *node, const char *name, const char *value) } } +/** + * Send event to clients + * @param from event sender + * @param rayo_event the event to send + * @param online_only only send to online clients + */ +static void broadcast_event(struct rayo_actor *from, iks *rayo_event, int online_only) +{ + switch_hash_index_t *hi = NULL; + switch_mutex_lock(globals.clients_mutex); + for (hi = switch_hash_first(NULL, globals.clients_roster); hi; hi = switch_hash_next(hi)) { + struct rayo_client *rclient; + const void *key; + void *val; + switch_hash_this(hi, &key, NULL, &val); + rclient = (struct rayo_client *)val; + switch_assert(rclient); + + if (!online_only || rclient->availability == PS_ONLINE) { + iks_insert_attrib(rayo_event, "to", RAYO_JID(rclient)); + RAYO_SEND_MESSAGE_DUP(from, RAYO_JID(rclient), rayo_event); + } + } + switch_mutex_unlock(globals.clients_mutex); +} + /** * Add an outbound dialing gateway * @param uri_prefix to match @@ -727,8 +805,9 @@ struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line if (actor) { if (!actor->destroy) { actor->ref_count++; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Locate %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Locate (jid) %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); } else { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_WARNING, "Locate (jid) %s: already marked for destruction!\n", jid); actor = NULL; } } @@ -750,8 +829,9 @@ struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int if (actor) { if (!actor->destroy) { actor->ref_count++; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Locate %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Locate (id) %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); } else { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_WARNING, "Locate (id) %s: already marked for destruction!\n", id); actor = NULL; } } @@ -776,7 +856,12 @@ void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line) } actor->destroy = 1; if (actor->ref_count <= 0) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Destroying %s\n", RAYO_JID(actor)); + if (actor->ref_count < 0) { + /* too many unlocks detected! */ + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_WARNING, "Destroying %s, ref_count = %i\n", RAYO_JID(actor), actor->ref_count); + } else { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Destroying %s\n", RAYO_JID(actor)); + } if (actor->cleanup_fn) { actor->cleanup_fn(actor); } @@ -809,7 +894,12 @@ void rayo_actor_unlock(struct rayo_actor *actor, const char *file, int line) if (actor) { switch_mutex_lock(globals.actors_mutex); actor->ref_count--; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Unlock %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); + if (actor->ref_count < 0) { + /* too many unlocks detected! */ + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_WARNING, "Unlock %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); + } else { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, "", SWITCH_LOG_DEBUG, "Unlock %s: ref count = %i\n", RAYO_JID(actor), actor->ref_count); + } if (actor->ref_count <= 0 && actor->destroy) { rayo_actor_destroy(actor, file, line); } @@ -874,15 +964,28 @@ static void rayo_call_cleanup(struct rayo_actor *actor) switch_hash_index_t *hi = NULL; iks *revent; iks *end; + const char *dcp_jid = rayo_call_get_dcp_jid(call); - if (!event) { + if (!event || call->dial_request_failed) { /* destroyed before FS session was created (in originate, for example) */ - return; + goto done; } + /* send call unjoined event, if not already sent */ + if (call->joined && call->joined_id) { + if (!zstr(dcp_jid)) { + iks *unjoined; + iks *uevent = iks_new_presence("unjoined", RAYO_NS, RAYO_JID(call), dcp_jid); + unjoined = iks_find(uevent, "unjoined"); + iks_insert_attrib_printf(unjoined, "call-uri", "%s", call->joined_id); + RAYO_SEND_MESSAGE(call, dcp_jid, uevent); + } + } + + /* build call end event */ revent = iks_new_presence("end", RAYO_NS, RAYO_JID(call), - rayo_call_get_dcp_jid(call)); + "foo"); iks_insert_attrib(revent, "type", "unavailable"); end = iks_find(revent, "end"); @@ -890,12 +993,17 @@ static void rayo_call_cleanup(struct rayo_actor *actor) iks_insert(end, RAYO_END_REASON_HANGUP_LOCAL); } else { /* remote hangup... translate to specific rayo reason */ + iks *reason; switch_call_cause_t cause = SWITCH_CAUSE_NONE; char *cause_str = switch_event_get_header(event, "variable_hangup_cause"); + char *cause_q850_str = switch_event_get_header(event, "variable_hangup_cause_q850"); if (cause_str) { cause = switch_channel_str2cause(cause_str); } - iks_insert(end, switch_cause_to_rayo_cause(cause)); + reason = iks_insert(end, switch_cause_to_rayo_cause(cause)); + if (!zstr(cause_q850_str)) { + iks_insert_attrib(reason, "platform-code", cause_q850_str); + } } #if 0 @@ -933,12 +1041,17 @@ static void rayo_call_cleanup(struct rayo_actor *actor) no_offered_clients = 0; } - if (no_offered_clients) { + if (no_offered_clients && !zstr(dcp_jid)) { /* send to DCP only */ - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_DEBUG, "Sending to DCP %s\n", rayo_call_get_dcp_jid(call)); - RAYO_SEND_MESSAGE_DUP(actor, rayo_call_get_dcp_jid(call), revent); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_DEBUG, "Sending to DCP %s\n", dcp_jid); + iks_insert_attrib(revent, "to", dcp_jid); + RAYO_SEND_MESSAGE_DUP(actor, dcp_jid, revent); } + iks_delete(revent); + +done: + /* lost the race: pending join failed... send IQ result to client now. */ if (call->pending_join_request) { iks *request = call->pending_join_request; @@ -948,8 +1061,10 @@ static void rayo_call_cleanup(struct rayo_actor *actor) iks_delete(call->pending_join_request); } - iks_delete(revent); - switch_event_destroy(&event); + if (event) { + switch_event_destroy(&event); + } + switch_core_hash_destroy(&call->pcps); } /** @@ -963,11 +1078,30 @@ const char *rayo_call_get_dcp_jid(struct rayo_call *call) /** * @param call the Rayo call - * @return true if joined + * @return true if joined (or a join is in progress) */ -static int rayo_call_is_joined(struct rayo_call *call) +int rayo_call_is_joined(struct rayo_call *call) { - return call->joined; + return call->joined || call->pending_join_request; +} + +/** + * @param call to check if faxing + * @return true if faxing is in progress + */ +int rayo_call_is_faxing(struct rayo_call *call) +{ + return call->faxing; +} + +/** + * Set faxing flag + * @param call the call to flag + * @param faxing true if faxing is in progress + */ +void rayo_call_set_faxing(struct rayo_call *call, int faxing) +{ + call->faxing = faxing; } #define RAYO_MIXER_LOCATE(mixer_name) rayo_mixer_locate(mixer_name, __FILE__, __LINE__) @@ -1080,6 +1214,9 @@ static struct rayo_call *rayo_call_init(struct rayo_call *call, switch_memory_po call->joined_id = NULL; call->ringing_sent = 0; call->pending_join_request = NULL; + call->dial_request_id = NULL; + call->end_event = NULL; + call->dial_request_failed = 0; switch_core_hash_init(&call->pcps, pool); switch_safe_free(call_jid); @@ -1104,13 +1241,23 @@ static struct rayo_call *_rayo_call_create(const char *uuid, const char *file, i return rayo_call_init(call, pool, uuid, file, line); } +/** + * Mixer destructor + */ +static void rayo_mixer_cleanup(struct rayo_actor *actor) +{ + struct rayo_mixer *mixer = RAYO_MIXER(actor); + switch_core_hash_destroy(&mixer->members); + switch_core_hash_destroy(&mixer->subscribers); +} + /** * Initialize mixer */ static struct rayo_mixer *rayo_mixer_init(struct rayo_mixer *mixer, switch_memory_pool_t *pool, const char *name, const char *file, int line) { char *mixer_jid = switch_mprintf("%s@%s", name, RAYO_JID(globals.server)); - rayo_actor_init(RAYO_ACTOR(mixer), pool, RAT_MIXER, "", name, mixer_jid, NULL, rayo_mixer_send, file, line); + rayo_actor_init(RAYO_ACTOR(mixer), pool, RAT_MIXER, "", name, mixer_jid, rayo_mixer_cleanup, rayo_mixer_send, file, line); switch_core_hash_init(&mixer->members, pool); switch_core_hash_init(&mixer->subscribers, pool); switch_safe_free(mixer_jid); @@ -1137,6 +1284,10 @@ static struct rayo_mixer *_rayo_mixer_create(const char *name, const char *file, */ static void rayo_component_cleanup(struct rayo_actor *actor) { + if (RAYO_COMPONENT(actor)->cleanup_fn) { + RAYO_COMPONENT(actor)->cleanup_fn(actor); + } + /* parent can now be destroyed */ RAYO_UNLOCK(RAYO_COMPONENT(actor)->parent); } @@ -1148,9 +1299,12 @@ static void rayo_component_cleanup(struct rayo_actor *actor) * @param id internal ID of this component * @param parent the parent that owns this component * @param client_jid the client that created this component + * @param cleanup optional cleanup function + * @param file file that called this function + * @param line line number that called this function * @return the component */ -struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, const char *file, int line) +struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line) { char *ref = switch_mprintf("%s-%d", subtype, rayo_actor_seq_next(parent)); char *jid = switch_mprintf("%s/%s", RAYO_JID(parent), ref); @@ -1164,6 +1318,7 @@ struct rayo_component *_rayo_component_init(struct rayo_component *component, sw component->client_jid = switch_core_strdup(pool, client_jid); component->ref = switch_core_strdup(pool, ref); component->parent = parent; + component->cleanup_fn = cleanup; switch_safe_free(ref); switch_safe_free(jid); @@ -1281,6 +1436,7 @@ static void rayo_peer_server_cleanup(struct rayo_actor *actor) RAYO_UNLOCK(client); RAYO_DESTROY(client); } + switch_core_hash_destroy(&rserver->clients); switch_mutex_unlock(globals.clients_mutex); } @@ -1465,16 +1621,39 @@ void rayo_server_send(struct rayo_actor *server, struct rayo_message *msg) void rayo_call_send(struct rayo_actor *call, struct rayo_message *msg) { rayo_actor_xmpp_handler handler = NULL; - iks *iq = msg->payload; + iks *stanza = msg->payload; switch_core_session_t *session; iks *response = NULL; + if (!strcmp("message", iks_name(stanza))) { + const char *type = iks_find_attrib_soft(stanza, "type"); + + if (!strcmp("normal", type)) { + const char *body = iks_find_cdata(stanza, "body"); + if (!zstr(body)) { + switch_event_t *event; + if (switch_event_create(&event, SWITCH_EVENT_SEND_MESSAGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "content-type", "text/plain"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "uuid", rayo_call_get_uuid(RAYO_CALL(call))); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", iks_find_cdata(stanza, "subject")); + switch_event_add_body(event, "%s", body); + switch_event_fire(&event); + } + } else if (!msg->is_reply) { + RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error_detailed(stanza, STANZA_ERROR_BAD_REQUEST, "missing body")); + } + } else if (!msg->is_reply) { + RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(stanza, STANZA_ERROR_FEATURE_NOT_IMPLEMENTED)); + } + return; + } + /* is this a command a call supports? */ handler = rayo_actor_command_handler_find(call, msg); if (!handler) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, no handler function for command\n", RAYO_JID(call)); if (!msg->is_reply) { - RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(iq, STANZA_ERROR_FEATURE_NOT_IMPLEMENTED)); + RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(stanza, STANZA_ERROR_FEATURE_NOT_IMPLEMENTED)); } return; } @@ -1484,7 +1663,7 @@ void rayo_call_send(struct rayo_actor *call, struct rayo_message *msg) if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, session not found\n", RAYO_JID(call)); if (!msg->is_reply) { - RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(iq, STANZA_ERROR_ITEM_NOT_FOUND)); + RAYO_SEND_REPLY(call, msg->from_jid, iks_new_error(stanza, STANZA_ERROR_ITEM_NOT_FOUND)); } return; } @@ -1663,22 +1842,33 @@ static iks *on_rayo_redirect(struct rayo_actor *call, struct rayo_message *msg, { iks *node = msg->payload; switch_core_session_t *session = (switch_core_session_t *)session_data; + switch_channel_t *channel = switch_core_session_get_channel(session); iks *response = NULL; iks *redirect = iks_find(node, "redirect"); char *redirect_to = iks_find_attrib(redirect, "to"); if (zstr(redirect_to)) { response = iks_new_error_detailed(node, STANZA_ERROR_BAD_REQUEST, "Missing redirect to attrib"); - } else { + } else if (switch_channel_test_flag(channel, CF_ANSWERED)) { + /* call is answered- must deflect */ switch_core_session_message_t msg = { 0 }; - add_signaling_headers(session, redirect, RAYO_SIP_RESPONSE_HEADER); - - /* Tell the channel to deflect the call */ + add_signaling_headers(session, redirect, RAYO_SIP_REQUEST_HEADER); msg.from = __FILE__; msg.string_arg = switch_core_session_strdup(session, redirect_to); msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT; switch_core_session_receive_message(session, &msg); response = iks_new_iq_result(node); + } else if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { + /* Inbound call not answered - redirect */ + switch_core_session_message_t msg = { 0 }; + add_signaling_headers(session, redirect, RAYO_SIP_RESPONSE_HEADER); + msg.from = __FILE__; + msg.string_arg = switch_core_session_strdup(session, redirect_to); + msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; + switch_core_session_receive_message(session, &msg); + response = iks_new_iq_result(node); + } else { + response = iks_new_error_detailed(node, STANZA_ERROR_UNEXPECTED_REQUEST, "Call must be answered"); } return response; } @@ -1942,6 +2132,12 @@ static iks *on_rayo_join(struct rayo_actor *call, struct rayo_message *msg, void goto done; } + if (rayo_call_is_faxing(RAYO_CALL(call))) { + /* can't join a call while it's faxing */ + response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "fax is in progress"); + goto done; + } + if (RAYO_CALL(call)->pending_join_request) { /* don't allow concurrent join requests */ response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "(un)join request is pending"); @@ -1979,7 +2175,7 @@ static iks *unjoin_call(struct rayo_call *call, switch_core_session_t *session, switch_ivr_park_session(session); } else { /* not bridged or wrong b-leg URI */ - response = iks_new_error(node, STANZA_ERROR_SERVICE_UNAVAILABLE); + response = iks_new_error_detailed_printf(node, STANZA_ERROR_SERVICE_UNAVAILABLE, "expected URI: %s", call->joined_id); } return response; @@ -2102,7 +2298,7 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void * /* create call and link to DCP */ call = rayo_call_create(NULL); call->dcp_jid = switch_core_strdup(RAYO_POOL(call), dcp_jid); - call->dial_id = iks_find_attrib(iq, "id"); + call->dial_request_id = iks_find_attrib(iq, "id"); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_INFO, "%s has control of call\n", dcp_jid); uuid = switch_core_strdup(dtdata->pool, rayo_call_get_uuid(call)); @@ -2206,27 +2402,63 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void * if (switch_api_execute("originate", stream.data, NULL, &api_stream) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got originate result: %s\n", (char *)api_stream.data); + switch_mutex_lock(RAYO_ACTOR(call)->mutex); /* check for failure */ if (strncmp("+OK", api_stream.data, strlen("+OK"))) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_INFO, "Failed to originate call\n"); - if (call->dial_id) { + if (call->dial_request_id) { + call->dial_request_failed = 1; + call->dial_request_id = NULL; + /* map failure reason to iq error */ if (!strncmp("-ERR DESTINATION_OUT_OF_ORDER", api_stream.data, strlen("-ERR DESTINATION_OUT_OF_ORDER"))) { - /* this -ERR is received when out of sessions */ - response = iks_new_error(iq, STANZA_ERROR_RESOURCE_CONSTRAINT); + /* out of sessions, typically */ + response = iks_new_error_detailed(iq, STANZA_ERROR_RESOURCE_CONSTRAINT, (char *)api_stream.data); + } else if (!strncmp("-ERR USER_NOT_REGISTERED", api_stream.data, strlen("-ERR USER_NOT_REGISTERED"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, (char *)api_stream.data); + } else if (!strncmp("-ERR EXCHANGE_ROUTING_ERROR", api_stream.data, strlen("-ERR EXCHANGE_ROUTING_ERROR"))) { + /* max forwards */ + response = iks_new_error_detailed(iq, STANZA_ERROR_RESOURCE_CONSTRAINT, (char *)api_stream.data); + } else if (!strncmp("-ERR CHAN_NOT_IMPLEMENTED", api_stream.data, strlen("-ERR CHAN_NOT_IMPLEMENTED"))) { + /* unsupported endpoint type */ + response = iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, (char *)api_stream.data); + } else if (!strncmp("-ERR INVALID_URL", api_stream.data, strlen("-ERR INVALID_URL"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, (char *)api_stream.data); + } else if (!strncmp("-ERR INVALID_GATEWAY", api_stream.data, strlen("-ERR INVALID_GATEWAY"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, (char *)api_stream.data); + } else if (!strncmp("-ERR INVALID_PROFILE", api_stream.data, strlen("-ERR INVALID_PROFILE"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, (char *)api_stream.data); + } else if (!strncmp("-ERR SYSTEM_SHUTDOWN", api_stream.data, strlen("-ERR SYSTEM_SHUTDOWN"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_RESOURCE_CONSTRAINT, (char *)api_stream.data); + } else if (!strncmp("-ERR GATEWAY_DOWN", api_stream.data, strlen("-ERR GATEWAY_DOWN"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_RESOURCE_CONSTRAINT, (char *)api_stream.data); + } else if (!strncmp("-ERR INVALID_NUMBER_FORMAT", api_stream.data, strlen("-ERR INVALID_NUMBER_FORMAT"))) { + response = iks_new_error_detailed(iq, STANZA_ERROR_RESOURCE_CONSTRAINT, (char *)api_stream.data); + } else { + /* other unspecified error */ + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, (char *)api_stream.data); } } } - } else if (call->dial_id) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Failed to exec originate API\n"); - response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to execute originate API"); + switch_mutex_unlock(RAYO_ACTOR(call)->mutex); + } else { + switch_mutex_lock(RAYO_ACTOR(call)->mutex); + if (call->dial_request_id) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Failed to exec originate API\n"); + call->dial_request_failed = 1; + call->dial_request_id = NULL; + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to execute originate API"); + } + switch_mutex_unlock(RAYO_ACTOR(call)->mutex); } switch_safe_free(api_stream.data); } else { /* will only happen if misconfigured */ switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_CRIT, "No dial gateway found for %s!\n", dial_to); + call->dial_request_failed = 1; + call->dial_request_id = NULL; response = iks_new_error_detailed_printf(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "No dial gateway found for %s!\n", dial_to); goto done; } @@ -2339,11 +2571,21 @@ static iks *on_iq_get_xmpp_disco(struct rayo_actor *server, struct rayo_message iks *node = msg->payload; iks *response = NULL; iks *x; + iks *feature; + iks *identity; + int i = 0; + const char *feature_string; response = iks_new_iq_result(node); x = iks_insert(response, "query"); iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_DISCO); - x = iks_insert(x, "feature"); - iks_insert_attrib(x, "var", RAYO_NS); + identity = iks_insert(x, "identity"); + iks_insert_attrib(identity, "category", rayo_server_identity.category); + iks_insert_attrib(identity, "type", rayo_server_identity.type); + i = 0; + while((feature_string = rayo_server_features[i++])) { + feature = iks_insert(x, "feature"); + iks_insert_attrib(feature, "var", feature_string); + } /* TODO The response MUST also include features for the application formats and transport methods supported by * the responding entity, as described in the relevant specifications. @@ -2559,6 +2801,15 @@ static void on_mixer_delete_member_event(struct rayo_mixer *mixer, switch_event_ static void on_mixer_destroy_event(struct rayo_mixer *mixer, switch_event_t *event) { if (mixer) { + iks *presence; + + /* notify online clients of mixer destruction */ + presence = iks_new("presence"); + iks_insert_attrib(presence, "from", RAYO_JID(mixer)); + iks_insert_attrib(presence, "type", "unavailable"); + broadcast_event(RAYO_ACTOR(mixer), presence, 1); + iks_delete(presence); + /* remove from hash and destroy */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, destroying mixer: %s\n", RAYO_JID(mixer), rayo_mixer_get_name(mixer)); RAYO_UNLOCK(mixer); /* release original lock */ @@ -2578,10 +2829,25 @@ static void on_mixer_add_member_event(struct rayo_mixer *mixer, switch_event_t * struct rayo_call *call = RAYO_CALL_LOCATE_BY_ID(uuid); if (!mixer) { + char *ver; + iks *presence, *c; + /* new mixer */ const char *mixer_name = switch_event_get_header(event, "Conference-Name"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating mixer: %s\n", mixer_name); mixer = rayo_mixer_create(mixer_name); + + /* notify online clients of mixer presence */ + ver = calculate_entity_sha1_ver(&rayo_mixer_identity, rayo_mixer_features); + + presence = iks_new_presence("c", IKS_NS_XMPP_ENTITY_CAPABILITIES, RAYO_JID(mixer), ""); + c = iks_find(presence, "c"); + iks_insert_attrib(c, "hash", "sha-1"); + iks_insert_attrib(c, "node", RAYO_MIXER_NS); + iks_insert_attrib(c, "ver", ver); + free(ver); + + broadcast_event(RAYO_ACTOR(mixer), presence, 1); } if (call) { @@ -2609,6 +2875,9 @@ static void on_mixer_add_member_event(struct rayo_mixer *mixer, switch_event_t * if (call->pending_join_request) { iks *request = call->pending_join_request; iks *result = iks_new_iq_result(request); + iks *ref = iks_insert(result, "ref"); + iks_insert_attrib(ref, "xmlns", RAYO_NS); + iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(mixer)); call->pending_join_request = NULL; RAYO_SEND_REPLY(call, iks_find_attrib_soft(request, "from"), result); iks_delete(request); @@ -2677,21 +2946,27 @@ static void on_call_originate_event(struct rayo_client *rclient, switch_event_t if (call && (session = switch_core_session_locate(uuid))) { iks *response, *ref; - switch_channel_set_private(switch_core_session_get_channel(session), "rayo_call_private", call); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_ID(call)), SWITCH_LOG_DEBUG, "Got originate event\n"); + + switch_mutex_lock(RAYO_ACTOR(call)->mutex); + if (call->dial_request_id) { + switch_channel_set_private(switch_core_session_get_channel(session), "rayo_call_private", call); + + /* send response to DCP */ + response = iks_new("iq"); + iks_insert_attrib(response, "from", RAYO_JID(globals.server)); + iks_insert_attrib(response, "to", rayo_call_get_dcp_jid(call)); + iks_insert_attrib(response, "id", call->dial_request_id); + iks_insert_attrib(response, "type", "result"); + ref = iks_insert(response, "ref"); + iks_insert_attrib(ref, "xmlns", RAYO_NS); + + iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(call)); + RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), response); + call->dial_request_id = NULL; + } + switch_mutex_unlock(RAYO_ACTOR(call)->mutex); switch_core_session_rwunlock(session); - - /* send response to DCP */ - response = iks_new("iq"); - iks_insert_attrib(response, "from", RAYO_JID(globals.server)); - iks_insert_attrib(response, "to", rayo_call_get_dcp_jid(call)); - iks_insert_attrib(response, "id", call->dial_id); - iks_insert_attrib(response, "type", "result"); - ref = iks_insert(response, "ref"); - iks_insert_attrib(ref, "xmlns", RAYO_NS); - - iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(call)); - RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), response); - call->dial_id = NULL; } RAYO_UNLOCK(call); } @@ -2712,9 +2987,15 @@ static void on_call_end_event(switch_event_t *event) switch_safe_free(event_str); } #endif - switch_event_dup(&call->end_event, event); - RAYO_UNLOCK(call); /* decrement ref from creation */ - RAYO_DESTROY(call); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_ID(call)), SWITCH_LOG_DEBUG, "Got channel destroy event\n"); + + switch_mutex_lock(RAYO_ACTOR(call)->mutex); + if (!call->dial_request_id && !call->dial_request_failed) { + switch_event_dup(&call->end_event, event); + RAYO_DESTROY(call); + RAYO_UNLOCK(call); /* decrement ref from creation */ + } + switch_mutex_unlock(RAYO_ACTOR(call)->mutex); RAYO_UNLOCK(call); /* decrement this ref */ } } @@ -2754,9 +3035,9 @@ static void on_call_ringing_event(struct rayo_client *rclient, switch_event_t *e switch_event_get_header(event, "variable_rayo_dcp_jid")); call->ringing_sent = 1; RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); - RAYO_UNLOCK(call); } switch_mutex_unlock(RAYO_ACTOR(call)->mutex); + RAYO_UNLOCK(call); } } } @@ -2792,7 +3073,7 @@ static void on_call_bridge_event(struct rayo_client *rclient, switch_event_t *ev b_call = RAYO_CALL_LOCATE_BY_ID(b_uuid); if (b_call) { b_call->joined = JOINED_CALL; - b_call->joined_id = switch_core_sprintf(RAYO_POOL(b_call), "xmpp:%s@s", a_uuid, RAYO_JID(globals.server)); + b_call->joined_id = switch_core_sprintf(RAYO_POOL(b_call), "xmpp:%s@%s", a_uuid, RAYO_JID(globals.server)); /* send IQ result to client now. */ if (b_call->pending_join_request) { @@ -2806,7 +3087,7 @@ static void on_call_bridge_event(struct rayo_client *rclient, switch_event_t *ev /* send B-leg event */ revent = iks_new_presence("joined", RAYO_NS, RAYO_JID(b_call), rayo_call_get_dcp_jid(b_call)); joined = iks_find(revent, "joined"); - iks_insert_attrib_printf(joined, "call-uri", "xmpp:%s@%s", a_uuid, RAYO_JID(globals.server)); + iks_insert_attrib_printf(joined, "call-uri", "%s", b_call->joined_id); RAYO_SEND_MESSAGE(b_call, rayo_call_get_dcp_jid(b_call), revent); RAYO_UNLOCK(b_call); @@ -2817,7 +3098,7 @@ static void on_call_bridge_event(struct rayo_client *rclient, switch_event_t *ev switch_event_get_header(event, "variable_rayo_call_jid"), switch_event_get_header(event, "variable_rayo_dcp_jid")); joined = iks_find(revent, "joined"); - iks_insert_attrib_printf(joined, "call-uri", "xmpp:%s@%s", b_uuid, RAYO_JID(globals.server)); + iks_insert_attrib_printf(joined, "call-uri", "%s", call->joined_id); RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); @@ -2826,63 +3107,41 @@ static void on_call_bridge_event(struct rayo_client *rclient, switch_event_t *ev } /** - * Handle call unbridge event + * Handle call park event - this is fired after unjoining a call * @param rclient the Rayo client * @param event the unbridge event */ -static void on_call_unbridge_event(struct rayo_client *rclient, switch_event_t *event) +static void on_call_park_event(struct rayo_client *rclient, switch_event_t *event) { const char *a_uuid = switch_event_get_header(event, "Unique-ID"); - const char *b_uuid = switch_event_get_header(event, "Bridge-B-Unique-ID"); struct rayo_call *call = RAYO_CALL_LOCATE_BY_ID(a_uuid); - struct rayo_call *b_call; if (call) { - iks *revent; - iks *joined; + if (call->joined) { + iks *revent; + iks *unjoined; + const char *joined_id = call->joined_id; - call->joined = 0; - call->joined_id = NULL; - - /* send IQ result to client now. */ - if (call->pending_join_request) { - iks *request = call->pending_join_request; - iks *result = iks_new_iq_result(request); - call->pending_join_request = NULL; - RAYO_SEND_REPLY(call, iks_find_attrib_soft(request, "from"), result); - iks_delete(request); - } - - b_call = RAYO_CALL_LOCATE_BY_ID(b_uuid); - if (b_call) { - b_call->joined = 0; - b_call->joined_id = NULL; + call->joined = 0; + call->joined_id = NULL; /* send IQ result to client now. */ - if (b_call->pending_join_request) { - iks *request = b_call->pending_join_request; + if (call->pending_join_request) { + iks *request = call->pending_join_request; iks *result = iks_new_iq_result(request); - b_call->pending_join_request = NULL; - RAYO_SEND_REPLY(b_call, iks_find_attrib_soft(request, "from"), result); + call->pending_join_request = NULL; + RAYO_SEND_REPLY(call, iks_find_attrib_soft(request, "from"), result); iks_delete(request); } - /* send B-leg event */ - revent = iks_new_presence("unjoined", RAYO_NS, RAYO_JID(b_call), rayo_call_get_dcp_jid(b_call)); - joined = iks_find(revent, "unjoined"); - iks_insert_attrib_printf(joined, "call-uri", "xmpp:%s@%s", a_uuid, RAYO_JID(globals.server)); - RAYO_SEND_MESSAGE(b_call, rayo_call_get_dcp_jid(b_call), revent); - RAYO_UNLOCK(b_call); + /* send A-leg event */ + revent = iks_new_presence("unjoined", RAYO_NS, + switch_event_get_header(event, "variable_rayo_call_jid"), + switch_event_get_header(event, "variable_rayo_dcp_jid")); + unjoined = iks_find(revent, "unjoined"); + iks_insert_attrib_printf(unjoined, "call-uri", "%s", joined_id); + RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); } - - /* send A-leg event */ - revent = iks_new_presence("unjoined", RAYO_NS, - switch_event_get_header(event, "variable_rayo_call_jid"), - switch_event_get_header(event, "variable_rayo_dcp_jid")); - joined = iks_find(revent, "unjoined"); - iks_insert_attrib_printf(joined, "call-uri", "xmpp:%s@%s", b_uuid, RAYO_JID(globals.server)); - RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent); - RAYO_UNLOCK(call); } } @@ -2940,8 +3199,8 @@ static void rayo_client_handle_event(struct rayo_client *rclient, switch_event_t case SWITCH_EVENT_CHANNEL_BRIDGE: on_call_bridge_event(rclient, event); break; - case SWITCH_EVENT_CHANNEL_UNBRIDGE: - on_call_unbridge_event(rclient, event); + case SWITCH_EVENT_CHANNEL_PARK: + on_call_park_event(rclient, event); break; case SWITCH_EVENT_CHANNEL_EXECUTE: on_call_execute_event(rclient, event); @@ -3013,12 +3272,24 @@ static iks *rayo_create_offer(struct rayo_call *call, switch_core_session_t *ses switch_channel_t *channel = switch_core_session_get_channel(session); switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); iks *presence = iks_new("presence"); + iks *c = iks_insert(presence, "c"); iks *offer = iks_insert(presence, "offer"); const char *val; + char *ver; + /* */ iks_insert_attrib(presence, "from", RAYO_JID(call)); - iks_insert_attrib(offer, "xmlns", RAYO_NS); + /* */ + ver = calculate_entity_sha1_ver(&rayo_call_identity, rayo_call_features); + iks_insert_attrib(c, "xmlns", IKS_NS_XMPP_ENTITY_CAPABILITIES); + iks_insert_attrib(c, "hash", "sha-1"); + iks_insert_attrib(c, "node", RAYO_CALL_NS); + iks_insert_attrib(c, "ver", ver); + free(ver); + + /* */ + iks_insert_attrib(offer, "xmlns", RAYO_NS); if (globals.offer_uri && (val = switch_channel_get_variable(channel, "sip_from_uri"))) { /* is a SIP call - pass the URI */ if (!strchr(val, ':')) { @@ -3074,7 +3345,7 @@ static switch_status_t rayo_call_on_read_frame(switch_core_session_t *session, s switch_time_t idle_start = call->idle_start_time; int idle_duration_ms = (now - idle_start) / 1000; /* detect idle session (rayo-client has stopped controlling call) and terminate call */ - if (rayo_call_is_joined(call)) { + if (rayo_call_is_joined(call) || rayo_call_is_faxing(call)) { call->idle_start_time = now; } else if (idle_duration_ms > globals.max_idle_ms) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Ending abandoned call. idle_duration_ms = %i ms\n", idle_duration_ms); @@ -3117,18 +3388,17 @@ SWITCH_STANDARD_APP(rayo_app) } } if (!call) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing rayo call!!\n"); - goto done; + /* this scenario can only happen if a call was originated through a mechanism other than + and then the rayo APP was executed to offer control */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Outbound call that wasn't created with , will try to offer control\n"); } ok = 1; - } else { - /* inbound call - offer control */ + } + + if (!call) { + /* offer control */ switch_hash_index_t *hi = NULL; iks *offer = NULL; - if (call) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Call is already under Rayo 3PCC!\n"); - goto done; - } call = rayo_call_create(switch_core_session_get_uuid(session)); switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_call_jid", RAYO_JID(call)); @@ -3156,11 +3426,12 @@ SWITCH_STANDARD_APP(rayo_app) RAYO_SEND_MESSAGE_DUP(call, RAYO_JID(rclient), offer); } } - iks_delete(offer); switch_mutex_unlock(globals.clients_mutex); + iks_delete(offer); /* nobody to offer to */ if (!ok) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Rejecting rayo call - there are no online rayo clients to offer call to\n"); switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE); } } @@ -3171,7 +3442,7 @@ done: switch_channel_set_variable(channel, "hangup_after_bridge", "false"); switch_channel_set_variable(channel, "transfer_after_bridge", ""); switch_channel_set_variable(channel, "park_after_bridge", "true"); - switch_channel_set_variable(channel, "hold_hangup_xfer_exten", "foo"); /* Icky hack to prevent unjoin of call on hold from hanging up b-leg. park_after_bridge will take precedence over the transfer_after_bridge variable that gets set by this var */ + switch_channel_set_variable(channel, "hold_hangup_xfer_exten", "park:inline:"); switch_channel_set_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE, "-1"); /* required so that output mixing works */ switch_core_event_hook_add_read_frame(session, rayo_call_on_read_frame); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { @@ -3295,19 +3566,41 @@ static void on_xmpp_stream_destroy(struct xmpp_stream *stream) } } +/** + * A command alias + */ +struct rayo_cmd_alias { + /** number of additional arguments for alias */ + int args; + /** the alias template */ + const char *cmd; +}; + /** * Add an alias to an API command * @param alias_name * @param alias_target * @param alias_cmd + * @param alias_args */ -static void rayo_add_cmd_alias(const char *alias_name, const char *alias_target, const char *alias_cmd) +static void rayo_add_cmd_alias(const char *alias_name, const char *alias_target, const char *alias_cmd, const char *alias_args) { + struct rayo_cmd_alias *alias = switch_core_alloc(globals.pool, sizeof(*alias)); + alias->args = 0; + if (switch_is_number(alias_args)) { + alias->args = atoi(alias_args); + if (alias->args < 0) { + alias->args = 0; + } + } + alias->cmd = alias_cmd; + switch_core_hash_insert(globals.cmd_aliases, alias_name, alias); + + /* set up autocomplete of alias */ if (zstr(alias_target)) { alias_target = "all"; } switch_console_set_complete(switch_core_sprintf(globals.pool, "add rayo %s ::rayo::list_%s", alias_name, alias_target)); - switch_core_hash_insert(globals.cmd_aliases, alias_name, alias_cmd); } /** @@ -3504,8 +3797,9 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_ for (alias = switch_xml_child(aliases, "alias"); alias; alias = alias->next) { const char *alias_name = switch_xml_attr_soft(alias, "name"); const char *alias_target = switch_xml_attr_soft(alias, "target"); + const char *alias_args = switch_xml_attr_soft(alias, "args"); if (!zstr(alias_name) && !zstr(alias->txt)) { - rayo_add_cmd_alias(alias_name, switch_core_strdup(pool, alias_target), switch_core_strdup(pool, alias->txt)); + rayo_add_cmd_alias(alias_name, switch_core_strdup(pool, alias_target), switch_core_strdup(pool, alias->txt), switch_core_strdup(pool, alias_args)); } } } @@ -3669,15 +3963,46 @@ static int command_api(char *cmd, switch_stream_handle_t *stream) /** * Send command to rayo actor */ -static int alias_api(const char *cmd, char *jid, switch_stream_handle_t *stream) +static int alias_api(struct rayo_cmd_alias *alias, char *args, switch_stream_handle_t *stream) { - if (zstr(cmd) || zstr(jid)) { - return 0; + char *argv[10] = { 0 }; + int argc, i; + char *cmd; + char *jid; + + if (zstr(alias->cmd)) { + stream->write_function(stream, "-ERR missing alias template. Check configuration.\n"); + } + + if (zstr(args)) { + stream->write_function(stream, "-ERR no args\n"); + return 1; + } + + /* check args */ + argc = switch_separate_string(args, ' ', argv, sizeof(argv) / sizeof(argv[0])); + if (argc != alias->args + 1) { + stream->write_function(stream, "-ERR wrong number of args (%i/%i)\n", argc, alias->args + 1); + return 1; + } + + jid = argv[0]; + + /* build command from args */ + cmd = strdup(alias->cmd); + for (i = 1; i < argc; i++) { + char *cmd_new; + char to_replace[4] = { 0 }; + sprintf(to_replace, "$%i", i); + cmd_new = switch_string_replace(cmd, to_replace, argv[i]); + free(cmd); + cmd = cmd_new; } /* send command */ send_console_command(globals.console, jid, cmd); stream->write_function(stream, "+OK\n"); + free(cmd); return 1; } @@ -3685,14 +4010,14 @@ static int alias_api(const char *cmd, char *jid, switch_stream_handle_t *stream) /** * Send message from console */ -static void send_console_message(struct rayo_client *client, const char *to, const char *message_str) +static void send_console_message(struct rayo_client *client, const char *to, const char *type, const char *message_str) { iks *message = NULL, *x; message = iks_new("message"); iks_insert_attrib(message, "to", to); iks_insert_attrib(message, "from", RAYO_JID(client)); iks_insert_attrib_printf(message, "id", "console-%i", RAYO_SEQ_NEXT(client)); - iks_insert_attrib(message, "type", "chat"); + iks_insert_attrib(message, "type", type); x = iks_insert(message, "body"); iks_insert_cdata(x, message_str, strlen(message_str)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nSEND: to %s, %s\n", to, iks_string(iks_stack(message), message)); @@ -3704,10 +4029,10 @@ static void send_console_message(struct rayo_client *client, const char *to, con */ static int message_api(char *cmd, switch_stream_handle_t *stream) { - char *argv[2] = { 0 }; + char *argv[3] = { 0 }; if (!zstr(cmd)) { int argc = switch_separate_string(cmd, ' ', argv, sizeof(argv) / sizeof(argv[0])); - if (argc != 2) { + if (argc != 3) { return 0; } } else { @@ -3715,7 +4040,7 @@ static int message_api(char *cmd, switch_stream_handle_t *stream) } /* send message */ - send_console_message(globals.console, argv[0], argv[1]); + send_console_message(globals.console, argv[0], argv[1], argv[2]); stream->write_function(stream, "+OK\n"); return 1; @@ -3771,17 +4096,22 @@ static int presence_api(char *cmd, switch_stream_handle_t *stream) #define RAYO_API_SYNTAX "status | ( ) | (cmd ) | (msg ) | (presence )" SWITCH_STANDARD_API(rayo_api) { - const char *alias; - char *cmd_dup = strdup(cmd); + struct rayo_cmd_alias *alias; + char *cmd_dup = NULL; char *argv[2] = { 0 }; int success = 0; + if (zstr(cmd) ) { + goto done; + } + + cmd_dup = strdup(cmd); switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); /* check if a command alias */ alias = switch_core_hash_find(globals.cmd_aliases, argv[0]); - if (!zstr(alias)) { + if (alias) { success = alias_api(alias, argv[1], stream); } else if (!strcmp("cmd", argv[0])) { success = command_api(argv[1], stream); @@ -3793,11 +4123,12 @@ SWITCH_STANDARD_API(rayo_api) success = presence_api(argv[1], stream); } +done: if (!success) { stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_API_SYNTAX); } - free(cmd_dup); + switch_safe_free(cmd_dup); return SWITCH_STATUS_SUCCESS; } @@ -4023,7 +4354,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) switch_event_bind(modname, SWITCH_EVENT_CHANNEL_PROGRESS, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_ANSWER, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_BRIDGE, NULL, route_call_event, NULL); - switch_event_bind(modname, SWITCH_EVENT_CHANNEL_UNBRIDGE, NULL, route_call_event, NULL); + switch_event_bind(modname, SWITCH_EVENT_CHANNEL_PARK, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_EXECUTE, NULL, route_call_event, NULL); switch_event_bind(modname, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE, NULL, route_call_event, NULL); @@ -4056,8 +4387,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) globals.console = rayo_console_client_create(); switch_console_set_complete("add rayo status"); - switch_console_set_complete("add rayo msg ::rayo::list_external"); - switch_console_set_complete("add rayo cmd ::rayo::list_all"); + switch_console_set_complete("add rayo msg ::rayo::list_all"); + switch_console_set_complete("add rayo msg ::rayo::list_all chat"); + switch_console_set_complete("add rayo msg ::rayo::list_all groupchat"); + switch_console_set_complete("add rayo msg ::rayo::list_all headline"); + switch_console_set_complete("add rayo msg ::rayo::list_all normal"); switch_console_set_complete("add rayo presence ::rayo::list_server online"); switch_console_set_complete("add rayo presence ::rayo::list_server offline"); switch_console_add_complete_func("::rayo::list_all", list_all); diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.h b/src/mod/event_handlers/mod_rayo/mod_rayo.h index dd0adb3192..43ed7d3dbc 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.h +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.h @@ -42,6 +42,9 @@ #define RAYO_CALL_NS RAYO_BASE "call:" RAYO_VERSION #define RAYO_MIXER_NS RAYO_BASE "mixer:" RAYO_VERSION +#define RAYO_CPA_BASE RAYO_BASE "cpa:" +#define RAYO_CPA_NS RAYO_CPA_BASE RAYO_VERSION + #define RAT_CALL "CALL" #define RAT_COMPONENT "COMPONENT" #define RAT_CALL_COMPONENT RAT_COMPONENT"_CALL" @@ -111,14 +114,16 @@ struct rayo_actor { struct rayo_component { /** base actor class */ struct rayo_actor base; - /** component type (input/output/prompt/etc) */ - const char *type; /** parent to this component */ struct rayo_actor *parent; /** owning client JID */ const char *client_jid; /** external ref */ const char *ref; + /** true if component has completed */ + int complete; + /** optional cleanup */ + rayo_actor_cleanup_fn cleanup_fn; }; #define RAYO_ACTOR(x) ((struct rayo_actor *)x) @@ -153,12 +158,16 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l #define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__) #define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x)) +extern int rayo_call_is_joined(struct rayo_call *call); +extern int rayo_call_is_faxing(struct rayo_call *call); +extern void rayo_call_set_faxing(struct rayo_call *call, int faxing); extern const char *rayo_call_get_dcp_jid(struct rayo_call *call); #define rayo_mixer_get_name(mixer) RAYO_ID(mixer) -#define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, __FILE__, __LINE__) -extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, const char *file, int line); +#define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, NULL, __FILE__, __LINE__) +#define rayo_component_init_cleanup(component, pool, type, subtype, id, parent, client_jid, cleanup) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, cleanup, __FILE__, __LINE__) +extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line); extern switch_bool_t is_component_actor(struct rayo_actor *); typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_message *, void *); diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.c b/src/mod/event_handlers/mod_rayo/rayo_components.c index b5137d9459..ac1c66175d 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.c +++ b/src/mod/event_handlers/mod_rayo/rayo_components.c @@ -112,6 +112,7 @@ iks *rayo_component_create_complete_event(struct rayo_component *component, cons */ void rayo_component_send_complete_event(struct rayo_component *component, iks *response) { + component->complete = 1; RAYO_SEND_REPLY(component, iks_find_attrib(response, "to"), response); RAYO_UNLOCK(component); RAYO_DESTROY(component); @@ -226,7 +227,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module if (rayo_input_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_output_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_prompt_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || - rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { + rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || + rayo_fax_components_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_TERM; } return SWITCH_STATUS_SUCCESS; @@ -241,6 +243,7 @@ switch_status_t rayo_components_shutdown(void) rayo_output_component_shutdown(); rayo_prompt_component_shutdown(); rayo_record_component_shutdown(); + rayo_fax_components_shutdown(); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.h b/src/mod/event_handlers/mod_rayo/rayo_components.h index 6e93dfbc43..5d1367d645 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.h +++ b/src/mod/event_handlers/mod_rayo/rayo_components.h @@ -49,6 +49,9 @@ #define RAYO_PROMPT_NS RAYO_BASE "prompt:" RAYO_VERSION #define RAYO_PROMPT_COMPLETE_NS RAYO_BASE "prompt:complete:" RAYO_VERSION +#define RAYO_FAX_NS RAYO_BASE "fax:" RAYO_VERSION +#define RAYO_FAX_COMPLETE_NS RAYO_BASE "fax:complete:" RAYO_VERSION + #define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS @@ -58,12 +61,14 @@ extern switch_status_t rayo_input_component_load(switch_loadable_module_interfac extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_components_shutdown(void); extern switch_status_t rayo_input_component_shutdown(void); extern switch_status_t rayo_output_component_shutdown(void); extern switch_status_t rayo_prompt_component_shutdown(void); extern switch_status_t rayo_record_component_shutdown(void); +extern switch_status_t rayo_fax_components_shutdown(void); extern void rayo_component_send_start(struct rayo_component *component, iks *iq); extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type); diff --git a/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c new file mode 100644 index 0000000000..bbb288d920 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c @@ -0,0 +1,401 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2014, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_cpa_component.c -- input component "cpa" mode implementation + */ +#include + +#include "rayo_cpa_component.h" +#include "mod_rayo.h" +#include "rayo_components.h" +#include "rayo_cpa_detector.h" + +/** + * Module globals + */ +struct { + /** signal subscribers */ + switch_hash_t *subscribers; + /** synchronizes access to subscribers */ + switch_mutex_t *subscribers_mutex; + /** module pool */ + switch_memory_pool_t *pool; +} globals; + +/** + * A CPA signal monitored by this component + */ +struct cpa_signal { + /** name of this signal */ + const char *name; + /** true if signal causes component termination */ + int terminate; +}; + +/** + * CPA component state + */ +struct cpa_component { + /** component base class */ + struct rayo_component base; + /** true if ready to forward detector events */ + int ready; + /** signals this component wants */ + switch_hash_t *signals; +}; + +#define CPA_COMPONENT(x) ((struct cpa_component *)x) + +typedef void (* subscriber_execute_fn)(const char *jid, void *user_data); + +/** + * Request signals + */ +static void subscribe(const char *uuid, const char *signal_type, const char *jid) +{ + char *key = switch_mprintf("%s:%s", uuid, signal_type); + switch_mutex_lock(globals.subscribers_mutex); + { + switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Subscribe %s => %s\n", signal_type, jid); + if (!signal_subscribers) { + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Create %s subscriber hash\n", signal_type); + switch_core_hash_init(&signal_subscribers, NULL); + switch_core_hash_insert(globals.subscribers, key, signal_subscribers); + } + switch_core_hash_insert(signal_subscribers, jid, "1"); + } + switch_mutex_unlock(globals.subscribers_mutex); + switch_safe_free(key); +} + +/** + * Stop receiving signals + */ +static void unsubscribe(const char *uuid, const char *signal_type, const char *jid) +{ + char *key = switch_mprintf("%s:%s", uuid, signal_type); + switch_mutex_lock(globals.subscribers_mutex); + { + switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key); + if (signal_subscribers) { + switch_core_hash_delete(signal_subscribers, jid); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Unsubscribe %s => %s\n", signal_type, jid); + + /* clean up hash if empty */ + if (!switch_core_hash_first(signal_subscribers)) { + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Destroy %s subscriber hash\n", signal_type); + switch_core_hash_destroy(&signal_subscribers); + switch_core_hash_delete(globals.subscribers, key); + } + } + } + switch_mutex_unlock(globals.subscribers_mutex); + switch_safe_free(key); +} + +/** + * Execute function for each subscriber + */ +static void subscriber_execute(const char *uuid, const char *signal_type, subscriber_execute_fn callback, void *user_data) +{ + switch_event_t *subscriber_list = NULL; + switch_event_header_t *subscriber = NULL; + + /* fetch list of subscribers */ + char *key = switch_mprintf("%s:%s", uuid, signal_type); + switch_event_create_subclass(&subscriber_list, SWITCH_EVENT_CLONE, NULL); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Subscriber execute %s\n", signal_type); + switch_mutex_lock(globals.subscribers_mutex); + { + switch_hash_index_t *hi = NULL; + switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key); + if (signal_subscribers) { + for (hi = switch_core_hash_first(signal_subscribers); hi; hi = switch_core_hash_next(hi)) { + const void *jid; + void *dont_care; + switch_core_hash_this(hi, &jid, NULL, &dont_care); + switch_event_add_header_string(subscriber_list, SWITCH_STACK_BOTTOM, "execute", (const char *)jid); + } + } else { + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "No subscribers for %s\n", signal_type); + } + } + switch_mutex_unlock(globals.subscribers_mutex); + switch_safe_free(key); + + /* execute function for each subscriber */ + for (subscriber = subscriber_list->headers; subscriber; subscriber = subscriber->next) { + callback(subscriber->value, user_data); + } + + switch_event_destroy(&subscriber_list); +} + +/** + * Stop all CPA detectors + */ +static void stop_cpa_detectors(struct cpa_component *cpa) +{ + if (cpa->signals) { + switch_hash_index_t *hi = NULL; + for (hi = switch_core_hash_first(cpa->signals); hi; hi = switch_core_hash_next(hi)) { + const void *signal_type; + void *cpa_signal = NULL; + switch_core_hash_this(hi, &signal_type, NULL, &cpa_signal); + if (cpa_signal) { + rayo_cpa_detector_stop(RAYO_COMPONENT(cpa)->parent->id, ((struct cpa_signal *)cpa_signal)->name); + unsubscribe(RAYO_COMPONENT(cpa)->parent->id, ((struct cpa_signal *)cpa_signal)->name, RAYO_JID(cpa)); + } + } + switch_core_hash_destroy(&cpa->signals); + cpa->signals = NULL; + } + unsubscribe(RAYO_COMPONENT(cpa)->parent->id, "hangup", RAYO_JID(cpa)); +} + +/** + * Stop execution of CPA component + */ +static iks *stop_cpa_component(struct rayo_actor *component, struct rayo_message *msg, void *data) +{ + stop_cpa_detectors(CPA_COMPONENT(component)); + rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); + return iks_new_iq_result(msg->payload); +} + +/** + * Forward CPA signal to client + */ +static void rayo_cpa_detector_event(const char *jid, void *user_data) +{ + struct rayo_actor *component = RAYO_LOCATE(jid); + if (component) { + if (CPA_COMPONENT(component)->ready) { + switch_event_t *event = (switch_event_t *)user_data; + const char *signal_type = switch_event_get_header(event, "signal-type"); + struct cpa_signal *cpa_signal = switch_core_hash_find(CPA_COMPONENT(component)->signals, signal_type); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_COMPONENT(component)->parent->id), SWITCH_LOG_DEBUG, "Handling CPA event\n"); + if (cpa_signal) { + const char *value = switch_event_get_header(event, "value"); + const char *duration = switch_event_get_header(event, "duration"); + if (cpa_signal->terminate) { + iks *complete_event; + iks *signal_xml; + + stop_cpa_detectors(CPA_COMPONENT(component)); + + /* send complete event to client */ + complete_event = rayo_component_create_complete_event(RAYO_COMPONENT(component), "signal", RAYO_CPA_NS); + signal_xml = iks_find(complete_event, "complete"); + signal_xml = iks_find(signal_xml, "signal"); + iks_insert_attrib(signal_xml, "type", signal_type); + if (!zstr(value)) { + iks_insert_attrib(signal_xml, "value", value); + } + if (!zstr(duration)) { + iks_insert_attrib(signal_xml, "duration", duration); + } + rayo_component_send_complete_event(RAYO_COMPONENT(component), complete_event); + } else { + /* send event to client */ + iks *signal_event = iks_new_presence("signal", RAYO_CPA_NS, RAYO_JID(component), RAYO_COMPONENT(component)->client_jid); + iks *signal_xml = iks_find(signal_event, "signal"); + iks_insert_attrib(signal_xml, "type", signal_type); + if (!zstr(value)) { + iks_insert_attrib(signal_xml, "value", value); + } + if (!zstr(duration)) { + iks_insert_attrib(signal_xml, "duration", duration); + } + RAYO_SEND_REPLY(component, RAYO_COMPONENT(component)->client_jid, signal_event); + } + } + } else { + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_COMPONENT(component)->parent->id), SWITCH_LOG_DEBUG, "Skipping CPA event\n"); + } + RAYO_UNLOCK(component); + } +} + +/** + * Handle CPA signal-type event + */ +static void on_rayo_cpa_detector_event(switch_event_t *event) +{ + subscriber_execute(switch_event_get_header(event, "Unique-ID"), switch_event_get_header(event, "signal-type"), rayo_cpa_detector_event, event); +} + +/** + * Handle CPA completion because of hangup + */ +static void rayo_cpa_component_hangup(const char *jid, void *user_data) +{ + struct rayo_actor *component = RAYO_LOCATE(jid); + if (component) { + stop_cpa_detectors(CPA_COMPONENT(component)); + rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP); + RAYO_UNLOCK(component); + } +} + +/** + * Handle hungup call event + */ +static void on_channel_hangup_complete_event(switch_event_t *event) +{ + subscriber_execute(switch_event_get_header(event, "Unique-ID"), "hangup", rayo_cpa_component_hangup, event); +} + +/** + * Start CPA + */ +iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = (switch_core_session_t *)session_data; + iks *input = iks_find(iq, "input"); + switch_memory_pool_t *pool = NULL; + struct cpa_component *component = NULL; + int have_grammar = 0; + iks *grammar = NULL; + + /* create CPA component */ + switch_core_new_memory_pool(&pool); + component = switch_core_alloc(pool, sizeof(*component)); + rayo_component_init((struct rayo_component *)component, pool, RAT_CALL_COMPONENT, "cpa", NULL, call, iks_find_attrib(iq, "from")); + + switch_core_hash_init(&component->signals, pool); + + /* start CPA detectors */ + for (grammar = iks_find(input, "grammar"); grammar; grammar = iks_next_tag(grammar)) { + if (!strcmp("grammar", iks_name(grammar))) { + const char *error_str = ""; + const char *url = iks_find_attrib_soft(grammar, "url"); + char *url_dup; + char *url_params; + + if (zstr(url)) { + stop_cpa_detectors(component); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing grammar URL"); + } + have_grammar = 1; + + url_dup = strdup(url); + if ((url_params = strchr(url_dup, '?'))) { + *url_params = '\0'; + url_params++; + } + + if (switch_core_hash_find(component->signals, url)) { + free(url_dup); + stop_cpa_detectors(component); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Duplicate URL"); + } + + /* start detector */ + /* TODO return better reasons... */ + if (rayo_cpa_detector_start(switch_core_session_get_uuid(session), url_dup, &error_str)) { + struct cpa_signal *cpa_signal = switch_core_alloc(pool, sizeof(*cpa_signal)); + cpa_signal->terminate = !zstr(url_params) && strstr(url_params, "terminate=true"); + cpa_signal->name = switch_core_strdup(pool, url_dup); + switch_core_hash_insert(component->signals, cpa_signal->name, cpa_signal); + subscribe(switch_core_session_get_uuid(session), cpa_signal->name, RAYO_JID(component)); + } else { + free(url_dup); + stop_cpa_detectors(component); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, error_str); + } + + free(url_dup); + } + } + + if (!have_grammar) { + stop_cpa_detectors(component); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "No grammar defined"); + } + + /* acknowledge command */ + rayo_component_send_start(RAYO_COMPONENT(component), iq); + + /* TODO hangup race condition */ + subscribe(switch_core_session_get_uuid(session), "hangup", RAYO_JID(component)); + + /* ready to forward detector events */ + component->ready = 1; + + return NULL; +} + +/** + * Load input CPA + * @param module_interface + * @param pool memory pool + * @param config_file + * @return SWITCH_STATUS_SUCCESS if successfully loaded + */ +switch_status_t rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) +{ + rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "cpa", "set:"RAYO_EXT_NS":stop", stop_cpa_component); + switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CUSTOM, "rayo::cpa", on_rayo_cpa_detector_event, NULL); + switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE, NULL, on_channel_hangup_complete_event, NULL); + + globals.pool = pool; + switch_core_hash_init(&globals.subscribers, pool); + switch_mutex_init(&globals.subscribers_mutex, SWITCH_MUTEX_NESTED, pool); + + return rayo_cpa_detector_load(module_interface, pool, config_file); +} + +/** + * Stop input CPA + */ +void rayo_cpa_component_shutdown(void) +{ + switch_event_unbind_callback(on_rayo_cpa_detector_event); + switch_event_unbind_callback(on_channel_hangup_complete_event); + rayo_cpa_detector_shutdown(); + switch_core_hash_destroy(&globals.subscribers); +} + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ diff --git a/src/mod/event_handlers/mod_rayo/rayo_cpa_component.h b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.h new file mode 100644 index 0000000000..36354c9508 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.h @@ -0,0 +1,53 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2014, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_cpa_component.h -- Rayo call progress analysis component + * + */ +#ifndef RAYO_CPA_COMPONENT_H +#define RAYO_CPA_COMPONENT_H + +#include +#include + +#include "mod_rayo.h" + +extern switch_status_t rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern void rayo_cpa_component_shutdown(void); +extern iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data); + +#endif + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ diff --git a/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.c b/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.c new file mode 100644 index 0000000000..ed1d87d152 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.c @@ -0,0 +1,451 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2014, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_cpa_detector.c -- Glue to normalize events from and to allow multiple instantiation of various detectors in FreeSWITCH + */ + +#include "rayo_cpa_detector.h" + +static struct { + /** detectors supported by this module mapped by signal-type */ + switch_hash_t *detectors; +} globals; + +struct rayo_cpa_detector; + +/** + * Detector definition + */ +struct rayo_cpa_detector { + /** unique internal name of this detector */ + const char *name; + /** detector ID */ + const char *uuid; + /** start detection APP */ + const char *start_app; + /** args to pass to start detection app */ + const char *start_app_args; + /** stop detection APP */ + const char *stop_app; + /** args to pass to stop detection app */ + const char *stop_app_args; + /** (optional) name of header to get the signal type from */ + const char *signal_type_header; + /** (optional) where to get the signal value from the event */ + const char *signal_value_header; + /** (optional) where to get the signal duration from the event */ + const char *signal_duration_header; + /** detector event to signal type mapping */ + switch_hash_t *signal_type_map; +}; + +/** + * Detection state + */ +struct rayo_cpa_detector_state { + /** reference count */ + int refs; +}; + +/** + * Start detecting + * @param call_uuid call to detect signal on + * @param signal_ns namespace of signal to detect + * @param error_detail on failure, describes the error + * @return 1 if successful, 0 if failed + */ +int rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail) +{ + struct rayo_cpa_detector *detector = switch_core_hash_find(globals.detectors, signal_ns); + switch_core_session_t *session; + if (detector) { + if (zstr(detector->start_app)) { + /* nothing to do */ + return 1; + } + session = switch_core_session_locate(call_uuid); + if (session) { + struct rayo_cpa_detector_state *detector_state = switch_channel_get_private(switch_core_session_get_channel(session), detector->uuid); + if (detector_state) { + /* detector is already running */ + detector_state->refs++; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Start detector %s, refs = %d\n", detector->name, detector_state->refs); + switch_core_session_rwunlock(session); + return 1; + } + detector_state = switch_core_session_alloc(session, sizeof(*detector_state)); + detector_state->refs = 1; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Starting detector %s, refs = 1\n", detector->name); + switch_channel_set_private(switch_core_session_get_channel(session), detector->uuid, detector_state); + switch_core_session_execute_application_async(session, detector->start_app, zstr(detector->start_app_args) ? NULL : detector->start_app_args); + switch_core_session_rwunlock(session); + return 1; + } else { + *error_detail = "session gone"; + return 0; + } + } + *error_detail = "detector not supported"; + return 0; +} + +/** + * Stop detecting + * @param call_uuid call to stop detecting signal on + * @param signal_ns name of signal to stop detecting + */ +void rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns) +{ + struct rayo_cpa_detector *detector = switch_core_hash_find(globals.detectors, signal_ns); + switch_core_session_t *session; + if (detector) { + if (zstr(detector->stop_app)) { + /* nothing to do */ + return; + } + session = switch_core_session_locate(call_uuid); + if (session) { + struct rayo_cpa_detector_state *detector_state = switch_channel_get_private(switch_core_session_get_channel(session), detector->uuid); + if (detector_state) { + detector_state->refs--; + if (detector_state->refs < 0) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Stop detector %s refs = %d\n", detector->name, detector_state->refs); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Stop detector %s refs = %d\n", detector->name, detector_state->refs); + } + if (detector_state->refs == 0) { + /* nobody interested in detector events- shut it down */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Stopping detector %s\n", detector->name); + switch_core_session_execute_application_async(session, detector->stop_app, zstr(detector->stop_app_args) ? NULL : detector->stop_app_args); + switch_channel_set_private(switch_core_session_get_channel(session), detector->uuid, NULL); + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Detector %s is already stopped\n", detector->name); + } + switch_core_session_rwunlock(session); + } + } +} + +/** + * Handle event from detector + */ +static void rayo_cpa_detector_event(switch_event_t *event) +{ + struct rayo_cpa_detector *detector = (struct rayo_cpa_detector *)event->bind_user_data; + if (detector) { + const char *signal_type = "rayo_default"; + if (!zstr(detector->signal_type_header)) { + signal_type = switch_event_get_header(event, detector->signal_type_header); + } + if (!zstr(signal_type)) { + signal_type = switch_core_hash_find(detector->signal_type_map, signal_type); + } + if (!zstr(signal_type)) { + switch_event_t *cpa_event; + const char *uuid = switch_event_get_header(event, "Unique-ID"); + if (zstr(uuid)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Detector %s %s event is missing call UUID!\n", detector->name, signal_type); + return; + } + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got Rayo CPA event %s\n", signal_type); + if (switch_event_create_subclass(&cpa_event, SWITCH_EVENT_CUSTOM, "rayo::cpa") == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(cpa_event, SWITCH_STACK_BOTTOM, "Unique-ID", uuid); + switch_event_add_header_string(cpa_event, SWITCH_STACK_BOTTOM, "detector-name", detector->name); + switch_event_add_header_string(cpa_event, SWITCH_STACK_BOTTOM, "detector-uuid", detector->uuid); + switch_event_add_header(cpa_event, SWITCH_STACK_BOTTOM, "signal-type", "%s%s:%s", RAYO_CPA_BASE, signal_type, RAYO_VERSION); + if (!zstr(detector->signal_value_header)) { + const char *value = switch_event_get_header(event, detector->signal_value_header); + if (!zstr(value)) { + switch_event_add_header_string(cpa_event, SWITCH_STACK_BOTTOM, "value", value); + } + } + if (!zstr(detector->signal_duration_header)) { + const char *duration = switch_event_get_header(event, detector->signal_duration_header); + if (!zstr(duration)) { + switch_event_add_header_string(cpa_event, SWITCH_STACK_BOTTOM, "duration", duration); + } + } + switch_event_fire(&cpa_event); + } + } else { + /* couldn't map event to Rayo signal-type */ + const char *event_name = switch_event_get_header(event, "Event-Name"); + const char *event_subclass = switch_event_get_header(event, "Event-Subclass"); + if (zstr(event_subclass)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Failed to find Rayo signal-type for event %s\n", event_name); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Failed to find Rayo signal-type for event %s %s\n", event_name, event_subclass); + } + } + } +} + +#define RAYO_CPA_DETECTOR_SYNTAX "rayo_cpa " +SWITCH_STANDARD_API(rayo_cpa_detector_api) +{ + char *cmd_dup = NULL; + char *argv[4] = { 0 }; + int argc = 0; + + if (zstr(cmd)) { + stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_CPA_DETECTOR_SYNTAX); + goto done; + } + + cmd_dup = strdup(cmd); + argc = switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); + + if (argc != 3) { + stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_CPA_DETECTOR_SYNTAX); + } else { + const char *err_reason = NULL; + if (!strcmp(argv[2], "stop")) { + rayo_cpa_detector_stop(argv[0], argv[1]); + stream->write_function(stream, "+OK\n"); + } else if (!strcmp(argv[2], "start")) { + if (!rayo_cpa_detector_start(argv[0], argv[1], &err_reason)) { + if (err_reason) { + stream->write_function(stream, "-ERR: %s\n", err_reason); + } else { + stream->write_function(stream, "-ERR\n"); + } + } else { + stream->write_function(stream, "+OK\n"); + } + } else { + stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_CPA_DETECTOR_SYNTAX); + } + } + +done: + switch_safe_free(cmd_dup); + + return SWITCH_STATUS_SUCCESS; +} + +/** + * Configure CPA + */ +static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_file) +{ + switch_xml_t cfg, xml, cpa_xml; + switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_hash_t *bound_events; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Configuring CPA\n"); + if (!(xml = switch_xml_open_cfg(config_file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", config_file); + return SWITCH_STATUS_TERM; + } + + switch_core_hash_init(&bound_events, pool); + + cpa_xml = switch_xml_child(cfg, "cpa"); + if (cpa_xml) { + switch_xml_t detector_xml; + + for (detector_xml = switch_xml_child(cpa_xml, "detector"); detector_xml; detector_xml = detector_xml->next) { + switch_xml_t start_xml, stop_xml, event_xml; + struct rayo_cpa_detector *detector; + char id[SWITCH_UUID_FORMATTED_LENGTH + 1] = { 0 }; + const char *name = switch_xml_attr_soft(detector_xml, "name"); + if (zstr(name)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing name of CPA detector!\n"); + status = SWITCH_STATUS_TERM; + goto done; + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CPA detector: %s\n", name); + detector = switch_core_alloc(pool, sizeof(*detector)); + switch_core_hash_init(&detector->signal_type_map, pool); + detector->name = switch_core_strdup(pool, name); + switch_uuid_str(id, sizeof(id)); + detector->uuid = switch_core_strdup(pool, id); + + start_xml = switch_xml_child(detector_xml, "start"); + if (start_xml) { + detector->start_app = switch_core_strdup(pool, switch_xml_attr_soft(start_xml, "application")); + detector->start_app_args = switch_core_strdup(pool, switch_xml_attr_soft(start_xml, "data")); + } + + stop_xml = switch_xml_child(detector_xml, "stop"); + if (stop_xml) { + detector->stop_app = switch_core_strdup(pool, switch_xml_attr_soft(stop_xml, "application")); + detector->stop_app_args = switch_core_strdup(pool, switch_xml_attr_soft(stop_xml, "data")); + } + + event_xml = switch_xml_child(detector_xml, "event"); + if (event_xml) { + int event_ok = 0; + switch_xml_t signal_type_xml; + const char *event_class = switch_xml_attr_soft(event_xml, "class"); + const char *event_subclass = switch_xml_attr_soft(event_xml, "subclass"); + switch_event_types_t event_type; + if (zstr(event_class)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing event class for CPA detector: %s\n", detector->name); + status = SWITCH_STATUS_TERM; + goto done; + } + + if (switch_name_event(event_class, &event_type) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid event class %s for CPA detector: %s\n", event_class, detector->name); + status = SWITCH_STATUS_TERM; + goto done; + } + + /* bind detector to event if not already done... */ + { + struct rayo_cpa_detector *bound_detector; + const char *event_name = switch_core_sprintf(pool, "%s %s", event_class, event_subclass); + if (!(bound_detector = switch_core_hash_find(bound_events, event_name))) { + /* not yet bound */ + if (zstr(event_subclass)) { + event_subclass = NULL; + } + switch_event_bind("rayo_cpa_detector", event_type, event_subclass, rayo_cpa_detector_event, detector); + switch_core_hash_insert(bound_events, event_name, detector); /* mark as bound */ + } else if (bound_detector != detector) { + /* can't have multiple detectors generating the same event! */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Detector %s attempted to bind to event %s that is already bound by %s\n", detector->name, event_name, bound_detector->name); + status = SWITCH_STATUS_TERM; + goto done; + } + } + + /* configure native event -> rayo CPA event mapping */ + detector->signal_type_header = switch_core_strdup(pool, switch_xml_attr_soft(event_xml, "type-header")); + detector->signal_value_header = switch_core_strdup(pool, switch_xml_attr_soft(event_xml, "value-header")); + detector->signal_duration_header = switch_core_strdup(pool, switch_xml_attr_soft(event_xml, "duration-header")); + + /* configure native event type -> rayo CPA signal type mapping */ + for (signal_type_xml = switch_xml_child(event_xml, "signal-type"); signal_type_xml; signal_type_xml = signal_type_xml->next) { + const char *header_value = switch_core_strdup(pool, switch_xml_attr_soft(signal_type_xml, "header-value")); + const char *signal_type = switch_core_strdup(pool, switch_xml_attr_soft(signal_type_xml, "value")); + if (zstr(signal_type)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Detector %s missing signal-type value!\n", detector->name); + status = SWITCH_STATUS_TERM; + goto done; + } else { + /* add signal-type to detector mapping */ + const char *signal_type_ns = switch_core_sprintf(pool, "%s%s:%s", RAYO_CPA_BASE, signal_type, RAYO_VERSION); + event_ok = 1; + switch_core_hash_insert(globals.detectors, signal_type_ns, detector); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding CPA %s => %s\n", signal_type_ns, detector->name); + } + + /* map event value to signal-type */ + if (zstr(header_value)) { + switch_core_hash_insert(detector->signal_type_map, "rayo_default", signal_type); + } else { + switch_core_hash_insert(detector->signal_type_map, header_value, signal_type); + } + } + + if (!event_ok) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Detector %s is missing Rayo signal-type for event\n", detector->name); + status = SWITCH_STATUS_TERM; + goto done; + } + } + } + } + +done: + switch_core_hash_destroy(&bound_events); + switch_xml_free(xml); + + return status; +} + +/** + * Console auto-completion for signal types + */ +static switch_status_t rayo_cpa_detector_signal_types(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + switch_hash_index_t *hi; + void *val; + const void *vvar; + switch_console_callback_match_t *my_matches = NULL; + + for (hi = switch_hash_first(NULL, globals.detectors); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &vvar, NULL, &val); + switch_console_push_match(&my_matches, (const char *) vvar); + } + + if (my_matches) { + *matches = my_matches; + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + +/** + * Load CPA signal detection features + * @param module_interface + * @param pool memory pool + * @param config_file + * @return SWITCH_STATUS_SUCCESS if successfully loaded + */ +switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) +{ + switch_api_interface_t *api_interface; + + SWITCH_ADD_API(api_interface, "rayo_cpa", "Query rayo status", rayo_cpa_detector_api, RAYO_CPA_DETECTOR_SYNTAX); + + switch_console_set_complete("add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types start"); + switch_console_set_complete("add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types stop"); + switch_console_add_complete_func("::rayo_cpa::list_signal_types", rayo_cpa_detector_signal_types); + + switch_core_hash_init(&globals.detectors, pool); + if (do_config(pool, config_file) != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_TERM; + } + return SWITCH_STATUS_SUCCESS; +} + +/** + * Disable CPA signal detection features + */ +void rayo_cpa_detector_shutdown(void) +{ + switch_console_set_complete("del rayo_cpa"); + switch_console_del_complete_func("::rayo_cpa::list_signal_types"); + switch_core_hash_destroy(&globals.detectors); + switch_event_unbind_callback(rayo_cpa_detector_event); +} + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ diff --git a/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.h b/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.h new file mode 100644 index 0000000000..fcdc35f2f4 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_cpa_detector.h @@ -0,0 +1,53 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2014, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_cpa_detector.h -- Rayo call progress analysis + * + */ +#ifndef RAYO_CPA_DETECTOR_H +#define RAYO_CPA_DETECTOR_H + +#include + +#include "mod_rayo.h" + +extern switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern void rayo_cpa_detector_shutdown(void); +extern int rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail); +extern void rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns); + +#endif + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.c b/src/mod/event_handlers/mod_rayo/rayo_elements.c index 34577a9492..1720471e31 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.c +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.c @@ -32,7 +32,8 @@ * component validation */ ELEMENT(RAYO_INPUT) - STRING_ATTRIB(mode, any, "any,dtmf,voice") + ATTRIB(xmlns,, any) + STRING_ATTRIB(mode, any, "any,dtmf,voice,cpa") OPTIONAL_ATTRIB(terminator,, dtmf_digit) ATTRIB(recognizer,, any) ATTRIB(language, en-US, any) @@ -48,10 +49,22 @@ ELEMENT(RAYO_INPUT) ATTRIB(start-timers, true, bool) ELEMENT_END +/** + * command validation + */ +ELEMENT(RAYO_JOIN) + ATTRIB(xmlns,, any) + STRING_ATTRIB(direction, duplex, "send,recv,duplex") + STRING_ATTRIB(media, bridge, "bridge,direct") + ATTRIB(call-uri,, any) + ATTRIB(mixer-name,, any) +ELEMENT_END + /** * component validation */ ELEMENT(RAYO_OUTPUT) + ATTRIB(xmlns,, any) ATTRIB(start-offset, 0, not_negative) ATTRIB(start-paused, false, bool) ATTRIB(repeat-interval, 0, not_negative) @@ -65,6 +78,7 @@ ELEMENT_END * validation */ ELEMENT(RAYO_OUTPUT_SEEK) + ATTRIB(xmlns,, any) STRING_ATTRIB(direction,, "forward,back") ATTRIB(amount,-1, positive) ELEMENT_END @@ -73,14 +87,23 @@ ELEMENT_END * component validation */ ELEMENT(RAYO_PROMPT) + ATTRIB(xmlns,, any) ATTRIB(barge-in, true, bool) ELEMENT_END +/** + * command validation + */ +ELEMENT(RAYO_RECEIVEFAX) + ATTRIB(xmlns,, any) +ELEMENT_END + /** * component validation */ ELEMENT(RAYO_RECORD) - ATTRIB(format, mp3, any) + ATTRIB(xmlns,, any) + ATTRIB(format, wav, any) ATTRIB(start-beep, false, bool) ATTRIB(stop-beep, false, bool) ATTRIB(start-paused, false, bool) @@ -92,13 +115,10 @@ ELEMENT(RAYO_RECORD) ELEMENT_END /** - * command validation + * command validation */ -ELEMENT(RAYO_JOIN) - STRING_ATTRIB(direction, duplex, "send,recv,duplex") - STRING_ATTRIB(media, bridge, "bridge,direct") - ATTRIB(call-uri,, any) - ATTRIB(mixer-name,, any) +ELEMENT(RAYO_SENDFAX) + ATTRIB(xmlns,, any) ELEMENT_END diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.h b/src/mod/event_handlers/mod_rayo/rayo_elements.h index c780f160cf..e76809cc9e 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.h +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.h @@ -32,11 +32,13 @@ #include "iks_helpers.h" ELEMENT_DECL(RAYO_INPUT) +ELEMENT_DECL(RAYO_JOIN) ELEMENT_DECL(RAYO_OUTPUT) ELEMENT_DECL(RAYO_OUTPUT_SEEK) ELEMENT_DECL(RAYO_PROMPT) +ELEMENT_DECL(RAYO_RECEIVEFAX) ELEMENT_DECL(RAYO_RECORD) -ELEMENT_DECL(RAYO_JOIN) +ELEMENT_DECL(RAYO_SENDFAX) #endif diff --git a/src/mod/event_handlers/mod_rayo/rayo_fax_components.c b/src/mod/event_handlers/mod_rayo/rayo_fax_components.c new file mode 100644 index 0000000000..4a4fc76f6b --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_fax_components.c @@ -0,0 +1,566 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_fax_components.c -- Rayo receivefax and sendfax components implementation + * + */ +#include "rayo_components.h" +#include "rayo_elements.h" + +/** + * settings + */ +static struct { + const char *file_prefix; +} globals; + +struct fax_component { + /** component base class */ + struct rayo_component base; + /** Flag to stop fax */ + int stop; +}; + +#define FAX_COMPONENT(x) ((struct fax_component *)x) + +struct receivefax_component { + /** fax component base class */ + struct fax_component base; + /** true if HTTP PUT needs to be done after fax is received */ + int http_put_after_receive; + /** fax stored on local filesystem */ + const char *local_filename; + /** fax final target (may be same as local filename) */ + const char *filename; +}; + +#define RECEIVEFAX_COMPONENT(x) ((struct receivefax_component *)x) + +#define FAX_FINISH "finish", RAYO_FAX_COMPLETE_NS + +/** + * Start execution of call sendfax component + * @param call the call to send fax to + * @param msg the original request + * @param session_data the call's session + */ +static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = (switch_core_session_t *)session_data; + struct fax_component *sendfax_component = NULL; + iks *sendfax = iks_find(iq, "sendfax"); + iks *response = NULL; + switch_event_t *execute_event = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_memory_pool_t *pool; + iks *document; + const char *fax_document; + const char *fax_header; + const char *fax_identity; + const char *pages; + + /* validate attributes */ + if (!VALIDATE_RAYO_SENDFAX(sendfax)) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + + /* fax is only allowed if the call is not currently joined */ + if (rayo_call_is_joined(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't send fax on a joined call"); + } + + if (rayo_call_is_faxing(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress"); + } + + /* get fax document */ + document = iks_find(sendfax, "document"); + if (!document) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "missing document"); + } + fax_document = iks_find_attrib_soft(document, "url"); + if (zstr(fax_document)) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "missing document url"); + } + + /* is valid URL type? */ + if (!strncasecmp(fax_document, "http://", 7) || !strncasecmp(fax_document, "https://", 8)) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + /* need to fetch document from server... */ + switch_api_execute("http_get", fax_document, session, &stream); + if (!zstr(stream.data) && !strncmp(fax_document, SWITCH_PATH_SEPARATOR, strlen(SWITCH_PATH_SEPARATOR))) { + fax_document = switch_core_session_strdup(session, stream.data); + } else { + switch_safe_free(stream.data); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to fetch document"); + } + switch_safe_free(stream.data); + } else if (!strncasecmp(fax_document, "file://", 7)) { + fax_document = fax_document + 7; + if (zstr(fax_document)) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid file:// url"); + } + } else if (strncasecmp(fax_document, SWITCH_PATH_SEPARATOR, strlen(SWITCH_PATH_SEPARATOR))) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "unsupported url type"); + } + + /* does document exist? */ + if (switch_file_exists(fax_document, pool) != SWITCH_STATUS_SUCCESS) { + return iks_new_error_detailed_printf(iq, STANZA_ERROR_BAD_REQUEST, "file not found: %s", fax_document); + } + + /* get fax identity and header */ + fax_identity = iks_find_attrib_soft(document, "identity"); + if (!zstr(fax_identity)) { + switch_channel_set_variable(channel, "fax_ident", fax_identity); + } else { + switch_channel_set_variable(channel, "fax_ident", NULL); + } + fax_header = iks_find_attrib_soft(document, "header"); + if (!zstr(fax_header)) { + switch_channel_set_variable(channel, "fax_header", fax_header); + } else { + switch_channel_set_variable(channel, "fax_header", NULL); + } + + /* get pages to send */ + pages = iks_find_attrib_soft(document, "pages"); + if (!zstr(pages)) { + if (switch_regex_match(pages, "[1-9][0-9]*(-[1-9][0-9]*)?") == SWITCH_STATUS_FALSE) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid pages value"); + } else { + int start = 0; + int end = 0; + char *pages_dup = switch_core_session_strdup(session, pages); + char *sep = strchr(pages_dup, '-'); + if (sep) { + *sep = '\0'; + sep++; + end = atoi(sep); + } + start = atoi(pages_dup); + if (end && end < start) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid pages value"); + } + switch_channel_set_variable(channel, "fax_start_page", pages_dup); + switch_channel_set_variable(channel, "fax_end_page", sep); + } + } else { + switch_channel_set_variable(channel, "fax_start_page", NULL); + switch_channel_set_variable(channel, "fax_end_page", NULL); + } + + /* create sendfax component */ + switch_core_new_memory_pool(&pool); + sendfax_component = switch_core_alloc(pool, sizeof(*sendfax_component)); + rayo_component_init((struct rayo_component *)sendfax_component, pool, RAT_CALL_COMPONENT, "sendfax", NULL, call, iks_find_attrib(iq, "from")); + + /* add channel variable so that fax component can be located from fax events */ + switch_channel_set_variable(channel, "rayo_fax_jid", RAYO_JID(sendfax_component)); + + /* clear fax result variables */ + switch_channel_set_variable(channel, "fax_success", NULL); + switch_channel_set_variable(channel, "fax_result_code", NULL); + switch_channel_set_variable(channel, "fax_result_text", NULL); + switch_channel_set_variable(channel, "fax_document_transferred_pages", NULL); + switch_channel_set_variable(channel, "fax_document_total_pages", NULL); + switch_channel_set_variable(channel, "fax_image_resolution", NULL); + switch_channel_set_variable(channel, "fax_image_size", NULL); + switch_channel_set_variable(channel, "fax_bad_rows", NULL); + switch_channel_set_variable(channel, "fax_transfer_rate", NULL); + switch_channel_set_variable(channel, "fax_ecm_used", NULL); + switch_channel_set_variable(channel, "fax_local_station_id", NULL); + switch_channel_set_variable(channel, "fax_remote_station_id", NULL); + + /* clear fax interrupt variable */ + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + + rayo_call_set_faxing(RAYO_CALL(call), 1); + + /* execute txfax APP */ + if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", "txfax"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", fax_document); + if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { + switch_channel_set_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA); + } + + if (switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to txfax (queue event failed)"); + if (execute_event) { + switch_event_destroy(&execute_event); + } + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(sendfax_component); + } else { + /* component starting... */ + rayo_component_send_start(RAYO_COMPONENT(sendfax_component), iq); + } + } else { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event"); + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(sendfax_component); + } + + return response; +} + +/** + * Start execution of call receivefax component + * @param call the call to receive fax from + * @param msg the original request + * @param session_data the call's session + */ +static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = (switch_core_session_t *)session_data; + struct receivefax_component *receivefax_component = NULL; + iks *receivefax = iks_find(iq, "receivefax"); + iks *response = NULL; + switch_event_t *execute_event = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_memory_pool_t *pool; + int file_no; + + /* validate attributes */ + if (!VALIDATE_RAYO_RECEIVEFAX(receivefax)) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + + /* fax is only allowed if the call is not currently joined */ + if (rayo_call_is_joined(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call"); + } + + if (rayo_call_is_faxing(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress"); + } + + /* create receivefax component */ + switch_core_new_memory_pool(&pool); + receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component)); + rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from")); + file_no = rayo_actor_seq_next(call); + receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d.tif", + globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no); + if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) { + /* This is an HTTP URL, need to PUT after fax is received */ + receivefax_component->local_filename = switch_core_sprintf(pool, "%s%s%s-%d", + SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no); + receivefax_component->http_put_after_receive = 1; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to HTTP URL\n", RAYO_JID(receivefax_component)); + } else { + /* assume file.. */ + receivefax_component->local_filename = receivefax_component->filename; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to local file\n", RAYO_JID(receivefax_component)); + } + + /* add channel variable so that fax component can be located from fax events */ + switch_channel_set_variable(channel, "rayo_fax_jid", RAYO_JID(receivefax_component)); + + /* clear fax result variables */ + switch_channel_set_variable(channel, "fax_success", NULL); + switch_channel_set_variable(channel, "fax_result_code", NULL); + switch_channel_set_variable(channel, "fax_result_text", NULL); + switch_channel_set_variable(channel, "fax_document_transferred_pages", NULL); + switch_channel_set_variable(channel, "fax_document_total_pages", NULL); + switch_channel_set_variable(channel, "fax_image_resolution", NULL); + switch_channel_set_variable(channel, "fax_image_size", NULL); + switch_channel_set_variable(channel, "fax_bad_rows", NULL); + switch_channel_set_variable(channel, "fax_transfer_rate", NULL); + switch_channel_set_variable(channel, "fax_ecm_used", NULL); + switch_channel_set_variable(channel, "fax_local_station_id", NULL); + switch_channel_set_variable(channel, "fax_remote_station_id", NULL); + + /* clear fax interrupt variable */ + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + + rayo_call_set_faxing(RAYO_CALL(call), 1); + + /* execute rxfax APP */ + if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", "rxfax"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", receivefax_component->local_filename); + if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { + switch_channel_set_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA); + } + + if (switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to rxfax (queue event failed)"); + if (execute_event) { + switch_event_destroy(&execute_event); + } + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(receivefax_component); + } else { + /* component starting... */ + rayo_component_send_start(RAYO_COMPONENT(receivefax_component), iq); + } + } else { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event"); + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(receivefax_component); + } + + return response; +} + +/** + * Stop execution of fax component + */ +static iks *stop_fax_component(struct rayo_actor *component, struct rayo_message *msg, void *data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); + FAX_COMPONENT(component)->stop = 1; + if (session) { + switch_core_session_execute_application_async(session, "stopfax", ""); + switch_core_session_rwunlock(session); + } + return iks_new_iq_result(iq); +} + +/** + * Add fax metadata to result + * @param event source of metadata + * @param name of metadata + * @param result to add metadata to + */ +static void insert_fax_metadata(switch_event_t *event, const char *name, iks *result) +{ + char actual_name[256]; + const char *value; + snprintf(actual_name, sizeof(actual_name), "variable_%s", name); + actual_name[sizeof(actual_name) - 1] = '\0'; + value = switch_event_get_header(event, actual_name); + if (!zstr(value)) { + iks *metadata = iks_insert(result, "metadata"); + iks_insert_attrib(metadata, "xmlns", RAYO_FAX_COMPLETE_NS); + iks_insert_attrib(metadata, "name", name); + iks_insert_attrib(metadata, "value", value); + } +} + +/** + * Handle fax completion event from FreeSWITCH core + * @param event received from FreeSWITCH core. It will be destroyed by the core after this function returns. + */ +static void on_execute_complete_event(switch_event_t *event) +{ + const char *application = switch_event_get_header(event, "Application"); + + if (!zstr(application) && (!strcmp(application, "rxfax") || !strcmp(application, "txfax"))) { + int is_rxfax = !strcmp(application, "rxfax"); + const char *uuid = switch_event_get_header(event, "Unique-ID"); + const char *fax_jid = switch_event_get_header(event, "variable_rayo_fax_jid"); + struct rayo_actor *component; + if (!zstr(fax_jid) && (component = RAYO_LOCATE(fax_jid))) { + iks *result; + iks *complete; + iks *fax; + int have_fax_document = 1; + switch_core_session_t *session; + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got result for %s\n", fax_jid); + + /* clean up channel */ + session = switch_core_session_locate(uuid); + if (session) { + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + switch_core_session_rwunlock(session); + } + + /* RX only: transfer HTTP document and delete local copy */ + if (is_rxfax && RECEIVEFAX_COMPONENT(component)->http_put_after_receive && switch_file_exists(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)) == SWITCH_STATUS_SUCCESS) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename); + switch_api_execute("http_put", RECEIVEFAX_COMPONENT(component)->filename, NULL, &stream); + /* check if successful */ + if (!zstr(stream.data) && strncmp(stream.data, "+OK", 3)) { + /* PUT failed */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s failed: %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename, (char *)stream.data); + have_fax_document = 0; + } + switch_safe_free(stream.data) + switch_file_remove(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)); + } + + /* successful fax? */ + if (have_fax_document && switch_true(switch_event_get_header(event, "variable_fax_success"))) { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), FAX_FINISH); + } else if (have_fax_document && FAX_COMPONENT(component)->stop) { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); + } else { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); + } + complete = iks_find(result, "complete"); + + /* RX only: add fax document information */ + if (is_rxfax && have_fax_document) { + const char *pages = switch_event_get_header(event, "variable_fax_document_transferred_pages"); + if (!zstr(pages) && switch_is_number(pages) && atoi(pages) > 0) { + const char *resolution = switch_event_get_header(event, "variable_fax_file_image_resolution"); + const char *size = switch_event_get_header(event, "variable_fax_image_size"); + + fax = iks_insert(complete, "fax"); + iks_insert_attrib(fax, "xmlns", RAYO_FAX_COMPLETE_NS); + + if (RECEIVEFAX_COMPONENT(component)->http_put_after_receive) { + iks_insert_attrib(fax, "url", RECEIVEFAX_COMPONENT(component)->filename); + } else { + /* convert absolute path to file:// URI */ + iks_insert_attrib_printf(fax, "url", "file://%s", RECEIVEFAX_COMPONENT(component)->filename); + } + + if (!zstr(resolution)) { + iks_insert_attrib(fax, "resolution", resolution); + } + if (!zstr(size)) { + iks_insert_attrib(fax, "size", size); + } + iks_insert_attrib(fax, "pages", pages); + } + } + + /* add metadata from event */ + insert_fax_metadata(event, "fax_success", complete); + insert_fax_metadata(event, "fax_result_code", complete); + insert_fax_metadata(event, "fax_result_text", complete); + insert_fax_metadata(event, "fax_document_transferred_pages", complete); + insert_fax_metadata(event, "fax_document_total_pages", complete); + insert_fax_metadata(event, "fax_image_resolution", complete); + insert_fax_metadata(event, "fax_image_size", complete); + insert_fax_metadata(event, "fax_bad_rows", complete); + insert_fax_metadata(event, "fax_transfer_rate", complete); + insert_fax_metadata(event, "fax_ecm_used", complete); + insert_fax_metadata(event, "fax_local_station_id", complete); + insert_fax_metadata(event, "fax_remote_station_id", complete); + + /* flag faxing as done */ + rayo_call_set_faxing(RAYO_CALL(RAYO_COMPONENT(component)->parent), 0); + + rayo_component_send_complete_event(RAYO_COMPONENT(component), result); + + RAYO_UNLOCK(component); + } + } +} + +/** + * Process module XML configuration + * @param pool memory pool to allocate from + * @param config_file to use + * @return SWITCH_STATUS_SUCCESS on successful configuration + */ +static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_file) +{ + switch_xml_t cfg, xml; + + /* set defaults */ + globals.file_prefix = switch_core_sprintf(pool, "%s%s", SWITCH_GLOBAL_dirs.recordings_dir, SWITCH_PATH_SEPARATOR); + + if (!(xml = switch_xml_open_cfg(config_file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", config_file); + return SWITCH_STATUS_TERM; + } + + /* get params */ + { + switch_xml_t settings = switch_xml_child(cfg, "fax"); + if (settings) { + switch_xml_t param; + for (param = switch_xml_child(settings, "param"); param; param = param->next) { + const char *var = switch_xml_attr_soft(param, "name"); + const char *val = switch_xml_attr_soft(param, "value"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param: %s = %s\n", var, val); + if (!strcasecmp(var, "receivefax-file-prefix")) { + if (!zstr(val)) { + globals.file_prefix = switch_core_strdup(pool, val); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var); + } + } + } + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "receivefax-file-prefix = %s\n", globals.file_prefix); + + switch_xml_free(xml); + + return SWITCH_STATUS_SUCCESS; +} + +/** + * Initialize fax components + * @param module_interface + * @param pool memory pool to allocate from + * @param config_file to use + * @return SWITCH_STATUS_SUCCESS if successful + */ +switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) +{ + if (do_config(pool, config_file) != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_TERM; + } + + switch_event_bind("rayo_fax_components", SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE, NULL, on_execute_complete_event, NULL); + + rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_FAX_NS":receivefax", start_receivefax_component); + rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "receivefax", "set:"RAYO_EXT_NS":stop", stop_fax_component); + + rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_FAX_NS":sendfax", start_sendfax_component); + rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "sendfax", "set:"RAYO_EXT_NS":stop", stop_fax_component); + + return SWITCH_STATUS_SUCCESS; +} + +/** + * Shutdown fax components + * @return SWITCH_STATUS_SUCCESS if successful + */ +switch_status_t rayo_fax_components_shutdown(void) +{ + switch_event_unbind_callback(on_execute_complete_event); + + return SWITCH_STATUS_SUCCESS; +} + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ + diff --git a/src/mod/event_handlers/mod_rayo/rayo_input_component.c b/src/mod/event_handlers/mod_rayo/rayo_input_component.c index 8238deb48a..7941c124fb 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_input_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_input_component.c @@ -1,6 +1,6 @@ /* * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2013, Grasshopper + * Copyright (C) 2013-2014, Grasshopper * * Version: MPL 1.1 * @@ -27,11 +27,12 @@ * */ #include "rayo_components.h" +#include "rayo_cpa_component.h" #include "rayo_elements.h" #include "srgs.h" #include "nlsml.h" -#define MAX_DTMF 64 +#define MAX_DTMF 256 #define INPUT_MATCH_TAG "match" #define INPUT_MATCH INPUT_MATCH_TAG, RAYO_INPUT_COMPLETE_NS @@ -101,8 +102,8 @@ struct input_handler { switch_media_bug_t *bug; /** active voice input component */ struct input_component *voice_component; - /** active dtmf input component */ - struct input_component *dtmf_component; + /** active dtmf input components */ + switch_hash_t *dtmf_components; /** synchronizes media bug and dtmf callbacks */ switch_mutex_t *mutex; /** last recognizer used */ @@ -146,79 +147,162 @@ static void send_barge_event(struct rayo_component *component) } /** - * Process DTMF press + * Check if dtmf component has timed out */ -static switch_status_t input_component_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction) +static switch_status_t dtmf_component_check_timeout(struct input_component *component, switch_core_session_t *session) +{ + /* check for stopped component */ + if (component->stop) { + rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); + + /* let handler know component is done */ + return SWITCH_STATUS_FALSE; + } + + /* check for timeout */ + if (component->start_timers) { + int elapsed_ms = (switch_micro_time_now() - component->last_digit_time) / 1000; + if (component->num_digits && component->inter_digit_timeout > 0 && elapsed_ms > component->inter_digit_timeout) { + enum srgs_match_type match; + const char *interpretation = NULL; + + /* we got some input, check for match */ + match = srgs_grammar_match(component->grammar, component->digits, &interpretation); + if (match == SMT_MATCH || match == SMT_MATCH_END) { + iks *result = nlsml_create_dtmf_match(component->digits, interpretation); + /* notify of match */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits); + send_match_event(RAYO_COMPONENT(component), result); + iks_delete(result); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "inter-digit-timeout\n"); + rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); + } + + /* let handler know component is done */ + return SWITCH_STATUS_FALSE; + } else if (!component->num_digits && component->initial_timeout > 0 && elapsed_ms > component->initial_timeout) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "initial-timeout\n"); + rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOINPUT); + + /* let handler know component is done */ + return SWITCH_STATUS_FALSE; + } + } + return SWITCH_STATUS_SUCCESS; +} + +/** + * Process DTMF press for a specific component + * @param component to receive DTMF + * @param session + * @param dtmf + * @param direction + * @return SWITCH_STATUS_FALSE if component is done + */ +static switch_status_t dtmf_component_on_dtmf(struct input_component *component, switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction) +{ + int is_term_digit = 0; + enum srgs_match_type match; + const char *interpretation = NULL; + + is_term_digit = digit_test(component->term_digit, dtmf->digit); + + if (!is_term_digit) { + component->digits[component->num_digits] = dtmf->digit; + component->num_digits++; + component->digits[component->num_digits] = '\0'; + component->last_digit_time = switch_micro_time_now(); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Collected digits = \"%s\"\n", component->digits); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Collected term digit = \"%c\"\n", dtmf->digit); + } + + match = srgs_grammar_match(component->grammar, component->digits, &interpretation); + + if (is_term_digit) { + /* finalize result if terminating digit was pressed */ + if (match == SMT_MATCH_PARTIAL) { + match = SMT_NO_MATCH; + } else if (match == SMT_MATCH) { + match = SMT_MATCH_END; + } + } else if (component->num_digits >= MAX_DTMF) { + /* maximum digits collected and still not a definitive match */ + if (match != SMT_MATCH_END) { + match = SMT_NO_MATCH; + } + } + + switch (match) { + case SMT_MATCH: + case SMT_MATCH_PARTIAL: { + /* need more digits */ + if (component->num_digits == 1) { + send_barge_event(RAYO_COMPONENT(component)); + } + break; + } + case SMT_NO_MATCH: { + /* notify of no-match and remove input component */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NO MATCH = %s\n", component->digits); + rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); + + /* let handler know component is done */ + return SWITCH_STATUS_FALSE; + } + case SMT_MATCH_END: { + iks *result = nlsml_create_dtmf_match(component->digits, interpretation); + /* notify of match and remove input component */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits); + send_match_event(RAYO_COMPONENT(component), result); + iks_delete(result); + + /* let handler know component is done */ + return SWITCH_STATUS_FALSE; + } + } + + /* still need more input */ + return SWITCH_STATUS_SUCCESS; +} + +/** + * Process DTMF press on call + */ +static switch_status_t input_handler_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction) { switch_channel_t *channel = switch_core_session_get_channel(session); struct input_handler *handler = (struct input_handler *)switch_channel_get_private(channel, RAYO_INPUT_COMPONENT_PRIVATE_VAR); if (handler) { - int is_term_digit = 0; - struct input_component *component; - enum srgs_match_type match; - const char *interpretation = NULL; + switch_event_t *components_to_remove = NULL; + switch_hash_index_t *hi; switch_mutex_lock(handler->mutex); - - component = handler->dtmf_component; - /* additional paranoia check */ - if (!component) { - switch_mutex_unlock(handler->mutex); - return SWITCH_STATUS_SUCCESS; - } - - is_term_digit = digit_test(component->term_digit, dtmf->digit); - - if (!is_term_digit) { - component->digits[component->num_digits] = dtmf->digit; - component->num_digits++; - component->digits[component->num_digits] = '\0'; - component->last_digit_time = switch_micro_time_now(); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Collected digits = \"%s\"\n", component->digits); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Collected term digit = \"%c\"\n", dtmf->digit); - } - - match = srgs_grammar_match(component->grammar, component->digits, &interpretation); - - /* adjust result if terminating digit was pressed */ - if (is_term_digit) { - if (match == SMT_MATCH_PARTIAL) { - match = SMT_NO_MATCH; - } else if (match == SMT_MATCH) { - match = SMT_MATCH_END; - } - } - - switch (match) { - case SMT_MATCH: - case SMT_MATCH_PARTIAL: { - /* need more digits */ - if (component->num_digits == 1) { - send_barge_event(RAYO_COMPONENT(component)); + + /* check input on each component */ + for (hi = switch_core_hash_first(handler->dtmf_components); hi; hi = switch_core_hash_next(hi)) { + const void *jid; + void *component; + switch_core_hash_this(hi, &jid, NULL, &component); + if (dtmf_component_on_dtmf(INPUT_COMPONENT(component), session, dtmf, direction) != SWITCH_STATUS_SUCCESS) { + if (!components_to_remove) { + switch_event_create_subclass(&components_to_remove, SWITCH_EVENT_CLONE, NULL); } - break; - } - case SMT_NO_MATCH: { - /* notify of no-match and remove input component */ - handler->dtmf_component = NULL; - switch_core_media_bug_remove(session, &handler->bug); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NO MATCH = %s\n", component->digits); - rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); - break; - } - case SMT_MATCH_END: { - iks *result = nlsml_create_dtmf_match(component->digits, interpretation); - /* notify of match and remove input component */ - handler->dtmf_component = NULL; - switch_core_media_bug_remove(session, &handler->bug); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits); - send_match_event(RAYO_COMPONENT(component), result); - iks_delete(result); - break; + switch_event_add_header_string(components_to_remove, SWITCH_STACK_BOTTOM, "done", RAYO_JID(component)); } } + + /* remove any finished components */ + if (components_to_remove) { + switch_event_header_t *component_to_remove = NULL; + for (component_to_remove = components_to_remove->headers; component_to_remove; component_to_remove = component_to_remove->next) { + switch_core_hash_delete(handler->dtmf_components, component_to_remove->value); + } + switch_event_destroy(&components_to_remove); + } + switch_mutex_unlock(handler->mutex); } return SWITCH_STATUS_SUCCESS; @@ -227,67 +311,60 @@ static switch_status_t input_component_on_dtmf(switch_core_session_t *session, c /** * Monitor for input */ -static switch_bool_t input_component_bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) +static switch_bool_t input_handler_bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) { switch_core_session_t *session = switch_core_media_bug_get_session(bug); struct input_handler *handler = (struct input_handler *)user_data; - struct input_component *component; + switch_hash_index_t *hi; switch_mutex_lock(handler->mutex); - component = handler->dtmf_component; switch(type) { case SWITCH_ABC_TYPE_INIT: { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Adding DTMF callback\n"); - switch_core_event_hook_add_recv_dtmf(session, input_component_on_dtmf); + switch_core_event_hook_add_recv_dtmf(session, input_handler_on_dtmf); break; } case SWITCH_ABC_TYPE_READ_REPLACE: { switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug); - /* check for timeout */ - if (component && component->start_timers) { - int elapsed_ms = (switch_micro_time_now() - component->last_digit_time) / 1000; - if (component->num_digits && component->inter_digit_timeout > 0 && elapsed_ms > component->inter_digit_timeout) { - enum srgs_match_type match; - const char *interpretation = NULL; - handler->dtmf_component = NULL; - switch_core_media_bug_set_flag(bug, SMBF_PRUNE); + switch_event_t *components_to_remove = NULL; - /* we got some input, check for match */ - match = srgs_grammar_match(component->grammar, component->digits, &interpretation); - if (match == SMT_MATCH || match == SMT_MATCH_END) { - iks *result = nlsml_create_dtmf_match(component->digits, interpretation); - /* notify of match */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits); - send_match_event(RAYO_COMPONENT(component), result); - iks_delete(result); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "inter-digit-timeout\n"); - rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH); + /* check timeout/stop on each component */ + for (hi = switch_core_hash_first(handler->dtmf_components); hi; hi = switch_core_hash_next(hi)) { + const void *jid; + void *component; + switch_core_hash_this(hi, &jid, NULL, &component); + if (dtmf_component_check_timeout(INPUT_COMPONENT(component), session) != SWITCH_STATUS_SUCCESS) { + if (!components_to_remove) { + switch_event_create_subclass(&components_to_remove, SWITCH_EVENT_CLONE, NULL); } - } else if (!component->num_digits && component->initial_timeout > 0 && elapsed_ms > component->initial_timeout) { - handler->dtmf_component = NULL; - switch_core_media_bug_set_flag(bug, SMBF_PRUNE); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "initial-timeout\n"); - rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOINPUT); + switch_event_add_header_string(components_to_remove, SWITCH_STACK_BOTTOM, "done", RAYO_JID(component)); } } + + /* remove any finished components */ + if (components_to_remove) { + switch_event_header_t *component_to_remove = NULL; + for (component_to_remove = components_to_remove->headers; component_to_remove; component_to_remove = component_to_remove->next) { + switch_core_hash_delete(handler->dtmf_components, component_to_remove->value); + } + switch_event_destroy(&components_to_remove); + } + switch_core_media_bug_set_read_replace_frame(bug, rframe); break; } case SWITCH_ABC_TYPE_CLOSE: - /* check for hangup */ - if (component) { - if (component->stop) { - handler->dtmf_component = NULL; - rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); - } else { - handler->dtmf_component = NULL; - rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP); - } + /* complete all components */ + for (hi = switch_core_hash_first(handler->dtmf_components); hi; hi = switch_core_hash_next(hi)) { + const void *jid; + void *component; + switch_core_hash_this(hi, &jid, NULL, &component); + rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP); } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Removing DTMF callback\n"); - switch_core_event_hook_remove_recv_dtmf(session, input_component_on_dtmf); + switch_core_event_hook_remove_recv_dtmf(session, input_handler_on_dtmf); + switch_core_hash_destroy(&handler->dtmf_components); break; default: break; @@ -336,6 +413,140 @@ static int validate_call_input(iks *input, const char **error) return 1; } +/** + * Start call input on voice resource + */ +static iks *start_call_voice_input(struct input_component *component, switch_core_session_t *session, iks *input, iks *iq, const char *output_file, int barge_in) +{ + struct input_handler *handler = component->handler; + switch_stream_handle_t grammar = { 0 }; + SWITCH_STANDARD_STREAM(grammar); + + if (component->speech_mode && handler->voice_component) { + /* don't allow multi voice input */ + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple voice input is not allowed"); + } + + handler->voice_component = component; + + if (zstr(component->recognizer)) { + component->recognizer = globals.default_recognizer; + } + + /* if recognition engine is different, we can't handle this request */ + if (!zstr(handler->last_recognizer) && strcmp(component->recognizer, handler->last_recognizer)) { + handler->voice_component = NULL; + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Must use the same recognizer for the entire call"); + } + handler->last_recognizer = switch_core_session_strdup(session, component->recognizer); + + if (!strcmp(component->recognizer, "pocketsphinx")) { + const char *jsgf_path; + + /* transform SRGS grammar to JSGF */ + if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); + handler->voice_component = NULL; + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); + } + jsgf_path = srgs_grammar_to_jsgf_file(component->grammar, SWITCH_GLOBAL_dirs.grammar_dir, "gram"); + if (!jsgf_path) { + handler->voice_component = NULL; + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Grammar conversion to JSGF error"); + } + + /* build pocketsphinx grammar string */ + grammar.write_function(&grammar, + "{start-input-timers=%s,no-input-timeout=%d,speech-timeout=%d,confidence-threshold=%d}%s", + component->start_timers ? "true" : "false", + component->initial_timeout, + component->max_silence, + (int)ceil(component->min_confidence * 100.0), + jsgf_path); + } else if (!strncmp(component->recognizer, "unimrcp", strlen("unimrcp"))) { + /* send inline grammar to unimrcp */ + grammar.write_function(&grammar, "{start-input-timers=%s,confidence-threshold=%f,sensitivity-level=%f", + component->start_timers ? "true" : "false", + component->min_confidence, + component->sensitivity); + + if (component->initial_timeout > 0) { + grammar.write_function(&grammar, ",no-input-timeout=%d", + component->initial_timeout); + } + + if (component->max_silence > 0) { + grammar.write_function(&grammar, ",speech-complete-timeout=%d,speech-incomplete-timeout=%d", + component->max_silence, + component->max_silence); + } + + if (!zstr(component->language)) { + grammar.write_function(&grammar, ",speech-language=%s", component->language); + } + + if (!strcmp(iks_find_attrib_soft(input, "mode"), "any")) { + /* set dtmf params */ + if (component->inter_digit_timeout > 0) { + grammar.write_function(&grammar, ",dtmf-interdigit-timeout=%d", component->inter_digit_timeout); + } + if (component->term_digit) { + grammar.write_function(&grammar, ",dtmf-term-char=%c", component->term_digit); + } + } + + grammar.write_function(&grammar, "}inline:%s", iks_find_cdata(input, "grammar")); + } else { + /* passthrough to unknown ASR module */ + grammar.write_function(&grammar, "%s", iks_find_cdata(input, "grammar")); + } + + /* acknowledge command */ + rayo_component_send_start(RAYO_COMPONENT(component), iq); + + /* start speech detection */ + switch_channel_set_variable(switch_core_session_get_channel(session), "fire_asr_events", "true"); + if (switch_ivr_detect_speech(session, component->recognizer, grammar.data, "mod_rayo_grammar", "", NULL) != SWITCH_STATUS_SUCCESS) { + handler->voice_component = NULL; + rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); + } + switch_safe_free(grammar.data); + + return NULL; +} + +/** + * Start call input on DTMF resource + */ +static iks *start_call_dtmf_input(struct input_component *component, switch_core_session_t *session, iks *input, iks *iq, const char *output_file, int barge_in) +{ + /* parse the grammar */ + if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); + } + + component->last_digit_time = switch_micro_time_now(); + + /* acknowledge command */ + rayo_component_send_start(RAYO_COMPONENT(component), iq); + + /* start dtmf input detection */ + switch_core_hash_insert(component->handler->dtmf_components, RAYO_JID(component), component); + + return NULL; +} + /** * Start call input for the given component * @param component the input or prompt component @@ -345,31 +556,36 @@ static int validate_call_input(iks *input, const char **error) */ static iks *start_call_input(struct input_component *component, switch_core_session_t *session, iks *input, iks *iq, const char *output_file, int barge_in) { + iks *result = NULL; + /* set up input component for new detection */ struct input_handler *handler = (struct input_handler *)switch_channel_get_private(switch_core_session_get_channel(session), RAYO_INPUT_COMPONENT_PRIVATE_VAR); if (!handler) { /* create input component */ handler = switch_core_session_alloc(session, sizeof(*handler)); switch_mutex_init(&handler->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + switch_core_hash_init(&handler->dtmf_components, NULL); switch_channel_set_private(switch_core_session_get_channel(session), RAYO_INPUT_COMPONENT_PRIVATE_VAR, handler); handler->last_recognizer = ""; + + /* fire up media bug to monitor lifecycle */ + if (switch_core_media_bug_add(session, "rayo_input_component", NULL, input_handler_bug_callback, handler, 0, SMBF_READ_REPLACE, &handler->bug) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to create input handler media bug\n"); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create input handler media bug"); + } } - /* TODO break up this function by mode... dtmf/voice/fax/etc */ - component->speech_mode = strcmp(iks_find_attrib_soft(input, "mode"), "dtmf"); - if (component->speech_mode && handler->voice_component) { - /* don't allow multi voice input */ - return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple voice input is not allowed"); - } - if (!component->speech_mode && handler->dtmf_component) { - /* don't allow multi dtmf input */ - return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple dtmf input is not allowed"); - } + switch_mutex_lock(handler->mutex); - if (component->speech_mode) { - handler->voice_component = component; - } else { - handler->dtmf_component = component; + if (!handler->dtmf_components) { + /* handler bug was destroyed */ + switch_mutex_unlock(handler->mutex); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Input handler media bug is closed\n"); + RAYO_UNLOCK(component); + RAYO_DESTROY(component); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Input handler media bug is closed\n"); } component->grammar = NULL; @@ -387,123 +603,17 @@ static iks *start_call_input(struct input_component *component, switch_core_sess component->recognizer = iks_find_attrib(input, "recognizer"); component->language = iks_find_attrib(input, "language"); component->handler = handler; + component->speech_mode = strcmp(iks_find_attrib_soft(input, "mode"), "dtmf"); - /* is this voice or dtmf srgs grammar? */ - if (!component->speech_mode) { - - /* parse the grammar */ - if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); - RAYO_UNLOCK(component); - RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); - } - - component->last_digit_time = switch_micro_time_now(); - - /* acknowledge command */ - rayo_component_send_start(RAYO_COMPONENT(component), iq); - - /* start dtmf input detection */ - if (switch_core_media_bug_add(session, "rayo_input_component", NULL, input_component_bug_callback, handler, 0, SMBF_READ_REPLACE, &handler->bug) != SWITCH_STATUS_SUCCESS) { - handler->dtmf_component = NULL; - rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); - } + if (component->speech_mode) { + result = start_call_voice_input(component, session, input, iq, output_file, barge_in); } else { - switch_stream_handle_t grammar = { 0 }; - SWITCH_STANDARD_STREAM(grammar); - - if (zstr(component->recognizer)) { - component->recognizer = globals.default_recognizer; - } - - /* if recognition engine is different, we can't handle this request */ - if (!zstr(handler->last_recognizer) && strcmp(component->recognizer, handler->last_recognizer)) { - handler->voice_component = NULL; - RAYO_UNLOCK(component); - RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Must use the same recognizer for the entire call"); - } - handler->last_recognizer = switch_core_session_strdup(session, component->recognizer); - - if (!strcmp(component->recognizer, "pocketsphinx")) { - const char *jsgf_path; - - /* transform SRGS grammar to JSGF */ - if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n"); - handler->voice_component = NULL; - RAYO_UNLOCK(component); - RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body"); - } - jsgf_path = srgs_grammar_to_jsgf_file(component->grammar, SWITCH_GLOBAL_dirs.grammar_dir, "gram"); - if (!jsgf_path) { - handler->voice_component = NULL; - RAYO_UNLOCK(component); - RAYO_DESTROY(component); - return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Grammar conversion to JSGF error"); - } - - /* build pocketsphinx grammar string */ - grammar.write_function(&grammar, - "{start-input-timers=%s,no-input-timeout=%d,speech-timeout=%d,confidence-threshold=%d}%s", - component->start_timers ? "true" : "false", - component->initial_timeout, - component->max_silence, - (int)ceil(component->min_confidence * 100.0), - jsgf_path); - } else if (!strncmp(component->recognizer, "unimrcp", strlen("unimrcp"))) { - /* send inline grammar to unimrcp */ - grammar.write_function(&grammar, "{start-input-timers=%s,confidence-threshold=%f,sensitivity-level=%f", - component->start_timers ? "true" : "false", - component->min_confidence, - component->sensitivity); - - if (component->initial_timeout > 0) { - grammar.write_function(&grammar, ",no-input-timeout=%d", - component->initial_timeout); - } - - if (component->max_silence > 0) { - grammar.write_function(&grammar, ",speech-complete-timeout=%d,speech-incomplete-timeout=%d", - component->max_silence, - component->max_silence); - } - - if (!zstr(component->language)) { - grammar.write_function(&grammar, ",speech-language=%s", component->language); - } - - if (!strcmp(iks_find_attrib_soft(input, "mode"), "any")) { - /* set dtmf params */ - if (component->inter_digit_timeout > 0) { - grammar.write_function(&grammar, ",dtmf-interdigit-timeout=%d", component->inter_digit_timeout); - } - if (component->term_digit) { - grammar.write_function(&grammar, ",dtmf-term-char=%c", component->term_digit); - } - } - - grammar.write_function(&grammar, "}inline:%s", iks_find_cdata(input, "grammar")); - } else { - /* passthrough to unknown ASR module */ - grammar.write_function(&grammar, "%s", iks_find_cdata(input, "grammar")); - } - - /* acknowledge command */ - rayo_component_send_start(RAYO_COMPONENT(component), iq); - - /* start speech detection */ - switch_channel_set_variable(switch_core_session_get_channel(session), "fire_asr_events", "true"); - if (switch_ivr_detect_speech(session, component->recognizer, grammar.data, "mod_rayo_grammar", "", NULL) != SWITCH_STATUS_SUCCESS) { - handler->voice_component = NULL; - rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); - } - switch_safe_free(grammar.data); + result = start_call_dtmf_input(component, session, input, iq, output_file, barge_in); } - return NULL; + switch_mutex_unlock(handler->mutex); + + return result; } /** @@ -517,6 +627,9 @@ static char *create_input_component_id(switch_core_session_t *session, iks *inpu const char *mode = "unk"; if (input) { mode = iks_find_attrib_soft(input, "mode"); + if (!strcmp(mode, "dtmf")) { + return NULL; + } if (!strcmp(mode, "any")) { mode = "voice"; } @@ -537,17 +650,20 @@ static iks *start_call_input_component(struct rayo_actor *call, struct rayo_mess struct input_component *input_component = NULL; const char *error = NULL; + /* Start CPA */ + if (!strcmp(iks_find_attrib_soft(input, "mode"), "cpa")) { + return rayo_cpa_component_start(call, msg, session_data); + } + + /* start input */ if (!validate_call_input(input, &error)) { return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, error); } - /* create component */ switch_core_new_memory_pool(&pool); input_component = switch_core_alloc(pool, sizeof(*input_component)); rayo_component_init(RAYO_COMPONENT(input_component), pool, RAT_CALL_COMPONENT, "input", component_id, call, iks_find_attrib(iq, "from")); - - /* start input */ - return start_call_input(input_component, session, iks_find(iq, "input"), iq, NULL, 0); + return start_call_input(input_component, session, input, iq, NULL, 0); } /** @@ -562,13 +678,10 @@ static iks *stop_call_input_component(struct rayo_actor *component, struct rayo_ switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); if (session) { switch_mutex_lock(input_component->handler->mutex); + input_component->stop = 1; if (input_component->speech_mode) { - input_component->stop = 1; switch_ivr_stop_detect_speech(session); rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); - } else if (input_component->handler->bug) { - input_component->stop = 1; - switch_core_media_bug_remove(session, &input_component->handler->bug); } switch_mutex_unlock(input_component->handler->mutex); switch_core_session_rwunlock(session); @@ -760,7 +873,7 @@ switch_status_t rayo_input_component_load(switch_loadable_module_interface_t **m rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "input", "set:"RAYO_INPUT_NS":start-timers", start_timers_call_input_component); switch_event_bind("rayo_input_component", SWITCH_EVENT_DETECTED_SPEECH, SWITCH_EVENT_SUBCLASS_ANY, on_detected_speech_event, NULL); - return SWITCH_STATUS_SUCCESS; + return rayo_cpa_component_load(module_interface, pool, config_file); } /** @@ -771,6 +884,9 @@ switch_status_t rayo_input_component_shutdown(void) { srgs_parser_destroy(globals.parser); switch_event_unbind_callback(on_detected_speech_event); + + rayo_cpa_component_shutdown(); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/rayo_output_component.c b/src/mod/event_handlers/mod_rayo/rayo_output_component.c index e092ebd046..5b9ed2eff5 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_output_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_output_component.c @@ -1,6 +1,6 @@ /* * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2013, Grasshopper + * Copyright (C) 2013-2014, Grasshopper * * Version: MPL 1.1 * @@ -37,16 +37,20 @@ struct output_component { struct rayo_component base; /** document to play */ iks *document; + /** where to start playing in document */ + int start_offset_ms; /** maximum time to play */ - int max_time; + int max_time_ms; /** silence between repeats */ - int repeat_interval; + int repeat_interval_ms; /** number of times to repeat */ int repeat_times; /** true if started paused */ switch_bool_t start_paused; /** true if stopped */ int stop; + /** output renderer to use */ + const char *renderer; }; #define OUTPUT_FINISH "finish", RAYO_OUTPUT_COMPLETE_NS @@ -67,10 +71,12 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor, rayo_component_init((struct rayo_component *)output_component, pool, type, "output", NULL, actor, client_jid); output_component->document = iks_copy(output); - output_component->repeat_interval = iks_find_int_attrib(output, "repeat-interval"); + output_component->start_offset_ms = iks_find_int_attrib(output, "start-offset"); + output_component->repeat_interval_ms = iks_find_int_attrib(output, "repeat-interval"); output_component->repeat_times = iks_find_int_attrib(output, "repeat-times"); - output_component->max_time = iks_find_int_attrib(output, "max-time"); + output_component->max_time_ms = iks_find_int_attrib(output, "max-time"); output_component->start_paused = iks_find_bool_attrib(output, "start-paused"); + output_component->renderer = iks_find_attrib(output, "renderer"); return (struct rayo_component *)output_component; } @@ -94,23 +100,30 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess stream.write_function(&stream, "{id=%s,session=%s,pause=%s", RAYO_JID(component), switch_core_session_get_uuid(session), OUTPUT_COMPONENT(component)->start_paused ? "true" : "false"); - if (OUTPUT_COMPONENT(component)->max_time > 0) { - stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time * 1000); + if (OUTPUT_COMPONENT(component)->max_time_ms > 0) { + stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time_ms); + } + if (OUTPUT_COMPONENT(component)->start_offset_ms > 0) { + stream.write_function(&stream, ",start_offset_ms=%i", OUTPUT_COMPONENT(component)->start_offset_ms); } stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component)); if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) { RAYO_UNLOCK(component); } else { - if (OUTPUT_COMPONENT(component)->document) { - iks_delete(OUTPUT_COMPONENT(component)->document); - } - if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) { - rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP); - component = NULL; + if (component->complete) { + /* component is already destroyed */ + RAYO_UNLOCK(component); } else { - rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR); - component = NULL; + /* need to destroy component */ + if (OUTPUT_COMPONENT(component)->document) { + iks_delete(OUTPUT_COMPONENT(component)->document); + } + if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) { + rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP); + } else { + rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR); + } } } switch_safe_free(stream.data); @@ -174,11 +187,17 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m stream.write_function(&stream, "{id=%s,pause=%s", RAYO_JID(component), OUTPUT_COMPONENT(component)->start_paused ? "true" : "false"); - if (OUTPUT_COMPONENT(component)->max_time > 0) { - stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time * 1000); + if (OUTPUT_COMPONENT(component)->max_time_ms > 0) { + stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time_ms); + } + if (OUTPUT_COMPONENT(component)->start_offset_ms > 0) { + stream.write_function(&stream, ",start_offset_ms=%i", OUTPUT_COMPONENT(component)->start_offset_ms); } stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component)); + /* acknowledge command */ + rayo_component_send_start(component, iq); + rayo_component_api_execute_async(component, "conference", stream.data); switch_safe_free(stream.data); @@ -378,7 +397,7 @@ static switch_status_t next_file(switch_file_handle_t *handle) if (!context->cur_doc) { if (output->repeat_times == 0 || ++context->play_count < output->repeat_times) { /* repeat all document(s) */ - if (!output->repeat_interval) { + if (!output->repeat_interval_ms) { goto top; } } else { @@ -391,7 +410,7 @@ static switch_status_t next_file(switch_file_handle_t *handle) if (!context->cur_doc) { /* play silence between repeats */ switch_safe_free(context->ssml); - context->ssml = switch_mprintf("silence_stream://%i", output->repeat_interval); + context->ssml = switch_mprintf("silence_stream://%i", output->repeat_interval_ms); } else { /* play next document */ iks *speak = NULL; @@ -402,7 +421,13 @@ static switch_status_t next_file(switch_file_handle_t *handle) if (speak) { /* is child node */ char *ssml_str = iks_string(NULL, speak); - context->ssml = switch_mprintf("ssml://%s", ssml_str); + if (zstr(output->renderer)) { + /* FS must parse the SSML */ + context->ssml = switch_mprintf("ssml://%s", ssml_str); + } else { + /* renderer will parse the SSML */ + context->ssml = switch_mprintf("tts://%s||%s", output->renderer, ssml_str); + } iks_free(ssml_str); } else if (iks_has_children(context->cur_doc)) { /* check if is in CDATA */ @@ -415,7 +440,13 @@ static switch_status_t next_file(switch_file_handle_t *handle) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Missing CDATA\n"); return SWITCH_STATUS_FALSE; } - context->ssml = switch_mprintf("ssml://%s", ssml_str); + if (zstr(output->renderer)) { + /* FS must parse the SSML */ + context->ssml = switch_mprintf("ssml://%s", ssml_str); + } else { + /* renderer will parse the SSML */ + context->ssml = switch_mprintf("tts://%s||%s", output->renderer, ssml_str); + } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Missing \n"); return SWITCH_STATUS_FALSE; @@ -494,9 +525,26 @@ static switch_status_t rayo_file_close(switch_file_handle_t *handle) if (output->stop) { rayo_component_send_complete(context->component, COMPONENT_COMPLETE_STOP); } else { - rayo_component_send_complete(context->component, OUTPUT_FINISH); + if (!strcmp(RAYO_ACTOR(context->component)->type, RAT_CALL_COMPONENT)) { + /* call output... check for hangup */ + switch_core_session_t *session = switch_core_session_locate(context->component->parent->id); + if (session) { + if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) { + rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP); + } else { + rayo_component_send_complete(context->component, OUTPUT_FINISH); + } + switch_core_session_rwunlock(session); + } else { + /* session is gone */ + rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP); + } + } else { + /* mixer output... finished */ + rayo_component_send_complete(context->component, OUTPUT_FINISH); + } } - /* TODO hangup / timed out */ + /* TODO timed out */ /* cleanup internals */ switch_safe_free(context->ssml); @@ -606,6 +654,7 @@ struct fileman_file_context { */ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const char *path) { + int start_offset_ms = 0; switch_status_t status = SWITCH_STATUS_FALSE; struct fileman_file_context *context = switch_core_alloc(handle->memory_pool, sizeof(*context)); handle->private_info = context; @@ -613,12 +662,19 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha if (handle->params) { const char *id = switch_event_get_header(handle->params, "id"); const char *uuid = switch_event_get_header(handle->params, "session"); + const char *start_offset_ms_str = switch_event_get_header(handle->params, "start_offset_ms"); if (!zstr(id)) { context->id = switch_core_strdup(handle->memory_pool, id); } if (!zstr(uuid)) { context->uuid = switch_core_strdup(handle->memory_pool, uuid); } + if (!zstr(start_offset_ms_str) && switch_is_number(start_offset_ms_str)) { + start_offset_ms = atoi(start_offset_ms_str); + if (start_offset_ms < 0) { + start_offset_ms = 0; + } + } } switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "Got path %s\n", path); @@ -669,6 +725,13 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha switch_set_flag(handle, SWITCH_FILE_PAUSE); } + if (handle->seekable && start_offset_ms) { + unsigned int pos = 0; + int32_t target = start_offset_ms * (handle->samplerate / 1000); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "seek to position %d\n", target); + switch_core_file_seek(&context->fh, &pos, target, SEEK_SET); + } + return status; } @@ -937,6 +1000,7 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t } if (fhp) { + struct fileman_file_context *context = (struct fileman_file_context *)fhp->private_info; if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) { return SWITCH_STATUS_FALSE; } @@ -1033,12 +1097,12 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t target = 0; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "seek to position %d\n", target); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "seek to position %d\n", target); switch_core_file_seek(fhp, &pos, target, SEEK_SET); } else { samps = switch_atoui(p) * (fhp->samplerate / 1000); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "seek to position %d\n", samps); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "seek to position %d\n", samps); switch_core_file_seek(fhp, &pos, samps, SEEK_SET); } } diff --git a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c index 7bb530fe3f..654f574728 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c @@ -64,6 +64,7 @@ struct prompt_component { iks *complete; const char *input_jid; const char *output_jid; + const char *start_timers_request_id; }; #define PROMPT_COMPONENT(x) ((struct prompt_component *)x) @@ -86,6 +87,20 @@ static const char *prompt_component_state_to_string(enum prompt_component_state return "UNKNOWN"; } +/** + * Send input-timers-started event + */ +void rayo_component_send_input_timers_started_event(struct rayo_component *component) +{ + iks *event = iks_new("presence"); + iks *x; + iks_insert_attrib(event, "from", RAYO_JID(component)); + iks_insert_attrib(event, "to", component->client_jid); + x = iks_insert(event, "input-timers-started"); + iks_insert_attrib(x, "xmlns", RAYO_PROMPT_NS); + RAYO_SEND_REPLY(component, component->client_jid, event); +} + /** * Send stop to component */ @@ -131,7 +146,8 @@ static void start_input_timers(struct prompt_component *prompt) iks_insert_attrib(iq, "from", RAYO_JID(prompt)); iks_insert_attrib(iq, "to", prompt->input_jid); iks_insert_attrib(iq, "type", "set"); - iks_insert_attrib_printf(iq, "id", "mod_rayo-prompt-%d", RAYO_SEQ_NEXT(prompt)); + prompt->start_timers_request_id = switch_core_sprintf(RAYO_POOL(prompt), "mod_rayo-prompt-%d", RAYO_SEQ_NEXT(prompt)); + iks_insert_attrib(iq, "id", prompt->start_timers_request_id); x = iks_insert(iq, "start-timers"); iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS); RAYO_SEND_MESSAGE(prompt, prompt->input_jid, iq); @@ -186,20 +202,19 @@ static iks *prompt_component_handle_input_start(struct rayo_actor *prompt, struc case PCS_START_INPUT: PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid); PROMPT_COMPONENT(prompt)->state = PCS_INPUT; + rayo_component_send_input_timers_started_event(RAYO_COMPONENT(prompt)); break; case PCS_START_INPUT_OUTPUT: PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid); PROMPT_COMPONENT(prompt)->state = PCS_INPUT_OUTPUT; /* send ref to client */ rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq); - iks_delete(PROMPT_COMPONENT(prompt)->iq); break; case PCS_START_INPUT_TIMERS: PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid); PROMPT_COMPONENT(prompt)->state = PCS_INPUT; /* send ref to client */ rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq); - iks_delete(PROMPT_COMPONENT(prompt)->iq); start_input_timers(PROMPT_COMPONENT(prompt)); break; case PCS_DONE: @@ -237,7 +252,7 @@ static iks *prompt_component_handle_io_start(struct rayo_actor *prompt, struct r } /** - * Handle barge event + * Handle failure to start timers */ static iks *prompt_component_handle_input_start_timers_error(struct rayo_actor *prompt, struct rayo_message *msg, void *data) { @@ -261,17 +276,38 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struc switch (PROMPT_COMPONENT(prompt)->state) { case PCS_START_INPUT_TIMERS: - case PCS_START_INPUT: - /* send error to client */ - PROMPT_COMPONENT(prompt)-> state = PCS_DONE; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, error: %s\n", RAYO_JID(prompt), iks_string(iks_stack(iq), iq)); + PROMPT_COMPONENT(prompt)->state = PCS_DONE; + + /* forward IQ error to client */ + iq = PROMPT_COMPONENT(prompt)->iq; + iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent)); + iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); + iks_insert_node(iq, iks_copy_within(error, iks_stack(iq))); + RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq); + + /* done */ iks_delete(PROMPT_COMPONENT(prompt)->iq); - rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR); + RAYO_UNLOCK(prompt); + RAYO_DESTROY(prompt); + break; + + case PCS_START_INPUT: + PROMPT_COMPONENT(prompt)->state = PCS_DONE; + iks_delete(PROMPT_COMPONENT(prompt)->iq); + if (iks_find(error, "item-not-found")) { + /* call is gone (hangup) */ + rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_HANGUP); + } else { + /* send presence error to client */ + rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR); + } break; case PCS_START_INPUT_OUTPUT: PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT; - /* forward error to client */ + /* forward IQ error to client */ iq = PROMPT_COMPONENT(prompt)->iq; iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent)); iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); @@ -312,7 +348,7 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *prompt, stru switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, error: %s\n", RAYO_JID(prompt), iks_string(iks_stack(iq), iq)); PROMPT_COMPONENT(prompt)->state = PCS_DONE; - /* forward error to client */ + /* forward IQ error to client */ iq = PROMPT_COMPONENT(prompt)->iq; iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent)); iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); @@ -320,6 +356,7 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *prompt, stru RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq); /* done */ + iks_delete(PROMPT_COMPONENT(prompt)->iq); RAYO_UNLOCK(prompt); RAYO_DESTROY(prompt); @@ -406,6 +443,7 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *prompt, st presence = iks_copy(presence); iks_insert_attrib(presence, "from", RAYO_JID(prompt)); iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid); + iks_delete(PROMPT_COMPONENT(prompt)->iq); rayo_component_send_complete_event(RAYO_COMPONENT(prompt), presence); break; case PCS_OUTPUT: @@ -430,11 +468,15 @@ static iks *prompt_component_handle_result(struct rayo_actor *prompt, struct ray iks *iq = msg->payload; /* forward all results, except for internal ones... */ - if (strncmp("mod_rayo-prompt", iks_find_attrib_soft(iq, "id"), 15)) { + const char *id = iks_find_attrib_soft(iq, "id"); + if (strncmp("mod_rayo-prompt", id, 15)) { iks_insert_attrib(iq, "from", RAYO_JID(prompt)); iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); RAYO_SEND_REPLY_DUP(prompt, RAYO_COMPONENT(prompt)->client_jid, iq); + } else if (!zstr(PROMPT_COMPONENT(prompt)->start_timers_request_id) && !strcmp(PROMPT_COMPONENT(prompt)->start_timers_request_id, id)) { + rayo_component_send_input_timers_started_event(RAYO_COMPONENT(prompt)); } + return NULL; } @@ -451,7 +493,6 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *prompt, s PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT; /* start input with timers enabled and barge events disabled */ start_input(PROMPT_COMPONENT(prompt), 1, 0); - iks_delete(PROMPT_COMPONENT(prompt)->iq); break; case PCS_START_INPUT_OUTPUT: /* output finished before input started */ @@ -467,6 +508,7 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *prompt, s break; case PCS_DONE_STOP_OUTPUT: if (PROMPT_COMPONENT(prompt)->complete) { + iks_delete(PROMPT_COMPONENT(prompt)->iq); rayo_component_send_complete_event(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->complete); } break; diff --git a/src/mod/event_handlers/mod_rayo/rayo_record_component.c b/src/mod/event_handlers/mod_rayo/rayo_record_component.c index f6b4db06aa..03b0ca40db 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_record_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_record_component.c @@ -122,8 +122,6 @@ static void complete_record(struct rayo_component *component, const char *reason iks_insert_attrib_printf(recording, "size", "%"SWITCH_SIZE_T_FMT, file_size); rayo_component_send_complete_with_metadata(component, reason, reason_namespace, recording, 1); iks_delete(recording); - - RAYO_UNLOCK(component); } /** @@ -143,6 +141,7 @@ static void on_call_record_stop_event(switch_event_t *event) /* TODO assume final timeout, for now */ complete_record(component, RECORD_COMPLETE_FINAL_TIMEOUT); } + RAYO_UNLOCK(component); } } @@ -366,6 +365,7 @@ static void on_mixer_record_event(switch_event_t *event) complete_record(component, RECORD_COMPLETE_FINAL_TIMEOUT); } } + RAYO_UNLOCK(component); } } diff --git a/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB b/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB index 82fdf4bbed..905b01af03 100644 --- a/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB +++ b/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB @@ -1,6 +1,6 @@ -- FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application --- Copyright (C) 2005-2012, Anthony Minessale II +-- Copyright (C) 2005-2014, Anthony Minessale II -- -- Version: MPL 1.1 -- diff --git a/src/mod/event_handlers/mod_snmp/mod_snmp.c b/src/mod/event_handlers/mod_snmp/mod_snmp.c index bf262b4977..e0dbe7caba 100644 --- a/src/mod/event_handlers/mod_snmp/mod_snmp.c +++ b/src/mod/event_handlers/mod_snmp/mod_snmp.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_snmp/subagent.c b/src/mod/event_handlers/mod_snmp/subagent.c index e5921b7381..5db0713150 100644 --- a/src/mod/event_handlers/mod_snmp/subagent.c +++ b/src/mod/event_handlers/mod_snmp/subagent.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -31,7 +31,6 @@ * */ #include -#include #include #include @@ -175,7 +174,7 @@ int handle_identity(netsnmp_mib_handler *handler, netsnmp_handler_registration * { netsnmp_request_info *request = NULL; oid subid; - static char const version[] = SWITCH_VERSION_FULL; + const char *version = switch_version_full(); char uuid[40] = ""; switch(reqinfo->mode) { diff --git a/src/mod/event_handlers/mod_snmp/subagent.h b/src/mod/event_handlers/mod_snmp/subagent.h index 2b7974fd86..fe564cbf46 100644 --- a/src/mod/event_handlers/mod_snmp/subagent.h +++ b/src/mod/event_handlers/mod_snmp/subagent.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index 6d91f9b653..6b72cb3f16 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -216,7 +216,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void continue; } - if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, temp_pool) != SWITCH_STATUS_SUCCESS) { + if (switch_core_timer_init(&timer, source->timer_name, source->interval, (int)source->samples, temp_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n"); switch_dir_close(source->dir_handle); source->dir_handle = NULL; @@ -233,7 +233,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void if (source->chime_total) { if (source->chime_counter > 0) { - source->chime_counter -= source->samples; + source->chime_counter -= (int32_t)source->samples; } if (!switch_test_flag((&source->chime_fh), SWITCH_FILE_OPEN) && source->chime_counter <= 0) { @@ -272,7 +272,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void source->chime_counter = source->rate * source->chime_freq; use_fh = &fh; goto retry; - switch_core_file_close(&fh); + //switch_core_file_close(&fh); } } } @@ -288,7 +288,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void is_open = 0; } else { if (use_fh == &source->chime_fh && source->chime_max) { - source->chime_max_counter += source->samples; + source->chime_max_counter += (int32_t)source->samples; if (source->chime_max_counter >= source->chime_max) { source->chime_max_counter = 0; switch_core_file_close(use_fh); @@ -311,16 +311,17 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void if (!is_open || used >= source->prebuf || (source->total && used > source->samples * 2)) { used = switch_buffer_read(audio_buffer, dist_buf, source->samples * 2); if (source->total) { - + uint32_t bused = 0; switch_mutex_lock(source->mutex); for (cp = source->context_list; cp && RUNNING; cp = cp->next) { if (switch_test_flag(cp->handle, SWITCH_FILE_CALLBACK)) { continue; } switch_mutex_lock(cp->audio_mutex); - if (switch_buffer_inuse(cp->audio_buffer) > source->samples * 768) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Leaking stream handle! [%s() %s:%d]\n", cp->func, cp->file, - cp->line); + bused = (uint32_t)switch_buffer_inuse(cp->audio_buffer); + if (bused > source->samples * 768) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Flushing Stream Handle Buffer [%s() %s:%d] size: %u samples: %ld\n", + cp->func, cp->file, cp->line, bused, (long)source->samples); switch_buffer_zero(cp->audio_buffer); } else { switch_buffer_write(cp->audio_buffer, dist_buf, used); diff --git a/src/mod/formats/mod_native_file/mod_native_file.c b/src/mod/formats/mod_native_file/mod_native_file.c index 22907c111b..b875e82c22 100644 --- a/src/mod/formats/mod_native_file/mod_native_file.c +++ b/src/mod/formats/mod_native_file/mod_native_file.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c b/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c index 1a0a0f228d..b5c8c5d878 100644 --- a/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c +++ b/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/formats/mod_shell_stream/mod_shell_stream.c b/src/mod/formats/mod_shell_stream/mod_shell_stream.c index 25b3717489..4c41e2e63a 100644 --- a/src/mod/formats/mod_shell_stream/mod_shell_stream.c +++ b/src/mod/formats/mod_shell_stream/mod_shell_stream.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -47,6 +47,7 @@ struct shell_stream_context { switch_mutex_t *mutex; switch_thread_rwlock_t *rwlock; int running; + switch_thread_t *thread; }; typedef struct shell_stream_context shell_stream_context_t; @@ -91,7 +92,6 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons { shell_stream_context_t *context; switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { @@ -127,9 +127,8 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool); switch_threadattr_create(&thd_attr, handle->memory_pool); - switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&thread, thd_attr, buffer_thread_run, context, handle->memory_pool); + switch_thread_create(&context->thread, thd_attr, buffer_thread_run, context, handle->memory_pool); context->running = 2; while (context->running == 2) { @@ -164,6 +163,7 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons static switch_status_t shell_stream_file_close(switch_file_handle_t *handle) { shell_stream_context_t *context = handle->private_info; + switch_status_t st; context->running = 0; @@ -171,6 +171,10 @@ static switch_status_t shell_stream_file_close(switch_file_handle_t *handle) close(context->fds[0]); } + if (context->thread) { + switch_thread_join(&st, context->thread); + } + if (context->audio_buffer) { switch_buffer_destroy(&context->audio_buffer); } diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 0b64ba7e5b..b05e4b393e 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -138,7 +138,7 @@ static void decode_fd(shout_context_t *context, void *data, size_t bytes); static inline void free_context(shout_context_t *context) { - int ret; + size_t ret; if (context) { switch_mutex_lock(context->audio_mutex); @@ -370,8 +370,9 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data) shout_context_t *context = data; int decode_status = 0; size_t usedlen; - uint32_t used, buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after + uint32_t buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after first 64k buffer is dry */ + switch_size_t used; if (context->prebuf) { buf_size = context->prebuf; @@ -553,13 +554,13 @@ static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t *thread, voi r[i] = audio[j++]; } - if ((rlen = lame_encode_buffer(context->gfp, l, r, audio_read / 4, mp3buf, sizeof(mp3buf))) < 0) { + if ((rlen = lame_encode_buffer(context->gfp, l, r, (int)(audio_read / 4), mp3buf, sizeof(mp3buf))) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); goto error; } } else if (context->channels == 1) { - if ((rlen = lame_encode_buffer(context->gfp, (void *) audio, NULL, audio_read / sizeof(int16_t), mp3buf, sizeof(mp3buf))) < 0) { + if ((rlen = lame_encode_buffer(context->gfp, (void *) audio, NULL, (int)(audio_read / sizeof(int16_t)), mp3buf, sizeof(mp3buf))) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); goto error; } @@ -653,7 +654,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char if (mpg123_format_all(context->mh) != MPG123_OK) { MPGERROR(); } - if (mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0) != MPG123_OK) { + if (mpg123_param(context->mh, MPG123_FORCE_RATE, (long)context->samplerate, 0) != MPG123_OK) { MPGERROR(); } @@ -1017,13 +1018,13 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data context->r[i] = audio[j++]; } - if ((rlen = lame_encode_buffer(context->gfp, context->l, context->r, nsamples, context->mp3buf, context->mp3buflen)) < 0) { + if ((rlen = lame_encode_buffer(context->gfp, context->l, context->r, (int)nsamples, context->mp3buf, (int)context->mp3buflen)) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); return SWITCH_STATUS_FALSE; } } else if (handle->channels == 1) { - if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, nsamples, context->mp3buf, context->mp3buflen)) < 0) { + if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, (int)nsamples, context->mp3buf, (int)context->mp3buflen)) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); return SWITCH_STATUS_FALSE; } @@ -1032,7 +1033,7 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data } if (rlen) { - int ret = fwrite(context->mp3buf, 1, rlen, context->fp); + int ret = (int)fwrite(context->mp3buf, 1, rlen, context->fp); if (ret < 0) { return SWITCH_STATUS_FALSE; } @@ -1268,7 +1269,7 @@ void do_telecast(switch_stream_handle_t *stream) memset(buf, 0, bytes); } - if ((rlen = lame_encode_buffer(gfp, (void *) buf, NULL, bytes / 2, mp3buf, sizeof(mp3buf))) < 0) { + if ((rlen = lame_encode_buffer(gfp, (void *) buf, NULL, (int)(bytes / 2), mp3buf, sizeof(mp3buf))) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); goto end; } @@ -1370,7 +1371,7 @@ void do_broadcast(switch_stream_handle_t *stream) break; } - if ((rlen = lame_encode_buffer(gfp, (void *) buf, NULL, samples, mp3buf, sizeof(mp3buf))) < 0) { + if ((rlen = lame_encode_buffer(gfp, (void *) buf, NULL, (int)samples, mp3buf, sizeof(mp3buf))) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); goto end; } diff --git a/src/mod/formats/mod_sndfile/mod_sndfile.c b/src/mod/formats/mod_sndfile/mod_sndfile.c index 27831c9c6f..6043115555 100644 --- a/src/mod/formats/mod_sndfile/mod_sndfile.c +++ b/src/mod/formats/mod_sndfile/mod_sndfile.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/formats/mod_ssml/mod_ssml.c b/src/mod/formats/mod_ssml/mod_ssml.c index 8b172721c7..ae2670a74c 100644 --- a/src/mod/formats/mod_ssml/mod_ssml.c +++ b/src/mod/formats/mod_ssml/mod_ssml.c @@ -259,17 +259,6 @@ static int process_tag(struct ssml_parser *parser, const char *name, char **atts return IKS_BADXML; } -/** - * Handle tag attributes that are ignored - * @param parser the parser - * @param atts the attributes - * @return IKS_OK - */ -static int process_attribs_ignore(struct ssml_parser *parser, char **atts) -{ - return IKS_OK; -} - /** * Handle CDATA that is ignored * @param parser the parser @@ -395,6 +384,19 @@ static struct voice *find_say_voice(struct ssml_node *cur_node) return find_voice(cur_node, globals.say_voice_map, "say", 1); } +/** + * Handle tag attributes that are ignored + * @param parser the parser + * @param atts the attributes + * @return IKS_OK + */ +static int process_attribs_ignore(struct ssml_parser *parsed_data, char **atts) +{ + struct ssml_node *cur_node = parsed_data->cur_node; + cur_node->tts_voice = find_tts_voice(cur_node); + return IKS_OK; +} + /** * open next file for reading * @param handle the file handle diff --git a/src/mod/formats/mod_tone_stream/mod_tone_stream.2012.vcxproj b/src/mod/formats/mod_tone_stream/mod_tone_stream.2012.vcxproj index 6084cb23f9..8e00439833 100644 --- a/src/mod/formats/mod_tone_stream/mod_tone_stream.2012.vcxproj +++ b/src/mod/formats/mod_tone_stream/mod_tone_stream.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -72,6 +72,7 @@ + /analyze:stacksize32768 false @@ -86,6 +87,7 @@ + /analyze:stacksize32768 false @@ -98,6 +100,8 @@ + + false @@ -112,6 +116,8 @@ + + false diff --git a/src/mod/formats/mod_tone_stream/mod_tone_stream.c b/src/mod/formats/mod_tone_stream/mod_tone_stream.c index 2aafff129f..9005f5ee8b 100644 --- a/src/mod/formats/mod_tone_stream/mod_tone_stream.c +++ b/src/mod/formats/mod_tone_stream/mod_tone_stream.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -90,11 +90,11 @@ static switch_status_t silence_stream_file_read(switch_file_handle_t *handle, vo *len = sh->samples; } - sh->samples -= *len; + sh->samples -= (int32_t)*len; } if (sh->silence) { - switch_generate_sln_silence((int16_t *) data, *len, sh->silence); + switch_generate_sln_silence((int16_t *) data, (uint32_t)*len, sh->silence); } else { memset(data, 0, *len * 2); } diff --git a/src/mod/formats/mod_vlc/mod_vlc.c b/src/mod/formats/mod_vlc/mod_vlc.c index fe0aeb71f0..24488f8899 100644 --- a/src/mod/formats/mod_vlc/mod_vlc.c +++ b/src/mod/formats/mod_vlc/mod_vlc.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -398,6 +398,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vlc_load) /* load the vlc engine. */ read_inst = libvlc_new(1, &vlc_args); + if ( ! read_inst ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "FAILED TO LOAD\n"); + return SWITCH_STATUS_GENERR; + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initialized VLC instance\n"); /* indicate that the module should continue to be loaded */ diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index 76de068715..fee7726382 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -3169,7 +3169,7 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_msleep(JNIEnv *je (void)jenv; (void)jcls; arg1 = (unsigned int)jarg1; - msleep(arg1); + switch_msleep(arg1); } diff --git a/src/mod/languages/mod_lua/freeswitch.i b/src/mod/languages/mod_lua/freeswitch.i index 6fca226001..e61cad315b 100644 --- a/src/mod/languages/mod_lua/freeswitch.i +++ b/src/mod/languages/mod_lua/freeswitch.i @@ -19,6 +19,8 @@ %} + + /* Lua function typemap */ %typemap(in, checkfn = "lua_isfunction") SWIGLUA_FN { $1.L = L; diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 34edfaea93..12a663c3a7 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -4,7 +4,7 @@ using namespace LUA; extern "C" { - int docall(lua_State * L, int narg, int nresults, int perror); + int docall(lua_State * L, int narg, int nresults, int perror, int fatal); }; Session::Session():CoreSession() @@ -81,7 +81,7 @@ void Session::setLUA(lua_State * state) if (session && allocated && uuid) { lua_setglobal(L, uuid); - lua_getfield(L, LUA_GLOBALSINDEX, uuid); + lua_getglobal(L, uuid); } } @@ -137,17 +137,17 @@ void Session::do_hangup_hook() return; } - lua_getfield(L, LUA_GLOBALSINDEX, (char *) hangup_func_str); - lua_getfield(L, LUA_GLOBALSINDEX, uuid); + lua_getglobal(L, (char *) hangup_func_str); + lua_getglobal(L, uuid); lua_pushstring(L, hook_state == CS_HANGUP ? "hangup" : "transfer"); if (hangup_func_arg) { - lua_getfield(L, LUA_GLOBALSINDEX, (char *) hangup_func_arg); + lua_getglobal(L, (char *) hangup_func_arg); arg_count++; } - docall(L, arg_count, 1, 1); + docall(L, arg_count, 1, 1, 0); const char *err = lua_tostring(L, -1); @@ -273,9 +273,10 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp switch_dtmf_t *dtmf = (switch_dtmf_t *) input; char str[3] = ""; int arg_count = 3; + int r; - lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_function); - lua_getfield(L, LUA_GLOBALSINDEX, uuid); + lua_getglobal(L, (char *) cb_function); + lua_getglobal(L, uuid); lua_pushstring(L, "dtmf"); @@ -290,14 +291,18 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp lua_rawset(L, -3); if (!zstr(cb_arg)) { - lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_arg); + lua_getglobal(L, (char *) cb_arg); arg_count++; } - docall(L, arg_count, 1, 1); + r = docall(L, arg_count, 1, 1, 0); - ret = lua_tostring(L, -1); - lua_pop(L, 1); + if (!r) { + ret = lua_tostring(L, -1); + lua_pop(L, 1); + } else { + ret = "SCRIPT_ERROR"; + } return process_callback_result((char *) ret); } @@ -308,20 +313,23 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp int arg_count = 3; - lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_function); - lua_getfield(L, LUA_GLOBALSINDEX, uuid); + lua_getglobal(L, (char *) cb_function); + lua_getglobal(L, uuid); lua_pushstring(L, "event"); mod_lua_conjure_event(L, event, "__Input_Event__", 1); - lua_getfield(L, LUA_GLOBALSINDEX, "__Input_Event__"); + lua_getglobal(L, "__Input_Event__"); if (!zstr(cb_arg)) { - lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_arg); + lua_getglobal(L, (char *) cb_arg); arg_count++; } - docall(L, arg_count, 1, 1); - ret = lua_tostring(L, -1); - lua_pop(L, 1); + if (!docall(L, arg_count, 1, 1, 0)) { + ret = lua_tostring(L, -1); + lua_pop(L, 1); + } else { + ret = "SCRIPT_ERROR"; + } return process_callback_result((char *) ret); } @@ -407,14 +415,17 @@ int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv) lua_settable(lua_fun->L, -3); } - docall(lua_fun->L, 1, 1, 1); - ret = lua_tonumber(lua_fun->L, -1); - lua_pop(lua_fun->L, 1); - - if (ret != 0) { - return 1; - } + if (docall(lua_fun->L, 1, 1, 1, 0)) { + return 1; + } + ret = lua_tonumber(lua_fun->L, -1); + lua_pop(lua_fun->L, 1); + + if (ret != 0) { + return 1; + } + return 0; /* 0 to continue with next row */ } diff --git a/src/mod/languages/mod_lua/hack.diff b/src/mod/languages/mod_lua/hack.diff index fc33ddb9d6..4004459b50 100644 --- a/src/mod/languages/mod_lua/hack.diff +++ b/src/mod/languages/mod_lua/hack.diff @@ -1,38 +1,56 @@ ---- mod_lua_wrap.cpp.orig 2010-09-05 16:39:26.000000000 +0200 -+++ mod_lua_wrap.cpp 2010-09-05 16:39:44.000000000 +0200 -@@ -4913,7 +4913,7 @@ - +--- mod_lua_wrap.cpp.orig 2013-11-13 07:48:40.587304736 +0500 ++++ mod_lua_wrap.cpp 2013-11-13 07:43:09.059309154 +0500 +@@ -6427,7 +6427,7 @@ + SWIG_check_num_args("LUA::Session",0,0) result = (LUA::Session *)new LUA::Session(); SWIG_arg=0; - SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); return SWIG_arg; - fail: -@@ -4934,7 +4934,7 @@ - arg2=(CoreSession *)SWIG_MustGetPtr(L,2,SWIGTYPE_p_CoreSession,0,2,"new_Session"); + if(0) SWIG_fail; +@@ -6455,7 +6455,7 @@ + result = (LUA::Session *)new LUA::Session(arg1,arg2); SWIG_arg=0; - SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); return SWIG_arg; - fail: -@@ -4952,7 +4952,7 @@ - arg1 = (char*)lua_tostring(L, 1); + if(0) SWIG_fail; +@@ -6476,7 +6476,7 @@ + arg1 = (char *)lua_tostring(L, 1); result = (LUA::Session *)new LUA::Session(arg1); SWIG_arg=0; - SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); return SWIG_arg; - fail: -@@ -4970,7 +4970,7 @@ - arg1=(switch_core_session_t *)SWIG_MustGetPtr(L,1,SWIGTYPE_p_switch_core_session_t,0,1,"new_Session"); + if(0) SWIG_fail; +@@ -6501,7 +6501,7 @@ + result = (LUA::Session *)new LUA::Session(arg1); SWIG_arg=0; - SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); return SWIG_arg; - fail: + if(0) SWIG_fail; +@@ -7913,7 +7913,7 @@ + } + #endif + +-static const struct luaL_reg swig_commands[] = { ++static const struct luaL_Reg swig_commands[] = { + { "setGlobalVariable", _wrap_setGlobalVariable}, + { "getGlobalVariable", _wrap_getGlobalVariable}, + { "consoleLog", _wrap_consoleLog}, +@@ -8325,7 +8325,7 @@ + { + int i; + /* start with global table */ +- lua_pushvalue(L,LUA_GLOBALSINDEX); ++ lua_pushglobaltable(L); + /* SWIG's internal initalisation */ + SWIG_InitializeModule((void*)L); + SWIG_PropagateClientData(); diff --git a/src/mod/languages/mod_lua/lua/Makefile b/src/mod/languages/mod_lua/lua/Makefile index e4a3cd6108..fea895bc06 100644 --- a/src/mod/languages/mod_lua/lua/Makefile +++ b/src/mod/languages/mod_lua/lua/Makefile @@ -1,6 +1,5 @@ -# makefile for building Lua -# see ../INSTALL for installation instructions -# see ../Makefile and luaconf.h for further customization +# Makefile for building Lua +# See ../doc/readme.html for installation and customization instructions. # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= @@ -8,37 +7,46 @@ PLAT= none CC= gcc -CFLAGS= -O2 -Wall $(MYCFLAGS) +CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS) +LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) +LIBS= -lm $(SYSLIBS) $(MYLIBS) + AR= ar rcu RANLIB= ranlib RM= rm -f -LIBS= -lm $(MYLIBS) + +SYSCFLAGS= +SYSLDFLAGS= +SYSLIBS= MYCFLAGS= MYLDFLAGS= MYLIBS= +MYOBJS= -# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= +# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris LUA_A= liblua.a -CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ - lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ - lundump.o lvm.o lzio.o -LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ - lstrlib.o loadlib.o linit.o +CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ + lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ + ltm.o lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \ + lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o +BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) LUA_T= lua LUA_O= lua.o LUAC_T= luac -LUAC_O= luac.o print.o +LUAC_O= luac.o -ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ALL_A= $(LUA_A) +# Targets start here. default: $(PLAT) all: $(ALL_T) @@ -47,136 +55,133 @@ o: $(ALL_O) a: $(ALL_A) -$(LUA_A): $(CORE_O) $(LIB_O) - $(AR) $@ $? +$(LUA_A): $(BASE_O) + $(AR) $@ $(BASE_O) $(RANLIB) $@ $(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) $(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) clean: $(RM) $(ALL_T) $(ALL_O) depend: - @$(CC) $(CFLAGS) -MM l*.c print.c + @$(CC) $(CFLAGS) -MM l*.c echo: - @echo "PLAT = $(PLAT)" - @echo "CC = $(CC)" - @echo "CFLAGS = $(CFLAGS)" - @echo "AR = $(AR)" - @echo "RANLIB = $(RANLIB)" - @echo "RM = $(RM)" - @echo "MYCFLAGS = $(MYCFLAGS)" - @echo "MYLDFLAGS = $(MYLDFLAGS)" - @echo "MYLIBS = $(MYLIBS)" + @echo "PLAT= $(PLAT)" + @echo "CC= $(CC)" + @echo "CFLAGS= $(CFLAGS)" + @echo "LDFLAGS= $(SYSLDFLAGS)" + @echo "LIBS= $(LIBS)" + @echo "AR= $(AR)" + @echo "RANLIB= $(RANLIB)" + @echo "RM= $(RM)" -# convenience targets for popular platforms +# Convenience targets for popular platforms +ALL= all none: - @echo "Please choose a platform:" + @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" @echo " $(PLATS)" aix: - $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + $(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall" ansi: - $(MAKE) all MYCFLAGS=-DLUA_ANSI + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_ANSI" bsd: - $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E" freebsd: - $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline" -generic: - $(MAKE) all MYCFLAGS= +generic: $(ALL) linux: - $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" macosx: - $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" -# use this on Mac OS X 10.3- -# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" mingw: - $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + $(MAKE) "LUA_A=lua52.dll" "LUA_T=lua.exe" \ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ - "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe $(MAKE) "LUAC_T=luac.exe" luac.exe posix: - $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" solaris: - $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" # list targets that do not create files (but not all makes understand .PHONY) .PHONY: all $(PLATS) default o a clean depend echo none # DO NOT DELETE -lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ - lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ - lundump.h lvm.h +lapi.o: lapi.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h ltm.h \ + lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h ltable.h lundump.h \ + lvm.h lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ - lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ - ltable.h + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + lstring.h ltable.h lvm.h +lcorolib.o: lcorolib.c lua.h luaconf.h lauxlib.h lualib.h +lctype.o: lctype.c lctype.h lua.h luaconf.h llimits.h ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h -ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ - llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ - lfunc.h lstring.h lgc.h ltable.h lvm.h -ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ - ltable.h lundump.h lvm.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \ + ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h ltm.h \ + lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h \ + lstring.h ltable.h lundump.h lvm.h ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ - lzio.h lmem.h lundump.h -lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ - lstate.h ltm.h lzio.h + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h \ + lstate.h ltm.h lzio.h lmem.h lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h -llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ - lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +llex.o: llex.c lua.h luaconf.h lctype.h llimits.h ldo.h lobject.h \ + lstate.h ltm.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h + ltm.h lzio.h lmem.h ldo.h lgc.h loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h -lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ - ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lobject.o: lobject.c lua.h luaconf.h lctype.h llimits.h ldebug.h lstate.h \ + lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ - lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ - lfunc.h lstring.h lgc.h ltable.h -lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lfunc.h \ + lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \ + ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h lstring.h \ + ltable.h lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ - ltm.h lzio.h lstring.h lgc.h + ltm.h lzio.h lstring.h lgc.h lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h + ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ - lmem.h lstring.h lgc.h ltable.h + lmem.h lstring.h lgc.h ltable.h lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h -luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ - lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ - lundump.h +luac.o: luac.c lua.h luaconf.h lauxlib.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ - llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ - lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ - lzio.h -print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h lopcodes.h lundump.h + lzio.h -# (end of Makefile) diff --git a/src/mod/languages/mod_lua/lua/lapi.c b/src/mod/languages/mod_lua/lua/lapi.c index 5d5145d2eb..791d85454f 100644 --- a/src/mod/languages/mod_lua/lua/lapi.c +++ b/src/mod/languages/mod_lua/lua/lapi.c @@ -1,12 +1,10 @@ /* -** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** $Id: lapi.c,v 2.171 2013/03/16 21:10:18 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ -#include -#include #include #include @@ -32,76 +30,80 @@ const char lua_ident[] = - "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" - "$Authors: " LUA_AUTHORS " $\n" - "$URL: www.lua.org $\n"; + "$LuaVersion: " LUA_COPYRIGHT " $" + "$LuaAuthors: " LUA_AUTHORS " $"; +/* value at a non-valid index */ +#define NONVALIDVALUE cast(TValue *, luaO_nilobject) -#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) +/* corresponding test */ +#define isvalid(o) ((o) != luaO_nilobject) -#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) +/* test for pseudo index */ +#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) -#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} +/* test for valid but not pseudo index */ +#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) + +#define api_checkvalidindex(L, o) api_check(L, isvalid(o), "invalid index") + +#define api_checkstackindex(L, i, o) \ + api_check(L, isstackindex(i, o), "index not in the stack") - -static TValue *index2adr (lua_State *L, int idx) { +static TValue *index2addr (lua_State *L, int idx) { + CallInfo *ci = L->ci; if (idx > 0) { - TValue *o = L->base + (idx - 1); - api_check(L, idx <= L->ci->top - L->base); - if (o >= L->top) return cast(TValue *, luaO_nilobject); + TValue *o = ci->func + idx; + api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index"); + if (o >= L->top) return NONVALIDVALUE; else return o; } - else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx != 0 && -idx <= L->top - L->base); + else if (!ispseudo(idx)) { /* negative index */ + api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); return L->top + idx; } - else switch (idx) { /* pseudo-indices */ - case LUA_REGISTRYINDEX: return registry(L); - case LUA_ENVIRONINDEX: { - Closure *func = curr_func(L); - sethvalue(L, &L->env, func->c.env); - return &L->env; - } - case LUA_GLOBALSINDEX: return gt(L); - default: { - Closure *func = curr_func(L); - idx = LUA_GLOBALSINDEX - idx; - return (idx <= func->c.nupvalues) - ? &func->c.upvalue[idx-1] - : cast(TValue *, luaO_nilobject); + else if (idx == LUA_REGISTRYINDEX) + return &G(L)->l_registry; + else { /* upvalues */ + idx = LUA_REGISTRYINDEX - idx; + api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); + if (ttislcf(ci->func)) /* light C function? */ + return NONVALIDVALUE; /* it has no upvalues */ + else { + CClosure *func = clCvalue(ci->func); + return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE; } } } -static Table *getcurrenv (lua_State *L) { - if (L->ci == L->base_ci) /* no enclosing function? */ - return hvalue(gt(L)); /* use global table as environment */ - else { - Closure *func = curr_func(L); - return func->c.env; - } -} - - -void luaA_pushobject (lua_State *L, const TValue *o) { - setobj2s(L, L->top, o); - api_incr_top(L); +/* +** to be called by 'lua_checkstack' in protected mode, to grow stack +** capturing memory errors +*/ +static void growstack (lua_State *L, void *ud) { + int size = *(int *)ud; + luaD_growstack(L, size); } LUA_API int lua_checkstack (lua_State *L, int size) { - int res = 1; + int res; + CallInfo *ci = L->ci; lua_lock(L); - if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) - res = 0; /* stack overflow */ - else if (size > 0) { - luaD_checkstack(L, size); - if (L->ci->top < L->top + size) - L->ci->top = L->top + size; + if (L->stack_last - L->top > size) /* stack large enough? */ + res = 1; /* yes; check is OK */ + else { /* no; need to grow stack */ + int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; + if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */ + res = 0; /* no */ + else /* try to grow stack */ + res = (luaD_rawrunprotected(L, &growstack, &size) == LUA_OK); } + if (res && ci->top < L->top + size) + ci->top = L->top + size; /* adjust frame top */ lua_unlock(L); return res; } @@ -112,8 +114,8 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { if (from == to) return; lua_lock(to); api_checknelems(from, n); - api_check(from, G(from) == G(to)); - api_check(from, to->ci->top - to->top >= n); + api_check(from, G(from) == G(to), "moving among independent states"); + api_check(from, to->ci->top - to->top >= n, "not enough elements to move"); from->top -= n; for (i = 0; i < n; i++) { setobj2s(to, to->top++, from->top + i); @@ -122,11 +124,6 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { } -LUA_API void lua_setlevel (lua_State *from, lua_State *to) { - to->nCcalls = from->nCcalls; -} - - LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { lua_CFunction old; lua_lock(L); @@ -137,16 +134,10 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { } -LUA_API lua_State *lua_newthread (lua_State *L) { - lua_State *L1; - lua_lock(L); - luaC_checkGC(L); - L1 = luaE_newthread(L); - setthvalue(L, L->top, L1); - api_incr_top(L); - lua_unlock(L); - luai_userstatethread(L, L1); - return L1; +LUA_API const lua_Number *lua_version (lua_State *L) { + static const lua_Number version = LUA_VERSION_NUM; + if (L == NULL) return &version; + else return G(L)->version; } @@ -156,21 +147,32 @@ LUA_API lua_State *lua_newthread (lua_State *L) { */ +/* +** convert an acceptable stack index into an absolute index +*/ +LUA_API int lua_absindex (lua_State *L, int idx) { + return (idx > 0 || ispseudo(idx)) + ? idx + : cast_int(L->top - L->ci->func + idx); +} + + LUA_API int lua_gettop (lua_State *L) { - return cast_int(L->top - L->base); + return cast_int(L->top - (L->ci->func + 1)); } LUA_API void lua_settop (lua_State *L, int idx) { + StkId func = L->ci->func; lua_lock(L); if (idx >= 0) { - api_check(L, idx <= L->stack_last - L->base); - while (L->top < L->base + idx) + api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); + while (L->top < (func + 1) + idx) setnilvalue(L->top++); - L->top = L->base + idx; + L->top = (func + 1) + idx; } else { - api_check(L, -(idx+1) <= (L->top - L->base)); + api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); L->top += idx+1; /* `subtract' index (index is negative) */ } lua_unlock(L); @@ -180,8 +182,8 @@ LUA_API void lua_settop (lua_State *L, int idx) { LUA_API void lua_remove (lua_State *L, int idx) { StkId p; lua_lock(L); - p = index2adr(L, idx); - api_checkvalidindex(L, p); + p = index2addr(L, idx); + api_checkstackindex(L, idx, p); while (++p < L->top) setobjs2s(L, p-1, p); L->top--; lua_unlock(L); @@ -192,42 +194,47 @@ LUA_API void lua_insert (lua_State *L, int idx) { StkId p; StkId q; lua_lock(L); - p = index2adr(L, idx); - api_checkvalidindex(L, p); - for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + p = index2addr(L, idx); + api_checkstackindex(L, idx, p); + for (q = L->top; q > p; q--) /* use L->top as a temporary */ + setobjs2s(L, q, q - 1); setobjs2s(L, p, L->top); lua_unlock(L); } +static void moveto (lua_State *L, TValue *fr, int idx) { + TValue *to = index2addr(L, idx); + api_checkvalidindex(L, to); + setobj(L, to, fr); + if (idx < LUA_REGISTRYINDEX) /* function upvalue? */ + luaC_barrier(L, clCvalue(L->ci->func), fr); + /* LUA_REGISTRYINDEX does not need gc barrier + (collector revisits it before finishing collection) */ +} + + LUA_API void lua_replace (lua_State *L, int idx) { - StkId o; lua_lock(L); - /* explicit test for incompatible code */ - if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) - luaG_runerror(L, "no calling environment"); api_checknelems(L, 1); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - if (idx == LUA_ENVIRONINDEX) { - Closure *func = curr_func(L); - api_check(L, ttistable(L->top - 1)); - func->c.env = hvalue(L->top - 1); - luaC_barrier(L, func, L->top - 1); - } - else { - setobj(L, o, L->top - 1); - if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ - luaC_barrier(L, curr_func(L), L->top - 1); - } + moveto(L, L->top - 1, idx); L->top--; lua_unlock(L); } +LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { + TValue *fr; + lua_lock(L); + fr = index2addr(L, fromidx); + moveto(L, fr, toidx); + lua_unlock(L); +} + + LUA_API void lua_pushvalue (lua_State *L, int idx) { lua_lock(L); - setobj2s(L, L->top, index2adr(L, idx)); + setobj2s(L, L->top, index2addr(L, idx)); api_incr_top(L); lua_unlock(L); } @@ -240,26 +247,26 @@ LUA_API void lua_pushvalue (lua_State *L, int idx) { LUA_API int lua_type (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); + StkId o = index2addr(L, idx); + return (isvalid(o) ? ttypenv(o) : LUA_TNONE); } LUA_API const char *lua_typename (lua_State *L, int t) { UNUSED(L); - return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; + return ttypename(t); } LUA_API int lua_iscfunction (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return iscfunction(o); + StkId o = index2addr(L, idx); + return (ttislcf(o) || (ttisCclosure(o))); } LUA_API int lua_isnumber (lua_State *L, int idx) { TValue n; - const TValue *o = index2adr(L, idx); + const TValue *o = index2addr(L, idx); return tonumber(o, &n); } @@ -271,77 +278,116 @@ LUA_API int lua_isstring (lua_State *L, int idx) { LUA_API int lua_isuserdata (lua_State *L, int idx) { - const TValue *o = index2adr(L, idx); + const TValue *o = index2addr(L, idx); return (ttisuserdata(o) || ttislightuserdata(o)); } LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { - StkId o1 = index2adr(L, index1); - StkId o2 = index2adr(L, index2); - return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 - : luaO_rawequalObj(o1, o2); + StkId o1 = index2addr(L, index1); + StkId o2 = index2addr(L, index2); + return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0; } -LUA_API int lua_equal (lua_State *L, int index1, int index2) { - StkId o1, o2; - int i; - lua_lock(L); /* may call tag method */ - o1 = index2adr(L, index1); - o2 = index2adr(L, index2); - i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); - lua_unlock(L); - return i; -} - - -LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { - StkId o1, o2; - int i; - lua_lock(L); /* may call tag method */ - o1 = index2adr(L, index1); - o2 = index2adr(L, index2); - i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 - : luaV_lessthan(L, o1, o2); - lua_unlock(L); - return i; -} - - - -LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { - TValue n; - const TValue *o = index2adr(L, idx); - if (tonumber(o, &n)) - return nvalue(o); +LUA_API void lua_arith (lua_State *L, int op) { + StkId o1; /* 1st operand */ + StkId o2; /* 2nd operand */ + lua_lock(L); + if (op != LUA_OPUNM) /* all other operations expect two operands */ + api_checknelems(L, 2); + else { /* for unary minus, add fake 2nd operand */ + api_checknelems(L, 1); + setobjs2s(L, L->top, L->top - 1); + L->top++; + } + o1 = L->top - 2; + o2 = L->top - 1; + if (ttisnumber(o1) && ttisnumber(o2)) { + setnvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2))); + } else - return 0; + luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD)); + L->top--; + lua_unlock(L); } -LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { +LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { + StkId o1, o2; + int i = 0; + lua_lock(L); /* may call tag method */ + o1 = index2addr(L, index1); + o2 = index2addr(L, index2); + if (isvalid(o1) && isvalid(o2)) { + switch (op) { + case LUA_OPEQ: i = equalobj(L, o1, o2); break; + case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; + case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; + default: api_check(L, 0, "invalid option"); + } + } + lua_unlock(L); + return i; +} + + +LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum) { TValue n; - const TValue *o = index2adr(L, idx); + const TValue *o = index2addr(L, idx); + if (tonumber(o, &n)) { + if (isnum) *isnum = 1; + return nvalue(o); + } + else { + if (isnum) *isnum = 0; + return 0; + } +} + + +LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) { + TValue n; + const TValue *o = index2addr(L, idx); if (tonumber(o, &n)) { lua_Integer res; lua_Number num = nvalue(o); lua_number2integer(res, num); + if (isnum) *isnum = 1; return res; } - else + else { + if (isnum) *isnum = 0; return 0; + } +} + + +LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *isnum) { + TValue n; + const TValue *o = index2addr(L, idx); + if (tonumber(o, &n)) { + lua_Unsigned res; + lua_Number num = nvalue(o); + lua_number2unsigned(res, num); + if (isnum) *isnum = 1; + return res; + } + else { + if (isnum) *isnum = 0; + return 0; + } } LUA_API int lua_toboolean (lua_State *L, int idx) { - const TValue *o = index2adr(L, idx); + const TValue *o = index2addr(L, idx); return !l_isfalse(o); } LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { - StkId o = index2adr(L, idx); + StkId o = index2addr(L, idx); if (!ttisstring(o)) { lua_lock(L); /* `luaV_tostring' may create a new string */ if (!luaV_tostring(L, o)) { /* conversion failed? */ @@ -350,7 +396,7 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { return NULL; } luaC_checkGC(L); - o = index2adr(L, idx); /* previous call may reallocate the stack */ + o = index2addr(L, idx); /* previous call may reallocate the stack */ lua_unlock(L); } if (len != NULL) *len = tsvalue(o)->len; @@ -358,33 +404,29 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { } -LUA_API size_t lua_objlen (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - switch (ttype(o)) { +LUA_API size_t lua_rawlen (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttypenv(o)) { case LUA_TSTRING: return tsvalue(o)->len; case LUA_TUSERDATA: return uvalue(o)->len; case LUA_TTABLE: return luaH_getn(hvalue(o)); - case LUA_TNUMBER: { - size_t l; - lua_lock(L); /* `luaV_tostring' may create a new string */ - l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); - lua_unlock(L); - return l; - } default: return 0; } } LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; + StkId o = index2addr(L, idx); + if (ttislcf(o)) return fvalue(o); + else if (ttisCclosure(o)) + return clCvalue(o)->f; + else return NULL; /* not a C function */ } LUA_API void *lua_touserdata (lua_State *L, int idx) { - StkId o = index2adr(L, idx); - switch (ttype(o)) { + StkId o = index2addr(L, idx); + switch (ttypenv(o)) { case LUA_TUSERDATA: return (rawuvalue(o) + 1); case LUA_TLIGHTUSERDATA: return pvalue(o); default: return NULL; @@ -393,16 +435,18 @@ LUA_API void *lua_touserdata (lua_State *L, int idx) { LUA_API lua_State *lua_tothread (lua_State *L, int idx) { - StkId o = index2adr(L, idx); + StkId o = index2addr(L, idx); return (!ttisthread(o)) ? NULL : thvalue(o); } LUA_API const void *lua_topointer (lua_State *L, int idx) { - StkId o = index2adr(L, idx); + StkId o = index2addr(L, idx); switch (ttype(o)) { case LUA_TTABLE: return hvalue(o); - case LUA_TFUNCTION: return clvalue(o); + case LUA_TLCL: return clLvalue(o); + case LUA_TCCL: return clCvalue(o); + case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); case LUA_TTHREAD: return thvalue(o); case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: @@ -429,6 +473,8 @@ LUA_API void lua_pushnil (lua_State *L) { LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { lua_lock(L); setnvalue(L->top, n); + luai_checknum(L, L->top, + luaG_runerror(L, "C API - attempt to push a signaling NaN")); api_incr_top(L); lua_unlock(L); } @@ -442,20 +488,43 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { } -LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { +LUA_API void lua_pushunsigned (lua_State *L, lua_Unsigned u) { + lua_Number n; lua_lock(L); - luaC_checkGC(L); - setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + n = lua_unsigned2number(u); + setnvalue(L->top, n); api_incr_top(L); lua_unlock(L); } -LUA_API void lua_pushstring (lua_State *L, const char *s) { - if (s == NULL) +LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { + TString *ts; + lua_lock(L); + luaC_checkGC(L); + ts = luaS_newlstr(L, s, len); + setsvalue2s(L, L->top, ts); + api_incr_top(L); + lua_unlock(L); + return getstr(ts); +} + + +LUA_API const char *lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) { lua_pushnil(L); - else - lua_pushlstring(L, s, strlen(s)); + return NULL; + } + else { + TString *ts; + lua_lock(L); + luaC_checkGC(L); + ts = luaS_new(L, s); + setsvalue2s(L, L->top, ts); + api_incr_top(L); + lua_unlock(L); + return getstr(ts); + } } @@ -484,17 +553,22 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { - Closure *cl; lua_lock(L); - luaC_checkGC(L); - api_checknelems(L, n); - cl = luaF_newCclosure(L, n, getcurrenv(L)); - cl->c.f = fn; - L->top -= n; - while (n--) - setobj2n(L, &cl->c.upvalue[n], L->top+n); - setclvalue(L, L->top, cl); - lua_assert(iswhite(obj2gco(cl))); + if (n == 0) { + setfvalue(L->top, fn); + } + else { + Closure *cl; + api_checknelems(L, n); + api_check(L, n <= MAXUPVAL, "upvalue index too large"); + luaC_checkGC(L); + cl = luaF_newCclosure(L, n); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top + n); + setclCvalue(L, L->top, cl); + } api_incr_top(L); lua_unlock(L); } @@ -531,11 +605,21 @@ LUA_API int lua_pushthread (lua_State *L) { */ +LUA_API void lua_getglobal (lua_State *L, const char *var) { + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt; /* global table */ + lua_lock(L); + gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + setsvalue2s(L, L->top++, luaS_new(L, var)); + luaV_gettable(L, gt, L->top - 1, L->top - 1); + lua_unlock(L); +} + + LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); + t = index2addr(L, idx); luaV_gettable(L, t, L->top - 1, L->top - 1); lua_unlock(L); } @@ -543,13 +627,11 @@ LUA_API void lua_gettable (lua_State *L, int idx) { LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { StkId t; - TValue key; lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_gettable(L, t, &key, L->top); + t = index2addr(L, idx); + setsvalue2s(L, L->top, luaS_new(L, k)); api_incr_top(L); + luaV_gettable(L, t, L->top - 1, L->top - 1); lua_unlock(L); } @@ -557,29 +639,46 @@ LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { LUA_API void lua_rawget (lua_State *L, int idx) { StkId t; lua_lock(L); - t = index2adr(L, idx); - api_check(L, ttistable(t)); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); lua_unlock(L); } LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { - StkId o; + StkId t; lua_lock(L); - o = index2adr(L, idx); - api_check(L, ttistable(o)); - setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2s(L, L->top, luaH_getint(hvalue(t), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) { + StkId t; + TValue k; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setpvalue(&k, cast(void *, p)); + setobj2s(L, L->top, luaH_get(hvalue(t), &k)); api_incr_top(L); lua_unlock(L); } LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + Table *t; lua_lock(L); luaC_checkGC(L); - sethvalue(L, L->top, luaH_new(L, narray, nrec)); + t = luaH_new(L); + sethvalue(L, L->top, t); api_incr_top(L); + if (narray > 0 || nrec > 0) + luaH_resize(L, t, narray, nrec); lua_unlock(L); } @@ -589,8 +688,8 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { Table *mt = NULL; int res; lua_lock(L); - obj = index2adr(L, objindex); - switch (ttype(obj)) { + obj = index2addr(L, objindex); + switch (ttypenv(obj)) { case LUA_TTABLE: mt = hvalue(obj)->metatable; break; @@ -598,7 +697,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { mt = uvalue(obj)->metatable; break; default: - mt = G(L)->mt[ttype(obj)]; + mt = G(L)->mt[ttypenv(obj)]; break; } if (mt == NULL) @@ -613,25 +712,15 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { } -LUA_API void lua_getfenv (lua_State *L, int idx) { +LUA_API void lua_getuservalue (lua_State *L, int idx) { StkId o; lua_lock(L); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - switch (ttype(o)) { - case LUA_TFUNCTION: - sethvalue(L, L->top, clvalue(o)->c.env); - break; - case LUA_TUSERDATA: - sethvalue(L, L->top, uvalue(o)->env); - break; - case LUA_TTHREAD: - setobj2s(L, L->top, gt(thvalue(o))); - break; - default: - setnilvalue(L->top); - break; - } + o = index2addr(L, idx); + api_check(L, ttisuserdata(o), "userdata expected"); + if (uvalue(o)->env) { + sethvalue(L, L->top, uvalue(o)->env); + } else + setnilvalue(L->top); api_incr_top(L); lua_unlock(L); } @@ -642,12 +731,24 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { */ +LUA_API void lua_setglobal (lua_State *L, const char *var) { + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt; /* global table */ + lua_lock(L); + api_checknelems(L, 1); + gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + setsvalue2s(L, L->top++, luaS_new(L, var)); + luaV_settable(L, gt, L->top - 1, L->top - 2); + L->top -= 2; /* pop value and key */ + lua_unlock(L); +} + + LUA_API void lua_settable (lua_State *L, int idx) { StkId t; lua_lock(L); api_checknelems(L, 2); - t = index2adr(L, idx); - api_checkvalidindex(L, t); + t = index2addr(L, idx); luaV_settable(L, t, L->top - 2, L->top - 1); L->top -= 2; /* pop index and value */ lua_unlock(L); @@ -656,14 +757,12 @@ LUA_API void lua_settable (lua_State *L, int idx) { LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { StkId t; - TValue key; lua_lock(L); api_checknelems(L, 1); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_settable(L, t, &key, L->top - 1); - L->top--; /* pop value */ + t = index2addr(L, idx); + setsvalue2s(L, L->top++, luaS_new(L, k)); + luaV_settable(L, t, L->top - 1, L->top - 2); + L->top -= 2; /* pop value and key */ lua_unlock(L); } @@ -672,23 +771,39 @@ LUA_API void lua_rawset (lua_State *L, int idx) { StkId t; lua_lock(L); api_checknelems(L, 2); - t = index2adr(L, idx); - api_check(L, ttistable(t)); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); - luaC_barriert(L, hvalue(t), L->top-1); + invalidateTMcache(hvalue(t)); + luaC_barrierback(L, gcvalue(t), L->top-1); L->top -= 2; lua_unlock(L); } LUA_API void lua_rawseti (lua_State *L, int idx, int n) { - StkId o; + StkId t; lua_lock(L); api_checknelems(L, 1); - o = index2adr(L, idx); - api_check(L, ttistable(o)); - setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); - luaC_barriert(L, hvalue(o), L->top-1); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + luaH_setint(L, hvalue(t), n, L->top - 1); + luaC_barrierback(L, gcvalue(t), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { + StkId t; + TValue k; + lua_lock(L); + api_checknelems(L, 1); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setpvalue(&k, cast(void *, p)); + setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1); + luaC_barrierback(L, gcvalue(t), L->top - 1); L->top--; lua_unlock(L); } @@ -699,29 +814,32 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { Table *mt; lua_lock(L); api_checknelems(L, 1); - obj = index2adr(L, objindex); - api_checkvalidindex(L, obj); + obj = index2addr(L, objindex); if (ttisnil(L->top - 1)) mt = NULL; else { - api_check(L, ttistable(L->top - 1)); + api_check(L, ttistable(L->top - 1), "table expected"); mt = hvalue(L->top - 1); } - switch (ttype(obj)) { + switch (ttypenv(obj)) { case LUA_TTABLE: { hvalue(obj)->metatable = mt; - if (mt) - luaC_objbarriert(L, hvalue(obj), mt); + if (mt) { + luaC_objbarrierback(L, gcvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + } break; } case LUA_TUSERDATA: { uvalue(obj)->metatable = mt; - if (mt) + if (mt) { luaC_objbarrier(L, rawuvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + } break; } default: { - G(L)->mt[ttype(obj)] = mt; + G(L)->mt[ttypenv(obj)] = mt; break; } } @@ -731,32 +849,21 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { } -LUA_API int lua_setfenv (lua_State *L, int idx) { +LUA_API void lua_setuservalue (lua_State *L, int idx) { StkId o; - int res = 1; lua_lock(L); api_checknelems(L, 1); - o = index2adr(L, idx); - api_checkvalidindex(L, o); - api_check(L, ttistable(L->top - 1)); - switch (ttype(o)) { - case LUA_TFUNCTION: - clvalue(o)->c.env = hvalue(L->top - 1); - break; - case LUA_TUSERDATA: - uvalue(o)->env = hvalue(L->top - 1); - break; - case LUA_TTHREAD: - sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); - break; - default: - res = 0; - break; + o = index2addr(L, idx); + api_check(L, ttisuserdata(o), "userdata expected"); + if (ttisnil(L->top - 1)) + uvalue(o)->env = NULL; + else { + api_check(L, ttistable(L->top - 1), "table expected"); + uvalue(o)->env = hvalue(L->top - 1); + luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); } - if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); L->top--; lua_unlock(L); - return res; } @@ -765,21 +872,37 @@ LUA_API int lua_setfenv (lua_State *L, int idx) { */ -#define adjustresults(L,nres) \ - { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } - - #define checkresults(L,na,nr) \ - api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) - + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ + "results from function overflow current stack size") -LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + +LUA_API int lua_getctx (lua_State *L, int *ctx) { + if (L->ci->callstatus & CIST_YIELDED) { + if (ctx) *ctx = L->ci->u.c.ctx; + return L->ci->u.c.status; + } + else return LUA_OK; +} + + +LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k) { StkId func; lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); func = L->top - (nargs+1); - luaD_call(L, func, nresults); + if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ + L->ci->u.c.k = k; /* save continuation */ + L->ci->u.c.ctx = ctx; /* save context */ + luaD_call(L, func, nresults, 1); /* do the call */ + } + else /* no continuation or no yieldable */ + luaD_call(L, func, nresults, 0); /* just do the call */ adjustresults(L, nresults); lua_unlock(L); } @@ -797,76 +920,75 @@ struct CallS { /* data to `f_call' */ static void f_call (lua_State *L, void *ud) { struct CallS *c = cast(struct CallS *, ud); - luaD_call(L, c->func, c->nresults); + luaD_call(L, c->func, c->nresults, 0); } -LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { +LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, + int ctx, lua_CFunction k) { struct CallS c; int status; ptrdiff_t func; lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); if (errfunc == 0) func = 0; else { - StkId o = index2adr(L, errfunc); - api_checkvalidindex(L, o); + StkId o = index2addr(L, errfunc); + api_checkstackindex(L, errfunc, o); func = savestack(L, o); } c.func = L->top - (nargs+1); /* function to be called */ - c.nresults = nresults; - status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */ + c.nresults = nresults; /* do a 'conventional' protected call */ + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + } + else { /* prepare continuation (call is already protected by 'resume') */ + CallInfo *ci = L->ci; + ci->u.c.k = k; /* save continuation */ + ci->u.c.ctx = ctx; /* save context */ + /* save information for error recovery */ + ci->extra = savestack(L, c.func); + ci->u.c.old_allowhook = L->allowhook; + ci->u.c.old_errfunc = L->errfunc; + L->errfunc = func; + /* mark that function may do error recovery */ + ci->callstatus |= CIST_YPCALL; + luaD_call(L, c.func, nresults, 1); /* do the call */ + ci->callstatus &= ~CIST_YPCALL; + L->errfunc = ci->u.c.old_errfunc; + status = LUA_OK; /* if it is here, there were no errors */ + } adjustresults(L, nresults); lua_unlock(L); return status; } -/* -** Execute a protected C call. -*/ -struct CCallS { /* data to `f_Ccall' */ - lua_CFunction func; - void *ud; -}; - - -static void f_Ccall (lua_State *L, void *ud) { - struct CCallS *c = cast(struct CCallS *, ud); - Closure *cl; - cl = luaF_newCclosure(L, 0, getcurrenv(L)); - cl->c.f = c->func; - setclvalue(L, L->top, cl); /* push function */ - api_incr_top(L); - setpvalue(L->top, c->ud); /* push only argument */ - api_incr_top(L); - luaD_call(L, L->top - 2, 0); -} - - -LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { - struct CCallS c; - int status; - lua_lock(L); - c.func = func; - c.ud = ud; - status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); - lua_unlock(L); - return status; -} - - LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, - const char *chunkname) { + const char *chunkname, const char *mode) { ZIO z; int status; lua_lock(L); if (!chunkname) chunkname = "?"; luaZ_init(L, &z, reader, data); - status = luaD_protectedparser(L, &z, chunkname); + status = luaD_protectedparser(L, &z, chunkname, mode); + if (status == LUA_OK) { /* no errors? */ + LClosure *f = clLvalue(L->top - 1); /* get newly created function */ + if (f->nupvalues == 1) { /* does it have one upvalue? */ + /* get global table from registry */ + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ + setobj(L, f->upvals[0]->v, gt); + luaC_barrier(L, f->upvals[0], gt); + } + } lua_unlock(L); return status; } @@ -879,7 +1001,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { api_checknelems(L, 1); o = L->top - 1; if (isLfunction(o)) - status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + status = luaU_dump(L, getproto(o), writer, data, 0); else status = 1; lua_unlock(L); @@ -887,7 +1009,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { } -LUA_API int lua_status (lua_State *L) { +LUA_API int lua_status (lua_State *L) { return L->status; } @@ -903,38 +1025,40 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { g = G(L); switch (what) { case LUA_GCSTOP: { - g->GCthreshold = MAX_LUMEM; + g->gcrunning = 0; break; } case LUA_GCRESTART: { - g->GCthreshold = g->totalbytes; + luaE_setdebt(g, 0); + g->gcrunning = 1; break; } case LUA_GCCOLLECT: { - luaC_fullgc(L); + luaC_fullgc(L, 0); break; } case LUA_GCCOUNT: { /* GC values are expressed in Kbytes: #bytes/2^10 */ - res = cast_int(g->totalbytes >> 10); + res = cast_int(gettotalbytes(g) >> 10); break; } case LUA_GCCOUNTB: { - res = cast_int(g->totalbytes & 0x3ff); + res = cast_int(gettotalbytes(g) & 0x3ff); break; } case LUA_GCSTEP: { - lu_mem a = (cast(lu_mem, data) << 10); - if (a <= g->totalbytes) - g->GCthreshold = g->totalbytes - a; - else - g->GCthreshold = 0; - while (g->GCthreshold <= g->totalbytes) { - luaC_step(L); - if (g->gcstate == GCSpause) { /* end of cycle? */ - res = 1; /* signal it */ - break; - } + if (g->gckind == KGC_GEN) { /* generational mode? */ + res = (g->GCestimate == 0); /* true if it will do major collection */ + luaC_forcestep(L); /* do a single step */ + } + else { + lu_mem debt = cast(lu_mem, data) * 1024 - GCSTEPSIZE; + if (g->gcrunning) + debt += g->GCdebt; /* include current debt */ + luaE_setdebt(g, debt); + luaC_forcestep(L); + if (g->gcstate == GCSpause) /* end of cycle? */ + res = 1; /* signal it */ } break; } @@ -943,11 +1067,28 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { g->gcpause = data; break; } + case LUA_GCSETMAJORINC: { + res = g->gcmajorinc; + g->gcmajorinc = data; + break; + } case LUA_GCSETSTEPMUL: { res = g->gcstepmul; g->gcstepmul = data; break; } + case LUA_GCISRUNNING: { + res = g->gcrunning; + break; + } + case LUA_GCGEN: { /* change collector to generational mode */ + luaC_changemode(L, KGC_GEN); + break; + } + case LUA_GCINC: { /* change collector to incremental mode */ + luaC_changemode(L, KGC_NORMAL); + break; + } default: res = -1; /* invalid option */ } lua_unlock(L); @@ -965,7 +1106,7 @@ LUA_API int lua_error (lua_State *L) { lua_lock(L); api_checknelems(L, 1); luaG_errormsg(L); - lua_unlock(L); + /* code unreachable; will unlock when control actually leaves the kernel */ return 0; /* to avoid warnings */ } @@ -974,8 +1115,8 @@ LUA_API int lua_next (lua_State *L, int idx) { StkId t; int more; lua_lock(L); - t = index2adr(L, idx); - api_check(L, ttistable(t)); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); more = luaH_next(L, hvalue(t), L->top - 1); if (more) { api_incr_top(L); @@ -992,8 +1133,7 @@ LUA_API void lua_concat (lua_State *L, int n) { api_checknelems(L, n); if (n >= 2) { luaC_checkGC(L); - luaV_concat(L, n, cast_int(L->top - L->base) - 1); - L->top -= (n-1); + luaV_concat(L, n); } else if (n == 0) { /* push empty string */ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); @@ -1004,6 +1144,16 @@ LUA_API void lua_concat (lua_State *L, int n) { } +LUA_API void lua_len (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + luaV_objlen(L, L->top, t); + api_incr_top(L); + lua_unlock(L); +} + + LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { lua_Alloc f; lua_lock(L); @@ -1026,7 +1176,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) { Udata *u; lua_lock(L); luaC_checkGC(L); - u = luaS_newudata(L, size, getcurrenv(L)); + u = luaS_newudata(L, size, NULL); setuvalue(L, L->top, u); api_incr_top(L); lua_unlock(L); @@ -1035,30 +1185,36 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) { - -static const char *aux_upvalue (StkId fi, int n, TValue **val) { - Closure *f; - if (!ttisfunction(fi)) return NULL; - f = clvalue(fi); - if (f->c.isC) { - if (!(1 <= n && n <= f->c.nupvalues)) return NULL; - *val = &f->c.upvalue[n-1]; - return ""; - } - else { - Proto *p = f->l.p; - if (!(1 <= n && n <= p->sizeupvalues)) return NULL; - *val = f->l.upvals[n-1]->v; - return getstr(p->upvalues[n-1]); +static const char *aux_upvalue (StkId fi, int n, TValue **val, + GCObject **owner) { + switch (ttype(fi)) { + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + if (!(1 <= n && n <= f->nupvalues)) return NULL; + *val = &f->upvalue[n-1]; + if (owner) *owner = obj2gco(f); + return ""; + } + case LUA_TLCL: { /* Lua closure */ + LClosure *f = clLvalue(fi); + TString *name; + Proto *p = f->p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->upvals[n-1]->v; + if (owner) *owner = obj2gco(f->upvals[n - 1]); + name = p->upvalues[n-1].name; + return (name == NULL) ? "" : getstr(name); + } + default: return NULL; /* not a closure */ } } LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { const char *name; - TValue *val; + TValue *val = NULL; /* to avoid warnings */ lua_lock(L); - name = aux_upvalue(index2adr(L, funcindex), n, &val); + name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL); if (name) { setobj2s(L, L->top, val); api_incr_top(L); @@ -1070,18 +1226,59 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { const char *name; - TValue *val; + TValue *val = NULL; /* to avoid warnings */ + GCObject *owner = NULL; /* to avoid warnings */ StkId fi; lua_lock(L); - fi = index2adr(L, funcindex); + fi = index2addr(L, funcindex); api_checknelems(L, 1); - name = aux_upvalue(fi, n, &val); + name = aux_upvalue(fi, n, &val, &owner); if (name) { L->top--; setobj(L, val, L->top); - luaC_barrier(L, clvalue(fi), L->top); + luaC_barrier(L, owner, L->top); } lua_unlock(L); return name; } + +static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { + LClosure *f; + StkId fi = index2addr(L, fidx); + api_check(L, ttisLclosure(fi), "Lua function expected"); + f = clLvalue(fi); + api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); + if (pf) *pf = f; + return &f->upvals[n - 1]; /* get its upvalue pointer */ +} + + +LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { + StkId fi = index2addr(L, fidx); + switch (ttype(fi)) { + case LUA_TLCL: { /* lua closure */ + return *getupvalref(L, fidx, n, NULL); + } + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index"); + return &f->upvalue[n - 1]; + } + default: { + api_check(L, 0, "closure expected"); + return NULL; + } + } +} + + +LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, + int fidx2, int n2) { + LClosure *f1; + UpVal **up1 = getupvalref(L, fidx1, n1, &f1); + UpVal **up2 = getupvalref(L, fidx2, n2, NULL); + *up1 = *up2; + luaC_objbarrier(L, f1, *up2); +} + diff --git a/src/mod/languages/mod_lua/lua/lapi.h b/src/mod/languages/mod_lua/lua/lapi.h index 2c3fab244e..0909a3911d 100644 --- a/src/mod/languages/mod_lua/lua/lapi.h +++ b/src/mod/languages/mod_lua/lua/lapi.h @@ -1,5 +1,5 @@ /* -** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp $ ** Auxiliary functions from Lua API ** See Copyright Notice in lua.h */ @@ -8,9 +8,17 @@ #define lapi_h -#include "lobject.h" +#include "llimits.h" +#include "lstate.h" +#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ + "stack overflow");} + +#define adjustresults(L,nres) \ + { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + +#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ + "not enough elements in the stack") -LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); #endif diff --git a/src/mod/languages/mod_lua/lua/lauxlib.c b/src/mod/languages/mod_lua/lua/lauxlib.c index 10f14e2c08..2e989d661b 100644 --- a/src/mod/languages/mod_lua/lua/lauxlib.c +++ b/src/mod/languages/mod_lua/lua/lauxlib.c @@ -1,11 +1,10 @@ /* -** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** $Id: lauxlib.c,v 1.248 2013/03/21 13:54:57 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ -#include #include #include #include @@ -25,12 +24,124 @@ #include "lauxlib.h" -#define FREELIST_REF 0 /* free list of references */ +/* +** {====================================================== +** Traceback +** ======================================================= +*/ -/* convert a stack index to positive */ -#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ - lua_gettop(L) + (i) + 1) +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + + + +/* +** search for 'objidx' in table at index -1. +** return 1 + string at top if find a good name. +*/ +static int findfield (lua_State *L, int objidx, int level) { + if (level == 0 || !lua_istable(L, -1)) + return 0; /* not found */ + lua_pushnil(L); /* start 'next' loop */ + while (lua_next(L, -2)) { /* for each pair in table */ + if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */ + if (lua_rawequal(L, objidx, -1)) { /* found object? */ + lua_pop(L, 1); /* remove value (but keep name) */ + return 1; + } + else if (findfield(L, objidx, level - 1)) { /* try recursively */ + lua_remove(L, -2); /* remove table (but keep name) */ + lua_pushliteral(L, "."); + lua_insert(L, -2); /* place '.' between the two names */ + lua_concat(L, 3); + return 1; + } + } + lua_pop(L, 1); /* remove value */ + } + return 0; /* not found */ +} + + +static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { + int top = lua_gettop(L); + lua_getinfo(L, "f", ar); /* push function */ + lua_pushglobaltable(L); + if (findfield(L, top + 1, 2)) { + lua_copy(L, -1, top + 1); /* move name to proper place */ + lua_pop(L, 2); /* remove pushed values */ + return 1; + } + else { + lua_settop(L, top); /* remove function and global table */ + return 0; + } +} + + +static void pushfuncname (lua_State *L, lua_Debug *ar) { + if (*ar->namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, "function " LUA_QS, ar->name); + else if (*ar->what == 'm') /* main? */ + lua_pushliteral(L, "main chunk"); + else if (*ar->what == 'C') { + if (pushglobalfuncname(L, ar)) { + lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1)); + lua_remove(L, -2); /* remove name */ + } + else + lua_pushliteral(L, "?"); + } + else + lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); +} + + +static int countlevels (lua_State *L) { + lua_Debug ar; + int li = 1, le = 1; + /* find an upper bound */ + while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } + /* do a binary search */ + while (li < le) { + int m = (li + le)/2; + if (lua_getstack(L, m, &ar)) li = m + 1; + else le = m; + } + return le - 1; +} + + +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, + const char *msg, int level) { + lua_Debug ar; + int top = lua_gettop(L); + int numlevels = countlevels(L1); + int mark = (numlevels > LEVELS1 + LEVELS2) ? LEVELS1 : 0; + if (msg) lua_pushfstring(L, "%s\n", msg); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level == mark) { /* too many levels? */ + lua_pushliteral(L, "\n\t..."); /* add a '...' */ + level = numlevels - LEVELS2; /* and skip to last ones */ + } + else { + lua_getinfo(L1, "Slnt", &ar); + lua_pushfstring(L, "\n\t%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + lua_pushliteral(L, " in "); + pushfuncname(L, &ar); + if (ar.istailcall) + lua_pushliteral(L, "\n\t(...tail calls...)"); + lua_concat(L, lua_gettop(L) - top); + } + } + lua_concat(L, lua_gettop(L) - top); +} + +/* }====================================================== */ /* @@ -39,7 +150,6 @@ ** ======================================================= */ - LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { lua_Debug ar; if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ @@ -52,13 +162,13 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { ar.name, extramsg); } if (ar.name == NULL) - ar.name = "?"; + ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", narg, ar.name, extramsg); } -LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { +static int typeerror (lua_State *L, int narg, const char *tname) { const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg)); return luaL_argerror(L, narg, msg); @@ -66,7 +176,7 @@ LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { static void tag_error (lua_State *L, int narg, int tag) { - luaL_typerror(L, narg, lua_typename(L, tag)); + typeerror(L, narg, lua_typename(L, tag)); } @@ -93,9 +203,120 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { return lua_error(L); } + +LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { + int en = errno; /* calls to Lua API may change this value */ + if (stat) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (fname) + lua_pushfstring(L, "%s: %s", fname, strerror(en)); + else + lua_pushstring(L, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +#if !defined(inspectstat) /* { */ + +#if defined(LUA_USE_POSIX) + +#include + +/* +** use appropriate macros to interpret 'pclose' return status +*/ +#define inspectstat(stat,what) \ + if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ + else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } + +#else + +#define inspectstat(stat,what) /* no op */ + +#endif + +#endif /* } */ + + +LUALIB_API int luaL_execresult (lua_State *L, int stat) { + const char *what = "exit"; /* type of termination */ + if (stat == -1) /* error? */ + return luaL_fileresult(L, 0, NULL); + else { + inspectstat(stat, what); /* interpret result */ + if (*what == 'e' && stat == 0) /* successful termination? */ + lua_pushboolean(L, 1); + else + lua_pushnil(L); + lua_pushstring(L, what); + lua_pushinteger(L, stat); + return 3; /* return true/nil,what,code */ + } +} + /* }====================================================== */ +/* +** {====================================================== +** Userdata's metatable manipulation +** ======================================================= +*/ + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); /* try to get metatable */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} + + +LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + luaL_getmetatable(L, tname); /* get correct metatable */ + if (!lua_rawequal(L, -1, -2)) /* not the same? */ + p = NULL; /* value is a userdata with wrong metatable */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + return NULL; /* value is not a userdata with a metatable */ +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = luaL_testudata(L, ud, tname); + if (p == NULL) typeerror(L, ud, tname); + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Argument check functions +** ======================================================= +*/ + LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, const char *const lst[]) { const char *name = (def) ? luaL_optstring(L, narg, def) : @@ -109,37 +330,15 @@ LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, } -LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ - if (!lua_isnil(L, -1)) /* name already in use? */ - return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_newtable(L); /* create metatable */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ - return 1; -} - - -LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { - void *p = lua_touserdata(L, ud); - if (p != NULL) { /* value is a userdata? */ - if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ - if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ - lua_pop(L, 2); /* remove both metatables */ - return p; - } - } +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { + /* keep some extra space to run error routines, if needed */ + const int extra = LUA_MINSTACK; + if (!lua_checkstack(L, space + extra)) { + if (msg) + luaL_error(L, "stack overflow (%s)", msg); + else + luaL_error(L, "stack overflow"); } - luaL_typerror(L, ud, tname); /* else error */ - return NULL; /* to avoid warnings */ -} - - -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { - if (!lua_checkstack(L, space)) - luaL_error(L, "stack overflow (%s)", mes); } @@ -174,8 +373,9 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { - lua_Number d = lua_tonumber(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + int isnum; + lua_Number d = lua_tonumberx(L, narg, &isnum); + if (!isnum) tag_error(L, narg, LUA_TNUMBER); return d; } @@ -187,8 +387,18 @@ LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { - lua_Integer d = lua_tointeger(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + int isnum; + lua_Integer d = lua_tointegerx(L, narg, &isnum); + if (!isnum) + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg) { + int isnum; + lua_Unsigned d = lua_tounsignedx(L, narg, &isnum); + if (!isnum) tag_error(L, narg, LUA_TNUMBER); return d; } @@ -200,6 +410,292 @@ LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, } +LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int narg, + lua_Unsigned def) { + return luaL_opt(L, luaL_checkunsigned, narg, def); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +/* +** check whether buffer is using a userdata on the stack as a temporary +** buffer +*/ +#define buffonstack(B) ((B)->b != (B)->initb) + + +/* +** returns a pointer to a free area with at least 'sz' bytes +*/ +LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { + lua_State *L = B->L; + if (B->size - B->n < sz) { /* not enough space? */ + char *newbuff; + size_t newsize = B->size * 2; /* double buffer size */ + if (newsize - B->n < sz) /* not big enough? */ + newsize = B->n + sz; + if (newsize < B->n || newsize - B->n < sz) + luaL_error(L, "buffer too large"); + /* create larger buffer */ + newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char)); + /* move content to new buffer */ + memcpy(newbuff, B->b, B->n * sizeof(char)); + if (buffonstack(B)) + lua_remove(L, -2); /* remove old buffer */ + B->b = newbuff; + B->size = newsize; + } + return &B->b[B->n]; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + char *b = luaL_prepbuffsize(B, l); + memcpy(b, s, l * sizeof(char)); + luaL_addsize(B, l); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + lua_State *L = B->L; + lua_pushlstring(L, B->b, B->n); + if (buffonstack(B)) + lua_remove(L, -2); /* remove old buffer */ +} + + +LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) { + luaL_addsize(B, sz); + luaL_pushresult(B); +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t l; + const char *s = lua_tolstring(L, -1, &l); + if (buffonstack(B)) + lua_insert(L, -2); /* put value below buffer */ + luaL_addlstring(B, s, l); + lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */ +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->b = B->initb; + B->n = 0; + B->size = LUAL_BUFFERSIZE; +} + + +LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { + luaL_buffinit(L, B); + return luaL_prepbuffsize(B, sz); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Reference system +** ======================================================= +*/ + +/* index of free-list header */ +#define freelist 0 + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */ + } + else /* no free elements */ + ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */ + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); + lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, freelist); /* t[freelist] = ref */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int n; /* number of pre-read characters */ + FILE *f; /* file being read */ + char buff[LUAL_BUFFERSIZE]; /* area for reading file */ +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; /* not used */ + if (lf->n > 0) { /* are there pre-read characters to be read? */ + *size = lf->n; /* return them (chars already in buffer) */ + lf->n = 0; /* no more pre-read characters */ + } + else { /* read a block from file */ + /* 'fread' can return > 0 *and* set the EOF flag. If next call to + 'getF' called 'fread', it might still wait for user input. + The next check avoids this problem. */ + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ + } + return lf->buff; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +static int skipBOM (LoadF *lf) { + const char *p = "\xEF\xBB\xBF"; /* Utf8 BOM mark */ + int c; + lf->n = 0; + do { + c = getc(lf->f); + if (c == EOF || c != *(const unsigned char *)p++) return c; + lf->buff[lf->n++] = c; /* to be read by the parser */ + } while (*p != '\0'); + lf->n = 0; /* prefix matched; discard it */ + return getc(lf->f); /* return next character */ +} + + +/* +** reads the first character of file 'f' and skips an optional BOM mark +** in its beginning plus its first line if it starts with '#'. Returns +** true if it skipped the first line. In any case, '*cp' has the +** first "valid" character of the file (after the optional BOM and +** a first-line comment). +*/ +static int skipcomment (LoadF *lf, int *cp) { + int c = *cp = skipBOM(lf); + if (c == '#') { /* first line is a comment (Unix exec. file)? */ + do { /* skip first line */ + c = getc(lf->f); + } while (c != EOF && c != '\n') ; + *cp = getc(lf->f); /* skip end-of-line, if present */ + return 1; /* there was a comment */ + } + else return 0; /* no comment */ +} + + +LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, + const char *mode) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + if (skipcomment(&lf, &c)) /* read initial portion */ + lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + skipcomment(&lf, &c); /* re-read initial portion */ + } + if (c != EOF) + lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ + status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; /* not used */ + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size, + const char *name, const char *mode) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name, mode); +} + + +LUALIB_API int luaL_loadstring (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + +/* }====================================================== */ + + + LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { if (!lua_getmetatable(L, obj)) /* no metatable? */ return 0; @@ -217,7 +713,7 @@ LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = abs_index(L, obj); + obj = lua_absindex(L, obj); if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ return 0; lua_pushvalue(L, obj); @@ -226,138 +722,52 @@ LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { } -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l) { - luaI_openlib(L, libname, l, 0); +LUALIB_API int luaL_len (lua_State *L, int idx) { + int l; + int isnum; + lua_len(L, idx); + l = (int)lua_tointegerx(L, -1, &isnum); + if (!isnum) + luaL_error(L, "object length is not a number"); + lua_pop(L, 1); /* remove object */ + return l; } -static int libsize (const luaL_Reg *l) { - int size = 0; - for (; l->name; l++) size++; - return size; -} - - -LUALIB_API void luaI_openlib (lua_State *L, const char *libname, - const luaL_Reg *l, int nup) { - if (libname) { - int size = libsize(l); - /* check whether lib already exists */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); - lua_getfield(L, -1, libname); /* get _LOADED[libname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) - luaL_error(L, "name conflict for module " LUA_QS, libname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ +LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { + if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */ + switch (lua_type(L, idx)) { + case LUA_TNUMBER: + case LUA_TSTRING: + lua_pushvalue(L, idx); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, idx), + lua_topointer(L, idx)); + break; } - lua_remove(L, -2); /* remove _LOADED table */ - lua_insert(L, -(nup+1)); /* move library table to below upvalues */ } - for (; l->name; l++) { - int i; - for (i=0; ifunc, nup); - lua_setfield(L, -(nup+2), l->name); - } - lua_pop(L, nup); /* remove upvalues */ + return lua_tolstring(L, -1, len); } - /* ** {====================================================== -** getn-setn: size for arrays +** Compatibility with 5.1 module functions ** ======================================================= */ +#if defined(LUA_COMPAT_MODULE) -#if defined(LUA_COMPAT_GETN) - -static int checkint (lua_State *L, int topop) { - int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; - lua_pop(L, topop); - return n; -} - - -static void getsizes (lua_State *L) { - lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); - if (lua_isnil(L, -1)) { /* no `size' table? */ - lua_pop(L, 1); /* remove nil */ - lua_newtable(L); /* create it */ - lua_pushvalue(L, -1); /* `size' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ - } -} - - -LUALIB_API void luaL_setn (lua_State *L, int t, int n) { - t = abs_index(L, t); - lua_pushliteral(L, "n"); - lua_rawget(L, t); - if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ - lua_pushliteral(L, "n"); /* use it */ - lua_pushinteger(L, n); - lua_rawset(L, t); - } - else { /* use `sizes' */ - getsizes(L); - lua_pushvalue(L, t); - lua_pushinteger(L, n); - lua_rawset(L, -3); /* sizes[t] = n */ - lua_pop(L, 1); /* remove `sizes' */ - } -} - - -LUALIB_API int luaL_getn (lua_State *L, int t) { - int n; - t = abs_index(L, t); - lua_pushliteral(L, "n"); /* try t.n */ - lua_rawget(L, t); - if ((n = checkint(L, 1)) >= 0) return n; - getsizes(L); /* else try sizes[t] */ - lua_pushvalue(L, t); - lua_rawget(L, -2); - if ((n = checkint(L, 2)) >= 0) return n; - return (int)lua_objlen(L, t); -} - -#endif - -/* }====================================================== */ - - - -LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, - const char *r) { - const char *wild; - size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); - while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, wild - s); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ - s = wild + l; /* continue after `p' */ - } - luaL_addstring(&b, s); /* push last suffix */ - luaL_pushresult(&b); - return lua_tostring(L, -1); -} - - -LUALIB_API const char *luaL_findtable (lua_State *L, int idx, - const char *fname, int szhint) { +static const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { const char *e; - lua_pushvalue(L, idx); + if (idx) lua_pushvalue(L, idx); do { e = strchr(fname, '.'); if (e == NULL) e = fname + strlen(fname); @@ -381,252 +791,133 @@ LUALIB_API const char *luaL_findtable (lua_State *L, int idx, } - /* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= +** Count number of elements in a luaL_Reg list. */ - - -#define bufflen(B) ((B)->p - (B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) - -#define LIMIT (LUA_MINSTACK/2) - - -static int emptybuffer (luaL_Buffer *B) { - size_t l = bufflen(B); - if (l == 0) return 0; /* put nothing on stack */ - else { - lua_pushlstring(B->L, B->buffer, l); - B->p = B->buffer; - B->lvl++; - return 1; - } +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l && l->name; l++) size++; + return size; } -static void adjuststack (luaL_Buffer *B) { - if (B->lvl > 1) { - lua_State *L = B->L; - int toget = 1; /* number of levels to concat */ - size_t toplen = lua_strlen(L, -1); - do { - size_t l = lua_strlen(L, -(toget+1)); - if (B->lvl - toget + 1 >= LIMIT || toplen > l) { - toplen += l; - toget++; - } - else break; - } while (toget < B->lvl); - lua_concat(L, toget); - B->lvl = B->lvl - toget + 1; - } -} - - -LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { - if (emptybuffer(B)) - adjuststack(B); - return B->buffer; -} - - -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - while (l--) - luaL_addchar(B, *s++); -} - - -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { - luaL_addlstring(B, s, strlen(s)); -} - - -LUALIB_API void luaL_pushresult (luaL_Buffer *B) { - emptybuffer(B); - lua_concat(B->L, B->lvl); - B->lvl = 1; -} - - -LUALIB_API void luaL_addvalue (luaL_Buffer *B) { - lua_State *L = B->L; - size_t vl; - const char *s = lua_tolstring(L, -1, &vl); - if (vl <= bufffree(B)) { /* fit into buffer? */ - memcpy(B->p, s, vl); /* put it there */ - B->p += vl; - lua_pop(L, 1); /* remove from stack */ - } - else { - if (emptybuffer(B)) - lua_insert(L, -2); /* put buffer before new value */ - B->lvl++; /* add new value into B stack */ - adjuststack(B); - } -} - - -LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { - B->L = L; - B->p = B->buffer; - B->lvl = 0; -} - -/* }====================================================== */ - - -LUALIB_API int luaL_ref (lua_State *L, int t) { - int ref; - t = abs_index(L, t); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* `nil' has a unique fixed reference */ - } - lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ - } - else { /* no free elements */ - ref = (int)lua_objlen(L, t); - ref++; /* create new reference */ - } - lua_rawseti(L, t, ref); - return ref; -} - - -LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { - if (ref >= 0) { - t = abs_index(L, t); - lua_rawgeti(L, t, FREELIST_REF); - lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ - } -} - - - /* -** {====================================================== -** Load functions -** ======================================================= +** Find or create a module table with a given name. The function +** first looks at the _LOADED table and, if that fails, try a +** global variable with that name. In any case, leaves on the stack +** the module table. */ - -typedef struct LoadF { - int extraline; - FILE *f; - char buff[LUAL_BUFFERSIZE]; -} LoadF; - - -static const char *getF (lua_State *L, void *ud, size_t *size) { - LoadF *lf = (LoadF *)ud; - (void)L; - if (lf->extraline) { - lf->extraline = 0; - *size = 1; - return "\n"; +LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, + int sizehint) { + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */ + lua_getfield(L, -1, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + lua_pushglobaltable(L); + if (luaL_findtable(L, 0, modname, sizehint) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ } - if (feof(lf->f)) return NULL; - *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); - return (*size > 0) ? lf->buff : NULL; + lua_remove(L, -2); /* remove _LOADED table */ } -static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); - lua_remove(L, fnameindex); - return LUA_ERRFILE; +LUALIB_API void luaL_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + luaL_checkversion(L); + if (libname) { + luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ + lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ + } + if (l) + luaL_setfuncs(L, l, nup); + else + lua_pop(L, nup); /* remove upvalues */ } - -LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { - LoadF lf; - int status, readstatus; - int c; - int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ - lf.extraline = 0; - if (filename == NULL) { - lua_pushliteral(L, "=stdin"); - lf.f = stdin; - } - else { - lua_pushfstring(L, "@%s", filename); - lf.f = fopen(filename, "r"); - if (lf.f == NULL) return errfile(L, "open", fnameindex); - } - c = getc(lf.f); - if (c == '#') { /* Unix exec. file? */ - lf.extraline = 1; - while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ - if (c == '\n') c = getc(lf.f); - } - if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ - lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ - if (lf.f == NULL) return errfile(L, "reopen", fnameindex); - /* skip eventual `#!...' */ - while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; - lf.extraline = 0; - } - ungetc(c, lf.f); - status = lua_load(L, getF, &lf, lua_tostring(L, -1)); - readstatus = ferror(lf.f); - if (filename) fclose(lf.f); /* close file (even in case of errors) */ - if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from `lua_load' */ - return errfile(L, "read", fnameindex); - } - lua_remove(L, fnameindex); - return status; -} - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - - -static const char *getS (lua_State *L, void *ud, size_t *size) { - LoadS *ls = (LoadS *)ud; - (void)L; - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - - -LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, - const char *name) { - LoadS ls; - ls.s = buff; - ls.size = size; - return lua_load(L, getS, &ls, name); -} - - -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { - return luaL_loadbuffer(L, s, strlen(s), s); -} - - - +#endif /* }====================================================== */ +/* +** set functions from list 'l' into table at top - 'nup'; each +** function gets the 'nup' elements at the top as upvalues. +** Returns with only the table at the stack. +*/ +LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { + luaL_checkversion(L); + luaL_checkstack(L, nup, "too many upvalues"); + for (; l->name != NULL; l++) { /* fill the table with given functions */ + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ + lua_setfield(L, -(nup + 2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + +/* +** ensure that stack[idx][fname] has a table and push that table +** into the stack +*/ +LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { + lua_getfield(L, idx, fname); + if (lua_istable(L, -1)) return 1; /* table already there */ + else { + lua_pop(L, 1); /* remove previous result */ + idx = lua_absindex(L, idx); + lua_newtable(L); + lua_pushvalue(L, -1); /* copy to be left at top */ + lua_setfield(L, idx, fname); /* assign new table to field */ + return 0; /* false, because did not find table there */ + } +} + + +/* +** stripped-down 'require'. Calls 'openf' to open a module, +** registers the result in 'package.loaded' table and, if 'glb' +** is true, also registers the result in the global table. +** Leaves resulting module on the top. +*/ +LUALIB_API void luaL_requiref (lua_State *L, const char *modname, + lua_CFunction openf, int glb) { + lua_pushcfunction(L, openf); + lua_pushstring(L, modname); /* argument to open function */ + lua_call(L, 1, 1); /* open module */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_pushvalue(L, -2); /* make copy of module (call result) */ + lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ + lua_pop(L, 1); /* remove _LOADED table */ + if (glb) { + lua_pushvalue(L, -1); /* copy of 'mod' */ + lua_setglobal(L, modname); /* _G[modname] = module */ + } +} + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; - (void)osize; + (void)ud; (void)osize; /* not used */ if (nsize == 0) { free(ptr); return NULL; @@ -637,10 +928,9 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { static int panic (lua_State *L) { - (void)L; /* to avoid warnings */ - fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", lua_tostring(L, -1)); - return 0; + return 0; /* return to Lua to abort */ } @@ -650,3 +940,20 @@ LUALIB_API lua_State *luaL_newstate (void) { return L; } + +LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { + const lua_Number *v = lua_version(L); + if (v != lua_version(NULL)) + luaL_error(L, "multiple Lua VMs detected"); + else if (*v != ver) + luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", + ver, *v); + /* check conversions number -> integer types */ + lua_pushnumber(L, -(lua_Number)0x1234); + if (lua_tointeger(L, -1) != -0x1234 || + lua_tounsigned(L, -1) != (lua_Unsigned)-0x1234) + luaL_error(L, "bad conversion number->int;" + " must recompile Lua with proper settings"); + lua_pop(L, 1); +} + diff --git a/src/mod/languages/mod_lua/lua/lauxlib.h b/src/mod/languages/mod_lua/lua/lauxlib.h index 34258235db..ac4d15fbb9 100644 --- a/src/mod/languages/mod_lua/lua/lauxlib.h +++ b/src/mod/languages/mod_lua/lua/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lauxlib.h,v 1.120 2011/11/29 15:55:08 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -15,18 +15,6 @@ #include "lua.h" -#if defined(LUA_COMPAT_GETN) -LUALIB_API int (luaL_getn) (lua_State *L, int t); -LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); -#else -#define luaL_getn(L,i) ((int)lua_objlen(L, i)) -#define luaL_setn(L,i,j) ((void)0) /* no op! */ -#endif - -#if defined(LUA_COMPAT_OPENLIB) -#define luaI_openlib luaL_openlib -#endif - /* extra error code for `luaL_load' */ #define LUA_ERRFILE (LUA_ERRERR+1) @@ -38,14 +26,12 @@ typedef struct luaL_Reg { } luaL_Reg; +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); +#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) -LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, - const luaL_Reg *l, int nup); -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l); LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, size_t *l); @@ -57,12 +43,17 @@ LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, lua_Integer def); +LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); +LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, + lua_Unsigned def); LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); LUALIB_API void (luaL_checkany) (lua_State *L, int narg); LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); LUALIB_API void (luaL_where) (lua_State *L, int lvl); @@ -71,25 +62,41 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, const char *const lst[]); +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + LUALIB_API int (luaL_ref) (lua_State *L, int t); LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); -LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); -LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, - const char *name); +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); LUALIB_API lua_State *(luaL_newstate) (void); +LUALIB_API int (luaL_len) (lua_State *L, int idx); LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, const char *r); -LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, - const char *fname, int szhint); +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); /* ** =============================================================== @@ -97,6 +104,12 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, ** =============================================================== */ + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + #define luaL_argcheck(L, cond,numarg,extramsg) \ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) @@ -118,56 +131,81 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + /* ** {====================================================== ** Generic Buffer manipulation ** ======================================================= */ - - typedef struct luaL_Buffer { - char *p; /* current position in buffer */ - int lvl; /* number of strings in the stack (level) */ + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ lua_State *L; - char buffer[LUAL_BUFFERSIZE]; + char initb[LUAL_BUFFERSIZE]; /* initial buffer */ } luaL_Buffer; + #define luaL_addchar(B,c) \ - ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ - (*(B)->p++ = (char)(c))) + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) -/* compatibility only */ -#define luaL_putchar(B,c) luaL_addchar(B,c) - -#define luaL_addsize(B,n) ((B)->p += (n)) +#define luaL_addsize(B,s) ((B)->n += (s)) LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); -LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) /* }====================================================== */ -/* compatibility with ref system */ -/* pre-defined references */ -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ -#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ - (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ -#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) - -#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) +#define LUA_FILEHANDLE "FILE*" -#define luaL_reg luaL_Reg +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + + + +/* compatibility with old module system */ +#if defined(LUA_COMPAT_MODULE) + +LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, + int sizehint); +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); + +#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) + +#endif + #endif diff --git a/src/mod/languages/mod_lua/lua/lbaselib.c b/src/mod/languages/mod_lua/lua/lbaselib.c index 2a4c079d3b..540e9a5cc0 100644 --- a/src/mod/languages/mod_lua/lua/lbaselib.c +++ b/src/mod/languages/mod_lua/lua/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** $Id: lbaselib.c,v 1.276 2013/02/21 13:44:53 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -20,60 +20,68 @@ #include "lualib.h" - - -/* -** If your system does not support `stdout', you can just remove this function. -** If you need, you can define your own `print' function, following this -** model but changing `fputs' to put the strings at a proper place -** (a console window or a log file, for instance). -*/ static int luaB_print (lua_State *L) { int n = lua_gettop(L); /* number of arguments */ int i; lua_getglobal(L, "tostring"); for (i=1; i<=n; i++) { const char *s; + size_t l; lua_pushvalue(L, -1); /* function to be called */ lua_pushvalue(L, i); /* value to print */ lua_call(L, 1, 1); - s = lua_tostring(L, -1); /* get result */ + s = lua_tolstring(L, -1, &l); /* get result */ if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("print")); - if (i>1) fputs("\t", stdout); - fputs(s, stdout); + return luaL_error(L, + LUA_QL("tostring") " must return a string to " LUA_QL("print")); + if (i>1) luai_writestring("\t", 1); + luai_writestring(s, l); lua_pop(L, 1); /* pop result */ } - fputs("\n", stdout); + luai_writeline(); return 0; } +#define SPACECHARS " \f\n\r\t\v" + static int luaB_tonumber (lua_State *L) { - int base = luaL_optint(L, 2, 10); - if (base == 10) { /* standard conversion */ - luaL_checkany(L, 1); - if (lua_isnumber(L, 1)) { - lua_pushnumber(L, lua_tonumber(L, 1)); + if (lua_isnoneornil(L, 2)) { /* standard conversion */ + int isnum; + lua_Number n = lua_tonumberx(L, 1, &isnum); + if (isnum) { + lua_pushnumber(L, n); return 1; - } + } /* else not a number; must be something */ + luaL_checkany(L, 1); } else { - const char *s1 = luaL_checkstring(L, 1); - char *s2; - unsigned long n; + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *e = s + l; /* end point for 's' */ + int base = luaL_checkint(L, 2); + int neg = 0; luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); - n = strtoul(s1, &s2, base); - if (s1 != s2) { /* at least one valid digit? */ - while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ - if (*s2 == '\0') { /* no invalid trailing characters? */ - lua_pushnumber(L, (lua_Number)n); + s += strspn(s, SPACECHARS); /* skip initial spaces */ + if (*s == '-') { s++; neg = 1; } /* handle signal */ + else if (*s == '+') s++; + if (isalnum((unsigned char)*s)) { + lua_Number n = 0; + do { + int digit = (isdigit((unsigned char)*s)) ? *s - '0' + : toupper((unsigned char)*s) - 'A' + 10; + if (digit >= base) break; /* invalid numeral; force a fail */ + n = n * (lua_Number)base + (lua_Number)digit; + s++; + } while (isalnum((unsigned char)*s)); + s += strspn(s, SPACECHARS); /* skip trailing spaces */ + if (s == e) { /* no invalid trailing characters? */ + lua_pushnumber(L, (neg) ? -n : n); return 1; - } - } + } /* else not a number */ + } /* else not a number */ } - lua_pushnil(L); /* else not a number */ + lua_pushnil(L); /* not a number */ return 1; } @@ -107,57 +115,13 @@ static int luaB_setmetatable (lua_State *L) { luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); if (luaL_getmetafield(L, 1, "__metatable")) - luaL_error(L, "cannot change a protected metatable"); + return luaL_error(L, "cannot change a protected metatable"); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; } -static void getfunc (lua_State *L, int opt) { - if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); - else { - lua_Debug ar; - int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); - luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); - if (lua_getstack(L, level, &ar) == 0) - luaL_argerror(L, 1, "invalid level"); - lua_getinfo(L, "f", &ar); - if (lua_isnil(L, -1)) - luaL_error(L, "no function environment for tail call at level %d", - level); - } -} - - -static int luaB_getfenv (lua_State *L) { - getfunc(L, 1); - if (lua_iscfunction(L, -1)) /* is a C function? */ - lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ - else - lua_getfenv(L, -1); - return 1; -} - - -static int luaB_setfenv (lua_State *L) { - luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L, 0); - lua_pushvalue(L, 2); - if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { - /* change environment of current thread */ - lua_pushthread(L); - lua_insert(L, -2); - lua_setfenv(L, -2); - return 0; - } - else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) - luaL_error(L, - LUA_QL("setfenv") " cannot change environment of given object"); - return 1; -} - - static int luaB_rawequal (lua_State *L) { luaL_checkany(L, 1); luaL_checkany(L, 2); @@ -166,6 +130,15 @@ static int luaB_rawequal (lua_State *L) { } +static int luaB_rawlen (lua_State *L) { + int t = lua_type(L, 1); + luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, + "table or string expected"); + lua_pushinteger(L, lua_rawlen(L, 1)); + return 1; +} + + static int luaB_rawget (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); @@ -184,32 +157,29 @@ static int luaB_rawset (lua_State *L) { } -static int luaB_gcinfo (lua_State *L) { - lua_pushinteger(L, lua_getgccount(L)); - return 1; -} - - static int luaB_collectgarbage (lua_State *L) { static const char *const opts[] = {"stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", NULL}; + "count", "step", "setpause", "setstepmul", + "setmajorinc", "isrunning", "generational", "incremental", NULL}; static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, - LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; - int o = luaL_checkoption(L, 1, "collect", opts); + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, + LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; + int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; int ex = luaL_optint(L, 2, 0); - int res = lua_gc(L, optsnum[o], ex); - switch (optsnum[o]) { + int res = lua_gc(L, o, ex); + switch (o) { case LUA_GCCOUNT: { int b = lua_gc(L, LUA_GCCOUNTB, 0); lua_pushnumber(L, res + ((lua_Number)b/1024)); - return 1; + lua_pushinteger(L, b); + return 2; } - case LUA_GCSTEP: { + case LUA_GCSTEP: case LUA_GCISRUNNING: { lua_pushboolean(L, res); return 1; } default: { - lua_pushnumber(L, res); + lua_pushinteger(L, res); return 1; } } @@ -223,6 +193,23 @@ static int luaB_type (lua_State *L) { } +static int pairsmeta (lua_State *L, const char *method, int iszero, + lua_CFunction iter) { + if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */ + luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ + lua_pushcfunction(L, iter); /* will return generator, */ + lua_pushvalue(L, 1); /* state, */ + if (iszero) lua_pushinteger(L, 0); /* and initial value */ + else lua_pushnil(L); + } + else { + lua_pushvalue(L, 1); /* argument 'self' to metamethod */ + lua_call(L, 1, 3); /* get 3 values from metamethod */ + } + return 3; +} + + static int luaB_next (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 2); /* create a 2nd argument if there isn't one */ @@ -236,11 +223,7 @@ static int luaB_next (lua_State *L) { static int luaB_pairs (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushnil(L); /* and initial value */ - return 3; + return pairsmeta(L, "__pairs", 0, luaB_next); } @@ -250,23 +233,25 @@ static int ipairsaux (lua_State *L) { i++; /* next value */ lua_pushinteger(L, i); lua_rawgeti(L, 1, i); - return (lua_isnil(L, -1)) ? 0 : 2; + return (lua_isnil(L, -1)) ? 1 : 2; } static int luaB_ipairs (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushinteger(L, 0); /* and initial value */ - return 3; + return pairsmeta(L, "__ipairs", 1, ipairsaux); } -static int load_aux (lua_State *L, int status) { - if (status == 0) /* OK? */ +static int load_aux (lua_State *L, int status, int envidx) { + if (status == LUA_OK) { + if (envidx != 0) { /* 'env' parameter? */ + lua_pushvalue(L, envidx); /* environment for loaded function */ + if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ + lua_pop(L, 1); /* remove 'env' if not used by previous call */ + } return 1; - else { + } + else { /* error (message is on top of the stack) */ lua_pushnil(L); lua_insert(L, -2); /* put before error message */ return 2; /* return nil plus error message */ @@ -274,20 +259,30 @@ static int load_aux (lua_State *L, int status) { } -static int luaB_loadstring (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - const char *chunkname = luaL_optstring(L, 2, s); - return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); -} - - static int luaB_loadfile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); - return load_aux(L, luaL_loadfile(L, fname)); + const char *mode = luaL_optstring(L, 2, NULL); + int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ + int status = luaL_loadfilex(L, fname, mode); + return load_aux(L, status, env); } +/* +** {====================================================== +** Generic Read function +** ======================================================= +*/ + + +/* +** reserved slot, above all arguments, to hold a copy of the returned +** string to avoid it being collected while parsed. 'load' has four +** optional arguments (chunk, source name, mode, and environment). +*/ +#define RESERVEDSLOT 5 + + /* ** Reader for generic `load' function: `lua_load' uses the ** stack for internal stuff, so the reader cannot change the @@ -295,66 +290,66 @@ static int luaB_loadfile (lua_State *L) { ** reserved slot inside the stack. */ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { - (void)ud; /* to avoid warnings */ + (void)(ud); /* not used */ luaL_checkstack(L, 2, "too many nested functions"); lua_pushvalue(L, 1); /* get function */ lua_call(L, 0, 1); /* call it */ if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* pop result */ *size = 0; return NULL; } - else if (lua_isstring(L, -1)) { - lua_replace(L, 3); /* save string in a reserved stack slot */ - return lua_tolstring(L, 3, size); - } - else luaL_error(L, "reader function must return a string"); - return NULL; /* to avoid warnings */ + else if (!lua_isstring(L, -1)) + luaL_error(L, "reader function must return a string"); + lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ + return lua_tolstring(L, RESERVEDSLOT, size); } static int luaB_load (lua_State *L) { int status; - const char *cname = luaL_optstring(L, 2, "=(load)"); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ - status = lua_load(L, generic_reader, NULL, cname); - return load_aux(L, status); + size_t l; + const char *s = lua_tolstring(L, 1, &l); + const char *mode = luaL_optstring(L, 3, "bt"); + int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ + if (s != NULL) { /* loading a string? */ + const char *chunkname = luaL_optstring(L, 2, s); + status = luaL_loadbufferx(L, s, l, chunkname, mode); + } + else { /* loading from a reader function */ + const char *chunkname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, RESERVEDSLOT); /* create reserved slot */ + status = lua_load(L, generic_reader, NULL, chunkname, mode); + } + return load_aux(L, status, env); +} + +/* }====================================================== */ + + +static int dofilecont (lua_State *L) { + return lua_gettop(L) - 1; } static int luaB_dofile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); - int n = lua_gettop(L); - if (luaL_loadfile(L, fname) != 0) lua_error(L); - lua_call(L, 0, LUA_MULTRET); - return lua_gettop(L) - n; + lua_settop(L, 1); + if (luaL_loadfile(L, fname) != LUA_OK) + return lua_error(L); + lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); + return dofilecont(L); } static int luaB_assert (lua_State *L) { - luaL_checkany(L, 1); if (!lua_toboolean(L, 1)) return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); return lua_gettop(L); } -static int luaB_unpack (lua_State *L) { - int i, e, n; - luaL_checktype(L, 1, LUA_TTABLE); - i = luaL_optint(L, 2, 1); - e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); - if (i > e) return 0; /* empty range */ - n = e - i + 1; /* number of elements */ - if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ - return luaL_error(L, "too many results to unpack"); - lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ - while (i++ < e) /* push arg[i + 1...e] */ - lua_rawgeti(L, 1, i); - return n; -} - - static int luaB_select (lua_State *L) { int n = lua_gettop(L); if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { @@ -371,75 +366,50 @@ static int luaB_select (lua_State *L) { } +static int finishpcall (lua_State *L, int status) { + if (!lua_checkstack(L, 1)) { /* no space for extra boolean? */ + lua_settop(L, 0); /* create space for return values */ + lua_pushboolean(L, 0); + lua_pushstring(L, "stack overflow"); + return 2; /* return false, msg */ + } + lua_pushboolean(L, status); /* first result (status) */ + lua_replace(L, 1); /* put first result in first slot */ + return lua_gettop(L); +} + + +static int pcallcont (lua_State *L) { + int status = lua_getctx(L, NULL); + return finishpcall(L, (status == LUA_YIELD)); +} + + static int luaB_pcall (lua_State *L) { int status; luaL_checkany(L, 1); - status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); - lua_pushboolean(L, (status == 0)); - lua_insert(L, 1); - return lua_gettop(L); /* return status + all results */ + lua_pushnil(L); + lua_insert(L, 1); /* create space for status result */ + status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, pcallcont); + return finishpcall(L, (status == LUA_OK)); } static int luaB_xpcall (lua_State *L) { int status; - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_insert(L, 1); /* put error function under function to be called */ - status = lua_pcall(L, 0, LUA_MULTRET, 1); - lua_pushboolean(L, (status == 0)); - lua_replace(L, 1); - return lua_gettop(L); /* return status + all results */ + int n = lua_gettop(L); + luaL_argcheck(L, n >= 2, 2, "value expected"); + lua_pushvalue(L, 1); /* exchange function... */ + lua_copy(L, 2, 1); /* ...and error handler */ + lua_replace(L, 2); + status = lua_pcallk(L, n - 2, LUA_MULTRET, 1, 0, pcallcont); + return finishpcall(L, (status == LUA_OK)); } static int luaB_tostring (lua_State *L) { luaL_checkany(L, 1); - if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ - return 1; /* use its value */ - switch (lua_type(L, 1)) { - case LUA_TNUMBER: - lua_pushstring(L, lua_tostring(L, 1)); - break; - case LUA_TSTRING: - lua_pushvalue(L, 1); - break; - case LUA_TBOOLEAN: - lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); - break; - case LUA_TNIL: - lua_pushliteral(L, "nil"); - break; - default: - lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); - break; - } - return 1; -} - - -static int luaB_newproxy (lua_State *L) { - lua_settop(L, 1); - lua_newuserdata(L, 0); /* create proxy */ - if (lua_toboolean(L, 1) == 0) - return 1; /* no metatable */ - else if (lua_isboolean(L, 1)) { - lua_newtable(L); /* create a new metatable `m' ... */ - lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ - lua_pushboolean(L, 1); - lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ - } - else { - int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ - if (lua_getmetatable(L, 1)) { - lua_rawget(L, lua_upvalueindex(1)); - validproxy = lua_toboolean(L, -1); - lua_pop(L, 1); /* remove value */ - } - luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); - lua_getmetatable(L, 1); /* metatable is valid; get it */ - } - lua_setmetatable(L, 2); + luaL_tolstring(L, 1, NULL); return 1; } @@ -449,205 +419,40 @@ static const luaL_Reg base_funcs[] = { {"collectgarbage", luaB_collectgarbage}, {"dofile", luaB_dofile}, {"error", luaB_error}, - {"gcinfo", luaB_gcinfo}, - {"getfenv", luaB_getfenv}, {"getmetatable", luaB_getmetatable}, + {"ipairs", luaB_ipairs}, {"loadfile", luaB_loadfile}, {"load", luaB_load}, - {"loadstring", luaB_loadstring}, +#if defined(LUA_COMPAT_LOADSTRING) + {"loadstring", luaB_load}, +#endif {"next", luaB_next}, + {"pairs", luaB_pairs}, {"pcall", luaB_pcall}, {"print", luaB_print}, {"rawequal", luaB_rawequal}, + {"rawlen", luaB_rawlen}, {"rawget", luaB_rawget}, {"rawset", luaB_rawset}, {"select", luaB_select}, - {"setfenv", luaB_setfenv}, {"setmetatable", luaB_setmetatable}, {"tonumber", luaB_tonumber}, {"tostring", luaB_tostring}, {"type", luaB_type}, - {"unpack", luaB_unpack}, {"xpcall", luaB_xpcall}, {NULL, NULL} }; -/* -** {====================================================== -** Coroutine library -** ======================================================= -*/ - -#define CO_RUN 0 /* running */ -#define CO_SUS 1 /* suspended */ -#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ -#define CO_DEAD 3 - -static const char *const statnames[] = - {"running", "suspended", "normal", "dead"}; - -static int costatus (lua_State *L, lua_State *co) { - if (L == co) return CO_RUN; - switch (lua_status(co)) { - case LUA_YIELD: - return CO_SUS; - case 0: { - lua_Debug ar; - if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ - return CO_NOR; /* it is running */ - else if (lua_gettop(co) == 0) - return CO_DEAD; - else - return CO_SUS; /* initial state */ - } - default: /* some error occured */ - return CO_DEAD; - } -} - - -static int luaB_costatus (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "coroutine expected"); - lua_pushstring(L, statnames[costatus(L, co)]); - return 1; -} - - -static int auxresume (lua_State *L, lua_State *co, int narg) { - int status = costatus(L, co); - if (!lua_checkstack(co, narg)) - luaL_error(L, "too many arguments to resume"); - if (status != CO_SUS) { - lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); - return -1; /* error flag */ - } - lua_xmove(L, co, narg); - lua_setlevel(L, co); - status = lua_resume(co, narg); - if (status == 0 || status == LUA_YIELD) { - int nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) - luaL_error(L, "too many results to resume"); - lua_xmove(co, L, nres); /* move yielded values */ - return nres; - } - else { - lua_xmove(co, L, 1); /* move error message */ - return -1; /* error flag */ - } -} - - -static int luaB_coresume (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - int r; - luaL_argcheck(L, co, 1, "coroutine expected"); - r = auxresume(L, co, lua_gettop(L) - 1); - if (r < 0) { - lua_pushboolean(L, 0); - lua_insert(L, -2); - return 2; /* return false + error message */ - } - else { - lua_pushboolean(L, 1); - lua_insert(L, -(r + 1)); - return r + 1; /* return true + `resume' returns */ - } -} - - -static int luaB_auxwrap (lua_State *L) { - lua_State *co = lua_tothread(L, lua_upvalueindex(1)); - int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { - if (lua_isstring(L, -1)) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ - lua_insert(L, -2); - lua_concat(L, 2); - } - lua_error(L); /* propagate error */ - } - return r; -} - - -static int luaB_cocreate (lua_State *L) { - lua_State *NL = lua_newthread(L); - luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, - "Lua function expected"); - lua_pushvalue(L, 1); /* move function to top */ - lua_xmove(L, NL, 1); /* move function from L to NL */ - return 1; -} - - -static int luaB_cowrap (lua_State *L) { - luaB_cocreate(L); - lua_pushcclosure(L, luaB_auxwrap, 1); - return 1; -} - - -static int luaB_yield (lua_State *L) { - return lua_yield(L, lua_gettop(L)); -} - - -static int luaB_corunning (lua_State *L) { - if (lua_pushthread(L)) - lua_pushnil(L); /* main thread is not a coroutine */ - return 1; -} - - -static const luaL_Reg co_funcs[] = { - {"create", luaB_cocreate}, - {"resume", luaB_coresume}, - {"running", luaB_corunning}, - {"status", luaB_costatus}, - {"wrap", luaB_cowrap}, - {"yield", luaB_yield}, - {NULL, NULL} -}; - -/* }====================================================== */ - - -static void auxopen (lua_State *L, const char *name, - lua_CFunction f, lua_CFunction u) { - lua_pushcfunction(L, u); - lua_pushcclosure(L, f, 1); - lua_setfield(L, -2, name); -} - - -static void base_open (lua_State *L) { +LUAMOD_API int luaopen_base (lua_State *L) { /* set global _G */ - lua_pushvalue(L, LUA_GLOBALSINDEX); - lua_setglobal(L, "_G"); + lua_pushglobaltable(L); + lua_pushglobaltable(L); + lua_setfield(L, -2, "_G"); /* open lib into global table */ - luaL_register(L, "_G", base_funcs); + luaL_setfuncs(L, base_funcs, 0); lua_pushliteral(L, LUA_VERSION); - lua_setglobal(L, "_VERSION"); /* set global _VERSION */ - /* `ipairs' and `pairs' need auxliliary functions as upvalues */ - auxopen(L, "ipairs", luaB_ipairs, ipairsaux); - auxopen(L, "pairs", luaB_pairs, luaB_next); - /* `newproxy' needs a weaktable as upvalue */ - lua_createtable(L, 0, 1); /* new table `w' */ - lua_pushvalue(L, -1); /* `w' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ - lua_pushcclosure(L, luaB_newproxy, 1); - lua_setglobal(L, "newproxy"); /* set global `newproxy' */ -} - - -LUALIB_API int luaopen_base (lua_State *L) { - base_open(L); - luaL_register(L, LUA_COLIBNAME, co_funcs); - return 2; + lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */ + return 1; } diff --git a/src/mod/languages/mod_lua/lua/lbitlib.c b/src/mod/languages/mod_lua/lua/lbitlib.c new file mode 100644 index 0000000000..9637532e3d --- /dev/null +++ b/src/mod/languages/mod_lua/lua/lbitlib.c @@ -0,0 +1,211 @@ +/* +** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $ +** Standard library for bitwise operations +** See Copyright Notice in lua.h +*/ + +#define lbitlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* number of bits to consider in a number */ +#if !defined(LUA_NBITS) +#define LUA_NBITS 32 +#endif + + +#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) + +/* macro to trim extra bits */ +#define trim(x) ((x) & ALLONES) + + +/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ +#define mask(n) (~((ALLONES << 1) << ((n) - 1))) + + +typedef lua_Unsigned b_uint; + + + +static b_uint andaux (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = ~(b_uint)0; + for (i = 1; i <= n; i++) + r &= luaL_checkunsigned(L, i); + return trim(r); +} + + +static int b_and (lua_State *L) { + b_uint r = andaux(L); + lua_pushunsigned(L, r); + return 1; +} + + +static int b_test (lua_State *L) { + b_uint r = andaux(L); + lua_pushboolean(L, r != 0); + return 1; +} + + +static int b_or (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r |= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_xor (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r ^= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_not (lua_State *L) { + b_uint r = ~luaL_checkunsigned(L, 1); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_shift (lua_State *L, b_uint r, int i) { + if (i < 0) { /* shift right? */ + i = -i; + r = trim(r); + if (i >= LUA_NBITS) r = 0; + else r >>= i; + } + else { /* shift left */ + if (i >= LUA_NBITS) r = 0; + else r <<= i; + r = trim(r); + } + lua_pushunsigned(L, r); + return 1; +} + + +static int b_lshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2)); +} + + +static int b_rshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2)); +} + + +static int b_arshift (lua_State *L) { + b_uint r = luaL_checkunsigned(L, 1); + int i = luaL_checkint(L, 2); + if (i < 0 || !(r & ((b_uint)1 << (LUA_NBITS - 1)))) + return b_shift(L, r, -i); + else { /* arithmetic shift for 'negative' number */ + if (i >= LUA_NBITS) r = ALLONES; + else + r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ + lua_pushunsigned(L, r); + return 1; + } +} + + +static int b_rot (lua_State *L, int i) { + b_uint r = luaL_checkunsigned(L, 1); + i &= (LUA_NBITS - 1); /* i = i % NBITS */ + r = trim(r); + r = (r << i) | (r >> (LUA_NBITS - i)); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_lrot (lua_State *L) { + return b_rot(L, luaL_checkint(L, 2)); +} + + +static int b_rrot (lua_State *L) { + return b_rot(L, -luaL_checkint(L, 2)); +} + + +/* +** get field and width arguments for field-manipulation functions, +** checking whether they are valid. +** ('luaL_error' called without 'return' to avoid later warnings about +** 'width' being used uninitialized.) +*/ +static int fieldargs (lua_State *L, int farg, int *width) { + int f = luaL_checkint(L, farg); + int w = luaL_optint(L, farg + 1, 1); + luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); + luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); + if (f + w > LUA_NBITS) + luaL_error(L, "trying to access non-existent bits"); + *width = w; + return f; +} + + +static int b_extract (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + int f = fieldargs(L, 2, &w); + r = (r >> f) & mask(w); + lua_pushunsigned(L, r); + return 1; +} + + +static int b_replace (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + b_uint v = luaL_checkunsigned(L, 2); + int f = fieldargs(L, 3, &w); + int m = mask(w); + v &= m; /* erase bits outside given width */ + r = (r & ~(m << f)) | (v << f); + lua_pushunsigned(L, r); + return 1; +} + + +static const luaL_Reg bitlib[] = { + {"arshift", b_arshift}, + {"band", b_and}, + {"bnot", b_not}, + {"bor", b_or}, + {"bxor", b_xor}, + {"btest", b_test}, + {"extract", b_extract}, + {"lrotate", b_lrot}, + {"lshift", b_lshift}, + {"replace", b_replace}, + {"rrotate", b_rrot}, + {"rshift", b_rshift}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_bit32 (lua_State *L) { + luaL_newlib(L, bitlib); + return 1; +} + diff --git a/src/mod/languages/mod_lua/lua/lcode.c b/src/mod/languages/mod_lua/lua/lcode.c index cff626b7fa..56c26ac8aa 100644 --- a/src/mod/languages/mod_lua/lua/lcode.c +++ b/src/mod/languages/mod_lua/lua/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** $Id: lcode.c,v 2.62 2012/08/16 17:34:28 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -21,7 +21,9 @@ #include "lobject.h" #include "lopcodes.h" #include "lparser.h" +#include "lstring.h" #include "ltable.h" +#include "lvm.h" #define hasjumps(e) ((e)->t != (e)->f) @@ -34,25 +36,23 @@ static int isnumeral(expdesc *e) { void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; + int l = from + n - 1; /* last register to set nil */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - if (fs->pc == 0) { /* function start? */ - if (from >= fs->nactvar) - return; /* positions are already clean */ - } - else { - previous = &fs->f->code[fs->pc-1]; - if (GET_OPCODE(*previous) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pto = GETARG_B(*previous); - if (pfrom <= from && from <= pto+1) { /* can connect both? */ - if (from+n-1 > pto) - SETARG_B(*previous, from+n-1); - return; - } + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pl = pfrom + GETARG_B(*previous); + if ((pfrom <= from && from <= pl + 1) || + (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ + if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ + if (pl > l) l = pl; /* l = max(l, pl) */ + SETARG_A(*previous, from); + SETARG_B(*previous, l - from); + return; } - } + } /* else go through */ } - luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ + luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ } @@ -176,6 +176,19 @@ void luaK_patchlist (FuncState *fs, int list, int target) { } +LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) { + level++; /* argument is +1 to reserve 0 as non-op */ + while (list != NO_JUMP) { + int next = getjump(fs, list); + lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && + (GETARG_A(fs->f->code[list]) == 0 || + GETARG_A(fs->f->code[list]) >= level)); + SETARG_A(fs->f->code[list], level); + list = next; + } +} + + void luaK_patchtohere (FuncState *fs, int list) { luaK_getlabel(fs); luaK_concat(fs, &fs->jpc, list); @@ -196,6 +209,55 @@ void luaK_concat (FuncState *fs, int *l1, int l2) { } +static int luaK_code (FuncState *fs, Instruction i) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "opcodes"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "opcodes"); + f->lineinfo[fs->pc] = fs->ls->lastline; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); + return luaK_code(fs, CREATE_ABC(o, a, b, c)); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, bc)); +} + + +static int codeextraarg (FuncState *fs, int a) { + lua_assert(a <= MAXARG_Ax); + return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); +} + + +int luaK_codek (FuncState *fs, int reg, int k) { + if (k <= MAXARG_Bx) + return luaK_codeABx(fs, OP_LOADK, reg, k); + else { + int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); + codeextraarg(fs, k); + return p; + } +} + + void luaK_checkstack (FuncState *fs, int n) { int newstack = fs->freereg + n; if (newstack > fs->f->maxstacksize) { @@ -222,42 +284,59 @@ static void freereg (FuncState *fs, int reg) { static void freeexp (FuncState *fs, expdesc *e) { if (e->k == VNONRELOC) - freereg(fs, e->u.s.info); + freereg(fs, e->u.info); } -static int addk (FuncState *fs, TValue *k, TValue *v) { - lua_State *L = fs->L; - TValue *idx = luaH_set(L, fs->h, k); +static int addk (FuncState *fs, TValue *key, TValue *v) { + lua_State *L = fs->ls->L; + TValue *idx = luaH_set(L, fs->h, key); Proto *f = fs->f; - int oldsize = f->sizek; + int k, oldsize; if (ttisnumber(idx)) { - lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); - return cast_int(nvalue(idx)); - } - else { /* constant not found; create a new entry */ - setnvalue(idx, cast_num(fs->nk)); - luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, - MAXARG_Bx, "constant table overflow"); - while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); - setobj(L, &f->k[fs->nk], v); - luaC_barrier(L, f, v); - return fs->nk++; + lua_Number n = nvalue(idx); + lua_number2int(k, n); + if (luaV_rawequalobj(&f->k[k], v)) + return k; + /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0"); + go through and create a new entry for this value */ } + /* constant not found; create a new entry */ + oldsize = f->sizek; + k = fs->nk; + /* numerical value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setnvalue(idx, cast_num(k)); + luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[k], v); + fs->nk++; + luaC_barrier(L, f, v); + return k; } int luaK_stringK (FuncState *fs, TString *s) { TValue o; - setsvalue(fs->L, &o, s); + setsvalue(fs->ls->L, &o, s); return addk(fs, &o, &o); } int luaK_numberK (FuncState *fs, lua_Number r) { + int n; + lua_State *L = fs->ls->L; TValue o; setnvalue(&o, r); - return addk(fs, &o, &o); + if (r == 0 || luai_numisnan(NULL, r)) { /* handle -0 and NaN */ + /* use raw representation as key to avoid numeric problems */ + setsvalue(L, L->top++, luaS_newlstr(L, (char *)&r, sizeof(r))); + n = addk(fs, L->top - 1, &o); + L->top--; + } + else + n = addk(fs, &o, &o); /* regular case */ + return n; } @@ -272,7 +351,7 @@ static int nilK (FuncState *fs) { TValue k, v; setnilvalue(&v); /* cannot use nil as key; instead use table itself to represent nil */ - sethvalue(fs->L, &k, fs->h); + sethvalue(fs->ls->L, &k, fs->h); return addk(fs, &k, &v); } @@ -292,7 +371,7 @@ void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { void luaK_setoneret (FuncState *fs, expdesc *e) { if (e->k == VCALL) { /* expression is an open function call? */ e->k = VNONRELOC; - e->u.s.info = GETARG_A(getcode(fs, e)); + e->u.info = GETARG_A(getcode(fs, e)); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), 2); @@ -308,19 +387,18 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { break; } case VUPVAL: { - e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); - e->k = VRELOCABLE; - break; - } - case VGLOBAL: { - e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); e->k = VRELOCABLE; break; } case VINDEXED: { - freereg(fs, e->u.s.aux); - freereg(fs, e->u.s.info); - e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */ + freereg(fs, e->u.ind.idx); + if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */ + freereg(fs, e->u.ind.t); + op = OP_GETTABLE; + } + e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); e->k = VRELOCABLE; break; } @@ -347,16 +425,16 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_nil(fs, reg, 1); break; } - case VFALSE: case VTRUE: { + case VFALSE: case VTRUE: { luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } case VK: { - luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + luaK_codek(fs, reg, e->u.info); break; } case VKNUM: { - luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); break; } case VRELOCABLE: { @@ -365,8 +443,8 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { break; } case VNONRELOC: { - if (reg != e->u.s.info) - luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + if (reg != e->u.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); break; } default: { @@ -374,7 +452,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { return; /* nothing to do... */ } } - e->u.s.info = reg; + e->u.info = reg; e->k = VNONRELOC; } @@ -390,7 +468,7 @@ static void discharge2anyreg (FuncState *fs, expdesc *e) { static void exp2reg (FuncState *fs, expdesc *e, int reg) { discharge2reg(fs, e, reg); if (e->k == VJMP) - luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + luaK_concat(fs, &e->t, e->u.info); /* put this jump in `t' list */ if (hasjumps(e)) { int final; /* position after whole expression */ int p_f = NO_JUMP; /* position of an eventual LOAD false */ @@ -406,7 +484,7 @@ static void exp2reg (FuncState *fs, expdesc *e, int reg) { patchlistaux(fs, e->t, final, reg, p_t); } e->f = e->t = NO_JUMP; - e->u.s.info = reg; + e->u.info = reg; e->k = VNONRELOC; } @@ -422,14 +500,20 @@ void luaK_exp2nextreg (FuncState *fs, expdesc *e) { int luaK_exp2anyreg (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); if (e->k == VNONRELOC) { - if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ - if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ - exp2reg(fs, e, e->u.s.info); /* put value on it */ - return e->u.s.info; + if (!hasjumps(e)) return e->u.info; /* exp is already in a register */ + if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.info); /* put value on it */ + return e->u.info; } } luaK_exp2nextreg(fs, e); /* default */ - return e->u.s.info; + return e->u.info; +} + + +void luaK_exp2anyregup (FuncState *fs, expdesc *e) { + if (e->k != VUPVAL || hasjumps(e)) + luaK_exp2anyreg(fs, e); } @@ -444,22 +528,24 @@ void luaK_exp2val (FuncState *fs, expdesc *e) { int luaK_exp2RK (FuncState *fs, expdesc *e) { luaK_exp2val(fs, e); switch (e->k) { - case VKNUM: case VTRUE: case VFALSE: case VNIL: { - if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ - e->u.s.info = (e->k == VNIL) ? nilK(fs) : - (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : - boolK(fs, (e->k == VTRUE)); + if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */ + e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE)); e->k = VK; - return RKASK(e->u.s.info); + return RKASK(e->u.info); } else break; } + case VKNUM: { + e->u.info = luaK_numberK(fs, e->u.nval); + e->k = VK; + /* go through */ + } case VK: { - if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ - return RKASK(e->u.s.info); + if (e->u.info <= MAXINDEXRK) /* constant fits in argC? */ + return RKASK(e->u.info); else break; } default: break; @@ -473,22 +559,18 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { switch (var->k) { case VLOCAL: { freeexp(fs, ex); - exp2reg(fs, ex, var->u.s.info); + exp2reg(fs, ex, var->u.info); return; } case VUPVAL: { int e = luaK_exp2anyreg(fs, ex); - luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); - break; - } - case VGLOBAL: { - int e = luaK_exp2anyreg(fs, ex); - luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); break; } case VINDEXED: { + OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; int e = luaK_exp2RK(fs, ex); - luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); break; } default: { @@ -501,20 +583,20 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { - int func; + int ereg; luaK_exp2anyreg(fs, e); + ereg = e->u.info; /* register where 'e' was placed */ freeexp(fs, e); - func = fs->freereg; - luaK_reserveregs(fs, 2); - luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); - freeexp(fs, key); - e->u.s.info = func; + e->u.info = fs->freereg; /* base register for op_self */ e->k = VNONRELOC; + luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ + luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key)); + freeexp(fs, key); } static void invertjump (FuncState *fs, expdesc *e) { - Instruction *pc = getjumpcontrol(fs, e->u.s.info); + Instruction *pc = getjumpcontrol(fs, e->u.info); lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && GET_OPCODE(*pc) != OP_TEST); SETARG_A(*pc, !(GETARG_A(*pc))); @@ -532,7 +614,7 @@ static int jumponcond (FuncState *fs, expdesc *e, int cond) { } discharge2anyreg(fs, e); freeexp(fs, e); - return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); + return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); } @@ -540,17 +622,13 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ luaK_dischargevars(fs, e); switch (e->k) { - case VK: case VKNUM: case VTRUE: { - pc = NO_JUMP; /* always true; do nothing */ - break; - } - case VFALSE: { - pc = luaK_jump(fs); /* always jump */ - break; - } case VJMP: { invertjump(fs, e); - pc = e->u.s.info; + pc = e->u.info; + break; + } + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ break; } default: { @@ -564,22 +642,18 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { } -static void luaK_goiffalse (FuncState *fs, expdesc *e) { +void luaK_goiffalse (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ luaK_dischargevars(fs, e); switch (e->k) { + case VJMP: { + pc = e->u.info; + break; + } case VNIL: case VFALSE: { pc = NO_JUMP; /* always false; do nothing */ break; } - case VTRUE: { - pc = luaK_jump(fs); /* always jump */ - break; - } - case VJMP: { - pc = e->u.s.info; - break; - } default: { pc = jumponcond(fs, e, 1); break; @@ -610,7 +684,7 @@ static void codenot (FuncState *fs, expdesc *e) { case VNONRELOC: { discharge2anyreg(fs, e); freeexp(fs, e); - e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); e->k = VRELOCABLE; break; } @@ -627,38 +701,28 @@ static void codenot (FuncState *fs, expdesc *e) { void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { - t->u.s.aux = luaK_exp2RK(fs, k); + lua_assert(!hasjumps(t)); + t->u.ind.t = t->u.info; + t->u.ind.idx = luaK_exp2RK(fs, k); + t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL + : check_exp(vkisinreg(t->k), VLOCAL); t->k = VINDEXED; } static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { - lua_Number v1, v2, r; + lua_Number r; if (!isnumeral(e1) || !isnumeral(e2)) return 0; - v1 = e1->u.nval; - v2 = e2->u.nval; - switch (op) { - case OP_ADD: r = luai_numadd(v1, v2); break; - case OP_SUB: r = luai_numsub(v1, v2); break; - case OP_MUL: r = luai_nummul(v1, v2); break; - case OP_DIV: - if (v2 == 0) return 0; /* do not attempt to divide by 0 */ - r = luai_numdiv(v1, v2); break; - case OP_MOD: - if (v2 == 0) return 0; /* do not attempt to divide by 0 */ - r = luai_nummod(v1, v2); break; - case OP_POW: r = luai_numpow(v1, v2); break; - case OP_UNM: r = luai_numunm(v1); break; - case OP_LEN: return 0; /* no constant folding for 'len' */ - default: lua_assert(0); r = 0; break; - } - if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0) + return 0; /* do not attempt to divide by 0 */ + r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); e1->u.nval = r; return 1; } -static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { +static void codearith (FuncState *fs, OpCode op, + expdesc *e1, expdesc *e2, int line) { if (constfolding(op, e1, e2)) return; else { @@ -672,8 +736,9 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { freeexp(fs, e2); freeexp(fs, e1); } - e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; + luaK_fixline(fs, line); } } @@ -689,25 +754,28 @@ static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ cond = 1; } - e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->u.info = condjump(fs, op, cond, o1, o2); e1->k = VJMP; } -void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { expdesc e2; e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; switch (op) { case OPR_MINUS: { - if (!isnumeral(e)) - luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ - codearith(fs, OP_UNM, e, &e2); + if (isnumeral(e)) /* minus constant? */ + e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */ + else { + luaK_exp2anyreg(fs, e); + codearith(fs, OP_UNM, e, &e2, line); + } break; } case OPR_NOT: codenot(fs, e); break; case OPR_LEN: { luaK_exp2anyreg(fs, e); /* cannot operate on constants */ - codearith(fs, OP_LEN, e, &e2); + codearith(fs, OP_LEN, e, &e2, line); break; } default: lua_assert(0); @@ -742,7 +810,8 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { } -void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { +void luaK_posfix (FuncState *fs, BinOpr op, + expdesc *e1, expdesc *e2, int line) { switch (op) { case OPR_AND: { lua_assert(e1->t == NO_JUMP); /* list must be closed */ @@ -761,29 +830,30 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { case OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { - lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); freeexp(fs, e1); - SETARG_B(getcode(fs, e2), e1->u.s.info); - e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + SETARG_B(getcode(fs, e2), e1->u.info); + e1->k = VRELOCABLE; e1->u.info = e2->u.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ - codearith(fs, OP_CONCAT, e1, e2); + codearith(fs, OP_CONCAT, e1, e2, line); } break; } - case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; - case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; - case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; - case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; - case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; - case OPR_POW: codearith(fs, OP_POW, e1, e2); break; - case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; - case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; - case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; - case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; - case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; - case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line); + break; + } + case OPR_EQ: case OPR_LT: case OPR_LE: { + codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2); + break; + } + case OPR_NE: case OPR_GT: case OPR_GE: { + codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2); + break; + } default: lua_assert(0); } } @@ -794,46 +864,18 @@ void luaK_fixline (FuncState *fs, int line) { } -static int luaK_code (FuncState *fs, Instruction i, int line) { - Proto *f = fs->f; - dischargejpc(fs); /* `pc' will change */ - /* put new instruction in code array */ - luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, - MAX_INT, "code size overflow"); - f->code[fs->pc] = i; - /* save corresponding line information */ - luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, - MAX_INT, "code size overflow"); - f->lineinfo[fs->pc] = line; - return fs->pc++; -} - - -int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { - lua_assert(getOpMode(o) == iABC); - lua_assert(getBMode(o) != OpArgN || b == 0); - lua_assert(getCMode(o) != OpArgN || c == 0); - return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); -} - - -int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { - lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); - lua_assert(getCMode(o) == OpArgN); - return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); -} - - void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; int b = (tostore == LUA_MULTRET) ? 0 : tostore; lua_assert(tostore != 0); if (c <= MAXARG_C) luaK_codeABC(fs, OP_SETLIST, base, b, c); - else { + else if (c <= MAXARG_Ax) { luaK_codeABC(fs, OP_SETLIST, base, b, 0); - luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + codeextraarg(fs, c); } + else + luaX_syntaxerror(fs->ls, "constructor too long"); fs->freereg = base + 1; /* free registers with list values */ } diff --git a/src/mod/languages/mod_lua/lua/lcode.h b/src/mod/languages/mod_lua/lua/lcode.h index b941c60721..5a1fa9feac 100644 --- a/src/mod/languages/mod_lua/lua/lcode.h +++ b/src/mod/languages/mod_lua/lua/lcode.h @@ -1,5 +1,5 @@ /* -** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lcode.h,v 1.58 2011/08/30 16:26:41 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -21,13 +21,13 @@ /* -** grep "ORDER OPR" if you change these enums +** grep "ORDER OPR" if you change these enums (ORDER OP) */ typedef enum BinOpr { OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, OPR_CONCAT, - OPR_NE, OPR_EQ, - OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_EQ, OPR_LT, OPR_LE, + OPR_NE, OPR_GT, OPR_GE, OPR_AND, OPR_OR, OPR_NOBINOPR } BinOpr; @@ -36,14 +36,17 @@ typedef enum BinOpr { typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; -#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) +#define getcode(fs,e) ((fs)->f->code[(e)->u.info]) #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) +#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) + LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); LUAI_FUNC void luaK_fixline (FuncState *fs, int line); LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); @@ -52,12 +55,14 @@ LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); @@ -65,11 +70,13 @@ LUAI_FUNC int luaK_jump (FuncState *fs); LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); LUAI_FUNC int luaK_getlabel (FuncState *fs); -LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); -LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, + expdesc *v2, int line); LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); diff --git a/src/mod/languages/mod_lua/lua/lcorolib.c b/src/mod/languages/mod_lua/lua/lcorolib.c new file mode 100644 index 0000000000..1326c8146c --- /dev/null +++ b/src/mod/languages/mod_lua/lua/lcorolib.c @@ -0,0 +1,155 @@ +/* +** $Id: lcorolib.c,v 1.5 2013/02/21 13:44:53 roberto Exp $ +** Coroutine Library +** See Copyright Notice in lua.h +*/ + + +#include + + +#define lcorolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status; + if (!lua_checkstack(co, narg)) { + lua_pushliteral(L, "too many arguments to resume"); + return -1; /* error flag */ + } + if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { + lua_pushliteral(L, "cannot resume dead coroutine"); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + status = lua_resume(co, L, narg); + if (status == LUA_OK || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) { + lua_pop(co, nres); /* remove results anyway */ + lua_pushliteral(L, "too many results to resume"); + return -1; /* error flag */ + } + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + return lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL; + luaL_checktype(L, 1, LUA_TFUNCTION); + NL = lua_newthread(L); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + if (L == co) lua_pushliteral(L, "running"); + else { + switch (lua_status(co)) { + case LUA_YIELD: + lua_pushliteral(L, "suspended"); + break; + case LUA_OK: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + lua_pushliteral(L, "normal"); /* it is running */ + else if (lua_gettop(co) == 0) + lua_pushliteral(L, "dead"); + else + lua_pushliteral(L, "suspended"); /* initial state */ + break; + } + default: /* some error occurred */ + lua_pushliteral(L, "dead"); + break; + } + } + return 1; +} + + +static int luaB_corunning (lua_State *L) { + int ismain = lua_pushthread(L); + lua_pushboolean(L, ismain); + return 2; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_coroutine (lua_State *L) { + luaL_newlib(L, co_funcs); + return 1; +} + diff --git a/src/mod/languages/mod_lua/lua/lctype.c b/src/mod/languages/mod_lua/lua/lctype.c new file mode 100644 index 0000000000..55e433a5dd --- /dev/null +++ b/src/mod/languages/mod_lua/lua/lctype.c @@ -0,0 +1,52 @@ +/* +** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#define lctype_c +#define LUA_CORE + +#include "lctype.h" + +#if !LUA_USE_CTYPE /* { */ + +#include + +LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { + 0x00, /* EOZ */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ + 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +#endif /* } */ diff --git a/src/mod/languages/mod_lua/lua/lctype.h b/src/mod/languages/mod_lua/lua/lctype.h new file mode 100644 index 0000000000..99c7d12237 --- /dev/null +++ b/src/mod/languages/mod_lua/lua/lctype.h @@ -0,0 +1,95 @@ +/* +** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lctype_h +#define lctype_h + +#include "lua.h" + + +/* +** WARNING: the functions defined here do not necessarily correspond +** to the similar functions in the standard C ctype.h. They are +** optimized for the specific needs of Lua +*/ + +#if !defined(LUA_USE_CTYPE) + +#if 'A' == 65 && '0' == 48 +/* ASCII case: can use its own tables; faster and fixed */ +#define LUA_USE_CTYPE 0 +#else +/* must use standard C ctype */ +#define LUA_USE_CTYPE 1 +#endif + +#endif + + +#if !LUA_USE_CTYPE /* { */ + +#include + +#include "llimits.h" + + +#define ALPHABIT 0 +#define DIGITBIT 1 +#define PRINTBIT 2 +#define SPACEBIT 3 +#define XDIGITBIT 4 + + +#define MASK(B) (1 << (B)) + + +/* +** add 1 to char to allow index -1 (EOZ) +*/ +#define testprop(c,p) (luai_ctype_[(c)+1] & (p)) + +/* +** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' +*/ +#define lislalpha(c) testprop(c, MASK(ALPHABIT)) +#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) +#define lisdigit(c) testprop(c, MASK(DIGITBIT)) +#define lisspace(c) testprop(c, MASK(SPACEBIT)) +#define lisprint(c) testprop(c, MASK(PRINTBIT)) +#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) + +/* +** this 'ltolower' only works for alphabetic characters +*/ +#define ltolower(c) ((c) | ('A' ^ 'a')) + + +/* two more entries for 0 and -1 (EOZ) */ +LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; + + +#else /* }{ */ + +/* +** use standard C ctypes +*/ + +#include + + +#define lislalpha(c) (isalpha(c) || (c) == '_') +#define lislalnum(c) (isalnum(c) || (c) == '_') +#define lisdigit(c) (isdigit(c)) +#define lisspace(c) (isspace(c)) +#define lisprint(c) (isprint(c)) +#define lisxdigit(c) (isxdigit(c)) + +#define ltolower(c) (tolower(c)) + +#endif /* } */ + +#endif + diff --git a/src/mod/languages/mod_lua/lua/ldblib.c b/src/mod/languages/mod_lua/lua/ldblib.c index 67de1222a9..c022694573 100644 --- a/src/mod/languages/mod_lua/lua/ldblib.c +++ b/src/mod/languages/mod_lua/lua/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -18,6 +18,9 @@ #include "lualib.h" +#define HOOKKEY "_HKEY" + + static int db_getregistry (lua_State *L) { lua_pushvalue(L, LUA_REGISTRYINDEX); @@ -39,23 +42,28 @@ static int db_setmetatable (lua_State *L) { luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); lua_settop(L, 2); - lua_pushboolean(L, lua_setmetatable(L, 1)); + lua_setmetatable(L, 1); + return 1; /* return 1st argument */ +} + + +static int db_getuservalue (lua_State *L) { + if (lua_type(L, 1) != LUA_TUSERDATA) + lua_pushnil(L); + else + lua_getuservalue(L, 1); return 1; } -static int db_getfenv (lua_State *L) { - lua_getfenv(L, 1); - return 1; -} - - -static int db_setfenv (lua_State *L) { - luaL_checktype(L, 2, LUA_TTABLE); +static int db_setuservalue (lua_State *L) { + if (lua_type(L, 1) == LUA_TLIGHTUSERDATA) + luaL_argerror(L, 1, "full userdata expected, got light userdata"); + luaL_checktype(L, 1, LUA_TUSERDATA); + if (!lua_isnoneornil(L, 2)) + luaL_checktype(L, 2, LUA_TTABLE); lua_settop(L, 2); - if (lua_setfenv(L, 1) == 0) - luaL_error(L, LUA_QL("setfenv") - " cannot change environment of given object"); + lua_setuservalue(L, 1); return 1; } @@ -72,6 +80,12 @@ static void settabsi (lua_State *L, const char *i, int v) { } +static void settabsb (lua_State *L, const char *i, int v) { + lua_pushboolean(L, v); + lua_setfield(L, -2, i); +} + + static lua_State *getthread (lua_State *L, int *arg) { if (lua_isthread(L, 1)) { *arg = 1; @@ -99,7 +113,7 @@ static int db_getinfo (lua_State *L) { lua_Debug ar; int arg; lua_State *L1 = getthread(L, &arg); - const char *options = luaL_optstring(L, arg+2, "flnSu"); + const char *options = luaL_optstring(L, arg+2, "flnStu"); if (lua_isnumber(L, arg+1)) { if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { lua_pushnil(L); /* level out of range */ @@ -126,38 +140,51 @@ static int db_getinfo (lua_State *L) { } if (strchr(options, 'l')) settabsi(L, "currentline", ar.currentline); - if (strchr(options, 'u')) + if (strchr(options, 'u')) { settabsi(L, "nups", ar.nups); + settabsi(L, "nparams", ar.nparams); + settabsb(L, "isvararg", ar.isvararg); + } if (strchr(options, 'n')) { settabss(L, "name", ar.name); settabss(L, "namewhat", ar.namewhat); } + if (strchr(options, 't')) + settabsb(L, "istailcall", ar.istailcall); if (strchr(options, 'L')) treatstackoption(L, L1, "activelines"); if (strchr(options, 'f')) treatstackoption(L, L1, "func"); return 1; /* return table */ } - + static int db_getlocal (lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); lua_Debug ar; const char *name; - if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); - name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); - if (name) { - lua_xmove(L1, L, 1); - lua_pushstring(L, name); - lua_pushvalue(L, -2); - return 2; - } - else { - lua_pushnil(L); + int nvar = luaL_checkint(L, arg+2); /* local-variable index */ + if (lua_isfunction(L, arg + 1)) { /* function argument? */ + lua_pushvalue(L, arg + 1); /* push function */ + lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ return 1; } + else { /* stack-level argument */ + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, nvar); + if (name) { + lua_xmove(L1, L, 1); /* push local value */ + lua_pushstring(L, name); /* push name */ + lua_pushvalue(L, -2); /* re-order */ + return 2; + } + else { + lua_pushnil(L); /* no name (nor value) */ + return 1; + } + } } @@ -179,7 +206,6 @@ static int auxupvalue (lua_State *L, int get) { const char *name; int n = luaL_checkint(L, 2); luaL_checktype(L, 1, LUA_TFUNCTION); - if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); if (name == NULL) return 0; lua_pushstring(L, name); @@ -199,16 +225,42 @@ static int db_setupvalue (lua_State *L) { } +static int checkupval (lua_State *L, int argf, int argnup) { + lua_Debug ar; + int nup = luaL_checkint(L, argnup); + luaL_checktype(L, argf, LUA_TFUNCTION); + lua_pushvalue(L, argf); + lua_getinfo(L, ">u", &ar); + luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index"); + return nup; +} -static const char KEY_HOOK = 'h'; + +static int db_upvalueid (lua_State *L) { + int n = checkupval(L, 1, 2); + lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); + return 1; +} + + +static int db_upvaluejoin (lua_State *L) { + int n1 = checkupval(L, 1, 2); + int n2 = checkupval(L, 3, 4); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); + lua_upvaluejoin(L, 1, n1, 3, n2); + return 0; +} + + +#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY) static void hookf (lua_State *L, lua_Debug *ar) { static const char *const hooknames[] = - {"call", "return", "line", "count", "tail return"}; - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - lua_pushlightuserdata(L, L); + {"call", "return", "line", "count", "tail call"}; + gethooktable(L); + lua_pushthread(L); lua_rawget(L, -2); if (lua_isfunction(L, -1)) { lua_pushstring(L, hooknames[(int)ar->event]); @@ -241,19 +293,6 @@ static char *unmakemask (int mask, char *smask) { } -static void gethooktable (lua_State *L) { - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - lua_createtable(L, 0, 1); - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_pushvalue(L, -2); - lua_rawset(L, LUA_REGISTRYINDEX); - } -} - - static int db_sethook (lua_State *L) { int arg, mask, count; lua_Hook func; @@ -268,11 +307,15 @@ static int db_sethook (lua_State *L) { count = luaL_optint(L, arg+3, 0); func = hookf; mask = makemask(smask, count); } - gethooktable(L); - lua_pushlightuserdata(L, L1); + if (gethooktable(L) == 0) { /* creating hook table? */ + lua_pushstring(L, "k"); + lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ + lua_pushvalue(L, -1); + lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ + } + lua_pushthread(L1); lua_xmove(L1, L, 1); lua_pushvalue(L, arg+1); lua_rawset(L, -3); /* set new hook */ - lua_pop(L, 1); /* remove hook table */ lua_sethook(L1, func, mask, count); /* set hooks */ return 0; } @@ -288,7 +331,7 @@ static int db_gethook (lua_State *L) { lua_pushliteral(L, "external hook"); else { gethooktable(L); - lua_pushlightuserdata(L, L1); + lua_pushthread(L1); lua_xmove(L1, L, 1); lua_rawget(L, -2); /* get hook */ lua_remove(L, -2); /* remove hook table */ } @@ -301,97 +344,55 @@ static int db_gethook (lua_State *L) { static int db_debug (lua_State *L) { for (;;) { char buffer[250]; - fputs("lua_debug> ", stderr); + luai_writestringerror("%s", "lua_debug> "); if (fgets(buffer, sizeof(buffer), stdin) == 0 || strcmp(buffer, "cont\n") == 0) return 0; if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || - lua_pcall(L, 0, 0, 0)) { - fputs(lua_tostring(L, -1), stderr); - fputs("\n", stderr); - } + lua_pcall(L, 0, 0, 0)) + luai_writestringerror("%s\n", lua_tostring(L, -1)); lua_settop(L, 0); /* remove eventual returns */ } } -#define LEVELS1 12 /* size of the first part of the stack */ -#define LEVELS2 10 /* size of the second part of the stack */ - -static int db_errorfb (lua_State *L) { - int level; - int firstpart = 1; /* still before eventual `...' */ +static int db_traceback (lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - if (lua_isnumber(L, arg+2)) { - level = (int)lua_tointeger(L, arg+2); - lua_pop(L, 1); + const char *msg = lua_tostring(L, arg + 1); + if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ + lua_pushvalue(L, arg + 1); /* return it untouched */ + else { + int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0); + luaL_traceback(L, L1, msg, level); } - else - level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ - if (lua_gettop(L) == arg) - lua_pushliteral(L, ""); - else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ - else lua_pushliteral(L, "\n"); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L1, level++, &ar)) { - if (level > LEVELS1 && firstpart) { - /* no more than `LEVELS2' more levels? */ - if (!lua_getstack(L1, level+LEVELS2, &ar)) - level--; /* keep going */ - else { - lua_pushliteral(L, "\n\t..."); /* too many levels */ - while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ - level++; - } - firstpart = 0; - continue; - } - lua_pushliteral(L, "\n\t"); - lua_getinfo(L1, "Snl", &ar); - lua_pushfstring(L, "%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - if (*ar.namewhat != '\0') /* is there a name? */ - lua_pushfstring(L, " in function " LUA_QS, ar.name); - else { - if (*ar.what == 'm') /* main? */ - lua_pushfstring(L, " in main chunk"); - else if (*ar.what == 'C' || *ar.what == 't') - lua_pushliteral(L, " ?"); /* C function or tail call */ - else - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); - } - lua_concat(L, lua_gettop(L) - arg); - } - lua_concat(L, lua_gettop(L) - arg); return 1; } static const luaL_Reg dblib[] = { {"debug", db_debug}, - {"getfenv", db_getfenv}, + {"getuservalue", db_getuservalue}, {"gethook", db_gethook}, {"getinfo", db_getinfo}, {"getlocal", db_getlocal}, {"getregistry", db_getregistry}, {"getmetatable", db_getmetatable}, {"getupvalue", db_getupvalue}, - {"setfenv", db_setfenv}, + {"upvaluejoin", db_upvaluejoin}, + {"upvalueid", db_upvalueid}, + {"setuservalue", db_setuservalue}, {"sethook", db_sethook}, {"setlocal", db_setlocal}, {"setmetatable", db_setmetatable}, {"setupvalue", db_setupvalue}, - {"traceback", db_errorfb}, + {"traceback", db_traceback}, {NULL, NULL} }; -LUALIB_API int luaopen_debug (lua_State *L) { - luaL_register(L, LUA_DBLIBNAME, dblib); +LUAMOD_API int luaopen_debug (lua_State *L) { + luaL_newlib(L, dblib); return 1; } diff --git a/src/mod/languages/mod_lua/lua/ldebug.c b/src/mod/languages/mod_lua/lua/ldebug.c index 50ad3d3803..7e04f9d09f 100644 --- a/src/mod/languages/mod_lua/lua/ldebug.c +++ b/src/mod/languages/mod_lua/lua/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** $Id: ldebug.c,v 2.90 2012/08/16 17:34:28 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -30,23 +30,20 @@ +#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) + + static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); -static int currentpc (lua_State *L, CallInfo *ci) { - if (!isLua(ci)) return -1; /* function is not a Lua function? */ - if (ci == L->ci) - ci->savedpc = L->savedpc; - return pcRel(ci->savedpc, ci_func(ci)->l.p); +static int currentpc (CallInfo *ci) { + lua_assert(isLua(ci)); + return pcRel(ci->u.l.savedpc, ci_func(ci)->p); } -static int currentline (lua_State *L, CallInfo *ci) { - int pc = currentpc(L, ci); - if (pc < 0) - return -1; /* only active lua functions have current-line information */ - else - return getline(ci_func(ci)->l.p, pc); +static int currentline (CallInfo *ci) { + return getfuncline(ci_func(ci)->p, currentpc(ci)); } @@ -58,6 +55,8 @@ LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { mask = 0; func = NULL; } + if (isLua(L->ci)) + L->oldpc = L->ci->u.l.savedpc; L->hook = func; L->basehookcount = count; resethookcount(L); @@ -84,19 +83,13 @@ LUA_API int lua_gethookcount (lua_State *L) { LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { int status; CallInfo *ci; + if (level < 0) return 0; /* invalid (negative) level */ lua_lock(L); - for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous) level--; - if (f_isLua(ci)) /* Lua function? */ - level -= ci->tailcalls; /* skip lost tail calls */ - } - if (level == 0 && ci > L->base_ci) { /* level found? */ + if (level == 0 && ci != &L->base_ci) { /* level found? */ status = 1; - ar->i_ci = cast_int(ci - L->base_ci); - } - else if (level < 0) { /* level is of a lost tail call? */ - status = 1; - ar->i_ci = 0; + ar->i_ci = ci; } else status = 0; /* no such level */ lua_unlock(L); @@ -104,43 +97,78 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { } -static Proto *getluaproto (CallInfo *ci) { - return (isLua(ci) ? ci_func(ci)->l.p : NULL); +static const char *upvalname (Proto *p, int uv) { + TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); + if (s == NULL) return "?"; + else return getstr(s); } -static const char *findlocal (lua_State *L, CallInfo *ci, int n) { - const char *name; - Proto *fp = getluaproto(ci); - if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) - return name; /* is a local variable in a Lua function */ +static const char *findvararg (CallInfo *ci, int n, StkId *pos) { + int nparams = clLvalue(ci->func)->p->numparams; + if (n >= ci->u.l.base - ci->func - nparams) + return NULL; /* no such vararg */ else { - StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; - if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - return "(*temporary)"; - else - return NULL; + *pos = ci->func + nparams + n; + return "(*vararg)"; /* generic name for any vararg */ } } +static const char *findlocal (lua_State *L, CallInfo *ci, int n, + StkId *pos) { + const char *name = NULL; + StkId base; + if (isLua(ci)) { + if (n < 0) /* access to vararg values? */ + return findvararg(ci, -n, pos); + else { + base = ci->u.l.base; + name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); + } + } + else + base = ci->func + 1; + if (name == NULL) { /* no 'standard' name? */ + StkId limit = (ci == L->ci) ? L->top : ci->next->func; + if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + name = "(*temporary)"; /* generic name for any valid slot */ + else + return NULL; /* no name */ + } + *pos = base + (n - 1); + return name; +} + + LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { - CallInfo *ci = L->base_ci + ar->i_ci; - const char *name = findlocal(L, ci, n); + const char *name; lua_lock(L); - if (name) - luaA_pushobject(L, ci->base + (n - 1)); + if (ar == NULL) { /* information about non-active function? */ + if (!isLfunction(L->top - 1)) /* not a Lua function? */ + name = NULL; + else /* consider live variables at function start (parameters) */ + name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); + } + else { /* active function; get information through 'ar' */ + StkId pos = 0; /* to avoid warnings */ + name = findlocal(L, ar->i_ci, n, &pos); + if (name) { + setobj2s(L, L->top, pos); + api_incr_top(L); + } + } lua_unlock(L); return name; } LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { - CallInfo *ci = L->base_ci + ar->i_ci; - const char *name = findlocal(L, ci, n); + StkId pos = 0; /* to avoid warnings */ + const char *name = findlocal(L, ar->i_ci, n, &pos); lua_lock(L); if (name) - setobjs2s(L, ci->base + (n - 1), L->top - 1); + setobjs2s(L, pos, L->top - 1); L->top--; /* pop value */ lua_unlock(L); return name; @@ -148,55 +176,45 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { static void funcinfo (lua_Debug *ar, Closure *cl) { - if (cl->c.isC) { + if (noLuaClosure(cl)) { ar->source = "=[C]"; ar->linedefined = -1; ar->lastlinedefined = -1; ar->what = "C"; } else { - ar->source = getstr(cl->l.p->source); - ar->linedefined = cl->l.p->linedefined; - ar->lastlinedefined = cl->l.p->lastlinedefined; + Proto *p = cl->l.p; + ar->source = p->source ? getstr(p->source) : "=?"; + ar->linedefined = p->linedefined; + ar->lastlinedefined = p->lastlinedefined; ar->what = (ar->linedefined == 0) ? "main" : "Lua"; } luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); } -static void info_tailcall (lua_Debug *ar) { - ar->name = ar->namewhat = ""; - ar->what = "tail"; - ar->lastlinedefined = ar->linedefined = ar->currentline = -1; - ar->source = "=(tail call)"; - luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); - ar->nups = 0; -} - - static void collectvalidlines (lua_State *L, Closure *f) { - if (f == NULL || f->c.isC) { + if (noLuaClosure(f)) { setnilvalue(L->top); + api_incr_top(L); } else { - Table *t = luaH_new(L, 0, 0); - int *lineinfo = f->l.p->lineinfo; int i; - for (i=0; il.p->sizelineinfo; i++) - setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); - sethvalue(L, L->top, t); + TValue v; + int *lineinfo = f->l.p->lineinfo; + Table *t = luaH_new(L); /* new table to store active lines */ + sethvalue(L, L->top, t); /* push it on stack */ + api_incr_top(L); + setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ + for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ + luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ } - incr_top(L); } static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, - Closure *f, CallInfo *ci) { + Closure *f, CallInfo *ci) { int status = 1; - if (f == NULL) { - info_tailcall(ar); - return status; - } for (; *what; what++) { switch (*what) { case 'S': { @@ -204,15 +222,31 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, break; } case 'l': { - ar->currentline = (ci) ? currentline(L, ci) : -1; + ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; break; } case 'u': { - ar->nups = f->c.nupvalues; + ar->nups = (f == NULL) ? 0 : f->c.nupvalues; + if (noLuaClosure(f)) { + ar->isvararg = 1; + ar->nparams = 0; + } + else { + ar->isvararg = f->l.p->is_vararg; + ar->nparams = f->l.p->numparams; + } + break; + } + case 't': { + ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0; break; } case 'n': { - ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + /* calling function is a known Lua function? */ + if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) + ar->namewhat = getfuncname(L, ci->previous, &ar->name); + else + ar->namewhat = NULL; if (ar->namewhat == NULL) { ar->namewhat = ""; /* not found */ ar->name = NULL; @@ -231,29 +265,30 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { int status; - Closure *f = NULL; - CallInfo *ci = NULL; + Closure *cl; + CallInfo *ci; + StkId func; lua_lock(L); if (*what == '>') { - StkId func = L->top - 1; - luai_apicheck(L, ttisfunction(func)); + ci = NULL; + func = L->top - 1; + api_check(L, ttisfunction(func), "function expected"); what++; /* skip the '>' */ - f = clvalue(func); L->top--; /* pop function */ } - else if (ar->i_ci != 0) { /* no tail call? */ - ci = L->base_ci + ar->i_ci; + else { + ci = ar->i_ci; + func = ci->func; lua_assert(ttisfunction(ci->func)); - f = clvalue(ci->func); } - status = auxgetinfo(L, what, ar, f, ci); + cl = ttisclosure(func) ? clvalue(func) : NULL; + status = auxgetinfo(L, what, ar, cl, ci); if (strchr(what, 'f')) { - if (f == NULL) setnilvalue(L->top); - else setclvalue(L, L->top, f); - incr_top(L); + setobjs2s(L, L->top, func); + api_incr_top(L); } if (strchr(what, 'L')) - collectvalidlines(L, f); + collectvalidlines(L, cl); lua_unlock(L); return status; } @@ -261,315 +296,218 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { /* ** {====================================================== -** Symbolic Execution and code checker +** Symbolic Execution ** ======================================================= */ -#define check(x) if (!(x)) return 0; - -#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) - -#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) +static const char *getobjname (Proto *p, int lastpc, int reg, + const char **name); - -static int precheck (const Proto *pt) { - check(pt->maxstacksize <= MAXSTACK); - check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); - check(!(pt->is_vararg & VARARG_NEEDSARG) || - (pt->is_vararg & VARARG_HASARG)); - check(pt->sizeupvalues <= pt->nups); - check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); - check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); - return 1; -} - - -#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) - -int luaG_checkopenop (Instruction i) { - switch (GET_OPCODE(i)) { - case OP_CALL: - case OP_TAILCALL: - case OP_RETURN: - case OP_SETLIST: { - check(GETARG_B(i) == 0); - return 1; +/* +** find a "name" for the RK value 'c' +*/ +static void kname (Proto *p, int pc, int c, const char **name) { + if (ISK(c)) { /* is 'c' a constant? */ + TValue *kvalue = &p->k[INDEXK(c)]; + if (ttisstring(kvalue)) { /* literal constant? */ + *name = svalue(kvalue); /* it is its own name */ + return; } - default: return 0; /* invalid instruction after an open call */ + /* else no reasonable name found */ } + else { /* 'c' is a register */ + const char *what = getobjname(p, pc, c, name); /* search for 'c' */ + if (what && *what == 'c') { /* found a constant name? */ + return; /* 'name' already filled */ + } + /* else no reasonable name found */ + } + *name = "?"; /* no reasonable name found */ } -static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { - switch (mode) { - case OpArgN: check(r == 0); break; - case OpArgU: break; - case OpArgR: checkreg(pt, r); break; - case OpArgK: - check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); - break; - } - return 1; -} - - -static Instruction symbexec (const Proto *pt, int lastpc, int reg) { +/* +** try to find last instruction before 'lastpc' that modified register 'reg' +*/ +static int findsetreg (Proto *p, int lastpc, int reg) { int pc; - int last; /* stores position of last instruction that changed `reg' */ - last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ - check(precheck(pt)); + int setreg = -1; /* keep last instruction that changed 'reg' */ for (pc = 0; pc < lastpc; pc++) { - Instruction i = pt->code[pc]; + Instruction i = p->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); - int b = 0; - int c = 0; - check(op < NUM_OPCODES); - checkreg(pt, a); - switch (getOpMode(op)) { - case iABC: { - b = GETARG_B(i); - c = GETARG_C(i); - check(checkArgMode(pt, b, getBMode(op))); - check(checkArgMode(pt, c, getCMode(op))); - break; - } - case iABx: { - b = GETARG_Bx(i); - if (getBMode(op) == OpArgK) check(b < pt->sizek); - break; - } - case iAsBx: { - b = GETARG_sBx(i); - if (getBMode(op) == OpArgR) { - int dest = pc+1+b; - check(0 <= dest && dest < pt->sizecode); - if (dest > 0) { - int j; - /* check that it does not jump to a setlist count; this - is tricky, because the count from a previous setlist may - have the same value of an invalid setlist; so, we must - go all the way back to the first of them (if any) */ - for (j = 0; j < dest; j++) { - Instruction d = pt->code[dest-1-j]; - if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; - } - /* if 'j' is even, previous value is not a setlist (even if - it looks like one) */ - check((j&1) == 0); - } - } - break; - } - } - if (testAMode(op)) { - if (a == reg) last = pc; /* change register `a' */ - } - if (testTMode(op)) { - check(pc+2 < pt->sizecode); /* check skip */ - check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); - } switch (op) { - case OP_LOADBOOL: { - if (c == 1) { /* does it jump? */ - check(pc+2 < pt->sizecode); /* check its jump */ - check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || - GETARG_C(pt->code[pc+1]) != 0); - } - break; - } case OP_LOADNIL: { - if (a <= reg && reg <= b) - last = pc; /* set registers from `a' to `b' */ + int b = GETARG_B(i); + if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ + setreg = pc; break; } - case OP_GETUPVAL: - case OP_SETUPVAL: { - check(b < pt->nups); - break; - } - case OP_GETGLOBAL: - case OP_SETGLOBAL: { - check(ttisstring(&pt->k[b])); - break; - } - case OP_SELF: { - checkreg(pt, a+1); - if (reg == a+1) last = pc; - break; - } - case OP_CONCAT: { - check(b < c); /* at least two operands */ - break; - } - case OP_TFORLOOP: { - check(c >= 1); /* at least one result (control variable) */ - checkreg(pt, a+2+c); /* space for results */ - if (reg >= a+2) last = pc; /* affect all regs above its base */ - break; - } - case OP_FORLOOP: - case OP_FORPREP: - checkreg(pt, a+3); - /* go through */ - case OP_JMP: { - int dest = pc+1+b; - /* not full check and jump is forward and do not skip `lastpc'? */ - if (reg != NO_REG && pc < dest && dest <= lastpc) - pc += b; /* do the jump */ + case OP_TFORCALL: { + if (reg >= a + 2) setreg = pc; /* affect all regs above its base */ break; } case OP_CALL: case OP_TAILCALL: { - if (b != 0) { - checkreg(pt, a+b-1); - } - c--; /* c = num. returns */ - if (c == LUA_MULTRET) { - check(checkopenop(pt, pc)); - } - else if (c != 0) - checkreg(pt, a+c-1); - if (reg >= a) last = pc; /* affect all registers above base */ + if (reg >= a) setreg = pc; /* affect all registers above base */ break; } - case OP_RETURN: { - b--; /* b = num. returns */ - if (b > 0) checkreg(pt, a+b-1); + case OP_JMP: { + int b = GETARG_sBx(i); + int dest = pc + 1 + b; + /* jump is forward and do not skip `lastpc'? */ + if (pc < dest && dest <= lastpc) + pc += b; /* do the jump */ break; } - case OP_SETLIST: { - if (b > 0) checkreg(pt, a + b); - if (c == 0) { - pc++; - check(pc < pt->sizecode - 1); - } + case OP_TEST: { + if (reg == a) setreg = pc; /* jumped code can change 'a' */ break; } - case OP_CLOSURE: { - int nup, j; - check(b < pt->sizep); - nup = pt->p[b]->nups; - check(pc + nup < pt->sizecode); - for (j = 1; j <= nup; j++) { - OpCode op1 = GET_OPCODE(pt->code[pc + j]); - check(op1 == OP_GETUPVAL || op1 == OP_MOVE); - } - if (reg != NO_REG) /* tracing? */ - pc += nup; /* do not 'execute' these pseudo-instructions */ + default: + if (testAMode(op) && reg == a) /* any instruction that set A */ + setreg = pc; break; - } - case OP_VARARG: { - check((pt->is_vararg & VARARG_ISVARARG) && - !(pt->is_vararg & VARARG_NEEDSARG)); - b--; - if (b == LUA_MULTRET) check(checkopenop(pt, pc)); - checkreg(pt, a+b-1); - break; - } - default: break; } } - return pt->code[last]; -} - -#undef check -#undef checkjump -#undef checkreg - -/* }====================================================== */ - - -int luaG_checkcode (const Proto *pt) { - return (symbexec(pt, pt->sizecode, NO_REG) != 0); + return setreg; } -static const char *kname (Proto *p, int c) { - if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) - return svalue(&p->k[INDEXK(c)]); - else - return "?"; -} - - -static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, +static const char *getobjname (Proto *p, int lastpc, int reg, const char **name) { - if (isLua(ci)) { /* a Lua function? */ - Proto *p = ci_func(ci)->l.p; - int pc = currentpc(L, ci); - Instruction i; - *name = luaF_getlocalname(p, stackpos+1, pc); - if (*name) /* is a local? */ - return "local"; - i = symbexec(p, pc, stackpos); /* try symbolic execution */ - lua_assert(pc != -1); - switch (GET_OPCODE(i)) { - case OP_GETGLOBAL: { - int g = GETARG_Bx(i); /* global index */ - lua_assert(ttisstring(&p->k[g])); - *name = svalue(&p->k[g]); - return "global"; - } + int pc; + *name = luaF_getlocalname(p, reg + 1, lastpc); + if (*name) /* is a local? */ + return "local"; + /* else try symbolic execution */ + pc = findsetreg(p, lastpc, reg); + if (pc != -1) { /* could find instruction? */ + Instruction i = p->code[pc]; + OpCode op = GET_OPCODE(i); + switch (op) { case OP_MOVE: { - int a = GETARG_A(i); - int b = GETARG_B(i); /* move from `b' to `a' */ - if (b < a) - return getobjname(L, ci, b, name); /* get name for `b' */ + int b = GETARG_B(i); /* move from 'b' to 'a' */ + if (b < GETARG_A(i)) + return getobjname(p, pc, b, name); /* get name for 'b' */ break; } + case OP_GETTABUP: case OP_GETTABLE: { int k = GETARG_C(i); /* key index */ - *name = kname(p, k); - return "field"; + int t = GETARG_B(i); /* table index */ + const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ + ? luaF_getlocalname(p, t + 1, pc) + : upvalname(p, t); + kname(p, pc, k, name); + return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; } case OP_GETUPVAL: { - int u = GETARG_B(i); /* upvalue index */ - *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + *name = upvalname(p, GETARG_B(i)); return "upvalue"; } + case OP_LOADK: + case OP_LOADKX: { + int b = (op == OP_LOADK) ? GETARG_Bx(i) + : GETARG_Ax(p->code[pc + 1]); + if (ttisstring(&p->k[b])) { + *name = svalue(&p->k[b]); + return "constant"; + } + break; + } case OP_SELF: { int k = GETARG_C(i); /* key index */ - *name = kname(p, k); + kname(p, pc, k, name); return "method"; } - default: break; + default: break; /* go through to return NULL */ } } - return NULL; /* no useful name found */ + return NULL; /* could not find reasonable name */ } static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { - Instruction i; - if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) - return NULL; /* calling function is not Lua (or is unknown) */ - ci--; /* calling function */ - i = ci_func(ci)->l.p->code[currentpc(L, ci)]; - if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || - GET_OPCODE(i) == OP_TFORLOOP) - return getobjname(L, ci, GETARG_A(i), name); - else - return NULL; /* no useful name can be found */ + TMS tm; + Proto *p = ci_func(ci)->p; /* calling function */ + int pc = currentpc(ci); /* calling instruction index */ + Instruction i = p->code[pc]; /* calling instruction */ + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: /* get function name */ + return getobjname(p, pc, GETARG_A(i), name); + case OP_TFORCALL: { /* for iterator */ + *name = "for iterator"; + return "for iterator"; + } + /* all other instructions can call only through metamethods */ + case OP_SELF: + case OP_GETTABUP: + case OP_GETTABLE: tm = TM_INDEX; break; + case OP_SETTABUP: + case OP_SETTABLE: tm = TM_NEWINDEX; break; + case OP_EQ: tm = TM_EQ; break; + case OP_ADD: tm = TM_ADD; break; + case OP_SUB: tm = TM_SUB; break; + case OP_MUL: tm = TM_MUL; break; + case OP_DIV: tm = TM_DIV; break; + case OP_MOD: tm = TM_MOD; break; + case OP_POW: tm = TM_POW; break; + case OP_UNM: tm = TM_UNM; break; + case OP_LEN: tm = TM_LEN; break; + case OP_LT: tm = TM_LT; break; + case OP_LE: tm = TM_LE; break; + case OP_CONCAT: tm = TM_CONCAT; break; + default: + return NULL; /* else no useful name can be found */ + } + *name = getstr(G(L)->tmname[tm]); + return "metamethod"; } +/* }====================================================== */ -/* only ANSI way to check whether a pointer points to an array */ + + +/* +** only ANSI way to check whether a pointer points to an array +** (used only for error messages, so efficiency is not a big concern) +*/ static int isinstack (CallInfo *ci, const TValue *o) { StkId p; - for (p = ci->base; p < ci->top; p++) + for (p = ci->u.l.base; p < ci->top; p++) if (o == p) return 1; return 0; } -void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { +static const char *getupvalname (CallInfo *ci, const TValue *o, + const char **name) { + LClosure *c = ci_func(ci); + int i; + for (i = 0; i < c->nupvalues; i++) { + if (c->upvals[i]->v == o) { + *name = upvalname(c->p, i); + return "upvalue"; + } + } + return NULL; +} + + +l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + CallInfo *ci = L->ci; const char *name = NULL; - const char *t = luaT_typenames[ttype(o)]; - const char *kind = (isinstack(L->ci, o)) ? - getobjname(L, L->ci, cast_int(o - L->base), &name) : - NULL; + const char *t = objtypename(o); + const char *kind = NULL; + if (isLua(ci)) { + kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ + if (!kind && isinstack(ci, o)) /* no? try a register */ + kind = getobjname(ci_func(ci)->p, currentpc(ci), + cast_int(o - ci->u.l.base), &name); + } if (kind) luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", op, kind, name, t); @@ -578,14 +516,14 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { } -void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { +l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2) { if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; - lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + lua_assert(!ttisstring(p1) && !ttisnumber(p2)); luaG_typeerror(L, p1, "concatenate"); } -void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { +l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { TValue temp; if (luaV_tonumber(p1, &temp) == NULL) p2 = p1; /* first operand is wrong */ @@ -593,14 +531,13 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { } -int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { - const char *t1 = luaT_typenames[ttype(p1)]; - const char *t2 = luaT_typenames[ttype(p2)]; - if (t1[2] == t2[2]) +l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = objtypename(p1); + const char *t2 = objtypename(p2); + if (t1 == t2) luaG_runerror(L, "attempt to compare two %s values", t1); else luaG_runerror(L, "attempt to compare %s with %s", t1, t2); - return 0; } @@ -608,27 +545,32 @@ static void addinfo (lua_State *L, const char *msg) { CallInfo *ci = L->ci; if (isLua(ci)) { /* is Lua code? */ char buff[LUA_IDSIZE]; /* add file:line information */ - int line = currentline(L, ci); - luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + int line = currentline(ci); + TString *src = ci_func(ci)->p->source; + if (src) + luaO_chunkid(buff, getstr(src), LUA_IDSIZE); + else { /* no source available; use "?" instead */ + buff[0] = '?'; buff[1] = '\0'; + } luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); } } -void luaG_errormsg (lua_State *L) { +l_noret luaG_errormsg (lua_State *L) { if (L->errfunc != 0) { /* is there an error handling function? */ StkId errfunc = restorestack(L, L->errfunc); if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); setobjs2s(L, L->top, L->top - 1); /* move argument */ setobjs2s(L, L->top - 1, errfunc); /* push function */ - incr_top(L); - luaD_call(L, L->top - 2, 1); /* call it */ + L->top++; + luaD_call(L, L->top - 2, 1, 0); /* call it */ } luaD_throw(L, LUA_ERRRUN); } -void luaG_runerror (lua_State *L, const char *fmt, ...) { +l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { va_list argp; va_start(argp, fmt); addinfo(L, luaO_pushvfstring(L, fmt, argp)); diff --git a/src/mod/languages/mod_lua/lua/ldebug.h b/src/mod/languages/mod_lua/lua/ldebug.h index ba28a97248..fe39556b06 100644 --- a/src/mod/languages/mod_lua/lua/ldebug.h +++ b/src/mod/languages/mod_lua/lua/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: ldebug.h,v 2.7 2011/10/07 20:45:19 roberto Exp $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ @@ -13,21 +13,22 @@ #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) -#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) +#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) #define resethookcount(L) (L->hookcount = L->basehookcount) +/* Active Lua function (given call info) */ +#define ci_func(ci) (clLvalue((ci)->func)) -LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, - const char *opname); -LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); -LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaG_errormsg (lua_State *L); -LUAI_FUNC int luaG_checkcode (const Proto *pt); -LUAI_FUNC int luaG_checkopenop (Instruction i); + +LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC l_noret luaG_errormsg (lua_State *L); #endif diff --git a/src/mod/languages/mod_lua/lua/ldo.c b/src/mod/languages/mod_lua/lua/ldo.c index 8de05f728e..aafa3dca23 100644 --- a/src/mod/languages/mod_lua/lua/ldo.c +++ b/src/mod/languages/mod_lua/lua/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** $Id: ldo.c,v 2.108 2012/10/01 14:05:04 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -14,6 +14,7 @@ #include "lua.h" +#include "lapi.h" #include "ldebug.h" #include "ldo.h" #include "lfunc.h" @@ -39,6 +40,38 @@ ** ======================================================= */ +/* +** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By +** default, Lua handles errors with exceptions when compiling as +** C++ code, with _longjmp/_setjmp when asked to use them, and with +** longjmp/setjmp otherwise. +*/ +#if !defined(LUAI_THROW) + +#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) \ + try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + +#endif + + /* chain list of long jump buffers */ struct lua_longjmp { @@ -48,18 +81,17 @@ struct lua_longjmp { }; -void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { +static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { switch (errcode) { - case LUA_ERRMEM: { - setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + case LUA_ERRMEM: { /* memory error? */ + setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ break; } case LUA_ERRERR: { setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); break; } - case LUA_ERRSYNTAX: - case LUA_ERRRUN: { + default: { setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ break; } @@ -68,55 +100,39 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { } -static void restore_stack_limit (lua_State *L) { - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); - if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ - int inuse = cast_int(L->ci - L->base_ci); - if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ - luaD_reallocCI(L, LUAI_MAXCALLS); +l_noret luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { /* thread has an error handler? */ + L->errorJmp->status = errcode; /* set status */ + LUAI_THROW(L, L->errorJmp); /* jump to it */ } -} - - -static void resetstack (lua_State *L, int status) { - L->ci = L->base_ci; - L->base = L->ci->base; - luaF_close(L, L->base); /* close eventual pending closures */ - luaD_seterrorobj(L, status, L->base); - L->nCcalls = L->baseCcalls; - L->allowhook = 1; - restore_stack_limit(L); - L->errfunc = 0; - L->errorJmp = NULL; -} - - -void luaD_throw (lua_State *L, int errcode) { - if (L->errorJmp) { - L->errorJmp->status = errcode; - LUAI_THROW(L, L->errorJmp); - } - else { - L->status = cast_byte(errcode); - if (G(L)->panic) { - resetstack(L, errcode); - lua_unlock(L); - G(L)->panic(L); + else { /* thread has no error handler */ + L->status = cast_byte(errcode); /* mark it as dead */ + if (G(L)->mainthread->errorJmp) { /* main thread has a handler? */ + setobjs2s(L, G(L)->mainthread->top++, L->top - 1); /* copy error obj. */ + luaD_throw(G(L)->mainthread, errcode); /* re-throw in main thread */ + } + else { /* no handler at all; abort */ + if (G(L)->panic) { /* panic function? */ + lua_unlock(L); + G(L)->panic(L); /* call it (last chance to jump out) */ + } + abort(); } - exit(EXIT_FAILURE); } } int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + unsigned short oldnCcalls = L->nCcalls; struct lua_longjmp lj; - lj.status = 0; + lj.status = LUA_OK; lj.previous = L->errorJmp; /* chain new error handler */ L->errorJmp = &lj; LUAI_TRY(L, &lj, (*f)(L, ud); ); L->errorJmp = lj.previous; /* restore old error handler */ + L->nCcalls = oldnCcalls; return lj.status; } @@ -129,112 +145,126 @@ static void correctstack (lua_State *L, TValue *oldstack) { L->top = (L->top - oldstack) + L->stack; for (up = L->openupval; up != NULL; up = up->gch.next) gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; - for (ci = L->base_ci; ci <= L->ci; ci++) { + for (ci = L->ci; ci != NULL; ci = ci->previous) { ci->top = (ci->top - oldstack) + L->stack; - ci->base = (ci->base - oldstack) + L->stack; ci->func = (ci->func - oldstack) + L->stack; + if (isLua(ci)) + ci->u.l.base = (ci->u.l.base - oldstack) + L->stack; } - L->base = (L->base - oldstack) + L->stack; } +/* some space for error handling */ +#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) + + void luaD_reallocstack (lua_State *L, int newsize) { TValue *oldstack = L->stack; - int realsize = newsize + 1 + EXTRA_STACK; - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); - luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); - L->stacksize = realsize; - L->stack_last = L->stack+newsize; + int lim = L->stacksize; + lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); + luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue); + for (; lim < newsize; lim++) + setnilvalue(L->stack + lim); /* erase new segment */ + L->stacksize = newsize; + L->stack_last = L->stack + newsize - EXTRA_STACK; correctstack(L, oldstack); } -void luaD_reallocCI (lua_State *L, int newsize) { - CallInfo *oldci = L->base_ci; - luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); - L->size_ci = newsize; - L->ci = (L->ci - oldci) + L->base_ci; - L->end_ci = L->base_ci + L->size_ci - 1; -} - - void luaD_growstack (lua_State *L, int n) { - if (n <= L->stacksize) /* double size is enough? */ - luaD_reallocstack(L, 2*L->stacksize); - else - luaD_reallocstack(L, L->stacksize + n); -} - - -static CallInfo *growCI (lua_State *L) { - if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + int size = L->stacksize; + if (size > LUAI_MAXSTACK) /* error after extra size? */ luaD_throw(L, LUA_ERRERR); else { - luaD_reallocCI(L, 2*L->size_ci); - if (L->size_ci > LUAI_MAXCALLS) + int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; + int newsize = 2 * size; + if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; + if (newsize < needed) newsize = needed; + if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ + luaD_reallocstack(L, ERRORSTACKSIZE); luaG_runerror(L, "stack overflow"); + } + else + luaD_reallocstack(L, newsize); } - return ++L->ci; } -void luaD_callhook (lua_State *L, int event, int line) { +static int stackinuse (lua_State *L) { + CallInfo *ci; + StkId lim = L->top; + for (ci = L->ci; ci != NULL; ci = ci->previous) { + lua_assert(ci->top <= L->stack_last); + if (lim < ci->top) lim = ci->top; + } + return cast_int(lim - L->stack) + 1; /* part of stack in use */ +} + + +void luaD_shrinkstack (lua_State *L) { + int inuse = stackinuse(L); + int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; + if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK; + if (inuse > LUAI_MAXSTACK || /* handling stack overflow? */ + goodsize >= L->stacksize) /* would grow instead of shrink? */ + condmovestack(L); /* don't change stack (change only for debugging) */ + else + luaD_reallocstack(L, goodsize); /* shrink it */ +} + + +void luaD_hook (lua_State *L, int event, int line) { lua_Hook hook = L->hook; if (hook && L->allowhook) { + CallInfo *ci = L->ci; ptrdiff_t top = savestack(L, L->top); - ptrdiff_t ci_top = savestack(L, L->ci->top); + ptrdiff_t ci_top = savestack(L, ci->top); lua_Debug ar; ar.event = event; ar.currentline = line; - if (event == LUA_HOOKTAILRET) - ar.i_ci = 0; /* tail call; no debug information about it */ - else - ar.i_ci = cast_int(L->ci - L->base_ci); + ar.i_ci = ci; luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - L->ci->top = L->top + LUA_MINSTACK; - lua_assert(L->ci->top <= L->stack_last); + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); L->allowhook = 0; /* cannot call hooks inside a hook */ + ci->callstatus |= CIST_HOOKED; lua_unlock(L); (*hook)(L, &ar); lua_lock(L); lua_assert(!L->allowhook); L->allowhook = 1; - L->ci->top = restorestack(L, ci_top); + ci->top = restorestack(L, ci_top); L->top = restorestack(L, top); + ci->callstatus &= ~CIST_HOOKED; } } +static void callhook (lua_State *L, CallInfo *ci) { + int hook = LUA_HOOKCALL; + ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ + if (isLua(ci->previous) && + GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) { + ci->callstatus |= CIST_TAIL; + hook = LUA_HOOKTAILCALL; + } + luaD_hook(L, hook, -1); + ci->u.l.savedpc--; /* correct 'pc' */ +} + + static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { int i; int nfixargs = p->numparams; - Table *htab = NULL; StkId base, fixed; - for (; actual < nfixargs; ++actual) - setnilvalue(L->top++); -#if defined(LUA_COMPAT_VARARG) - if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ - int nvar = actual - nfixargs; /* number of extra arguments */ - lua_assert(p->is_vararg & VARARG_HASARG); - luaC_checkGC(L); - htab = luaH_new(L, nvar, 1); /* create `arg' table */ - for (i=0; itop - nvar + i); - /* store counter in field `n' */ - setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); - } -#endif + lua_assert(actual >= nfixargs); /* move fixed parameters to final position */ fixed = L->top - actual; /* first fixed argument */ base = L->top; /* final position of first argument */ for (i=0; itop++, fixed+i); - setnilvalue(fixed+i); - } - /* add `arg' parameter */ - if (htab) { - sethvalue(L, L->top++, htab); - lua_assert(iswhite(obj2gco(htab))); + setobjs2s(L, L->top++, fixed + i); + setnilvalue(fixed + i); } return base; } @@ -256,100 +286,87 @@ static StkId tryfuncTM (lua_State *L, StkId func) { -#define inc_ci(L) \ - ((L->ci == L->end_ci) ? growCI(L) : \ - (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) +#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) +/* +** returns true if function has been executed (C function) +*/ int luaD_precall (lua_State *L, StkId func, int nresults) { - LClosure *cl; - ptrdiff_t funcr; - if (!ttisfunction(func)) /* `func' is not a function? */ - func = tryfuncTM(L, func); /* check the `function' tag method */ - funcr = savestack(L, func); - cl = &clvalue(func)->l; - L->ci->savedpc = L->savedpc; - if (!cl->isC) { /* Lua function? prepare its call */ - CallInfo *ci; - StkId st, base; - Proto *p = cl->p; - luaD_checkstack(L, p->maxstacksize); - func = restorestack(L, funcr); - if (!p->is_vararg) { /* no varargs? */ - base = func + 1; - if (L->top > base + p->numparams) - L->top = base + p->numparams; - } - else { /* vararg function */ - int nargs = cast_int(L->top - func) - 1; - base = adjust_varargs(L, p, nargs); - func = restorestack(L, funcr); /* previous call may change the stack */ - } - ci = inc_ci(L); /* now `enter' new function */ - ci->func = func; - L->base = ci->base = base; - ci->top = L->base + p->maxstacksize; - lua_assert(ci->top <= L->stack_last); - L->savedpc = p->code; /* starting point */ - ci->tailcalls = 0; - ci->nresults = nresults; - for (st = L->top; st < ci->top; st++) - setnilvalue(st); - L->top = ci->top; - if (L->hookmask & LUA_MASKCALL) { - L->savedpc++; /* hooks assume 'pc' is already incremented */ - luaD_callhook(L, LUA_HOOKCALL, -1); - L->savedpc--; /* correct 'pc' */ - } - return PCRLUA; - } - else { /* if is a C function, call it */ - CallInfo *ci; - int n; - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci = inc_ci(L); /* now `enter' new function */ - ci->func = restorestack(L, funcr); - L->base = ci->base = ci->func + 1; - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); - ci->nresults = nresults; - if (L->hookmask & LUA_MASKCALL) - luaD_callhook(L, LUA_HOOKCALL, -1); - lua_unlock(L); - n = (*curr_func(L)->c.f)(L); /* do the actual call */ - lua_lock(L); - if (n < 0) /* yielding? */ - return PCRYIELD; - else { + lua_CFunction f; + CallInfo *ci; + int n; /* number of arguments (Lua) or returns (C) */ + ptrdiff_t funcr = savestack(L, func); + switch (ttype(func)) { + case LUA_TLCF: /* light C function */ + f = fvalue(func); + goto Cfunc; + case LUA_TCCL: { /* C closure */ + f = clCvalue(func)->f; + Cfunc: + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = restorestack(L, funcr); + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->callstatus = 0; + luaC_checkGC(L); /* stack grow uses memory */ + if (L->hookmask & LUA_MASKCALL) + luaD_hook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*f)(L); /* do the actual call */ + lua_lock(L); + api_checknelems(L, n); luaD_poscall(L, L->top - n); - return PCRC; + return 1; + } + case LUA_TLCL: { /* Lua function: prepare its call */ + StkId base; + Proto *p = clLvalue(func)->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + n = cast_int(L->top - func) - 1; /* number of real arguments */ + for (; n < p->numparams; n++) + setnilvalue(L->top++); /* complete missing arguments */ + base = (!p->is_vararg) ? func + 1 : adjust_varargs(L, p, n); + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = func; + ci->u.l.base = base; + ci->top = base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + ci->u.l.savedpc = p->code; /* starting point */ + ci->callstatus = CIST_LUA; + L->top = ci->top; + luaC_checkGC(L); /* stack grow uses memory */ + if (L->hookmask & LUA_MASKCALL) + callhook(L, ci); + return 0; + } + default: { /* not a function */ + func = tryfuncTM(L, func); /* retry with 'function' tag method */ + return luaD_precall(L, func, nresults); /* now it must be a function */ } } } -static StkId callrethooks (lua_State *L, StkId firstResult) { - ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ - luaD_callhook(L, LUA_HOOKRET, -1); - if (f_isLua(L->ci)) { /* Lua function? */ - while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ - luaD_callhook(L, LUA_HOOKTAILRET, -1); - } - return restorestack(L, fr); -} - - int luaD_poscall (lua_State *L, StkId firstResult) { StkId res; int wanted, i; - CallInfo *ci; - if (L->hookmask & LUA_MASKRET) - firstResult = callrethooks(L, firstResult); - ci = L->ci--; + CallInfo *ci = L->ci; + if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) { + if (L->hookmask & LUA_MASKRET) { + ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */ + luaD_hook(L, LUA_HOOKRET, -1); + firstResult = restorestack(L, fr); + } + L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ + } res = ci->func; /* res == final position of 1st result */ wanted = ci->nresults; - L->base = (ci - 1)->base; /* restore base */ - L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + L->ci = ci = ci->previous; /* back to caller */ /* move results to correct place */ for (i = wanted; i != 0 && firstResult < L->top; i--) setobjs2s(L, res++, firstResult++); @@ -365,112 +382,225 @@ int luaD_poscall (lua_State *L, StkId firstResult) { ** The arguments are on the stack, right after the function. ** When returns, all the results are on the stack, starting at the original ** function position. -*/ -void luaD_call (lua_State *L, StkId func, int nResults) { +*/ +void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { if (++L->nCcalls >= LUAI_MAXCCALLS) { if (L->nCcalls == LUAI_MAXCCALLS) luaG_runerror(L, "C stack overflow"); else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ } - if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ - luaV_execute(L, 1); /* call it */ + if (!allowyield) L->nny++; + if (!luaD_precall(L, func, nResults)) /* is a Lua function? */ + luaV_execute(L); /* call it */ + if (!allowyield) L->nny--; L->nCcalls--; - luaC_checkGC(L); } +static void finishCcall (lua_State *L) { + CallInfo *ci = L->ci; + int n; + lua_assert(ci->u.c.k != NULL); /* must have a continuation */ + lua_assert(L->nny == 0); + if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ + ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */ + L->errfunc = ci->u.c.old_errfunc; + } + /* finish 'lua_callk'/'lua_pcall' */ + adjustresults(L, ci->nresults); + /* call continuation function */ + if (!(ci->callstatus & CIST_STAT)) /* no call status? */ + ci->u.c.status = LUA_YIELD; /* 'default' status */ + lua_assert(ci->u.c.status != LUA_OK); + ci->callstatus = (ci->callstatus & ~(CIST_YPCALL | CIST_STAT)) | CIST_YIELDED; + lua_unlock(L); + n = (*ci->u.c.k)(L); + lua_lock(L); + api_checknelems(L, n); + /* finish 'luaD_precall' */ + luaD_poscall(L, L->top - n); +} + + +static void unroll (lua_State *L, void *ud) { + UNUSED(ud); + for (;;) { + if (L->ci == &L->base_ci) /* stack is empty? */ + return; /* coroutine finished normally */ + if (!isLua(L->ci)) /* C function? */ + finishCcall(L); + else { /* Lua function */ + luaV_finishOp(L); /* finish interrupted instruction */ + luaV_execute(L); /* execute down to higher C 'boundary' */ + } + } +} + + +/* +** check whether thread has a suspended protected call +*/ +static CallInfo *findpcall (lua_State *L) { + CallInfo *ci; + for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */ + if (ci->callstatus & CIST_YPCALL) + return ci; + } + return NULL; /* no pending pcall */ +} + + +static int recover (lua_State *L, int status) { + StkId oldtop; + CallInfo *ci = findpcall(L); + if (ci == NULL) return 0; /* no recovery point */ + /* "finish" luaD_pcall */ + oldtop = restorestack(L, ci->extra); + luaF_close(L, oldtop); + seterrorobj(L, status, oldtop); + L->ci = ci; + L->allowhook = ci->u.c.old_allowhook; + L->nny = 0; /* should be zero to be yieldable */ + luaD_shrinkstack(L); + L->errfunc = ci->u.c.old_errfunc; + ci->callstatus |= CIST_STAT; /* call has error status */ + ci->u.c.status = status; /* (here it is) */ + return 1; /* continue running the coroutine */ +} + + +/* +** signal an error in the call to 'resume', not in the execution of the +** coroutine itself. (Such errors should not be handled by any coroutine +** error handler and should not kill the coroutine.) +*/ +static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { + L->top = firstArg; /* remove args from the stack */ + setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ + api_incr_top(L); + luaD_throw(L, -1); /* jump back to 'lua_resume' */ +} + + +/* +** do the work for 'lua_resume' in protected mode +*/ static void resume (lua_State *L, void *ud) { + int nCcalls = L->nCcalls; StkId firstArg = cast(StkId, ud); CallInfo *ci = L->ci; - if (L->status == 0) { /* start coroutine? */ - lua_assert(ci == L->base_ci && firstArg > L->base); - if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) - return; + if (nCcalls >= LUAI_MAXCCALLS) + resume_error(L, "C stack overflow", firstArg); + if (L->status == LUA_OK) { /* may be starting a coroutine */ + if (ci != &L->base_ci) /* not in base level? */ + resume_error(L, "cannot resume non-suspended coroutine", firstArg); + /* coroutine is in base level; start running it */ + if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ + luaV_execute(L); /* call it */ } + else if (L->status != LUA_YIELD) + resume_error(L, "cannot resume dead coroutine", firstArg); else { /* resuming from previous yield */ - lua_assert(L->status == LUA_YIELD); - L->status = 0; - if (!f_isLua(ci)) { /* `common' yield? */ - /* finish interrupted execution of `OP_CALL' */ - lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || - GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); - if (luaD_poscall(L, firstArg)) /* complete it... */ - L->top = L->ci->top; /* and correct top if not multiple results */ + L->status = LUA_OK; + ci->func = restorestack(L, ci->extra); + if (isLua(ci)) /* yielded inside a hook? */ + luaV_execute(L); /* just continue running Lua code */ + else { /* 'common' yield */ + if (ci->u.c.k != NULL) { /* does it have a continuation? */ + int n; + ci->u.c.status = LUA_YIELD; /* 'default' status */ + ci->callstatus |= CIST_YIELDED; + lua_unlock(L); + n = (*ci->u.c.k)(L); /* call continuation */ + lua_lock(L); + api_checknelems(L, n); + firstArg = L->top - n; /* yield results come from continuation */ + } + luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ } - else /* yielded inside a hook: just continue its execution */ - L->base = L->ci->base; + unroll(L, NULL); } - luaV_execute(L, cast_int(L->ci - L->base_ci)); + lua_assert(nCcalls == L->nCcalls); } -static int resume_error (lua_State *L, const char *msg) { - L->top = L->ci->base; - setsvalue2s(L, L->top, luaS_new(L, msg)); - incr_top(L); - lua_unlock(L); - return LUA_ERRRUN; -} - - -LUA_API int lua_resume (lua_State *L, int nargs) { +LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { int status; lua_lock(L); - if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) - return resume_error(L, "cannot resume non-suspended coroutine"); - if (L->nCcalls >= LUAI_MAXCCALLS) - return resume_error(L, "C stack overflow"); luai_userstateresume(L, nargs); - lua_assert(L->errfunc == 0); - L->baseCcalls = ++L->nCcalls; + L->nCcalls = (from) ? from->nCcalls + 1 : 1; + L->nny = 0; /* allow yields */ + api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); status = luaD_rawrunprotected(L, resume, L->top - nargs); - if (status != 0) { /* error? */ - L->status = cast_byte(status); /* mark thread as `dead' */ - luaD_seterrorobj(L, status, L->top); - L->ci->top = L->top; + if (status == -1) /* error calling 'lua_resume'? */ + status = LUA_ERRRUN; + else { /* yield or regular error */ + while (status != LUA_OK && status != LUA_YIELD) { /* error? */ + if (recover(L, status)) /* recover point? */ + status = luaD_rawrunprotected(L, unroll, NULL); /* run continuation */ + else { /* unrecoverable error */ + L->status = cast_byte(status); /* mark thread as `dead' */ + seterrorobj(L, status, L->top); + L->ci->top = L->top; + break; + } + } + lua_assert(status == L->status); } - else { - lua_assert(L->nCcalls == L->baseCcalls); - status = L->status; - } - --L->nCcalls; + L->nny = 1; /* do not allow yields */ + L->nCcalls--; + lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); lua_unlock(L); return status; } -LUA_API int lua_yield (lua_State *L, int nresults) { +LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { + CallInfo *ci = L->ci; luai_userstateyield(L, nresults); lua_lock(L); - if (L->nCcalls > L->baseCcalls) - luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); - L->base = L->top - nresults; /* protect stack slots below */ + api_checknelems(L, nresults); + if (L->nny > 0) { + if (L != G(L)->mainthread) + luaG_runerror(L, "attempt to yield across a C-call boundary"); + else + luaG_runerror(L, "attempt to yield from outside a coroutine"); + } L->status = LUA_YIELD; + ci->extra = savestack(L, ci->func); /* save current 'func' */ + if (isLua(ci)) { /* inside a hook? */ + api_check(L, k == NULL, "hooks cannot continue after yielding"); + } + else { + if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ + ci->u.c.ctx = ctx; /* save context */ + ci->func = L->top - nresults - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); + } + lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ lua_unlock(L); - return -1; + return 0; /* return to 'luaD_hook' */ } int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef) { int status; - unsigned short oldnCcalls = L->nCcalls; - ptrdiff_t old_ci = saveci(L, L->ci); + CallInfo *old_ci = L->ci; lu_byte old_allowhooks = L->allowhook; + unsigned short old_nny = L->nny; ptrdiff_t old_errfunc = L->errfunc; L->errfunc = ef; status = luaD_rawrunprotected(L, func, u); - if (status != 0) { /* an error occurred? */ + if (status != LUA_OK) { /* an error occurred? */ StkId oldtop = restorestack(L, old_top); - luaF_close(L, oldtop); /* close eventual pending closures */ - luaD_seterrorobj(L, status, oldtop); - L->nCcalls = oldnCcalls; - L->ci = restoreci(L, old_ci); - L->base = L->ci->base; - L->savedpc = L->ci->savedpc; + luaF_close(L, oldtop); /* close possible pending closures */ + seterrorobj(L, status, oldtop); + L->ci = old_ci; L->allowhook = old_allowhooks; - restore_stack_limit(L); + L->nny = old_nny; + luaD_shrinkstack(L); } L->errfunc = old_errfunc; return status; @@ -483,35 +613,60 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, */ struct SParser { /* data to `f_parser' */ ZIO *z; - Mbuffer buff; /* buffer to be used by the scanner */ + Mbuffer buff; /* dynamic structure used by the scanner */ + Dyndata dyd; /* dynamic structures used by the parser */ + const char *mode; const char *name; }; -static void f_parser (lua_State *L, void *ud) { - int i; - Proto *tf; - Closure *cl; - struct SParser *p = cast(struct SParser *, ud); - int c = luaZ_lookahead(p->z); - luaC_checkGC(L); - tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, - &p->buff, p->name); - cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); - cl->l.p = tf; - for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ - cl->l.upvals[i] = luaF_newupval(L); - setclvalue(L, L->top, cl); - incr_top(L); + +static void checkmode (lua_State *L, const char *mode, const char *x) { + if (mode && strchr(mode, x[0]) == NULL) { + luaO_pushfstring(L, + "attempt to load a %s chunk (mode is " LUA_QS ")", x, mode); + luaD_throw(L, LUA_ERRSYNTAX); + } } -int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { +static void f_parser (lua_State *L, void *ud) { + int i; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = zgetc(p->z); /* read first character */ + if (c == LUA_SIGNATURE[0]) { + checkmode(L, p->mode, "binary"); + cl = luaU_undump(L, p->z, &p->buff, p->name); + } + else { + checkmode(L, p->mode, "text"); + cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); + } + lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); + for (i = 0; i < cl->l.nupvalues; i++) { /* initialize upvalues */ + UpVal *up = luaF_newupval(L); + cl->l.upvals[i] = up; + luaC_objbarrier(L, cl, up); + } +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode) { struct SParser p; int status; - p.z = z; p.name = name; + L->nny++; /* cannot yield during parsing */ + p.z = z; p.name = name; p.mode = mode; + p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; + p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; + p.dyd.label.arr = NULL; p.dyd.label.size = 0; luaZ_initbuffer(L, &p.buff); status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); luaZ_freebuffer(L, &p.buff); + luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); + luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); + luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); + L->nny--; return status; } diff --git a/src/mod/languages/mod_lua/lua/ldo.h b/src/mod/languages/mod_lua/lua/ldo.h index 98fddac59f..27b837d999 100644 --- a/src/mod/languages/mod_lua/lua/ldo.h +++ b/src/mod/languages/mod_lua/lua/ldo.h @@ -1,5 +1,5 @@ /* -** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: ldo.h,v 2.20 2011/11/29 15:55:08 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -13,45 +13,34 @@ #include "lzio.h" -#define luaD_checkstack(L,n) \ - if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ - luaD_growstack(L, n); \ - else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); +#define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ + luaD_growstack(L, n); else condmovestack(L); -#define incr_top(L) {luaD_checkstack(L,1); L->top++;} +#define incr_top(L) {L->top++; luaD_checkstack(L,0);} #define savestack(L,p) ((char *)(p) - (char *)L->stack) #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) -#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) -#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) - - -/* results from luaD_precall */ -#define PCRLUA 0 /* initiated a call to a Lua function */ -#define PCRC 1 /* did a call to a C function */ -#define PCRYIELD 2 /* C funtion yielded */ - /* type of protected functions, to be ran by `runprotected' */ typedef void (*Pfunc) (lua_State *L, void *ud); -LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); -LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode); +LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); -LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, + int allowyield); LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef); LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); -LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); LUAI_FUNC void luaD_growstack (lua_State *L, int n); +LUAI_FUNC void luaD_shrinkstack (lua_State *L); -LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); -LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); - #endif diff --git a/src/mod/languages/mod_lua/lua/ldump.c b/src/mod/languages/mod_lua/lua/ldump.c index c9d3d4870f..d5e6a47cb3 100644 --- a/src/mod/languages/mod_lua/lua/ldump.c +++ b/src/mod/languages/mod_lua/lua/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -24,7 +24,7 @@ typedef struct { } DumpState; #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) -#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) static void DumpBlock(const void* b, size_t size, DumpState* D) { @@ -60,7 +60,7 @@ static void DumpVector(const void* b, int n, size_t size, DumpState* D) static void DumpString(const TString* s, DumpState* D) { - if (s==NULL || getstr(s)==NULL) + if (s==NULL) { size_t size=0; DumpVar(size,D); @@ -69,13 +69,13 @@ static void DumpString(const TString* s, DumpState* D) { size_t size=s->tsv.len+1; /* include trailing '\0' */ DumpVar(size,D); - DumpBlock(getstr(s),size,D); + DumpBlock(getstr(s),size*sizeof(char),D); } } #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) -static void DumpFunction(const Proto* f, const TString* p, DumpState* D); +static void DumpFunction(const Proto* f, DumpState* D); static void DumpConstants(const Proto* f, DumpState* D) { @@ -84,8 +84,8 @@ static void DumpConstants(const Proto* f, DumpState* D) for (i=0; ik[i]; - DumpChar(ttype(o),D); - switch (ttype(o)) + DumpChar(ttypenv(o),D); + switch (ttypenv(o)) { case LUA_TNIL: break; @@ -98,19 +98,29 @@ static void DumpConstants(const Proto* f, DumpState* D) case LUA_TSTRING: DumpString(rawtsvalue(o),D); break; - default: - lua_assert(0); /* cannot happen */ - break; + default: lua_assert(0); } } n=f->sizep; DumpInt(n,D); - for (i=0; ip[i],f->source,D); + for (i=0; ip[i],D); +} + +static void DumpUpvalues(const Proto* f, DumpState* D) +{ + int i,n=f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i].instack,D); + DumpChar(f->upvalues[i].idx,D); + } } static void DumpDebug(const Proto* f, DumpState* D) { int i,n; + DumpString((D->strip) ? NULL : f->source,D); n= (D->strip) ? 0 : f->sizelineinfo; DumpVector(f->lineinfo,n,sizeof(int),D); n= (D->strip) ? 0 : f->sizelocvars; @@ -123,26 +133,25 @@ static void DumpDebug(const Proto* f, DumpState* D) } n= (D->strip) ? 0 : f->sizeupvalues; DumpInt(n,D); - for (i=0; iupvalues[i],D); + for (i=0; iupvalues[i].name,D); } -static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +static void DumpFunction(const Proto* f, DumpState* D) { - DumpString((f->source==p || D->strip) ? NULL : f->source,D); DumpInt(f->linedefined,D); DumpInt(f->lastlinedefined,D); - DumpChar(f->nups,D); DumpChar(f->numparams,D); DumpChar(f->is_vararg,D); DumpChar(f->maxstacksize,D); DumpCode(f,D); DumpConstants(f,D); + DumpUpvalues(f,D); DumpDebug(f,D); } static void DumpHeader(DumpState* D) { - char h[LUAC_HEADERSIZE]; + lu_byte h[LUAC_HEADERSIZE]; luaU_header(h); DumpBlock(h,LUAC_HEADERSIZE,D); } @@ -159,6 +168,6 @@ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip D.strip=strip; D.status=0; DumpHeader(&D); - DumpFunction(f,NULL,&D); + DumpFunction(f,&D); return D.status; } diff --git a/src/mod/languages/mod_lua/lua/lfunc.c b/src/mod/languages/mod_lua/lua/lfunc.c index 813e88f583..c2128405b9 100644 --- a/src/mod/languages/mod_lua/lua/lfunc.c +++ b/src/mod/languages/mod_lua/lua/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** $Id: lfunc.c,v 2.30 2012/10/03 12:36:46 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -20,30 +20,24 @@ -Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { - Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); - luaC_link(L, obj2gco(c), LUA_TFUNCTION); - c->c.isC = 1; - c->c.env = e; - c->c.nupvalues = cast_byte(nelems); +Closure *luaF_newCclosure (lua_State *L, int n) { + Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl; + c->c.nupvalues = cast_byte(n); return c; } -Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { - Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); - luaC_link(L, obj2gco(c), LUA_TFUNCTION); - c->l.isC = 0; - c->l.env = e; - c->l.nupvalues = cast_byte(nelems); - while (nelems--) c->l.upvals[nelems] = NULL; +Closure *luaF_newLclosure (lua_State *L, int n) { + Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl; + c->l.p = NULL; + c->l.nupvalues = cast_byte(n); + while (n--) c->l.upvals[n] = NULL; return c; } UpVal *luaF_newupval (lua_State *L) { - UpVal *uv = luaM_new(L, UpVal); - luaC_link(L, obj2gco(uv), LUA_TUPVAL); + UpVal *uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), NULL, 0)->uv; uv->v = &uv->u.value; setnilvalue(uv->v); return uv; @@ -55,21 +49,20 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { GCObject **pp = &L->openupval; UpVal *p; UpVal *uv; - while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + while (*pp != NULL && (p = gco2uv(*pp))->v >= level) { + GCObject *o = obj2gco(p); lua_assert(p->v != &p->u.value); + lua_assert(!isold(o) || isold(obj2gco(L))); if (p->v == level) { /* found a corresponding upvalue? */ - if (isdead(g, obj2gco(p))) /* is it dead? */ - changewhite(obj2gco(p)); /* ressurect it */ + if (isdead(g, o)) /* is it dead? */ + changewhite(o); /* resurrect it */ return p; } pp = &p->next; } - uv = luaM_new(L, UpVal); /* not found: create a new one */ - uv->tt = LUA_TUPVAL; - uv->marked = luaC_white(g); + /* not found: create a new one */ + uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), pp, 0)->uv; uv->v = level; /* current value lives in the stack */ - uv->next = *pp; /* chain it in the proper position */ - *pp = obj2gco(uv); uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ uv->u.l.next = g->uvhead.u.l.next; uv->u.l.next->u.l.prev = uv; @@ -96,41 +89,42 @@ void luaF_freeupval (lua_State *L, UpVal *uv) { void luaF_close (lua_State *L, StkId level) { UpVal *uv; global_State *g = G(L); - while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + while (L->openupval != NULL && (uv = gco2uv(L->openupval))->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); L->openupval = uv->next; /* remove from `open' list */ if (isdead(g, o)) luaF_freeupval(L, uv); /* free upvalue */ else { - unlinkupval(uv); - setobj(L, &uv->u.value, uv->v); + unlinkupval(uv); /* remove upvalue from 'uvhead' list */ + setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ uv->v = &uv->u.value; /* now current value lives here */ - luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */ + g->allgc = o; + luaC_checkupvalcolor(g, uv); } } } Proto *luaF_newproto (lua_State *L) { - Proto *f = luaM_new(L, Proto); - luaC_link(L, obj2gco(f), LUA_TPROTO); + Proto *f = &luaC_newobj(L, LUA_TPROTO, sizeof(Proto), NULL, 0)->p; f->k = NULL; f->sizek = 0; f->p = NULL; f->sizep = 0; f->code = NULL; + f->cache = NULL; f->sizecode = 0; + f->lineinfo = NULL; f->sizelineinfo = 0; - f->sizeupvalues = 0; - f->nups = 0; f->upvalues = NULL; + f->sizeupvalues = 0; f->numparams = 0; f->is_vararg = 0; f->maxstacksize = 0; - f->lineinfo = NULL; - f->sizelocvars = 0; f->locvars = NULL; + f->sizelocvars = 0; f->linedefined = 0; f->lastlinedefined = 0; f->source = NULL; @@ -139,23 +133,16 @@ Proto *luaF_newproto (lua_State *L) { void luaF_freeproto (lua_State *L, Proto *f) { - luaM_freearray(L, f->code, f->sizecode, Instruction); - luaM_freearray(L, f->p, f->sizep, Proto *); - luaM_freearray(L, f->k, f->sizek, TValue); - luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); - luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); - luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_freearray(L, f->code, f->sizecode); + luaM_freearray(L, f->p, f->sizep); + luaM_freearray(L, f->k, f->sizek); + luaM_freearray(L, f->lineinfo, f->sizelineinfo); + luaM_freearray(L, f->locvars, f->sizelocvars); + luaM_freearray(L, f->upvalues, f->sizeupvalues); luaM_free(L, f); } -void luaF_freeclosure (lua_State *L, Closure *c) { - int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : - sizeLclosure(c->l.nupvalues); - luaM_freemem(L, c, size); -} - - /* ** Look for n-th local variable at line `line' in function `func'. ** Returns NULL if not found. diff --git a/src/mod/languages/mod_lua/lua/lfunc.h b/src/mod/languages/mod_lua/lua/lfunc.h index a68cf5151c..e236a717c6 100644 --- a/src/mod/languages/mod_lua/lua/lfunc.h +++ b/src/mod/languages/mod_lua/lua/lfunc.h @@ -1,5 +1,5 @@ /* -** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lfunc.h,v 2.8 2012/05/08 13:53:33 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -19,13 +19,12 @@ LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); -LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); LUAI_FUNC UpVal *luaF_newupval (lua_State *L); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC void luaF_close (lua_State *L, StkId level); LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); -LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, int pc); diff --git a/src/mod/languages/mod_lua/lua/lgc.c b/src/mod/languages/mod_lua/lua/lgc.c index d9e0b78294..535e988ae0 100644 --- a/src/mod/languages/mod_lua/lua/lgc.c +++ b/src/mod/languages/mod_lua/lua/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lgc.c,v 2.140 2013/03/16 21:10:18 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -23,689 +23,1191 @@ #include "ltm.h" -#define GCSTEPSIZE 1024u -#define GCSWEEPMAX 40 -#define GCSWEEPCOST 10 -#define GCFINALIZECOST 100 + +/* +** cost of sweeping one element (the size of a small object divided +** by some adjust for the sweep speed) +*/ +#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) + +/* maximum number of elements to sweep in each single step */ +#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) + +/* maximum number of finalizers to call in each GC step */ +#define GCFINALIZENUM 4 -#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) +/* +** macro to adjust 'stepmul': 'stepmul' is actually used like +** 'stepmul / STEPMULADJ' (value chosen by tests) +*/ +#define STEPMULADJ 200 + +/* +** macro to adjust 'pause': 'pause' is actually used like +** 'pause / PAUSEADJ' (value chosen by tests) +*/ +#define PAUSEADJ 100 + + +/* +** 'makewhite' erases all color bits plus the old bit and then +** sets only the current white bit +*/ +#define maskcolors (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS)) #define makewhite(g,x) \ - ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g))) -#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) -#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) - -#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) +#define white2gray(x) resetbits(gch(x)->marked, WHITEBITS) +#define black2gray(x) resetbit(gch(x)->marked, BLACKBIT) -#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) -#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) +#define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT) + +#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) -#define KEYWEAK bitmask(KEYWEAKBIT) -#define VALUEWEAK bitmask(VALUEWEAKBIT) - +#define checkconsistency(obj) \ + lua_longassert(!iscollectable(obj) || righttt(obj)) #define markvalue(g,o) { checkconsistency(o); \ - if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } -#define markobject(g,t) { if (iswhite(obj2gco(t))) \ +#define markobject(g,t) { if ((t) && iswhite(obj2gco(t))) \ reallymarkobject(g, obj2gco(t)); } - -#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) +static void reallymarkobject (global_State *g, GCObject *o); +/* +** {====================================================== +** Generic functions +** ======================================================= +*/ + + +/* +** one after last element in a hash array +*/ +#define gnodelast(h) gnode(h, cast(size_t, sizenode(h))) + + +/* +** link table 'h' into list pointed by 'p' +*/ +#define linktable(h,p) ((h)->gclist = *(p), *(p) = obj2gco(h)) + + +/* +** if key is not marked, mark its entry as dead (therefore removing it +** from the table) +*/ static void removeentry (Node *n) { lua_assert(ttisnil(gval(n))); - if (iscollectable(gkey(n))) - setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ + if (valiswhite(gkey(n))) + setdeadvalue(gkey(n)); /* unused and unmarked key; remove it */ } +/* +** tells whether a key or value can be cleared from a weak +** table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for objects +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (global_State *g, const TValue *o) { + if (!iscollectable(o)) return 0; + else if (ttisstring(o)) { + markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + else return iswhite(gcvalue(o)); +} + + +/* +** barrier that moves collector forward, that is, mark the white object +** being pointed by a black object. +*/ +void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSpause); + lua_assert(gch(o)->tt != LUA_TTABLE); + if (keepinvariantout(g)) /* must keep invariant? */ + reallymarkobject(g, v); /* restore invariant */ + else { /* sweep phase */ + lua_assert(issweepphase(g)); + makewhite(g, o); /* mark main obj. as white to avoid other barriers */ + } +} + + +/* +** barrier that moves collector backward, that is, mark the black object +** pointing to a white object as gray again. (Current implementation +** only works for tables; access to 'gclist' is not uniform across +** different types.) +*/ +void luaC_barrierback_ (lua_State *L, GCObject *o) { + global_State *g = G(L); + lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE); + black2gray(o); /* make object gray (again) */ + gco2t(o)->gclist = g->grayagain; + g->grayagain = o; +} + + +/* +** barrier for prototypes. When creating first closure (cache is +** NULL), use a forward barrier; this may be the only closure of the +** prototype (if it is a "regular" function, with a single instance) +** and the prototype may be big, so it is better to avoid traversing +** it again. Otherwise, use a backward barrier, to avoid marking all +** possible instances. +*/ +LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) { + global_State *g = G(L); + lua_assert(isblack(obj2gco(p))); + if (p->cache == NULL) { /* first time? */ + luaC_objbarrier(L, p, c); + } + else { /* use a backward barrier */ + black2gray(obj2gco(p)); /* make prototype gray (again) */ + p->gclist = g->grayagain; + g->grayagain = obj2gco(p); + } +} + + +/* +** check color (and invariants) for an upvalue that was closed, +** i.e., moved into the 'allgc' list +*/ +void luaC_checkupvalcolor (global_State *g, UpVal *uv) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o)); /* open upvalues are never black */ + if (isgray(o)) { + if (keepinvariant(g)) { + resetoldbit(o); /* see MOVE OLD rule */ + gray2black(o); /* it is being visited now */ + markvalue(g, uv->v); + } + else { + lua_assert(issweepphase(g)); + makewhite(g, o); + } + } +} + + +/* +** create a new collectable object (with given type and size) and link +** it to '*list'. 'offset' tells how many bytes to allocate before the +** object itself (used only by states). +*/ +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, + int offset) { + global_State *g = G(L); + char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); + GCObject *o = obj2gco(raw + offset); + if (list == NULL) + list = &g->allgc; /* standard list for collectable objects */ + gch(o)->marked = luaC_white(g); + gch(o)->tt = tt; + gch(o)->next = *list; + *list = o; + return o; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Mark functions +** ======================================================= +*/ + + +/* +** mark an object. Userdata, strings, and closed upvalues are visited +** and turned black here. Other objects are marked gray and added +** to appropriate list to be visited (and turned black) later. (Open +** upvalues are already linked in 'headuv' list.) +*/ static void reallymarkobject (global_State *g, GCObject *o) { - lua_assert(iswhite(o) && !isdead(g, o)); + lu_mem size; white2gray(o); - switch (o->gch.tt) { - case LUA_TSTRING: { - return; + switch (gch(o)->tt) { + case LUA_TSHRSTR: + case LUA_TLNGSTR: { + size = sizestring(gco2ts(o)); + break; /* nothing else to mark; make it black */ } case LUA_TUSERDATA: { Table *mt = gco2u(o)->metatable; - gray2black(o); /* udata are never gray */ - if (mt) markobject(g, mt); + markobject(g, mt); markobject(g, gco2u(o)->env); - return; + size = sizeudata(gco2u(o)); + break; } case LUA_TUPVAL: { UpVal *uv = gco2uv(o); markvalue(g, uv->v); - if (uv->v == &uv->u.value) /* closed? */ - gray2black(o); /* open upvalues are never black */ + if (uv->v != &uv->u.value) /* open? */ + return; /* open upvalues remain gray */ + size = sizeof(UpVal); + break; + } + case LUA_TLCL: { + gco2lcl(o)->gclist = g->gray; + g->gray = o; return; } - case LUA_TFUNCTION: { - gco2cl(o)->c.gclist = g->gray; + case LUA_TCCL: { + gco2ccl(o)->gclist = g->gray; g->gray = o; - break; + return; } case LUA_TTABLE: { - gco2h(o)->gclist = g->gray; - g->gray = o; - break; + linktable(gco2t(o), &g->gray); + return; } case LUA_TTHREAD: { gco2th(o)->gclist = g->gray; g->gray = o; - break; + return; } case LUA_TPROTO: { gco2p(o)->gclist = g->gray; g->gray = o; - break; + return; } - default: lua_assert(0); + default: lua_assert(0); return; } -} - - -static void marktmu (global_State *g) { - GCObject *u = g->tmudata; - if (u) { - do { - u = u->gch.next; - makewhite(g, u); /* may be marked, if left from previous GC */ - reallymarkobject(g, u); - } while (u != g->tmudata); - } -} - - -/* move `dead' udata that need finalization to list `tmudata' */ -size_t luaC_separateudata (lua_State *L, int all) { - global_State *g = G(L); - size_t deadmem = 0; - GCObject **p = &g->mainthread->next; - GCObject *curr; - while ((curr = *p) != NULL) { - if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) - p = &curr->gch.next; /* don't bother with them */ - else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { - markfinalized(gco2u(curr)); /* don't need finalization */ - p = &curr->gch.next; - } - else { /* must call its gc method */ - deadmem += sizeudata(gco2u(curr)); - markfinalized(gco2u(curr)); - *p = curr->gch.next; - /* link `curr' at the end of `tmudata' list */ - if (g->tmudata == NULL) /* list is empty? */ - g->tmudata = curr->gch.next = curr; /* creates a circular list */ - else { - curr->gch.next = g->tmudata->gch.next; - g->tmudata->gch.next = curr; - g->tmudata = curr; - } - } - } - return deadmem; -} - - -static int traversetable (global_State *g, Table *h) { - int i; - int weakkey = 0; - int weakvalue = 0; - const TValue *mode; - if (h->metatable) - markobject(g, h->metatable); - mode = gfasttm(g, h->metatable, TM_MODE); - if (mode && ttisstring(mode)) { /* is there a weak mode? */ - weakkey = (strchr(svalue(mode), 'k') != NULL); - weakvalue = (strchr(svalue(mode), 'v') != NULL); - if (weakkey || weakvalue) { /* is really weak? */ - h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ - h->marked |= cast_byte((weakkey << KEYWEAKBIT) | - (weakvalue << VALUEWEAKBIT)); - h->gclist = g->weak; /* must be cleared after GC, ... */ - g->weak = obj2gco(h); /* ... so put in the appropriate list */ - } - } - if (weakkey && weakvalue) return 1; - if (!weakvalue) { - i = h->sizearray; - while (i--) - markvalue(g, &h->array[i]); - } - i = sizenode(h); - while (i--) { - Node *n = gnode(h, i); - lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); - if (ttisnil(gval(n))) - removeentry(n); /* remove empty entries */ - else { - lua_assert(!ttisnil(gkey(n))); - if (!weakkey) markvalue(g, gkey(n)); - if (!weakvalue) markvalue(g, gval(n)); - } - } - return weakkey || weakvalue; -} - - -/* -** All marks are conditional because a GC may happen while the -** prototype is still being created -*/ -static void traverseproto (global_State *g, Proto *f) { - int i; - if (f->source) stringmark(f->source); - for (i=0; isizek; i++) /* mark literals */ - markvalue(g, &f->k[i]); - for (i=0; isizeupvalues; i++) { /* mark upvalue names */ - if (f->upvalues[i]) - stringmark(f->upvalues[i]); - } - for (i=0; isizep; i++) { /* mark nested protos */ - if (f->p[i]) - markobject(g, f->p[i]); - } - for (i=0; isizelocvars; i++) { /* mark local-variable names */ - if (f->locvars[i].varname) - stringmark(f->locvars[i].varname); - } -} - - - -static void traverseclosure (global_State *g, Closure *cl) { - markobject(g, cl->c.env); - if (cl->c.isC) { - int i; - for (i=0; ic.nupvalues; i++) /* mark its upvalues */ - markvalue(g, &cl->c.upvalue[i]); - } - else { - int i; - lua_assert(cl->l.nupvalues == cl->l.p->nups); - markobject(g, cl->l.p); - for (i=0; il.nupvalues; i++) /* mark its upvalues */ - markobject(g, cl->l.upvals[i]); - } -} - - -static void checkstacksizes (lua_State *L, StkId max) { - int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ - int s_used = cast_int(max - L->stack); /* part of stack in use */ - if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ - return; /* do not touch the stacks */ - if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) - luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ - condhardstacktests(luaD_reallocCI(L, ci_used + 1)); - if (4*s_used < L->stacksize && - 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) - luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ - condhardstacktests(luaD_reallocstack(L, s_used)); -} - - -static void traversestack (global_State *g, lua_State *l) { - StkId o, lim; - CallInfo *ci; - markvalue(g, gt(l)); - lim = l->top; - for (ci = l->base_ci; ci <= l->ci; ci++) { - lua_assert(ci->top <= l->stack_last); - if (lim < ci->top) lim = ci->top; - } - for (o = l->stack; o < l->top; o++) - markvalue(g, o); - for (; o <= lim; o++) - setnilvalue(o); - checkstacksizes(l, lim); -} - - -/* -** traverse one gray object, turning it to black. -** Returns `quantity' traversed. -*/ -static l_mem propagatemark (global_State *g) { - GCObject *o = g->gray; - lua_assert(isgray(o)); gray2black(o); - switch (o->gch.tt) { - case LUA_TTABLE: { - Table *h = gco2h(o); - g->gray = h->gclist; - if (traversetable(g, h)) /* table is weak? */ - black2gray(o); /* keep it gray */ - return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * sizenode(h); - } - case LUA_TFUNCTION: { - Closure *cl = gco2cl(o); - g->gray = cl->c.gclist; - traverseclosure(g, cl); - return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : - sizeLclosure(cl->l.nupvalues); - } - case LUA_TTHREAD: { - lua_State *th = gco2th(o); - g->gray = th->gclist; - th->gclist = g->grayagain; - g->grayagain = o; - black2gray(o); - traversestack(g, th); - return sizeof(lua_State) + sizeof(TValue) * th->stacksize + - sizeof(CallInfo) * th->size_ci; - } - case LUA_TPROTO: { - Proto *p = gco2p(o); - g->gray = p->gclist; - traverseproto(g, p); - return sizeof(Proto) + sizeof(Instruction) * p->sizecode + - sizeof(Proto *) * p->sizep + - sizeof(TValue) * p->sizek + - sizeof(int) * p->sizelineinfo + - sizeof(LocVar) * p->sizelocvars + - sizeof(TString *) * p->sizeupvalues; - } - default: lua_assert(0); return 0; - } -} - - -static size_t propagateall (global_State *g) { - size_t m = 0; - while (g->gray) m += propagatemark(g); - return m; + g->GCmemtrav += size; } /* -** The next function tells whether a key or value can be cleared from -** a weak table. Non-collectable objects are never removed from weak -** tables. Strings behave as `values', so are never removed too. for -** other objects: if really collected, cannot keep them; for userdata -** being finalized, keep them in keys, but not in values +** mark metamethods for basic types */ -static int iscleared (const TValue *o, int iskey) { - if (!iscollectable(o)) return 0; - if (ttisstring(o)) { - stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ - return 0; - } - return iswhite(gcvalue(o)) || - (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); -} - - -/* -** clear collected entries from weaktables -*/ -static void cleartable (GCObject *l) { - while (l) { - Table *h = gco2h(l); - int i = h->sizearray; - lua_assert(testbit(h->marked, VALUEWEAKBIT) || - testbit(h->marked, KEYWEAKBIT)); - if (testbit(h->marked, VALUEWEAKBIT)) { - while (i--) { - TValue *o = &h->array[i]; - if (iscleared(o, 0)) /* value was collected? */ - setnilvalue(o); /* remove value */ - } - } - i = sizenode(h); - while (i--) { - Node *n = gnode(h, i); - if (!ttisnil(gval(n)) && /* non-empty entry? */ - (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { - setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* remove entry from table */ - } - } - l = h->gclist; - } -} - - -static void freeobj (lua_State *L, GCObject *o) { - switch (o->gch.tt) { - case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; - case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; - case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; - case LUA_TTABLE: luaH_free(L, gco2h(o)); break; - case LUA_TTHREAD: { - lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); - luaE_freethread(L, gco2th(o)); - break; - } - case LUA_TSTRING: { - G(L)->strt.nuse--; - luaM_freemem(L, o, sizestring(gco2ts(o))); - break; - } - case LUA_TUSERDATA: { - luaM_freemem(L, o, sizeudata(gco2u(o))); - break; - } - default: lua_assert(0); - } -} - - - -#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) - - -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { - GCObject *curr; - global_State *g = G(L); - int deadmask = otherwhite(g); - while ((curr = *p) != NULL && count-- > 0) { - if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ - sweepwholelist(L, &gco2th(curr)->openupval); - if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ - lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); - makewhite(g, curr); /* make it white (for next cycle) */ - p = &curr->gch.next; - } - else { /* must erase `curr' */ - lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); - *p = curr->gch.next; - if (curr == g->rootgc) /* is the first element of the list? */ - g->rootgc = curr->gch.next; /* adjust first */ - freeobj(L, curr); - } - } - return p; -} - - -static void checkSizes (lua_State *L) { - global_State *g = G(L); - /* check size of string hash */ - if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && - g->strt.size > MINSTRTABSIZE*2) - luaS_resize(L, g->strt.size/2); /* table is too big */ - /* check size of buffer */ - if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ - size_t newsize = luaZ_sizebuffer(&g->buff) / 2; - luaZ_resizebuffer(L, &g->buff, newsize); - } -} - - -static void GCTM (lua_State *L) { - global_State *g = G(L); - GCObject *o = g->tmudata->gch.next; /* get first element */ - Udata *udata = rawgco2u(o); - const TValue *tm; - /* remove udata from `tmudata' */ - if (o == g->tmudata) /* last element? */ - g->tmudata = NULL; - else - g->tmudata->gch.next = udata->uv.next; - udata->uv.next = g->mainthread->next; /* return it to `root' list */ - g->mainthread->next = o; - makewhite(g, o); - tm = fasttm(L, udata->uv.metatable, TM_GC); - if (tm != NULL) { - lu_byte oldah = L->allowhook; - lu_mem oldt = g->GCthreshold; - L->allowhook = 0; /* stop debug hooks during GC tag method */ - g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ - setobj2s(L, L->top, tm); - setuvalue(L, L->top+1, udata); - L->top += 2; - luaD_call(L, L->top - 2, 0); - L->allowhook = oldah; /* restore hooks */ - g->GCthreshold = oldt; /* restore threshold */ - } -} - - -/* -** Call all GC tag methods -*/ -void luaC_callGCTM (lua_State *L) { - while (G(L)->tmudata) - GCTM(L); -} - - -void luaC_freeall (lua_State *L) { - global_State *g = G(L); - int i; - g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ - sweepwholelist(L, &g->rootgc); - for (i = 0; i < g->strt.size; i++) /* free all string lists */ - sweepwholelist(L, &g->strt.hash[i]); -} - - static void markmt (global_State *g) { int i; - for (i=0; imt[i]) markobject(g, g->mt[i]); + for (i=0; i < LUA_NUMTAGS; i++) + markobject(g, g->mt[i]); } -/* mark root set */ -static void markroot (lua_State *L) { - global_State *g = G(L); - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - markobject(g, g->mainthread); - /* make global table be traversed before main stack */ - markvalue(g, gt(g->mainthread)); - markvalue(g, registry(L)); - markmt(g); - g->gcstate = GCSpropagate; +/* +** mark all objects in list of being-finalized +*/ +static void markbeingfnz (global_State *g) { + GCObject *o; + for (o = g->tobefnz; o != NULL; o = gch(o)->next) { + makewhite(g, o); + reallymarkobject(g, o); + } } +/* +** mark all values stored in marked open upvalues. (See comment in +** 'lstate.h'.) +*/ static void remarkupvals (global_State *g) { UpVal *uv; for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); if (isgray(obj2gco(uv))) markvalue(g, uv->v); } } -static void atomic (lua_State *L) { - global_State *g = G(L); - size_t udsize; /* total size of userdata to be finalized */ - /* remark occasional upvalues of (maybe) dead threads */ - remarkupvals(g); - /* traverse objects cautch by write barrier and by 'remarkupvals' */ - propagateall(g); - /* remark weak tables */ - g->gray = g->weak; - g->weak = NULL; - lua_assert(!iswhite(obj2gco(g->mainthread))); - markobject(g, L); /* mark running thread */ - markmt(g); /* mark basic metatables (again) */ - propagateall(g); - /* remark gray again */ - g->gray = g->grayagain; - g->grayagain = NULL; - propagateall(g); - udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ - marktmu(g); /* mark `preserved' userdata */ - udsize += propagateall(g); /* remark, to propagate `preserveness' */ - cleartable(g->weak); /* remove collected objects from weak tables */ - /* flip current white */ - g->currentwhite = cast_byte(otherwhite(g)); - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - g->gcstate = GCSsweepstring; - g->estimate = g->totalbytes - udsize; /* first estimate */ +/* +** mark root set and reset all gray lists, to start a new +** incremental (or full) collection +*/ +static void restartcollection (global_State *g) { + g->gray = g->grayagain = NULL; + g->weak = g->allweak = g->ephemeron = NULL; + markobject(g, g->mainthread); + markvalue(g, &g->l_registry); + markmt(g); + markbeingfnz(g); /* mark any finalizing object left from previous cycle */ +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Traverse functions +** ======================================================= +*/ + +static void traverseweakvalue (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + /* if there is array part, assume it may have white values (do not + traverse it just to check) */ + int hasclears = (h->sizearray > 0); + for (n = gnode(h, 0); n < limit; n++) { + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ + hasclears = 1; /* table will have to be cleared */ + } + } + if (hasclears) + linktable(h, &g->weak); /* has to be cleared later */ + else /* no white values */ + linktable(h, &g->grayagain); /* no need to clean */ } -static l_mem singlestep (lua_State *L) { +static int traverseephemeron (global_State *g, Table *h) { + int marked = 0; /* true if an object is marked in this traversal */ + int hasclears = 0; /* true if table has white keys */ + int prop = 0; /* true if table has entry "white-key -> white-value" */ + Node *n, *limit = gnodelast(h); + int i; + /* traverse array part (numeric keys are 'strong') */ + for (i = 0; i < h->sizearray; i++) { + if (valiswhite(&h->array[i])) { + marked = 1; + reallymarkobject(g, gcvalue(&h->array[i])); + } + } + /* traverse hash part */ + for (n = gnode(h, 0); n < limit; n++) { + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ + hasclears = 1; /* table must be cleared */ + if (valiswhite(gval(n))) /* value not marked yet? */ + prop = 1; /* must propagate again */ + } + else if (valiswhite(gval(n))) { /* value not marked yet? */ + marked = 1; + reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ + } + } + if (prop) + linktable(h, &g->ephemeron); /* have to propagate again */ + else if (hasclears) /* does table have white keys? */ + linktable(h, &g->allweak); /* may have to clean white keys */ + else /* no white keys */ + linktable(h, &g->grayagain); /* no need to clean */ + return marked; +} + + +static void traversestrongtable (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + int i; + for (i = 0; i < h->sizearray; i++) /* traverse array part */ + markvalue(g, &h->array[i]); + for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + markvalue(g, gval(n)); /* mark value */ + } + } +} + + +static lu_mem traversetable (global_State *g, Table *h) { + const char *weakkey, *weakvalue; + const TValue *mode = gfasttm(g, h->metatable, TM_MODE); + markobject(g, h->metatable); + if (mode && ttisstring(mode) && /* is there a weak mode? */ + ((weakkey = strchr(svalue(mode), 'k')), + (weakvalue = strchr(svalue(mode), 'v')), + (weakkey || weakvalue))) { /* is really weak? */ + black2gray(obj2gco(h)); /* keep table gray */ + if (!weakkey) /* strong keys? */ + traverseweakvalue(g, h); + else if (!weakvalue) /* strong values? */ + traverseephemeron(g, h); + else /* all weak */ + linktable(h, &g->allweak); /* nothing to traverse now */ + } + else /* not weak */ + traversestrongtable(g, h); + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * cast(size_t, sizenode(h)); +} + + +static int traverseproto (global_State *g, Proto *f) { + int i; + if (f->cache && iswhite(obj2gco(f->cache))) + f->cache = NULL; /* allow cache to be collected */ + markobject(g, f->source); + for (i = 0; i < f->sizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ + markobject(g, f->upvalues[i].name); + for (i = 0; i < f->sizep; i++) /* mark nested protos */ + markobject(g, f->p[i]); + for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ + markobject(g, f->locvars[i].varname); + return sizeof(Proto) + sizeof(Instruction) * f->sizecode + + sizeof(Proto *) * f->sizep + + sizeof(TValue) * f->sizek + + sizeof(int) * f->sizelineinfo + + sizeof(LocVar) * f->sizelocvars + + sizeof(Upvaldesc) * f->sizeupvalues; +} + + +static lu_mem traverseCclosure (global_State *g, CClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->upvalue[i]); + return sizeCclosure(cl->nupvalues); +} + +static lu_mem traverseLclosure (global_State *g, LClosure *cl) { + int i; + markobject(g, cl->p); /* mark its prototype */ + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->upvals[i]); + return sizeLclosure(cl->nupvalues); +} + + +static lu_mem traversestack (global_State *g, lua_State *th) { + StkId o = th->stack; + if (o == NULL) + return 1; /* stack not completely built yet */ + for (; o < th->top; o++) + markvalue(g, o); + if (g->gcstate == GCSatomic) { /* final traversal? */ + StkId lim = th->stack + th->stacksize; /* real end of stack */ + for (; o < lim; o++) /* clear not-marked stack slice */ + setnilvalue(o); + } + return sizeof(lua_State) + sizeof(TValue) * th->stacksize; +} + + +/* +** traverse one gray object, turning it to black (except for threads, +** which are always gray). +*/ +static void propagatemark (global_State *g) { + lu_mem size; + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (gch(o)->tt) { + case LUA_TTABLE: { + Table *h = gco2t(o); + g->gray = h->gclist; /* remove from 'gray' list */ + size = traversetable(g, h); + break; + } + case LUA_TLCL: { + LClosure *cl = gco2lcl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseLclosure(g, cl); + break; + } + case LUA_TCCL: { + CClosure *cl = gco2ccl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseCclosure(g, cl); + break; + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; /* remove from 'gray' list */ + th->gclist = g->grayagain; + g->grayagain = o; /* insert into 'grayagain' list */ + black2gray(o); + size = traversestack(g, th); + break; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; /* remove from 'gray' list */ + size = traverseproto(g, p); + break; + } + default: lua_assert(0); return; + } + g->GCmemtrav += size; +} + + +static void propagateall (global_State *g) { + while (g->gray) propagatemark(g); +} + + +static void propagatelist (global_State *g, GCObject *l) { + lua_assert(g->gray == NULL); /* no grays left */ + g->gray = l; + propagateall(g); /* traverse all elements from 'l' */ +} + +/* +** retraverse all gray lists. Because tables may be reinserted in other +** lists when traversed, traverse the original lists to avoid traversing +** twice the same table (which is not wrong, but inefficient) +*/ +static void retraversegrays (global_State *g) { + GCObject *weak = g->weak; /* save original lists */ + GCObject *grayagain = g->grayagain; + GCObject *ephemeron = g->ephemeron; + g->weak = g->grayagain = g->ephemeron = NULL; + propagateall(g); /* traverse main gray list */ + propagatelist(g, grayagain); + propagatelist(g, weak); + propagatelist(g, ephemeron); +} + + +static void convergeephemerons (global_State *g) { + int changed; + do { + GCObject *w; + GCObject *next = g->ephemeron; /* get ephemeron list */ + g->ephemeron = NULL; /* tables will return to this list when traversed */ + changed = 0; + while ((w = next) != NULL) { + next = gco2t(w)->gclist; + if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ + propagateall(g); /* propagate changes */ + changed = 1; /* will have to revisit all ephemeron tables */ + } + } + } while (changed); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Sweep Functions +** ======================================================= +*/ + + +/* +** clear entries with unmarked keys from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearkeys (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +/* +** clear entries with unmarked values from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearvalues (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + int i; + for (i = 0; i < h->sizearray; i++) { + TValue *o = &h->array[i]; + if (iscleared(g, o)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (gch(o)->tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TLCL: { + luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues)); + break; + } + case LUA_TCCL: { + luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); + break; + } + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2t(o)); break; + case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; + case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; + case LUA_TSHRSTR: + G(L)->strt.nuse--; + /* go through */ + case LUA_TLNGSTR: { + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + default: lua_assert(0); + } +} + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count); + + +/* +** sweep the (open) upvalues of a thread and resize its stack and +** list of call-info structures. +*/ +static void sweepthread (lua_State *L, lua_State *L1) { + if (L1->stack == NULL) return; /* stack not completely built yet */ + sweepwholelist(L, &L1->openupval); /* sweep open upvalues */ + luaE_freeCI(L1); /* free extra CallInfo slots */ + /* should not change the stack during an emergency gc cycle */ + if (G(L)->gckind != KGC_EMERGENCY) + luaD_shrinkstack(L1); +} + + +/* +** sweep at most 'count' elements from a list of GCObjects erasing dead +** objects, where a dead (not alive) object is one marked with the "old" +** (non current) white and not fixed. +** In non-generational mode, change all non-dead objects back to white, +** preparing for next collection cycle. +** In generational mode, keep black objects black, and also mark them as +** old; stop when hitting an old object, as all objects after that +** one will be old too. +** When object is a thread, sweep its list of open upvalues too. +*/ +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + global_State *g = G(L); + int ow = otherwhite(g); + int toclear, toset; /* bits to clear and to set in all live objects */ + int tostop; /* stop sweep when this is true */ + if (isgenerational(g)) { /* generational mode? */ + toclear = ~0; /* clear nothing */ + toset = bitmask(OLDBIT); /* set the old bit of all surviving objects */ + tostop = bitmask(OLDBIT); /* do not sweep old generation */ + } + else { /* normal mode */ + toclear = maskcolors; /* clear all color bits + old bit */ + toset = luaC_white(g); /* make object white */ + tostop = 0; /* do not stop */ + } + while (*p != NULL && count-- > 0) { + GCObject *curr = *p; + int marked = gch(curr)->marked; + if (isdeadm(ow, marked)) { /* is 'curr' dead? */ + *p = gch(curr)->next; /* remove 'curr' from list */ + freeobj(L, curr); /* erase 'curr' */ + } + else { + if (testbits(marked, tostop)) + return NULL; /* stop sweeping this list */ + if (gch(curr)->tt == LUA_TTHREAD) + sweepthread(L, gco2th(curr)); /* sweep thread's upvalues */ + /* update marks */ + gch(curr)->marked = cast_byte((marked & toclear) | toset); + p = &gch(curr)->next; /* go to next element */ + } + } + return (*p == NULL) ? NULL : p; +} + + +/* +** sweep a list until a live object (or end of list) +*/ +static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { + GCObject ** old = p; + int i = 0; + do { + i++; + p = sweeplist(L, p, 1); + } while (p == old); + if (n) *n += i; + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Finalization +** ======================================================= +*/ + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + if (g->gckind != KGC_EMERGENCY) { /* do not change sizes in emergency */ + int hs = g->strt.size / 2; /* half the size of the string table */ + if (g->strt.nuse < cast(lu_int32, hs)) /* using less than that half? */ + luaS_resize(L, hs); /* halve its size */ + luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */ + } +} + + +static GCObject *udata2finalize (global_State *g) { + GCObject *o = g->tobefnz; /* get first element */ + lua_assert(isfinalized(o)); + g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */ + gch(o)->next = g->allgc; /* return it to 'allgc' list */ + g->allgc = o; + resetbit(gch(o)->marked, SEPARATED); /* mark that it is not in 'tobefnz' */ + lua_assert(!isold(o)); /* see MOVE OLD rule */ + if (!keepinvariantout(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + return o; +} + + +static void dothecall (lua_State *L, void *ud) { + UNUSED(ud); + luaD_call(L, L->top - 2, 0, 0); +} + + +static void GCTM (lua_State *L, int propagateerrors) { + global_State *g = G(L); + const TValue *tm; + TValue v; + setgcovalue(L, &v, udata2finalize(g)); + tm = luaT_gettmbyobj(L, &v, TM_GC); + if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */ + int status; + lu_byte oldah = L->allowhook; + int running = g->gcrunning; + L->allowhook = 0; /* stop debug hooks during GC metamethod */ + g->gcrunning = 0; /* avoid GC steps */ + setobj2s(L, L->top, tm); /* push finalizer... */ + setobj2s(L, L->top + 1, &v); /* ... and its argument */ + L->top += 2; /* and (next line) call the finalizer */ + status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); + L->allowhook = oldah; /* restore hooks */ + g->gcrunning = running; /* restore state */ + if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ + if (status == LUA_ERRRUN) { /* is there an error object? */ + const char *msg = (ttisstring(L->top - 1)) + ? svalue(L->top - 1) + : "no message"; + luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); + status = LUA_ERRGCMM; /* error in __gc metamethod */ + } + luaD_throw(L, status); /* re-throw error */ + } + } +} + + +/* +** move all unreachable objects (or 'all' objects) that need +** finalization from list 'finobj' to list 'tobefnz' (to be finalized) +*/ +static void separatetobefnz (lua_State *L, int all) { + global_State *g = G(L); + GCObject **p = &g->finobj; + GCObject *curr; + GCObject **lastnext = &g->tobefnz; + /* find last 'next' field in 'tobefnz' list (to add elements in its end) */ + while (*lastnext != NULL) + lastnext = &gch(*lastnext)->next; + while ((curr = *p) != NULL) { /* traverse all finalizable objects */ + lua_assert(!isfinalized(curr)); + lua_assert(testbit(gch(curr)->marked, SEPARATED)); + if (!(iswhite(curr) || all)) /* not being collected? */ + p = &gch(curr)->next; /* don't bother with it */ + else { + l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ + *p = gch(curr)->next; /* remove 'curr' from 'finobj' list */ + gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ + *lastnext = curr; + lastnext = &gch(curr)->next; + } + } +} + + +/* +** if object 'o' has a finalizer, remove it from 'allgc' list (must +** search the list to find it) and link it in 'finobj' list. +*/ +void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { + global_State *g = G(L); + if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */ + isfinalized(o) || /* ... or is finalized... */ + gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ + return; /* nothing to be done */ + else { /* move 'o' to 'finobj' list */ + GCObject **p; + GCheader *ho = gch(o); + if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */ + lua_assert(issweepphase(g)); + g->sweepgc = sweeptolive(L, g->sweepgc, NULL); + } + /* search for pointer pointing to 'o' */ + for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } + *p = ho->next; /* remove 'o' from root list */ + ho->next = g->finobj; /* link it in list 'finobj' */ + g->finobj = o; + l_setbit(ho->marked, SEPARATED); /* mark it as such */ + if (!keepinvariantout(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + else + resetoldbit(o); /* see MOVE OLD rule */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** GC control +** ======================================================= +*/ + + +/* +** set a reasonable "time" to wait before starting a new GC cycle; +** cycle will start when memory use hits threshold +*/ +static void setpause (global_State *g, l_mem estimate) { + l_mem debt, threshold; + estimate = estimate / PAUSEADJ; /* adjust 'estimate' */ + threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ + ? estimate * g->gcpause /* no overflow */ + : MAX_LMEM; /* overflow; truncate to maximum */ + debt = -cast(l_mem, threshold - gettotalbytes(g)); + luaE_setdebt(g, debt); +} + + +#define sweepphases \ + (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep)) + + +/* +** enter first sweep phase (strings) and prepare pointers for other +** sweep phases. The calls to 'sweeptolive' make pointers point to an +** object inside the list (instead of to the header), so that the real +** sweep do not need to skip objects created between "now" and the start +** of the real sweep. +** Returns how many objects it swept. +*/ +static int entersweep (lua_State *L) { + global_State *g = G(L); + int n = 0; + g->gcstate = GCSsweepstring; + lua_assert(g->sweepgc == NULL && g->sweepfin == NULL); + /* prepare to sweep strings, finalizable objects, and regular objects */ + g->sweepstrgc = 0; + g->sweepfin = sweeptolive(L, &g->finobj, &n); + g->sweepgc = sweeptolive(L, &g->allgc, &n); + return n; +} + + +/* +** change GC mode +*/ +void luaC_changemode (lua_State *L, int mode) { + global_State *g = G(L); + if (mode == g->gckind) return; /* nothing to change */ + if (mode == KGC_GEN) { /* change to generational mode */ + /* make sure gray lists are consistent */ + luaC_runtilstate(L, bitmask(GCSpropagate)); + g->GCestimate = gettotalbytes(g); + g->gckind = KGC_GEN; + } + else { /* change to incremental mode */ + /* sweep all objects to turn them back to white + (as white has not changed, nothing extra will be collected) */ + g->gckind = KGC_NORMAL; + entersweep(L); + luaC_runtilstate(L, ~sweepphases); + } +} + + +/* +** call all pending finalizers +*/ +static void callallpendingfinalizers (lua_State *L, int propagateerrors) { + global_State *g = G(L); + while (g->tobefnz) { + resetoldbit(g->tobefnz); + GCTM(L, propagateerrors); + } +} + + +void luaC_freeallobjects (lua_State *L) { + global_State *g = G(L); + int i; + separatetobefnz(L, 1); /* separate all objects with finalizers */ + lua_assert(g->finobj == NULL); + callallpendingfinalizers(L, 0); + g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ + g->gckind = KGC_NORMAL; + sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */ + sweepwholelist(L, &g->allgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); + lua_assert(g->strt.nuse == 0); +} + + +static l_mem atomic (lua_State *L) { + global_State *g = G(L); + l_mem work = -cast(l_mem, g->GCmemtrav); /* start counting work */ + GCObject *origweak, *origall; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + /* registry and global metatables may be changed by API */ + markvalue(g, &g->l_registry); + markmt(g); /* mark basic metatables */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + propagateall(g); /* propagate changes */ + work += g->GCmemtrav; /* stop counting (do not (re)count grays) */ + /* traverse objects caught by write barrier and by 'remarkupvals' */ + retraversegrays(g); + work -= g->GCmemtrav; /* restart counting */ + convergeephemerons(g); + /* at this point, all strongly accessible objects are marked. */ + /* clear values from weak tables, before checking finalizers */ + clearvalues(g, g->weak, NULL); + clearvalues(g, g->allweak, NULL); + origweak = g->weak; origall = g->allweak; + work += g->GCmemtrav; /* stop counting (objects being finalized) */ + separatetobefnz(L, 0); /* separate objects to be finalized */ + markbeingfnz(g); /* mark objects that will be finalized */ + propagateall(g); /* remark, to propagate `preserveness' */ + work -= g->GCmemtrav; /* restart counting */ + convergeephemerons(g); + /* at this point, all resurrected objects are marked. */ + /* remove dead objects from weak tables */ + clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ + clearkeys(g, g->allweak, NULL); /* clear keys from all allweak tables */ + /* clear values from resurrected weak tables */ + clearvalues(g, g->weak, origweak); + clearvalues(g, g->allweak, origall); + g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ + work += g->GCmemtrav; /* complete counting */ + return work; /* estimate of memory marked by 'atomic' */ +} + + +static lu_mem singlestep (lua_State *L) { global_State *g = G(L); - /*lua_checkmemory(L);*/ switch (g->gcstate) { case GCSpause: { - markroot(L); /* start a new collection */ - return 0; + /* start to count memory traversed */ + g->GCmemtrav = g->strt.size * sizeof(GCObject*); + lua_assert(!isgenerational(g)); + restartcollection(g); + g->gcstate = GCSpropagate; + return g->GCmemtrav; } case GCSpropagate: { - if (g->gray) - return propagatemark(g); + if (g->gray) { + lu_mem oldtrav = g->GCmemtrav; + propagatemark(g); + return g->GCmemtrav - oldtrav; /* memory traversed in this step */ + } else { /* no more `gray' objects */ - atomic(L); /* finish mark phase */ - return 0; + lu_mem work; + int sw; + g->gcstate = GCSatomic; /* finish mark phase */ + g->GCestimate = g->GCmemtrav; /* save what was counted */; + work = atomic(L); /* add what was traversed by 'atomic' */ + g->GCestimate += work; /* estimate of total memory traversed */ + sw = entersweep(L); + return work + sw * GCSWEEPCOST; } } case GCSsweepstring: { - lu_mem old = g->totalbytes; - sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); - if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ - g->gcstate = GCSsweep; /* end sweep-string phase */ - lua_assert(old >= g->totalbytes); - g->estimate -= old - g->totalbytes; - return GCSWEEPCOST; + int i; + for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++) + sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]); + g->sweepstrgc += i; + if (g->sweepstrgc >= g->strt.size) /* no more strings to sweep? */ + g->gcstate = GCSsweepudata; + return i * GCSWEEPCOST; } - case GCSsweep: { - lu_mem old = g->totalbytes; - g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); - if (*g->sweepgc == NULL) { /* nothing more to sweep? */ - checkSizes(L); - g->gcstate = GCSfinalize; /* end sweep phase */ - } - lua_assert(old >= g->totalbytes); - g->estimate -= old - g->totalbytes; - return GCSWEEPMAX*GCSWEEPCOST; - } - case GCSfinalize: { - if (g->tmudata) { - GCTM(L); - if (g->estimate > GCFINALIZECOST) - g->estimate -= GCFINALIZECOST; - return GCFINALIZECOST; + case GCSsweepudata: { + if (g->sweepfin) { + g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX); + return GCSWEEPMAX*GCSWEEPCOST; } else { - g->gcstate = GCSpause; /* end collection */ - g->gcdept = 0; + g->gcstate = GCSsweep; return 0; } } + case GCSsweep: { + if (g->sweepgc) { + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + return GCSWEEPMAX*GCSWEEPCOST; + } + else { + /* sweep main thread */ + GCObject *mt = obj2gco(g->mainthread); + sweeplist(L, &mt, 1); + checkSizes(L); + g->gcstate = GCSpause; /* finish collection */ + return GCSWEEPCOST; + } + } default: lua_assert(0); return 0; } } -void luaC_step (lua_State *L) { +/* +** advances the garbage collector until it reaches a state allowed +** by 'statemask' +*/ +void luaC_runtilstate (lua_State *L, int statesmask) { global_State *g = G(L); - l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; - if (lim == 0) - lim = (MAX_LUMEM-1)/2; /* no limit */ - g->gcdept += g->totalbytes - g->GCthreshold; - do { - lim -= singlestep(L); - if (g->gcstate == GCSpause) - break; - } while (lim > 0); - if (g->gcstate != GCSpause) { - if (g->gcdept < GCSTEPSIZE) - g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ - else { - g->gcdept -= GCSTEPSIZE; - g->GCthreshold = g->totalbytes; - } + while (!testbit(statesmask, g->gcstate)) + singlestep(L); +} + + +static void generationalcollection (lua_State *L) { + global_State *g = G(L); + lua_assert(g->gcstate == GCSpropagate); + if (g->GCestimate == 0) { /* signal for another major collection? */ + luaC_fullgc(L, 0); /* perform a full regular collection */ + g->GCestimate = gettotalbytes(g); /* update control */ } else { - lua_assert(g->totalbytes >= g->estimate); - setthreshold(g); + lu_mem estimate = g->GCestimate; + luaC_runtilstate(L, bitmask(GCSpause)); /* run complete (minor) cycle */ + g->gcstate = GCSpropagate; /* skip restart */ + if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) + g->GCestimate = 0; /* signal for a major collection */ + else + g->GCestimate = estimate; /* keep estimate from last major coll. */ + + } + setpause(g, gettotalbytes(g)); + lua_assert(g->gcstate == GCSpropagate); +} + + +static void incstep (lua_State *L) { + global_State *g = G(L); + l_mem debt = g->GCdebt; + int stepmul = g->gcstepmul; + if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values (and 0) */ + /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */ + debt = (debt / STEPMULADJ) + 1; + debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; + do { /* always perform at least one single step */ + lu_mem work = singlestep(L); /* do some work */ + debt -= work; + } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); + if (g->gcstate == GCSpause) + setpause(g, g->GCestimate); /* pause until next cycle */ + else { + debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */ + luaE_setdebt(g, debt); } } -void luaC_fullgc (lua_State *L) { +/* +** performs a basic GC step +*/ +void luaC_forcestep (lua_State *L) { global_State *g = G(L); - if (g->gcstate <= GCSpropagate) { - /* reset sweep marks to sweep all elements (returning them to white) */ - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - /* reset other collector lists */ - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - g->gcstate = GCSsweepstring; + int i; + if (isgenerational(g)) generationalcollection(L); + else incstep(L); + /* run a few finalizers (or all of them at the end of a collect cycle) */ + for (i = 0; g->tobefnz && (i < GCFINALIZENUM || g->gcstate == GCSpause); i++) + GCTM(L, 1); /* call one finalizer */ +} + + +/* +** performs a basic GC step only if collector is running +*/ +void luaC_step (lua_State *L) { + global_State *g = G(L); + if (g->gcrunning) luaC_forcestep(L); + else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */ +} + + + +/* +** performs a full GC cycle; if "isemergency", does not call +** finalizers (which could change stack positions) +*/ +void luaC_fullgc (lua_State *L, int isemergency) { + global_State *g = G(L); + int origkind = g->gckind; + lua_assert(origkind != KGC_EMERGENCY); + if (isemergency) /* do not run finalizers during emergency GC */ + g->gckind = KGC_EMERGENCY; + else { + g->gckind = KGC_NORMAL; + callallpendingfinalizers(L, 1); } - lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); - /* finish any pending sweep phase */ - while (g->gcstate != GCSfinalize) { - lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); - singlestep(L); + if (keepinvariant(g)) { /* may there be some black objects? */ + /* must sweep all objects to turn them back to white + (as white has not changed, nothing will be collected) */ + entersweep(L); } - markroot(L); - while (g->gcstate != GCSpause) { - singlestep(L); + /* finish any pending sweep phase to start a new cycle */ + luaC_runtilstate(L, bitmask(GCSpause)); + luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */ + luaC_runtilstate(L, bitmask(GCSpause)); /* run entire collection */ + if (origkind == KGC_GEN) { /* generational mode? */ + /* generational mode must be kept in propagate phase */ + luaC_runtilstate(L, bitmask(GCSpropagate)); } - setthreshold(g); + g->gckind = origkind; + setpause(g, gettotalbytes(g)); + if (!isemergency) /* do not run finalizers during emergency GC */ + callallpendingfinalizers(L, 1); } - -void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { - global_State *g = G(L); - lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - lua_assert(ttype(&o->gch) != LUA_TTABLE); - /* must keep invariant? */ - if (g->gcstate == GCSpropagate) - reallymarkobject(g, v); /* restore invariant */ - else /* don't mind */ - makewhite(g, o); /* mark as white just to avoid other barriers */ -} +/* }====================================================== */ -void luaC_barrierback (lua_State *L, Table *t) { - global_State *g = G(L); - GCObject *o = obj2gco(t); - lua_assert(isblack(o) && !isdead(g, o)); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - black2gray(o); /* make table gray (again) */ - t->gclist = g->grayagain; - g->grayagain = o; -} - - -void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { - global_State *g = G(L); - o->gch.next = g->rootgc; - g->rootgc = o; - o->gch.marked = luaC_white(g); - o->gch.tt = tt; -} - - -void luaC_linkupval (lua_State *L, UpVal *uv) { - global_State *g = G(L); - GCObject *o = obj2gco(uv); - o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ - g->rootgc = o; - if (isgray(o)) { - if (g->gcstate == GCSpropagate) { - gray2black(o); /* closed upvalues need barrier */ - luaC_barrier(L, uv, uv->v); - } - else { /* sweep phase: sweep it (turning it into white) */ - makewhite(g, o); - lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); - } - } -} - diff --git a/src/mod/languages/mod_lua/lua/lgc.h b/src/mod/languages/mod_lua/lua/lgc.h index 5a8dc605b3..dee270b4dc 100644 --- a/src/mod/languages/mod_lua/lua/lgc.h +++ b/src/mod/languages/mod_lua/lua/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lgc.h,v 2.58 2012/09/11 12:53:08 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -9,65 +9,107 @@ #include "lobject.h" +#include "lstate.h" + +/* +** Collectable objects may have one of three colors: white, which +** means the object is not marked; gray, which means the +** object is marked, but its references may be not marked; and +** black, which means that the object and all its references are marked. +** The main invariant of the garbage collector, while marking objects, +** is that a black object can never point to a white one. Moreover, +** any gray object must be in a "gray list" (gray, grayagain, weak, +** allweak, ephemeron) so that it can be visited again before finishing +** the collection cycle. These lists have no meaning when the invariant +** is not being enforced (e.g., sweep phase). +*/ + + + +/* how much to allocate before next GC step */ +#if !defined(GCSTEPSIZE) +/* ~100 small strings */ +#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) +#endif /* ** Possible states of the Garbage Collector */ -#define GCSpause 0 -#define GCSpropagate 1 +#define GCSpropagate 0 +#define GCSatomic 1 #define GCSsweepstring 2 -#define GCSsweep 3 -#define GCSfinalize 4 +#define GCSsweepudata 3 +#define GCSsweep 4 +#define GCSpause 5 + + +#define issweepphase(g) \ + (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep) + +#define isgenerational(g) ((g)->gckind == KGC_GEN) + +/* +** macros to tell when main invariant (white objects cannot point to black +** ones) must be kept. During a non-generational collection, the sweep +** phase may break the invariant, as objects turned white may point to +** still-black objects. The invariant is restored when sweep ends and +** all objects are white again. During a generational collection, the +** invariant must be kept all times. +*/ + +#define keepinvariant(g) (isgenerational(g) || g->gcstate <= GCSatomic) /* -** some userful bit tricks +** Outside the collector, the state in generational mode is kept in +** 'propagate', so 'keepinvariant' is always true. */ -#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) -#define setbits(x,m) ((x) |= (m)) -#define testbits(x,m) ((x) & (m)) -#define bitmask(b) (1<<(b)) -#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) -#define l_setbit(x,b) setbits(x, bitmask(b)) -#define resetbit(x,b) resetbits(x, bitmask(b)) -#define testbit(x,b) testbits(x, bitmask(b)) -#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) -#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) -#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) - +#define keepinvariantout(g) \ + check_exp(g->gcstate == GCSpropagate || !isgenerational(g), \ + g->gcstate <= GCSatomic) /* -** Layout for bit use in `marked' field: -** bit 0 - object is white (type 0) -** bit 1 - object is white (type 1) -** bit 2 - object is black -** bit 3 - for userdata: has been finalized -** bit 3 - for tables: has weak keys -** bit 4 - for tables: has weak values -** bit 5 - object is fixed (should not be collected) -** bit 6 - object is "super" fixed (only the main thread) +** some useful bit tricks */ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) -#define WHITE0BIT 0 -#define WHITE1BIT 1 -#define BLACKBIT 2 -#define FINALIZEDBIT 3 -#define KEYWEAKBIT 3 -#define VALUEWEAKBIT 4 -#define FIXEDBIT 5 -#define SFIXEDBIT 6 +/* Layout for bit use in `marked' field: */ +#define WHITE0BIT 0 /* object is white (type 0) */ +#define WHITE1BIT 1 /* object is white (type 1) */ +#define BLACKBIT 2 /* object is black */ +#define FINALIZEDBIT 3 /* object has been separated for finalization */ +#define SEPARATED 4 /* object is in 'finobj' list or in 'tobefnz' */ +#define FIXEDBIT 5 /* object is fixed (should not be collected) */ +#define OLDBIT 6 /* object is old (only in generational mode) */ +/* bit 7 is currently used by tests (luaL_checkmemory) */ + #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) -#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define iswhite(x) testbits((x)->gch.marked, WHITEBITS) #define isblack(x) testbit((x)->gch.marked, BLACKBIT) -#define isgray(x) (!isblack(x) && !iswhite(x)) +#define isgray(x) /* neither white nor black */ \ + (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) + +#define isold(x) testbit((x)->gch.marked, OLDBIT) + +/* MOVE OLD rule: whenever an object is moved to the beginning of + a GC list, its old bit must be cleared */ +#define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT) #define otherwhite(g) (g->currentwhite ^ WHITEBITS) -#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) +#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) +#define isdead(g,v) isdeadm(otherwhite(g), (v)->gch.marked) #define changewhite(x) ((x)->gch.marked ^= WHITEBITS) #define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) @@ -77,34 +119,39 @@ #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) -#define luaC_checkGC(L) { \ - condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ - if (G(L)->totalbytes >= G(L)->GCthreshold) \ - luaC_step(L); } +#define luaC_condGC(L,c) \ + {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);} +#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);) #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ - luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + luaC_barrier_(L,obj2gco(p),gcvalue(v)); } -#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ - luaC_barrierback(L,t); } +#define luaC_barrierback(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierback_(L,p); } #define luaC_objbarrier(L,p,o) \ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ - luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + luaC_barrier_(L,obj2gco(p),obj2gco(o)); } -#define luaC_objbarriert(L,t,o) \ - { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } +#define luaC_objbarrierback(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); } -LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); -LUAI_FUNC void luaC_callGCTM (lua_State *L); -LUAI_FUNC void luaC_freeall (lua_State *L); +#define luaC_barrierproto(L,p,c) \ + { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } + +LUAI_FUNC void luaC_freeallobjects (lua_State *L); LUAI_FUNC void luaC_step (lua_State *L); -LUAI_FUNC void luaC_fullgc (lua_State *L); -LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); -LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); -LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); -LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); - +LUAI_FUNC void luaC_forcestep (lua_State *L); +LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); +LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); +LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, + GCObject **list, int offset); +LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); +LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c); +LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); +LUAI_FUNC void luaC_checkupvalcolor (global_State *g, UpVal *uv); +LUAI_FUNC void luaC_changemode (lua_State *L, int mode); #endif diff --git a/src/mod/languages/mod_lua/lua/linit.c b/src/mod/languages/mod_lua/lua/linit.c index c1f90dfab7..8d3aa6576f 100644 --- a/src/mod/languages/mod_lua/lua/linit.c +++ b/src/mod/languages/mod_lua/lua/linit.c @@ -1,10 +1,18 @@ /* -** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ -** Initialization of libraries for lua.c +** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $ +** Initialization of libraries for lua.c and other clients ** See Copyright Notice in lua.h */ +/* +** If you embed Lua in your program and need to open the standard +** libraries, call luaL_openlibs in your program. If you need a +** different set of libraries, copy this file to your project and edit +** it to suit your needs. +*/ + + #define linit_c #define LUA_LIB @@ -14,25 +22,46 @@ #include "lauxlib.h" -static const luaL_Reg lualibs[] = { - {"", luaopen_base}, +/* +** these libs are loaded by lua.c and are readily available to any Lua +** program +*/ +static const luaL_Reg loadedlibs[] = { + {"_G", luaopen_base}, {LUA_LOADLIBNAME, luaopen_package}, + {LUA_COLIBNAME, luaopen_coroutine}, {LUA_TABLIBNAME, luaopen_table}, {LUA_IOLIBNAME, luaopen_io}, {LUA_OSLIBNAME, luaopen_os}, {LUA_STRLIBNAME, luaopen_string}, + {LUA_BITLIBNAME, luaopen_bit32}, {LUA_MATHLIBNAME, luaopen_math}, {LUA_DBLIBNAME, luaopen_debug}, {NULL, NULL} }; +/* +** these libs are preloaded and must be required before used +*/ +static const luaL_Reg preloadedlibs[] = { + {NULL, NULL} +}; + + LUALIB_API void luaL_openlibs (lua_State *L) { - const luaL_Reg *lib = lualibs; - for (; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_pushstring(L, lib->name); - lua_call(L, 1, 0); + const luaL_Reg *lib; + /* call open functions from 'loadedlibs' and set results to global table */ + for (lib = loadedlibs; lib->func; lib++) { + luaL_requiref(L, lib->name, lib->func, 1); + lua_pop(L, 1); /* remove lib */ } + /* add open functions from 'preloadedlibs' into 'package.preload' table */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); + for (lib = preloadedlibs; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_setfield(L, -2, lib->name); + } + lua_pop(L, 1); /* remove _PRELOAD table */ } diff --git a/src/mod/languages/mod_lua/lua/liolib.c b/src/mod/languages/mod_lua/lua/liolib.c index e79ed1cb2e..3f80db1927 100644 --- a/src/mod/languages/mod_lua/lua/liolib.c +++ b/src/mod/languages/mod_lua/lua/liolib.c @@ -1,10 +1,20 @@ /* -** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** $Id: liolib.c,v 2.111 2013/03/21 13:57:27 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ +/* +** POSIX idiosyncrasy! +** This definition must come before the inclusion of 'stdio.h'; it +** should not affect non-POSIX systems +*/ +#if !defined(_FILE_OFFSET_BITS) +#define _FILE_OFFSET_BITS 64 +#endif + + #include #include #include @@ -19,49 +29,110 @@ #include "lualib.h" +#if !defined(lua_checkmode) -#define IO_INPUT 1 -#define IO_OUTPUT 2 +/* +** Check whether 'mode' matches '[rwa]%+?b?'. +** Change this macro to accept other modes for 'fopen' besides +** the standard ones. +*/ +#define lua_checkmode(mode) \ + (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \ + (*mode != '+' || ++mode) && /* skip if char is '+' */ \ + (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \ + (*mode == '\0')) + +#endif + +/* +** {====================================================== +** lua_popen spawns a new process connected to the current +** one through the file streams. +** ======================================================= +*/ + +#if !defined(lua_popen) /* { */ + +#if defined(LUA_USE_POPEN) /* { */ + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, pclose(file)) + +#elif defined(LUA_WIN) /* }{ */ + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, _pclose(file)) -static const char *const fnames[] = {"input", "output"}; +#else /* }{ */ + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), -1) -static int pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - if (filename) - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - else - lua_pushfstring(L, "%s", strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} +#endif /* } */ + +#endif /* } */ + +/* }====================================================== */ -static void fileerror (lua_State *L, int arg, const char *filename) { - lua_pushfstring(L, "%s: %s", filename, strerror(errno)); - luaL_argerror(L, arg, lua_tostring(L, -1)); -} +/* +** {====================================================== +** lua_fseek/lua_ftell: configuration for longer offsets +** ======================================================= +*/ + +#if !defined(lua_fseek) /* { */ + +#if defined(LUA_USE_POSIX) + +#define l_fseek(f,o,w) fseeko(f,o,w) +#define l_ftell(f) ftello(f) +#define l_seeknum off_t + +#elif defined(LUA_WIN) && !defined(_CRTIMP_TYPEINFO) \ + && defined(_MSC_VER) && (_MSC_VER >= 1400) +/* Windows (but not DDK) and Visual C++ 2005 or higher */ + +#define l_fseek(f,o,w) _fseeki64(f,o,w) +#define l_ftell(f) _ftelli64(f) +#define l_seeknum __int64 + +#else + +#define l_fseek(f,o,w) fseek(f,o,w) +#define l_ftell(f) ftell(f) +#define l_seeknum long + +#endif + +#endif /* } */ + +/* }====================================================== */ -#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) +#define IO_PREFIX "_IO_" +#define IO_INPUT (IO_PREFIX "input") +#define IO_OUTPUT (IO_PREFIX "output") + + +typedef luaL_Stream LStream; + + +#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + +#define isclosed(p) ((p)->closef == NULL) static int io_type (lua_State *L) { - void *ud; + LStream *p; luaL_checkany(L, 1); - ud = lua_touserdata(L, 1); - lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); - if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE); + if (p == NULL) lua_pushnil(L); /* not a file */ - else if (*((FILE **)ud) == NULL) + else if (isclosed(p)) lua_pushliteral(L, "closed file"); else lua_pushliteral(L, "file"); @@ -69,47 +140,59 @@ static int io_type (lua_State *L) { } -static FILE *tofile (lua_State *L) { - FILE **f = tofilep(L); - if (*f == NULL) - luaL_error(L, "attempt to use a closed file"); - return *f; +static int f_tostring (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", p->f); + return 1; } +static FILE *tofile (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + luaL_error(L, "attempt to use a closed file"); + lua_assert(p->f); + return p->f; +} + /* ** When creating file handles, always creates a `closed' file handle ** before opening the actual file; so, if there is a memory error, the ** file is not left opened. */ -static FILE **newfile (lua_State *L) { - FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); - *pf = NULL; /* file handle is currently `closed' */ - luaL_getmetatable(L, LUA_FILEHANDLE); - lua_setmetatable(L, -2); - return pf; +static LStream *newprefile (lua_State *L) { + LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); + p->closef = NULL; /* mark file handle as 'closed' */ + luaL_setmetatable(L, LUA_FILEHANDLE); + return p; } -/* -** function to (not) close the standard files stdin, stdout, and stderr -*/ -static int io_noclose (lua_State *L) { - lua_pushnil(L); - lua_pushliteral(L, "cannot close standard file"); - return 2; +static int aux_close (lua_State *L) { + LStream *p = tolstream(L); + lua_CFunction cf = p->closef; + p->closef = NULL; /* mark stream as closed */ + return (*cf)(L); /* close it */ } -/* -** function to close 'popen' files -*/ -static int io_pclose (lua_State *L) { - FILE **p = tofilep(L); - int ok = lua_pclose(L, *p); - *p = NULL; - return pushresult(L, ok, NULL); +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) /* no argument? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ + tofile(L); /* make sure argument is an open stream */ + return aux_close(L); +} + + +static int f_gc (lua_State *L) { + LStream *p = tolstream(L); + if (!isclosed(p) && p->f != NULL) + aux_close(L); /* ignore closed and incompletely open files */ + return 0; } @@ -117,103 +200,88 @@ static int io_pclose (lua_State *L) { ** function to close regular files */ static int io_fclose (lua_State *L) { - FILE **p = tofilep(L); - int ok = (fclose(*p) == 0); - *p = NULL; - return pushresult(L, ok, NULL); + LStream *p = tolstream(L); + int res = fclose(p->f); + return luaL_fileresult(L, (res == 0), NULL); } -static int aux_close (lua_State *L) { - lua_getfenv(L, 1); - lua_getfield(L, -1, "__close"); - return (lua_tocfunction(L, -1))(L); +static LStream *newfile (lua_State *L) { + LStream *p = newprefile(L); + p->f = NULL; + p->closef = &io_fclose; + return p; } -static int io_close (lua_State *L) { - if (lua_isnone(L, 1)) - lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); - tofile(L); /* make sure argument is a file */ - return aux_close(L); -} - - -static int io_gc (lua_State *L) { - FILE *f = *tofilep(L); - /* ignore closed files */ - if (f != NULL) - aux_close(L); - return 0; -} - - -static int io_tostring (lua_State *L) { - FILE *f = *tofilep(L); - if (f == NULL) - lua_pushliteral(L, "file (closed)"); - else - lua_pushfstring(L, "file (%p)", f); - return 1; +static void opencheck (lua_State *L, const char *fname, const char *mode) { + LStream *p = newfile(L); + p->f = fopen(fname, mode); + if (p->f == NULL) + luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno)); } static int io_open (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; + LStream *p = newfile(L); + const char *md = mode; /* to traverse/check mode */ + luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode"); + p->f = fopen(filename, mode); + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; } /* -** this function has a separated environment, which defines the -** correct __close for 'popen' files +** function to close 'popen' files */ +static int io_pclose (lua_State *L) { + LStream *p = tolstream(L); + return luaL_execresult(L, lua_pclose(L, p->f)); +} + + static int io_popen (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = lua_popen(L, filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; + LStream *p = newprefile(L); + p->f = lua_popen(L, filename, mode); + p->closef = &io_pclose; + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; } static int io_tmpfile (lua_State *L) { - FILE **pf = newfile(L); - *pf = tmpfile(); - return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; + LStream *p = newfile(L); + p->f = tmpfile(); + return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1; } -static FILE *getiofile (lua_State *L, int findex) { - FILE *f; - lua_rawgeti(L, LUA_ENVIRONINDEX, findex); - f = *(FILE **)lua_touserdata(L, -1); - if (f == NULL) - luaL_error(L, "standard %s file is closed", fnames[findex - 1]); - return f; +static FILE *getiofile (lua_State *L, const char *findex) { + LStream *p; + lua_getfield(L, LUA_REGISTRYINDEX, findex); + p = (LStream *)lua_touserdata(L, -1); + if (isclosed(p)) + luaL_error(L, "standard %s file is closed", findex + strlen(IO_PREFIX)); + return p->f; } -static int g_iofile (lua_State *L, int f, const char *mode) { +static int g_iofile (lua_State *L, const char *f, const char *mode) { if (!lua_isnoneornil(L, 1)) { const char *filename = lua_tostring(L, 1); - if (filename) { - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - if (*pf == NULL) - fileerror(L, 1, filename); - } + if (filename) + opencheck(L, filename, mode); else { tofile(L); /* check that it's a valid file handle */ lua_pushvalue(L, 1); } - lua_rawseti(L, LUA_ENVIRONINDEX, f); + lua_setfield(L, LUA_REGISTRYINDEX, f); } /* return current value */ - lua_rawgeti(L, LUA_ENVIRONINDEX, f); + lua_getfield(L, LUA_REGISTRYINDEX, f); return 1; } @@ -231,35 +299,43 @@ static int io_output (lua_State *L) { static int io_readline (lua_State *L); -static void aux_lines (lua_State *L, int idx, int toclose) { - lua_pushvalue(L, idx); +static void aux_lines (lua_State *L, int toclose) { + int i; + int n = lua_gettop(L) - 1; /* number of arguments to read */ + /* ensure that arguments will fit here and into 'io_readline' stack */ + luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options"); + lua_pushvalue(L, 1); /* file handle */ + lua_pushinteger(L, n); /* number of arguments to read */ lua_pushboolean(L, toclose); /* close/not close file when finished */ - lua_pushcclosure(L, io_readline, 2); + for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */ + lua_pushcclosure(L, io_readline, 3 + n); } static int f_lines (lua_State *L) { tofile(L); /* check that it's a valid file handle */ - aux_lines(L, 1, 0); + aux_lines(L, 0); return 1; } static int io_lines (lua_State *L) { - if (lua_isnoneornil(L, 1)) { /* no arguments? */ - /* will iterate over default input */ - lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); - return f_lines(L); + int toclose; + if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ + if (lua_isnil(L, 1)) { /* no file name? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */ + lua_replace(L, 1); /* put it at index 1 */ + tofile(L); /* check that it's a valid file handle */ + toclose = 0; /* do not close it after iteration */ } - else { + else { /* open a new file */ const char *filename = luaL_checkstring(L, 1); - FILE **pf = newfile(L); - *pf = fopen(filename, "r"); - if (*pf == NULL) - fileerror(L, 1, filename); - aux_lines(L, lua_gettop(L), 1); - return 1; + opencheck(L, filename, "r"); + lua_replace(L, 1); /* put file at index 1 */ + toclose = 1; /* close it after iteration */ } + aux_lines(L, toclose); + return 1; } @@ -276,7 +352,10 @@ static int read_number (lua_State *L, FILE *f) { lua_pushnumber(L, d); return 1; } - else return 0; /* read fails */ + else { + lua_pushnil(L); /* "result" to be removed */ + return 0; /* read fails */ + } } @@ -288,7 +367,7 @@ static int test_eof (lua_State *L, FILE *f) { } -static int read_line (lua_State *L, FILE *f) { +static int read_line (lua_State *L, FILE *f, int chop) { luaL_Buffer b; luaL_buffinit(L, &b); for (;;) { @@ -296,13 +375,13 @@ static int read_line (lua_State *L, FILE *f) { char *p = luaL_prepbuffer(&b); if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ luaL_pushresult(&b); /* close buffer */ - return (lua_objlen(L, -1) > 0); /* check whether read something */ + return (lua_rawlen(L, -1) > 0); /* check whether read something */ } l = strlen(p); if (l == 0 || p[l-1] != '\n') luaL_addsize(&b, l); else { - luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_addsize(&b, l - chop); /* chop 'eol' if needed */ luaL_pushresult(&b); /* close buffer */ return 1; /* read at least an `eol' */ } @@ -310,21 +389,34 @@ static int read_line (lua_State *L, FILE *f) { } -static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t rlen; /* how much to read */ - size_t nr; /* number of chars actually read */ +#define MAX_SIZE_T (~(size_t)0) + +static void read_all (lua_State *L, FILE *f) { + size_t rlen = LUAL_BUFFERSIZE; /* how much to read in each cycle */ luaL_Buffer b; luaL_buffinit(L, &b); - rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ - do { - char *p = luaL_prepbuffer(&b); - if (rlen > n) rlen = n; /* cannot read more than asked */ - nr = fread(p, sizeof(char), rlen, f); + for (;;) { + char *p = luaL_prepbuffsize(&b, rlen); + size_t nr = fread(p, sizeof(char), rlen, f); luaL_addsize(&b, nr); - n -= nr; /* still have to read `n' chars */ - } while (n > 0 && nr == rlen); /* until end of count or eof */ + if (nr < rlen) break; /* eof? */ + else if (rlen <= (MAX_SIZE_T / 4)) /* avoid buffers too large */ + rlen *= 2; /* double buffer size at each iteration */ + } luaL_pushresult(&b); /* close buffer */ - return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t nr; /* number of chars actually read */ + char *p; + luaL_Buffer b; + luaL_buffinit(L, &b); + p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ + nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ + luaL_addsize(&b, nr); + luaL_pushresult(&b); /* close buffer */ + return (nr > 0); /* true iff read something */ } @@ -334,7 +426,7 @@ static int g_read (lua_State *L, FILE *f, int first) { int n; clearerr(f); if (nargs == 0) { /* no arguments? */ - success = read_line(L, f); + success = read_line(L, f, 1); n = first+1; /* to return 1 result */ } else { /* ensure stack space for all results and for auxlib's buffer */ @@ -353,10 +445,13 @@ static int g_read (lua_State *L, FILE *f, int first) { success = read_number(L, f); break; case 'l': /* line */ - success = read_line(L, f); + success = read_line(L, f, 1); + break; + case 'L': /* line with end-of-line */ + success = read_line(L, f, 0); break; case 'a': /* file */ - read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + read_all(L, f); /* read entire file */ success = 1; /* always success */ break; default: @@ -366,7 +461,7 @@ static int g_read (lua_State *L, FILE *f, int first) { } } if (ferror(f)) - return pushresult(L, 0, NULL); + return luaL_fileresult(L, 0, NULL); if (!success) { lua_pop(L, 1); /* remove last result */ lua_pushnil(L); /* push nil instead */ @@ -386,16 +481,24 @@ static int f_read (lua_State *L) { static int io_readline (lua_State *L) { - FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); - int sucess; - if (f == NULL) /* file is already closed? */ - luaL_error(L, "file is already closed"); - sucess = read_line(L, f); - if (ferror(f)) - return luaL_error(L, "%s", strerror(errno)); - if (sucess) return 1; - else { /* EOF */ - if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); + int i; + int n = (int)lua_tointeger(L, lua_upvalueindex(2)); + if (isclosed(p)) /* file is already closed? */ + return luaL_error(L, "file is already closed"); + lua_settop(L , 1); + for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ + lua_pushvalue(L, lua_upvalueindex(3 + i)); + n = g_read(L, p->f, 2); /* 'n' is number of results */ + lua_assert(n > 0); /* should return at least a nil */ + if (!lua_isnil(L, -n)) /* read at least one value? */ + return n; /* return them */ + else { /* first result is nil: EOF or error */ + if (n > 1) { /* is there error information? */ + /* 2nd result is error message */ + return luaL_error(L, "%s", lua_tostring(L, -n + 1)); + } + if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ lua_settop(L, 0); lua_pushvalue(L, lua_upvalueindex(1)); aux_close(L); /* close it */ @@ -408,7 +511,7 @@ static int io_readline (lua_State *L) { static int g_write (lua_State *L, FILE *f, int arg) { - int nargs = lua_gettop(L) - 1; + int nargs = lua_gettop(L) - arg; int status = 1; for (; nargs--; arg++) { if (lua_type(L, arg) == LUA_TNUMBER) { @@ -422,7 +525,8 @@ static int g_write (lua_State *L, FILE *f, int arg) { status = status && (fwrite(s, sizeof(char), l, f) == l); } } - return pushresult(L, status, NULL); + if (status) return 1; /* file handle already on stack top */ + else return luaL_fileresult(L, status, NULL); } @@ -432,7 +536,9 @@ static int io_write (lua_State *L) { static int f_write (lua_State *L) { - return g_write(L, tofile(L), 2); + FILE *f = tofile(L); + lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ + return g_write(L, f, 2); } @@ -441,12 +547,15 @@ static int f_seek (lua_State *L) { static const char *const modenames[] = {"set", "cur", "end", NULL}; FILE *f = tofile(L); int op = luaL_checkoption(L, 2, "cur", modenames); - long offset = luaL_optlong(L, 3, 0); - op = fseek(f, offset, mode[op]); + lua_Number p3 = luaL_optnumber(L, 3, 0); + l_seeknum offset = (l_seeknum)p3; + luaL_argcheck(L, (lua_Number)offset == p3, 3, + "not an integer in proper range"); + op = l_fseek(f, offset, mode[op]); if (op) - return pushresult(L, 0, NULL); /* error */ + return luaL_fileresult(L, 0, NULL); /* error */ else { - lua_pushinteger(L, ftell(f)); + lua_pushnumber(L, (lua_Number)l_ftell(f)); return 1; } } @@ -459,21 +568,24 @@ static int f_setvbuf (lua_State *L) { int op = luaL_checkoption(L, 2, NULL, modenames); lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); int res = setvbuf(f, NULL, mode[op], sz); - return pushresult(L, res == 0, NULL); + return luaL_fileresult(L, res == 0, NULL); } static int io_flush (lua_State *L) { - return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); + return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); } static int f_flush (lua_State *L) { - return pushresult(L, fflush(tofile(L)) == 0, NULL); + return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); } +/* +** functions for 'io' library +*/ static const luaL_Reg iolib[] = { {"close", io_close}, {"flush", io_flush}, @@ -490,6 +602,9 @@ static const luaL_Reg iolib[] = { }; +/* +** methods for file handles +*/ static const luaL_Reg flib[] = { {"close", io_close}, {"flush", f_flush}, @@ -498,8 +613,8 @@ static const luaL_Reg flib[] = { {"seek", f_seek}, {"setvbuf", f_setvbuf}, {"write", f_write}, - {"__gc", io_gc}, - {"__tostring", io_tostring}, + {"__gc", f_gc}, + {"__tostring", f_tostring}, {NULL, NULL} }; @@ -508,46 +623,43 @@ static void createmeta (lua_State *L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, flib); /* file methods */ + luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ + lua_pop(L, 1); /* pop new metatable */ } -static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { - *newfile(L) = f; - if (k > 0) { +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + LStream *p = tolstream(L); + p->closef = &io_noclose; /* keep file opened */ + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +static void createstdfile (lua_State *L, FILE *f, const char *k, + const char *fname) { + LStream *p = newprefile(L); + p->f = f; + p->closef = &io_noclose; + if (k != NULL) { lua_pushvalue(L, -1); - lua_rawseti(L, LUA_ENVIRONINDEX, k); + lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */ } - lua_pushvalue(L, -2); /* copy environment */ - lua_setfenv(L, -2); /* set it */ - lua_setfield(L, -3, fname); + lua_setfield(L, -2, fname); /* add file to module */ } -static void newfenv (lua_State *L, lua_CFunction cls) { - lua_createtable(L, 0, 1); - lua_pushcfunction(L, cls); - lua_setfield(L, -2, "__close"); -} - - -LUALIB_API int luaopen_io (lua_State *L) { +LUAMOD_API int luaopen_io (lua_State *L) { + luaL_newlib(L, iolib); /* new module */ createmeta(L); - /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ - newfenv(L, io_fclose); - lua_replace(L, LUA_ENVIRONINDEX); - /* open library */ - luaL_register(L, LUA_IOLIBNAME, iolib); /* create (and set) default files */ - newfenv(L, io_noclose); /* close function for default files */ createstdfile(L, stdin, IO_INPUT, "stdin"); createstdfile(L, stdout, IO_OUTPUT, "stdout"); - createstdfile(L, stderr, 0, "stderr"); - lua_pop(L, 1); /* pop environment for default files */ - lua_getfield(L, -1, "popen"); - newfenv(L, io_pclose); /* create environment for 'popen' */ - lua_setfenv(L, -2); /* set fenv for 'popen' */ - lua_pop(L, 1); /* pop 'popen' */ + createstdfile(L, stderr, NULL, "stderr"); return 1; } diff --git a/src/mod/languages/mod_lua/lua/llex.c b/src/mod/languages/mod_lua/lua/llex.c index 6dc319358c..1a32e348b0 100644 --- a/src/mod/languages/mod_lua/lua/llex.c +++ b/src/mod/languages/mod_lua/lua/llex.c @@ -1,11 +1,10 @@ /* -** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ -#include #include #include @@ -14,6 +13,7 @@ #include "lua.h" +#include "lctype.h" #include "ldo.h" #include "llex.h" #include "lobject.h" @@ -29,35 +29,36 @@ - #define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') /* ORDER RESERVED */ -const char *const luaX_tokens [] = { +static const char *const luaX_tokens [] = { "and", "break", "do", "else", "elseif", - "end", "false", "for", "function", "if", + "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while", - "..", "...", "==", ">=", "<=", "~=", - "", "", "", "", - NULL + "..", "...", "==", ">=", "<=", "~=", "::", "", + "", "", "" }; #define save_and_next(ls) (save(ls, ls->current), next(ls)) +static l_noret lexerror (LexState *ls, const char *msg, int token); + + static void save (LexState *ls, int c) { Mbuffer *b = ls->buff; - if (b->n + 1 > b->buffsize) { + if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) { size_t newsize; - if (b->buffsize >= MAX_SIZET/2) - luaX_lexerror(ls, "lexical element too long", 0); - newsize = b->buffsize * 2; + if (luaZ_sizebuffer(b) >= MAX_SIZET/2) + lexerror(ls, "lexical element too long", 0); + newsize = luaZ_sizebuffer(b) * 2; luaZ_resizebuffer(ls->L, b, newsize); } - b->buffer[b->n++] = cast(char, c); + b->buffer[luaZ_bufflen(b)++] = cast(char, c); } @@ -66,23 +67,24 @@ void luaX_init (lua_State *L) { for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + ts->tsv.extra = cast_byte(i+1); /* reserved word */ } } -#define MAXSRC 80 - - const char *luaX_token2str (LexState *ls, int token) { - if (token < FIRST_RESERVED) { + if (token < FIRST_RESERVED) { /* single-byte symbols? */ lua_assert(token == cast(unsigned char, token)); - return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : - luaO_pushfstring(ls->L, "%c", token); + return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) : + luaO_pushfstring(ls->L, "char(%d)", token); + } + else { + const char *s = luaX_tokens[token - FIRST_RESERVED]; + if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ + return luaO_pushfstring(ls->L, LUA_QS, s); + else /* names, strings, and numerals */ + return s; } - else - return luaX_tokens[token-FIRST_RESERVED]; } @@ -92,38 +94,54 @@ static const char *txtToken (LexState *ls, int token) { case TK_STRING: case TK_NUMBER: save(ls, '\0'); - return luaZ_buffer(ls->buff); + return luaO_pushfstring(ls->L, LUA_QS, luaZ_buffer(ls->buff)); default: return luaX_token2str(ls, token); } } -void luaX_lexerror (LexState *ls, const char *msg, int token) { - char buff[MAXSRC]; - luaO_chunkid(buff, getstr(ls->source), MAXSRC); +static l_noret lexerror (LexState *ls, const char *msg, int token) { + char buff[LUA_IDSIZE]; + luaO_chunkid(buff, getstr(ls->source), LUA_IDSIZE); msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); if (token) - luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaO_pushfstring(ls->L, "%s near %s", msg, txtToken(ls, token)); luaD_throw(ls->L, LUA_ERRSYNTAX); } -void luaX_syntaxerror (LexState *ls, const char *msg) { - luaX_lexerror(ls, msg, ls->t.token); +l_noret luaX_syntaxerror (LexState *ls, const char *msg) { + lexerror(ls, msg, ls->t.token); } +/* +** creates a new string and anchors it in function's table so that +** it will not be collected until the end of the function's compilation +** (by that time it should be anchored in function's prototype) +*/ TString *luaX_newstring (LexState *ls, const char *str, size_t l) { lua_State *L = ls->L; - TString *ts = luaS_newlstr(L, str, l); - TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ - if (ttisnil(o)) - setbvalue(o, 1); /* make sure `str' will not be collected */ + TValue *o; /* entry for `str' */ + TString *ts = luaS_newlstr(L, str, l); /* create new string */ + setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */ + o = luaH_set(L, ls->fs->h, L->top - 1); + if (ttisnil(o)) { /* not in use yet? (see 'addK') */ + /* boolean value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setbvalue(o, 1); /* t[string] = true */ + luaC_checkGC(L); + } + L->top--; /* remove string from stack */ return ts; } +/* +** increment line number and skips newline sequence (any of +** \n, \r, \n\r, or \r\n) +*/ static void inclinenumber (LexState *ls) { int old = ls->current; lua_assert(currIsNewline(ls)); @@ -135,17 +153,20 @@ static void inclinenumber (LexState *ls) { } -void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, + int firstchar) { ls->decpoint = '.'; ls->L = L; + ls->current = firstchar; ls->lookahead.token = TK_EOS; /* no look-ahead token */ ls->z = z; ls->fs = NULL; ls->linenumber = 1; ls->lastline = 1; ls->source = source; + ls->envn = luaS_new(L, LUA_ENV); /* create env name */ + luaS_fix(ls->envn); /* never collect this name */ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ - next(ls); /* read first char */ } @@ -159,13 +180,16 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { static int check_next (LexState *ls, const char *set) { - if (!strchr(set, ls->current)) + if (ls->current == '\0' || !strchr(set, ls->current)) return 0; save_and_next(ls); return 1; } +/* +** change all characters 'from' in buffer to 'to' +*/ static void buffreplace (LexState *ls, char from, char to) { size_t n = luaZ_bufflen(ls->buff); char *p = luaZ_buffer(ls->buff); @@ -174,37 +198,59 @@ static void buffreplace (LexState *ls, char from, char to) { } +#if !defined(getlocaledecpoint) +#define getlocaledecpoint() (localeconv()->decimal_point[0]) +#endif + + +#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e) + +/* +** in case of format error, try to change decimal point separator to +** the one defined in the current locale and check again +*/ static void trydecpoint (LexState *ls, SemInfo *seminfo) { - /* format error: try to update decimal point separator */ - struct lconv *cv = localeconv(); char old = ls->decpoint; - ls->decpoint = (cv ? cv->decimal_point[0] : '.'); - buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ - if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + ls->decpoint = getlocaledecpoint(); + buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ + if (!buff2d(ls->buff, &seminfo->r)) { /* format error with correct decimal point: no more options */ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ - luaX_lexerror(ls, "malformed number", TK_NUMBER); + lexerror(ls, "malformed number", TK_NUMBER); } } /* LUA_NUMBER */ +/* +** this function is quite liberal in what it accepts, as 'luaO_str2d' +** will reject ill-formed numerals. +*/ static void read_numeral (LexState *ls, SemInfo *seminfo) { - lua_assert(isdigit(ls->current)); - do { - save_and_next(ls); - } while (isdigit(ls->current) || ls->current == '.'); - if (check_next(ls, "Ee")) /* `E'? */ - check_next(ls, "+-"); /* optional exponent sign */ - while (isalnum(ls->current) || ls->current == '_') - save_and_next(ls); + const char *expo = "Ee"; + int first = ls->current; + lua_assert(lisdigit(ls->current)); + save_and_next(ls); + if (first == '0' && check_next(ls, "Xx")) /* hexadecimal? */ + expo = "Pp"; + for (;;) { + if (check_next(ls, expo)) /* exponent part? */ + check_next(ls, "+-"); /* optional exponent sign */ + if (lisxdigit(ls->current) || ls->current == '.') + save_and_next(ls); + else break; + } save(ls, '\0'); buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ - if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + if (!buff2d(ls->buff, &seminfo->r)) /* format error? */ trydecpoint(ls, seminfo); /* try to update decimal point separator */ } +/* +** skip a sequence '[=*[' or ']=*]' and return its number of '='s or +** -1 if sequence is malformed +*/ static int skip_sep (LexState *ls) { int count = 0; int s = ls->current; @@ -219,43 +265,23 @@ static int skip_sep (LexState *ls) { static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { - int cont = 0; - (void)(cont); /* avoid warnings when `cont' is not used */ save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ inclinenumber(ls); /* skip it */ for (;;) { switch (ls->current) { case EOZ: - luaX_lexerror(ls, (seminfo) ? "unfinished long string" : - "unfinished long comment", TK_EOS); + lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); break; /* to avoid warnings */ -#if defined(LUA_COMPAT_LSTR) - case '[': { - if (skip_sep(ls) == sep) { - save_and_next(ls); /* skip 2nd `[' */ - cont++; -#if LUA_COMPAT_LSTR == 1 - if (sep == 0) - luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); -#endif - } - break; - } -#endif case ']': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ -#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 - cont--; - if (sep == 0 && cont >= 0) break; -#endif goto endloop; } break; } - case '\n': - case '\r': { + case '\n': case '\r': { save(ls, '\n'); inclinenumber(ls); if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ @@ -273,51 +299,91 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { } +static void escerror (LexState *ls, int *c, int n, const char *msg) { + int i; + luaZ_resetbuffer(ls->buff); /* prepare error message */ + save(ls, '\\'); + for (i = 0; i < n && c[i] != EOZ; i++) + save(ls, c[i]); + lexerror(ls, msg, TK_STRING); +} + + +static int readhexaesc (LexState *ls) { + int c[3], i; /* keep input for error message */ + int r = 0; /* result accumulator */ + c[0] = 'x'; /* for error message */ + for (i = 1; i < 3; i++) { /* read two hexadecimal digits */ + c[i] = next(ls); + if (!lisxdigit(c[i])) + escerror(ls, c, i + 1, "hexadecimal digit expected"); + r = (r << 4) + luaO_hexavalue(c[i]); + } + return r; +} + + +static int readdecesc (LexState *ls) { + int c[3], i; + int r = 0; /* result accumulator */ + for (i = 0; i < 3 && lisdigit(ls->current); i++) { /* read up to 3 digits */ + c[i] = ls->current; + r = 10*r + c[i] - '0'; + next(ls); + } + if (r > UCHAR_MAX) + escerror(ls, c, i, "decimal escape too large"); + return r; +} + + static void read_string (LexState *ls, int del, SemInfo *seminfo) { - save_and_next(ls); + save_and_next(ls); /* keep delimiter (for error messages) */ while (ls->current != del) { switch (ls->current) { case EOZ: - luaX_lexerror(ls, "unfinished string", TK_EOS); - continue; /* to avoid warnings */ + lexerror(ls, "unfinished string", TK_EOS); + break; /* to avoid warnings */ case '\n': case '\r': - luaX_lexerror(ls, "unfinished string", TK_STRING); - continue; /* to avoid warnings */ - case '\\': { - int c; + lexerror(ls, "unfinished string", TK_STRING); + break; /* to avoid warnings */ + case '\\': { /* escape sequences */ + int c; /* final character to be saved */ next(ls); /* do not save the `\' */ switch (ls->current) { - case 'a': c = '\a'; break; - case 'b': c = '\b'; break; - case 'f': c = '\f'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'v': c = '\v'; break; - case '\n': /* go through */ - case '\r': save(ls, '\n'); inclinenumber(ls); continue; - case EOZ: continue; /* will raise an error next loop */ - default: { - if (!isdigit(ls->current)) - save_and_next(ls); /* handles \\, \", \', and \? */ - else { /* \xxx */ - int i = 0; - c = 0; - do { - c = 10*c + (ls->current-'0'); - next(ls); - } while (++i<3 && isdigit(ls->current)); - if (c > UCHAR_MAX) - luaX_lexerror(ls, "escape sequence too large", TK_STRING); - save(ls, c); + case 'a': c = '\a'; goto read_save; + case 'b': c = '\b'; goto read_save; + case 'f': c = '\f'; goto read_save; + case 'n': c = '\n'; goto read_save; + case 'r': c = '\r'; goto read_save; + case 't': c = '\t'; goto read_save; + case 'v': c = '\v'; goto read_save; + case 'x': c = readhexaesc(ls); goto read_save; + case '\n': case '\r': + inclinenumber(ls); c = '\n'; goto only_save; + case '\\': case '\"': case '\'': + c = ls->current; goto read_save; + case EOZ: goto no_save; /* will raise an error next loop */ + case 'z': { /* zap following span of spaces */ + next(ls); /* skip the 'z' */ + while (lisspace(ls->current)) { + if (currIsNewline(ls)) inclinenumber(ls); + else next(ls); } - continue; + goto no_save; + } + default: { + if (!lisdigit(ls->current)) + escerror(ls, &ls->current, 1, "invalid escape sequence"); + /* digital escape \ddd */ + c = readdecesc(ls); + goto only_save; } } - save(ls, c); - next(ls); - continue; + read_save: next(ls); /* read next character */ + only_save: save(ls, c); /* save 'c' */ + no_save: break; } default: save_and_next(ls); @@ -333,38 +399,41 @@ static int llex (LexState *ls, SemInfo *seminfo) { luaZ_resetbuffer(ls->buff); for (;;) { switch (ls->current) { - case '\n': - case '\r': { + case '\n': case '\r': { /* line breaks */ inclinenumber(ls); - continue; + break; } - case '-': { + case ' ': case '\f': case '\t': case '\v': { /* spaces */ + next(ls); + break; + } + case '-': { /* '-' or '--' (comment) */ next(ls); if (ls->current != '-') return '-'; /* else is a comment */ next(ls); - if (ls->current == '[') { + if (ls->current == '[') { /* long comment? */ int sep = skip_sep(ls); luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { - read_long_string(ls, NULL, sep); /* long comment */ - luaZ_resetbuffer(ls->buff); - continue; + read_long_string(ls, NULL, sep); /* skip long comment */ + luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ + break; } } /* else short comment */ while (!currIsNewline(ls) && ls->current != EOZ) - next(ls); - continue; + next(ls); /* skip until end of line (or end of file) */ + break; } - case '[': { + case '[': { /* long string or simply '[' */ int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep == -1) return '['; - else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + else lexerror(ls, "invalid long string delimiter", TK_STRING); } case '=': { next(ls); @@ -386,56 +455,52 @@ static int llex (LexState *ls, SemInfo *seminfo) { if (ls->current != '=') return '~'; else { next(ls); return TK_NE; } } - case '"': - case '\'': { + case ':': { + next(ls); + if (ls->current != ':') return ':'; + else { next(ls); return TK_DBCOLON; } + } + case '"': case '\'': { /* short literal strings */ read_string(ls, ls->current, seminfo); return TK_STRING; } - case '.': { + case '.': { /* '.', '..', '...', or number */ save_and_next(ls); if (check_next(ls, ".")) { if (check_next(ls, ".")) - return TK_DOTS; /* ... */ - else return TK_CONCAT; /* .. */ - } - else if (!isdigit(ls->current)) return '.'; - else { - read_numeral(ls, seminfo); - return TK_NUMBER; + return TK_DOTS; /* '...' */ + else return TK_CONCAT; /* '..' */ } + else if (!lisdigit(ls->current)) return '.'; + /* else go through */ + } + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { + read_numeral(ls, seminfo); + return TK_NUMBER; } case EOZ: { return TK_EOS; } default: { - if (isspace(ls->current)) { - lua_assert(!currIsNewline(ls)); - next(ls); - continue; - } - else if (isdigit(ls->current)) { - read_numeral(ls, seminfo); - return TK_NUMBER; - } - else if (isalpha(ls->current) || ls->current == '_') { - /* identifier or reserved word */ + if (lislalpha(ls->current)) { /* identifier or reserved word? */ TString *ts; do { save_and_next(ls); - } while (isalnum(ls->current) || ls->current == '_'); + } while (lislalnum(ls->current)); ts = luaX_newstring(ls, luaZ_buffer(ls->buff), luaZ_bufflen(ls->buff)); - if (ts->tsv.reserved > 0) /* reserved word? */ - return ts->tsv.reserved - 1 + FIRST_RESERVED; + seminfo->ts = ts; + if (isreserved(ts)) /* reserved word? */ + return ts->tsv.extra - 1 + FIRST_RESERVED; else { - seminfo->ts = ts; return TK_NAME; } } - else { + else { /* single-char tokens (+ - / ...) */ int c = ls->current; next(ls); - return c; /* single-char tokens (+ - / ...) */ + return c; } } } @@ -454,8 +519,9 @@ void luaX_next (LexState *ls) { } -void luaX_lookahead (LexState *ls) { +int luaX_lookahead (LexState *ls) { lua_assert(ls->lookahead.token == TK_EOS); ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); + return ls->lookahead.token; } diff --git a/src/mod/languages/mod_lua/lua/llex.h b/src/mod/languages/mod_lua/lua/llex.h index a9201cee48..9ca8a29948 100644 --- a/src/mod/languages/mod_lua/lua/llex.h +++ b/src/mod/languages/mod_lua/lua/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: llex.h,v 1.72 2011/11/30 12:43:51 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -13,8 +13,6 @@ #define FIRST_RESERVED 257 -/* maximum length of a reserved word */ -#define TOKEN_LEN (sizeof("function")/sizeof(char)) /* @@ -25,21 +23,17 @@ enum RESERVED { /* terminal symbols denoted by reserved words */ TK_AND = FIRST_RESERVED, TK_BREAK, TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, - TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, /* other terminal symbols */ - TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, - TK_NAME, TK_STRING, TK_EOS + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, + TK_NUMBER, TK_NAME, TK_STRING }; /* number of reserved words */ #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) -/* array with token `names' */ -LUAI_DATA const char *const luaX_tokens []; - - typedef union { lua_Number r; TString *ts; @@ -52,29 +46,32 @@ typedef struct Token { } Token; +/* state of the lexer plus state of the parser when shared by all + functions */ typedef struct LexState { int current; /* current character (charint) */ int linenumber; /* input line counter */ int lastline; /* line of last token `consumed' */ Token t; /* current token */ Token lookahead; /* look ahead token */ - struct FuncState *fs; /* `FuncState' is private to the parser */ + struct FuncState *fs; /* current function (parser) */ struct lua_State *L; ZIO *z; /* input stream */ Mbuffer *buff; /* buffer for tokens */ + struct Dyndata *dyd; /* dynamic structures used by the parser */ TString *source; /* current source name */ + TString *envn; /* environment variable name */ char decpoint; /* locale decimal point */ } LexState; LUAI_FUNC void luaX_init (lua_State *L); LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, - TString *source); + TString *source, int firstchar); LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); LUAI_FUNC void luaX_next (LexState *ls); -LUAI_FUNC void luaX_lookahead (LexState *ls); -LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); -LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC int luaX_lookahead (LexState *ls); +LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); diff --git a/src/mod/languages/mod_lua/lua/llimits.h b/src/mod/languages/mod_lua/lua/llimits.h index ca8dcb7224..1b8c79bda2 100644 --- a/src/mod/languages/mod_lua/lua/llimits.h +++ b/src/mod/languages/mod_lua/lua/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: llimits.h,v 1.103 2013/02/20 14:08:56 roberto Exp $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -15,7 +15,7 @@ #include "lua.h" -typedef LUAI_UINT32 lu_int32; +typedef unsigned LUA_INT32 lu_int32; typedef LUAI_UMEM lu_mem; @@ -31,6 +31,8 @@ typedef unsigned char lu_byte; #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) +#define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2)) + #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ @@ -44,6 +46,10 @@ typedef unsigned char lu_byte; /* type to ensure maximum alignment */ +#if !defined(LUAI_USER_ALIGNMENT_T) +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } +#endif + typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; @@ -52,34 +58,73 @@ typedef LUAI_UACNUMBER l_uacNumber; /* internal assertions for in-house debugging */ -#ifdef lua_assert - +#if defined(lua_assert) #define check_exp(c,e) (lua_assert(c), (e)) -#define api_check(l,e) lua_assert(e) - +/* to avoid problems with conditions too long */ +#define lua_longassert(c) { if (!(c)) lua_assert(0); } #else - #define lua_assert(c) ((void)0) #define check_exp(c,e) (e) -#define api_check luai_apicheck +#define lua_longassert(c) ((void)0) +#endif + +/* +** assertion for checking API calls +*/ +#if !defined(luai_apicheck) + +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,e) assert(e) +#else +#define luai_apicheck(L,e) lua_assert(e) +#endif #endif +#define api_check(l,e,msg) luai_apicheck(l,(e) && msg) -#ifndef UNUSED + +#if !defined(UNUSED) #define UNUSED(x) ((void)(x)) /* to avoid warnings */ #endif -#ifndef cast #define cast(t, exp) ((t)(exp)) -#endif #define cast_byte(i) cast(lu_byte, (i)) #define cast_num(i) cast(lua_Number, (i)) #define cast_int(i) cast(int, (i)) +#define cast_uchar(i) cast(unsigned char, (i)) +/* +** non-return type +*/ +#if defined(__GNUC__) +#define l_noret void __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define l_noret void __declspec(noreturn) +#else +#define l_noret void +#endif + + + +/* +** maximum depth for nested C calls and syntactical nested non-terminals +** in a program. (Value must fit in an unsigned short int.) +*/ +#if !defined(LUAI_MAXCCALLS) +#define LUAI_MAXCCALLS 200 +#endif + +/* +** maximum number of upvalues in a closure (both C and Lua). (Value +** must fit in an unsigned char.) +*/ +#define MAXUPVAL UCHAR_MAX + /* ** type for virtual-machine instructions @@ -95,34 +140,170 @@ typedef lu_int32 Instruction; /* minimum size for the string table (must be power of 2) */ -#ifndef MINSTRTABSIZE +#if !defined(MINSTRTABSIZE) #define MINSTRTABSIZE 32 #endif /* minimum size for string buffer */ -#ifndef LUA_MINBUFFER +#if !defined(LUA_MINBUFFER) #define LUA_MINBUFFER 32 #endif -#ifndef lua_lock -#define lua_lock(L) ((void) 0) +#if !defined(lua_lock) +#define lua_lock(L) ((void) 0) #define lua_unlock(L) ((void) 0) #endif -#ifndef luai_threadyield +#if !defined(luai_threadyield) #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} #endif /* -** macro to control inclusion of some hard tests on stack reallocation -*/ -#ifndef HARDSTACKTESTS -#define condhardstacktests(x) ((void)0) +** these macros allow user-specific actions on threads when you defined +** LUAI_EXTRASPACE and need to do something extra when a thread is +** created/deleted/resumed/yielded. +*/ +#if !defined(luai_userstateopen) +#define luai_userstateopen(L) ((void)L) +#endif + +#if !defined(luai_userstateclose) +#define luai_userstateclose(L) ((void)L) +#endif + +#if !defined(luai_userstatethread) +#define luai_userstatethread(L,L1) ((void)L) +#endif + +#if !defined(luai_userstatefree) +#define luai_userstatefree(L,L1) ((void)L) +#endif + +#if !defined(luai_userstateresume) +#define luai_userstateresume(L,n) ((void)L) +#endif + +#if !defined(luai_userstateyield) +#define luai_userstateyield(L,n) ((void)L) +#endif + +/* +** lua_number2int is a macro to convert lua_Number to int. +** lua_number2integer is a macro to convert lua_Number to lua_Integer. +** lua_number2unsigned is a macro to convert a lua_Number to a lua_Unsigned. +** lua_unsigned2number is a macro to convert a lua_Unsigned to a lua_Number. +** luai_hashnum is a macro to hash a lua_Number value into an integer. +** The hash must be deterministic and give reasonable values for +** both small and large values (outside the range of integers). +*/ + +#if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) /* { */ +/* trick with Microsoft assembler for X86 */ + +#define lua_number2int(i,n) __asm {__asm fld n __asm fistp i} +#define lua_number2integer(i,n) lua_number2int(i, n) +#define lua_number2unsigned(i,n) \ + {__int64 l; __asm {__asm fld n __asm fistp l} i = (unsigned int)l;} + + +#elif defined(LUA_IEEE754TRICK) /* }{ */ +/* the next trick should work on any machine using IEEE754 with + a 32-bit int type */ + +union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; + +#if !defined(LUA_IEEEENDIAN) /* { */ +#define LUAI_EXTRAIEEE \ + static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)}; +#define LUA_IEEEENDIANLOC (ieeeendian.l_p[1] == 33) #else -#define condhardstacktests(x) x +#define LUA_IEEEENDIANLOC LUA_IEEEENDIAN +#define LUAI_EXTRAIEEE /* empty */ +#endif /* } */ + +#define lua_number2int32(i,n,t) \ + { LUAI_EXTRAIEEE \ + volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \ + (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; } + +#define luai_hashnum(i,n) \ + { volatile union luai_Cast u; u.l_d = (n) + 1.0; /* avoid -0 */ \ + (i) = u.l_p[0]; (i) += u.l_p[1]; } /* add double bits for his hash */ + +#define lua_number2int(i,n) lua_number2int32(i, n, int) +#define lua_number2unsigned(i,n) lua_number2int32(i, n, lua_Unsigned) + +/* the trick can be expanded to lua_Integer when it is a 32-bit value */ +#if defined(LUA_IEEELL) +#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer) +#endif + +#endif /* } */ + + +/* the following definitions always work, but may be slow */ + +#if !defined(lua_number2int) +#define lua_number2int(i,n) ((i)=(int)(n)) +#endif + +#if !defined(lua_number2integer) +#define lua_number2integer(i,n) ((i)=(lua_Integer)(n)) +#endif + +#if !defined(lua_number2unsigned) /* { */ +/* the following definition assures proper modulo behavior */ +#if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT) +#include +#define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1) +#define lua_number2unsigned(i,n) \ + ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED)) +#else +#define lua_number2unsigned(i,n) ((i)=(lua_Unsigned)(n)) +#endif +#endif /* } */ + + +#if !defined(lua_unsigned2number) +/* on several machines, coercion from unsigned to double is slow, + so it may be worth to avoid */ +#define lua_unsigned2number(u) \ + (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u)) +#endif + + + +#if defined(ltable_c) && !defined(luai_hashnum) + +#include +#include + +#define luai_hashnum(i,n) { int e; \ + n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ + lua_number2int(i, n); i += e; } + +#endif + + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#if !defined(HARDSTACKTESTS) +#define condmovestack(L) ((void)0) +#else +/* realloc stack keeping its size */ +#define condmovestack(L) luaD_reallocstack((L), (L)->stacksize) +#endif + +#if !defined(HARDMEMTESTS) +#define condchangemem(L) condmovestack(L) +#else +#define condchangemem(L) \ + ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1))) #endif #endif diff --git a/src/mod/languages/mod_lua/lua/lmathlib.c b/src/mod/languages/mod_lua/lua/lmathlib.c index 441fbf736c..a49f1fd25a 100644 --- a/src/mod/languages/mod_lua/lua/lmathlib.c +++ b/src/mod/languages/mod_lua/lua/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lmathlib.c,v 1.83 2013/03/07 18:21:32 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -18,111 +18,126 @@ #undef PI -#define PI (3.14159265358979323846) -#define RADIANS_PER_DEGREE (PI/180.0) +#define PI ((lua_Number)(3.1415926535897932384626433832795)) +#define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0)) static int math_abs (lua_State *L) { - lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); return 1; } static int math_sin (lua_State *L) { - lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1))); return 1; } static int math_sinh (lua_State *L) { - lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1))); return 1; } static int math_cos (lua_State *L) { - lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1))); return 1; } static int math_cosh (lua_State *L) { - lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1))); return 1; } static int math_tan (lua_State *L) { - lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1))); return 1; } static int math_tanh (lua_State *L) { - lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1))); return 1; } static int math_asin (lua_State *L) { - lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1))); return 1; } static int math_acos (lua_State *L) { - lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1))); return 1; } static int math_atan (lua_State *L) { - lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(atan)(luaL_checknumber(L, 1))); return 1; } static int math_atan2 (lua_State *L) { - lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + lua_pushnumber(L, l_mathop(atan2)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); return 1; } static int math_ceil (lua_State *L) { - lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(ceil)(luaL_checknumber(L, 1))); return 1; } static int math_floor (lua_State *L) { - lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(floor)(luaL_checknumber(L, 1))); return 1; } static int math_fmod (lua_State *L) { - lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); return 1; } static int math_modf (lua_State *L) { - double ip; - double fp = modf(luaL_checknumber(L, 1), &ip); + lua_Number ip; + lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip); lua_pushnumber(L, ip); lua_pushnumber(L, fp); return 2; } static int math_sqrt (lua_State *L) { - lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1))); return 1; } static int math_pow (lua_State *L) { - lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + lua_Number x = luaL_checknumber(L, 1); + lua_Number y = luaL_checknumber(L, 2); + lua_pushnumber(L, l_mathop(pow)(x, y)); return 1; } static int math_log (lua_State *L) { - lua_pushnumber(L, log(luaL_checknumber(L, 1))); + lua_Number x = luaL_checknumber(L, 1); + lua_Number res; + if (lua_isnoneornil(L, 2)) + res = l_mathop(log)(x); + else { + lua_Number base = luaL_checknumber(L, 2); + if (base == (lua_Number)10.0) res = l_mathop(log10)(x); + else res = l_mathop(log)(x)/l_mathop(log)(base); + } + lua_pushnumber(L, res); return 1; } +#if defined(LUA_COMPAT_LOG10) static int math_log10 (lua_State *L) { - lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1))); return 1; } +#endif static int math_exp (lua_State *L) { - lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1))); return 1; } @@ -138,13 +153,15 @@ static int math_rad (lua_State *L) { static int math_frexp (lua_State *L) { int e; - lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e)); lua_pushinteger(L, e); return 2; } static int math_ldexp (lua_State *L) { - lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + lua_Number x = luaL_checknumber(L, 1); + int ep = luaL_checkint(L, 2); + lua_pushnumber(L, l_mathop(ldexp)(x, ep)); return 1; } @@ -188,16 +205,16 @@ static int math_random (lua_State *L) { break; } case 1: { /* only upper limit */ - int u = luaL_checkint(L, 1); - luaL_argcheck(L, 1<=u, 1, "interval is empty"); - lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + lua_Number u = luaL_checknumber(L, 1); + luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty"); + lua_pushnumber(L, l_mathop(floor)(r*u) + (lua_Number)(1.0)); /* [1, u] */ break; } case 2: { /* lower and upper limits */ - int l = luaL_checkint(L, 1); - int u = luaL_checkint(L, 2); - luaL_argcheck(L, l<=u, 2, "interval is empty"); - lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + lua_Number l = luaL_checknumber(L, 1); + lua_Number u = luaL_checknumber(L, 2); + luaL_argcheck(L, l <= u, 2, "interval is empty"); + lua_pushnumber(L, l_mathop(floor)(r*(u-l+1)) + l); /* [l, u] */ break; } default: return luaL_error(L, "wrong number of arguments"); @@ -207,7 +224,8 @@ static int math_random (lua_State *L) { static int math_randomseed (lua_State *L) { - srand(luaL_checkint(L, 1)); + srand(luaL_checkunsigned(L, 1)); + (void)rand(); /* discard first value to avoid undesirable correlations */ return 0; } @@ -227,7 +245,9 @@ static const luaL_Reg mathlib[] = { {"fmod", math_fmod}, {"frexp", math_frexp}, {"ldexp", math_ldexp}, +#if defined(LUA_COMPAT_LOG10) {"log10", math_log10}, +#endif {"log", math_log}, {"max", math_max}, {"min", math_min}, @@ -248,16 +268,12 @@ static const luaL_Reg mathlib[] = { /* ** Open math library */ -LUALIB_API int luaopen_math (lua_State *L) { - luaL_register(L, LUA_MATHLIBNAME, mathlib); +LUAMOD_API int luaopen_math (lua_State *L) { + luaL_newlib(L, mathlib); lua_pushnumber(L, PI); lua_setfield(L, -2, "pi"); lua_pushnumber(L, HUGE_VAL); lua_setfield(L, -2, "huge"); -#if defined(LUA_COMPAT_MOD) - lua_getfield(L, -1, "fmod"); - lua_setfield(L, -2, "mod"); -#endif return 1; } diff --git a/src/mod/languages/mod_lua/lua/lmem.c b/src/mod/languages/mod_lua/lua/lmem.c index ae7d8c965f..3f88496e09 100644 --- a/src/mod/languages/mod_lua/lua/lmem.c +++ b/src/mod/languages/mod_lua/lua/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lmem.c,v 1.84 2012/05/23 15:41:53 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -14,6 +14,7 @@ #include "ldebug.h" #include "ldo.h" +#include "lgc.h" #include "lmem.h" #include "lobject.h" #include "lstate.h" @@ -25,12 +26,11 @@ ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); ** (`osize' is the old size, `nsize' is the new size) ** -** Lua ensures that (ptr == NULL) iff (osize == 0). -** -** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** * frealloc(ud, NULL, x, s) creates a new block of size `s' (no +** matter 'x'). ** ** * frealloc(ud, p, x, 0) frees the block `p' -** (in this specific case, frealloc must return NULL). +** (in this specific case, frealloc must return NULL); ** particularly, frealloc(ud, NULL, 0, 0) does nothing ** (which is equivalent to free(NULL) in ANSI C) ** @@ -44,12 +44,12 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, - int limit, const char *errormsg) { + int limit, const char *what) { void *newblock; int newsize; if (*size >= limit/2) { /* cannot double it? */ if (*size >= limit) /* cannot grow even a little? */ - luaG_runerror(L, errormsg); + luaG_runerror(L, "too many %s (limit is %d)", what, limit); newsize = limit; /* still have at least one free place */ } else { @@ -63,9 +63,8 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, } -void *luaM_toobig (lua_State *L) { +l_noret luaM_toobig (lua_State *L) { luaG_runerror(L, "memory allocation error: block too big"); - return NULL; /* to avoid warnings */ } @@ -74,13 +73,27 @@ void *luaM_toobig (lua_State *L) { ** generic allocation routine. */ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + void *newblock; global_State *g = G(L); - lua_assert((osize == 0) == (block == NULL)); - block = (*g->frealloc)(g->ud, block, osize, nsize); - if (block == NULL && nsize > 0) - luaD_throw(L, LUA_ERRMEM); - lua_assert((nsize == 0) == (block == NULL)); - g->totalbytes = (g->totalbytes - osize) + nsize; - return block; + size_t realosize = (block) ? osize : 0; + lua_assert((realosize == 0) == (block == NULL)); +#if defined(HARDMEMTESTS) + if (nsize > realosize && g->gcrunning) + luaC_fullgc(L, 1); /* force a GC whenever possible */ +#endif + newblock = (*g->frealloc)(g->ud, block, osize, nsize); + if (newblock == NULL && nsize > 0) { + api_check(L, nsize > realosize, + "realloc cannot fail when shrinking a block"); + if (g->gcrunning) { + luaC_fullgc(L, 1); /* try to free some memory... */ + newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ + } + if (newblock == NULL) + luaD_throw(L, LUA_ERRMEM); + } + lua_assert((nsize == 0) == (newblock == NULL)); + g->GCdebt = (g->GCdebt + nsize) - realosize; + return newblock; } diff --git a/src/mod/languages/mod_lua/lua/lmem.h b/src/mod/languages/mod_lua/lua/lmem.h index 7c2dcb3220..5f850999a9 100644 --- a/src/mod/languages/mod_lua/lua/lmem.h +++ b/src/mod/languages/mod_lua/lua/lmem.h @@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lmem.h,v 1.40 2013/02/20 14:08:21 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -13,23 +13,30 @@ #include "llimits.h" #include "lua.h" -#define MEMERRMSG "not enough memory" - +/* +** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is +** always constant. +** The macro is somewhat complex to avoid warnings: +** +1 avoids warnings of "comparison has constant result"; +** cast to 'void' avoids warnings of "value unused". +*/ #define luaM_reallocv(L,b,on,n,e) \ - ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ - luaM_toobig(L)) + (cast(void, \ + (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e))) #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) -#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) +#define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) -#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) #define luaM_newvector(L,n,t) \ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) +#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) + #define luaM_growvector(L,v,nelems,size,t,limit,e) \ if ((nelems)+1 > (size)) \ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) @@ -37,13 +44,14 @@ #define luaM_reallocvector(L, v,oldn,n,t) \ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) +LUAI_FUNC l_noret luaM_toobig (lua_State *L); +/* not to be called directly */ LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, size_t size); -LUAI_FUNC void *luaM_toobig (lua_State *L); LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elem, int limit, - const char *errormsg); + const char *what); #endif diff --git a/src/mod/languages/mod_lua/lua/loadlib.c b/src/mod/languages/mod_lua/lua/loadlib.c index 0589b61fed..a9959277bd 100644 --- a/src/mod/languages/mod_lua/lua/loadlib.c +++ b/src/mod/languages/mod_lua/lua/loadlib.c @@ -1,14 +1,22 @@ /* -** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** ** This module contains an implementation of loadlib for Unix systems -** that have dlfcn, an implementation for Darwin (Mac OS X), an -** implementation for Windows, and a stub for other systems. +** that have dlfcn, an implementation for Windows, and a stub for other +** systems. */ +/* +** if needed, includes windows header before everything else +*/ +#if defined(_WIN32) +#include +#endif + + #include #include @@ -22,6 +30,61 @@ #include "lualib.h" +/* +** LUA_PATH and LUA_CPATH are the names of the environment +** variables that Lua check to set its paths. +*/ +#if !defined(LUA_PATH) +#define LUA_PATH "LUA_PATH" +#endif + +#if !defined(LUA_CPATH) +#define LUA_CPATH "LUA_CPATH" +#endif + +#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + +#define LUA_PATHVERSION LUA_PATH LUA_PATHSUFFIX +#define LUA_CPATHVERSION LUA_CPATH LUA_PATHSUFFIX + +/* +** LUA_PATH_SEP is the character that separates templates in a path. +** LUA_PATH_MARK is the string that marks the substitution points in a +** template. +** LUA_EXEC_DIR in a Windows path is replaced by the executable's +** directory. +** LUA_IGMARK is a mark to ignore all before it when building the +** luaopen_ function name. +*/ +#if !defined (LUA_PATH_SEP) +#define LUA_PATH_SEP ";" +#endif +#if !defined (LUA_PATH_MARK) +#define LUA_PATH_MARK "?" +#endif +#if !defined (LUA_EXEC_DIR) +#define LUA_EXEC_DIR "!" +#endif +#if !defined (LUA_IGMARK) +#define LUA_IGMARK "-" +#endif + + +/* +** LUA_CSUBSEP is the character that replaces dots in submodule names +** when searching for a C loader. +** LUA_LSUBSEP is the character that replaces dots in submodule names +** when searching for a Lua loader. +*/ +#if !defined(LUA_CSUBSEP) +#define LUA_CSUBSEP LUA_DIRSEP +#endif + +#if !defined(LUA_LSUBSEP) +#define LUA_LSUBSEP LUA_DIRSEP +#endif + + /* prefix for open functions in C libraries */ #define LUA_POF "luaopen_" @@ -29,9 +92,9 @@ #define LUA_OFSEP "_" -#define LIBPREFIX "LOADLIB: " +/* table (in the registry) that keeps handles for all loaded C libraries */ +#define CLIBS "_CLIBS" -#define POF LUA_POF #define LIB_FAIL "open" @@ -42,13 +105,16 @@ #define setprogdir(L) ((void)0) +/* +** system-dependent functions +*/ static void ll_unloadlib (void *lib); -static void *ll_load (lua_State *L, const char *path); +static void *ll_load (lua_State *L, const char *path, int seeglb); static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); -#if defined(LUA_DL_DLOPEN) +#if defined(LUA_USE_DLOPEN) /* ** {======================================================================== ** This is an implementation of loadlib based on the dlfcn interface. @@ -65,8 +131,8 @@ static void ll_unloadlib (void *lib) { } -static void *ll_load (lua_State *L, const char *path) { - void *lib = dlopen(path, RTLD_NOW); +static void *ll_load (lua_State *L, const char *path, int seeglb) { + void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL)); if (lib == NULL) lua_pushstring(L, dlerror()); return lib; } @@ -89,11 +155,16 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { ** ======================================================================= */ -#include - - #undef setprogdir +/* +** optional flags for LoadLibraryEx +*/ +#if !defined(LUA_LLE_FLAGS) +#define LUA_LLE_FLAGS 0 +#endif + + static void setprogdir (lua_State *L) { char buff[MAX_PATH + 1]; char *lb; @@ -103,7 +174,7 @@ static void setprogdir (lua_State *L) { luaL_error(L, "unable to get ModuleFileName"); else { *lb = '\0'; - luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff); lua_remove(L, -2); /* remove original string */ } } @@ -113,26 +184,27 @@ static void pusherror (lua_State *L) { int error = GetLastError(); char buffer[128]; if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, buffer, sizeof(buffer), NULL)) + NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL)) lua_pushstring(L, buffer); else lua_pushfstring(L, "system error %d\n", error); } static void ll_unloadlib (void *lib) { - FreeLibrary((HINSTANCE)lib); + FreeLibrary((HMODULE)lib); } -static void *ll_load (lua_State *L, const char *path) { - HINSTANCE lib = LoadLibraryA(path); +static void *ll_load (lua_State *L, const char *path, int seeglb) { + HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS); + (void)(seeglb); /* not used: symbols are 'global' by default */ if (lib == NULL) pusherror(L); return lib; } static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); if (f == NULL) pusherror(L); return f; } @@ -140,88 +212,6 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { /* }====================================================== */ - -#elif defined(LUA_DL_DYLD) -/* -** {====================================================================== -** Native Mac OS X / Darwin Implementation -** ======================================================================= -*/ - -#include - - -/* Mac appends a `_' before C function names */ -#undef POF -#define POF "_" LUA_POF - - -static void pusherror (lua_State *L) { - const char *err_str; - const char *err_file; - NSLinkEditErrors err; - int err_num; - NSLinkEditError(&err, &err_num, &err_file, &err_str); - lua_pushstring(L, err_str); -} - - -static const char *errorfromcode (NSObjectFileImageReturnCode ret) { - switch (ret) { - case NSObjectFileImageInappropriateFile: - return "file is not a bundle"; - case NSObjectFileImageArch: - return "library is for wrong CPU type"; - case NSObjectFileImageFormat: - return "bad format"; - case NSObjectFileImageAccess: - return "cannot access file"; - case NSObjectFileImageFailure: - default: - return "unable to load library"; - } -} - - -static void ll_unloadlib (void *lib) { - NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); -} - - -static void *ll_load (lua_State *L, const char *path) { - NSObjectFileImage img; - NSObjectFileImageReturnCode ret; - /* this would be a rare case, but prevents crashing if it happens */ - if (!_dyld_present()) { - lua_pushliteral(L, "dyld not present"); - return NULL; - } - ret = NSCreateObjectFileImageFromFile(path, &img); - if (ret == NSObjectFileImageSuccess) { - NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | - NSLINKMODULE_OPTION_RETURN_ON_ERROR); - NSDestroyObjectFileImage(img); - if (mod == NULL) pusherror(L); - return mod; - } - lua_pushstring(L, errorfromcode(ret)); - return NULL; -} - - -static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); - if (nss == NULL) { - lua_pushfstring(L, "symbol " LUA_QS " not found", sym); - return NULL; - } - return (lua_CFunction)NSAddressOfSymbol(nss); -} - -/* }====================================================== */ - - - #else /* ** {====================================================== @@ -237,19 +227,19 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { static void ll_unloadlib (void *lib) { - (void)lib; /* to avoid warnings */ + (void)(lib); /* not used */ } -static void *ll_load (lua_State *L, const char *path) { - (void)path; /* to avoid warnings */ +static void *ll_load (lua_State *L, const char *path, int seeglb) { + (void)(path); (void)(seeglb); /* not used */ lua_pushliteral(L, DLMSG); return NULL; } static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { - (void)lib; (void)sym; /* to avoid warnings */ + (void)(lib); (void)(sym); /* not used */ lua_pushliteral(L, DLMSG); return NULL; } @@ -258,50 +248,58 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { #endif - -static void **ll_register (lua_State *L, const char *path) { - void **plib; - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ - if (!lua_isnil(L, -1)) /* is there an entry? */ - plib = (void **)lua_touserdata(L, -1); - else { /* no entry yet; create one */ - lua_pop(L, 1); - plib = (void **)lua_newuserdata(L, sizeof(const void *)); - *plib = NULL; - luaL_getmetatable(L, "_LOADLIB"); - lua_setmetatable(L, -2); - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_pushvalue(L, -2); - lua_settable(L, LUA_REGISTRYINDEX); - } +static void *ll_checkclib (lua_State *L, const char *path) { + void *plib; + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_getfield(L, -1, path); + plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ + lua_pop(L, 2); /* pop CLIBS table and 'plib' */ return plib; } +static void ll_addtoclib (lua_State *L, const char *path, void *plib) { + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_pushlightuserdata(L, plib); + lua_pushvalue(L, -1); + lua_setfield(L, -3, path); /* CLIBS[path] = plib */ + lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ + lua_pop(L, 1); /* pop CLIBS table */ +} + + /* -** __gc tag method: calls library's `ll_unloadlib' function with the lib -** handle +** __gc tag method for CLIBS table: calls 'll_unloadlib' for all lib +** handles in list CLIBS */ static int gctm (lua_State *L) { - void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); - if (*lib) ll_unloadlib(*lib); - *lib = NULL; /* mark library as closed */ + int n = luaL_len(L, 1); + for (; n >= 1; n--) { /* for each handle, in reverse order */ + lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ + ll_unloadlib(lua_touserdata(L, -1)); + lua_pop(L, 1); /* pop handle */ + } return 0; } static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { - void **reg = ll_register(L, path); - if (*reg == NULL) *reg = ll_load(L, path); - if (*reg == NULL) - return ERRLIB; /* unable to load library */ + void *reg = ll_checkclib(L, path); /* check loaded C libraries */ + if (reg == NULL) { /* must load library? */ + reg = ll_load(L, path, *sym == '*'); + if (reg == NULL) return ERRLIB; /* unable to load library */ + ll_addtoclib(L, path, reg); + } + if (*sym == '*') { /* loading only library (no function)? */ + lua_pushboolean(L, 1); /* return 'true' */ + return 0; /* no errors */ + } else { - lua_CFunction f = ll_sym(L, *reg, sym); + lua_CFunction f = ll_sym(L, reg, sym); if (f == NULL) return ERRFUNC; /* unable to find function */ - lua_pushcfunction(L, f); - return 0; /* return function */ + lua_pushcfunction(L, f); /* else create new function */ + return 0; /* no errors */ } } @@ -339,104 +337,137 @@ static int readable (const char *filename) { static const char *pushnexttemplate (lua_State *L, const char *path) { const char *l; - while (*path == *LUA_PATHSEP) path++; /* skip separators */ + while (*path == *LUA_PATH_SEP) path++; /* skip separators */ if (*path == '\0') return NULL; /* no more templates */ - l = strchr(path, *LUA_PATHSEP); /* find next separator */ + l = strchr(path, *LUA_PATH_SEP); /* find next separator */ if (l == NULL) l = path + strlen(path); lua_pushlstring(L, path, l - path); /* template */ return l; } -static const char *findfile (lua_State *L, const char *name, - const char *pname) { - const char *path; - name = luaL_gsub(L, name, ".", LUA_DIRSEP); - lua_getfield(L, LUA_ENVIRONINDEX, pname); - path = lua_tostring(L, -1); - if (path == NULL) - luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushliteral(L, ""); /* error accumulator */ +static const char *searchpath (lua_State *L, const char *name, + const char *path, + const char *sep, + const char *dirsep) { + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + if (*sep != '\0') /* non-empty separator? */ + name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ while ((path = pushnexttemplate(L, path)) != NULL) { - const char *filename; - filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + const char *filename = luaL_gsub(L, lua_tostring(L, -1), + LUA_PATH_MARK, name); lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ lua_pushfstring(L, "\n\tno file " LUA_QS, filename); lua_remove(L, -2); /* remove file name */ - lua_concat(L, 2); /* add entry to possible error message */ + luaL_addvalue(&msg); /* concatenate error msg. entry */ } + luaL_pushresult(&msg); /* create error message */ return NULL; /* not found */ } -static void loaderror (lua_State *L, const char *filename) { - luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", - lua_tostring(L, 1), filename, lua_tostring(L, -1)); +static int ll_searchpath (lua_State *L) { + const char *f = searchpath(L, luaL_checkstring(L, 1), + luaL_checkstring(L, 2), + luaL_optstring(L, 3, "."), + luaL_optstring(L, 4, LUA_DIRSEP)); + if (f != NULL) return 1; + else { /* error message is on top of the stack */ + lua_pushnil(L); + lua_insert(L, -2); + return 2; /* return nil + error message */ + } } -static int loader_Lua (lua_State *L) { +static const char *findfile (lua_State *L, const char *name, + const char *pname, + const char *dirsep) { + const char *path; + lua_getfield(L, lua_upvalueindex(1), pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + return searchpath(L, name, path, ".", dirsep); +} + + +static int checkload (lua_State *L, int stat, const char *filename) { + if (stat) { /* module loaded successfully? */ + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; /* return open function and file name */ + } + else + return luaL_error(L, "error loading module " LUA_QS + " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int searcher_Lua (lua_State *L) { const char *filename; const char *name = luaL_checkstring(L, 1); - filename = findfile(L, name, "path"); - if (filename == NULL) return 1; /* library not found in this path */ - if (luaL_loadfile(L, filename) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ + filename = findfile(L, name, "path", LUA_LSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename); } -static const char *mkfuncname (lua_State *L, const char *modname) { +static int loadfunc (lua_State *L, const char *filename, const char *modname) { const char *funcname; - const char *mark = strchr(modname, *LUA_IGMARK); - if (mark) modname = mark + 1; - funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); - funcname = lua_pushfstring(L, POF"%s", funcname); - lua_remove(L, -2); /* remove 'gsub' result */ - return funcname; + const char *mark; + modname = luaL_gsub(L, modname, ".", LUA_OFSEP); + mark = strchr(modname, *LUA_IGMARK); + if (mark) { + int stat; + funcname = lua_pushlstring(L, modname, mark - modname); + funcname = lua_pushfstring(L, LUA_POF"%s", funcname); + stat = ll_loadfunc(L, filename, funcname); + if (stat != ERRFUNC) return stat; + modname = mark + 1; /* else go ahead and try old-style name */ + } + funcname = lua_pushfstring(L, LUA_POF"%s", modname); + return ll_loadfunc(L, filename, funcname); } -static int loader_C (lua_State *L) { - const char *funcname; +static int searcher_C (lua_State *L) { const char *name = luaL_checkstring(L, 1); - const char *filename = findfile(L, name, "cpath"); - if (filename == NULL) return 1; /* library not found in this path */ - funcname = mkfuncname(L, name); - if (ll_loadfunc(L, filename, funcname) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ + const char *filename = findfile(L, name, "cpath", LUA_CSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (loadfunc(L, filename, name) == 0), filename); } -static int loader_Croot (lua_State *L) { - const char *funcname; +static int searcher_Croot (lua_State *L) { const char *filename; const char *name = luaL_checkstring(L, 1); const char *p = strchr(name, '.'); int stat; if (p == NULL) return 0; /* is root */ lua_pushlstring(L, name, p - name); - filename = findfile(L, lua_tostring(L, -1), "cpath"); + filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); if (filename == NULL) return 1; /* root not found */ - funcname = mkfuncname(L, name); - if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { - if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); - return 1; /* function not found */ + if ((stat = loadfunc(L, filename, name)) != 0) { + if (stat != ERRFUNC) + return checkload(L, 0, filename); /* real error */ + else { /* open function not found */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; + } } - return 1; + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; } -static int loader_preload (lua_State *L) { +static int searcher_preload (lua_State *L) { const char *name = luaL_checkstring(L, 1); - lua_getfield(L, LUA_ENVIRONINDEX, "preload"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ lua_pushfstring(L, "\n\tno field package.preload['%s']", name); @@ -444,48 +475,53 @@ static int loader_preload (lua_State *L) { } -static const int sentinel_ = 0; -#define sentinel ((void *)&sentinel_) +static void findloader (lua_State *L, const char *name) { + int i; + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ + if (!lua_istable(L, 3)) + luaL_error(L, LUA_QL("package.searchers") " must be a table"); + /* iterate over available searchers to find a loader */ + for (i = 1; ; i++) { + lua_rawgeti(L, 3, i); /* get a searcher */ + if (lua_isnil(L, -1)) { /* no more searchers? */ + lua_pop(L, 1); /* remove nil */ + luaL_pushresult(&msg); /* create error message */ + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -1)); + } + lua_pushstring(L, name); + lua_call(L, 1, 2); /* call it */ + if (lua_isfunction(L, -2)) /* did it find a loader? */ + return; /* module loader found */ + else if (lua_isstring(L, -2)) { /* searcher returned error message? */ + lua_pop(L, 1); /* remove extra return */ + luaL_addvalue(&msg); /* concatenate error message */ + } + else + lua_pop(L, 2); /* remove both returns */ + } +} static int ll_require (lua_State *L) { const char *name = luaL_checkstring(L, 1); - int i; lua_settop(L, 1); /* _LOADED table will be at index 2 */ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, 2, name); - if (lua_toboolean(L, -1)) { /* is it there? */ - if (lua_touserdata(L, -1) == sentinel) /* check loops */ - luaL_error(L, "loop or previous error loading module " LUA_QS, name); + lua_getfield(L, 2, name); /* _LOADED[name] */ + if (lua_toboolean(L, -1)) /* is it there? */ return 1; /* package is already loaded */ - } - /* else must load it; iterate over available loaders */ - lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushliteral(L, ""); /* error message accumulator */ - for (i=1; ; i++) { - lua_rawgeti(L, -2, i); /* get a loader */ - if (lua_isnil(L, -1)) - luaL_error(L, "module " LUA_QS " not found:%s", - name, lua_tostring(L, -2)); - lua_pushstring(L, name); - lua_call(L, 1, 1); /* call it */ - if (lua_isfunction(L, -1)) /* did it find module? */ - break; /* module loaded successfully */ - else if (lua_isstring(L, -1)) /* loader returned error message? */ - lua_concat(L, 2); /* accumulate it */ - else - lua_pop(L, 1); - } - lua_pushlightuserdata(L, sentinel); - lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ - lua_pushstring(L, name); /* pass name as argument to module */ - lua_call(L, 1, 1); /* run loaded module */ + /* else must load package */ + lua_pop(L, 1); /* remove 'getfield' result */ + findloader(L, name); + lua_pushstring(L, name); /* pass name as argument to module loader */ + lua_insert(L, -2); /* name is 1st argument (before search data) */ + lua_call(L, 2, 1); /* run loader to load module */ if (!lua_isnil(L, -1)) /* non-nil return? */ lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ lua_getfield(L, 2, name); - if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + if (lua_isnil(L, -1)) { /* module did not set a value? */ lua_pushboolean(L, 1); /* use true as result */ lua_pushvalue(L, -1); /* extra copy to be returned */ lua_setfield(L, 2, name); /* _LOADED[name] = true */ @@ -502,26 +538,31 @@ static int ll_require (lua_State *L) { ** 'module' function ** ======================================================= */ - +#if defined(LUA_COMPAT_MODULE) -static void setfenv (lua_State *L) { +/* +** changes the environment variable of calling function +*/ +static void set_env (lua_State *L) { lua_Debug ar; if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ lua_iscfunction(L, -1)) luaL_error(L, LUA_QL("module") " not called from a Lua function"); - lua_pushvalue(L, -2); - lua_setfenv(L, -2); - lua_pop(L, 1); + lua_pushvalue(L, -2); /* copy new environment table to top */ + lua_setupvalue(L, -2, 1); + lua_pop(L, 1); /* remove function */ } static void dooptions (lua_State *L, int n) { int i; for (i = 2; i <= n; i++) { - lua_pushvalue(L, i); /* get option (a function) */ - lua_pushvalue(L, -2); /* module */ - lua_call(L, 1, 0); + if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } } } @@ -543,17 +584,8 @@ static void modinit (lua_State *L, const char *modname) { static int ll_module (lua_State *L) { const char *modname = luaL_checkstring(L, 1); - int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) - return luaL_error(L, "name conflict for module " LUA_QS, modname); - lua_pushvalue(L, -1); - lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ - } + int lastarg = lua_gettop(L); /* last parameter */ + luaL_pushmodule(L, modname, 1); /* get/create module table */ /* check whether table already has a _NAME field */ lua_getfield(L, -1, "_NAME"); if (!lua_isnil(L, -1)) /* is table an initialized module? */ @@ -563,9 +595,9 @@ static int ll_module (lua_State *L) { modinit(L, modname); } lua_pushvalue(L, -1); - setfenv(L); - dooptions(L, loaded - 1); - return 0; + set_env(L); + dooptions(L, lastarg); + return 1; } @@ -576,12 +608,12 @@ static int ll_seeall (lua_State *L) { lua_pushvalue(L, -1); lua_setmetatable(L, 1); } - lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_pushglobaltable(L); lua_setfield(L, -2, "__index"); /* mt.__index = _G */ return 0; } - +#endif /* }====================================================== */ @@ -589,15 +621,30 @@ static int ll_seeall (lua_State *L) { /* auxiliary mark (for internal use) */ #define AUXMARK "\1" -static void setpath (lua_State *L, const char *fieldname, const char *envname, - const char *def) { - const char *path = getenv(envname); + +/* +** return registry.LUA_NOENV as a boolean +*/ +static int noenv (lua_State *L) { + int b; + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + b = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + return b; +} + + +static void setpath (lua_State *L, const char *fieldname, const char *envname1, + const char *envname2, const char *def) { + const char *path = getenv(envname1); if (path == NULL) /* no environment variable? */ + path = getenv(envname2); /* try alternative name */ + if (path == NULL || noenv(L)) /* no environment variable? */ lua_pushstring(L, def); /* use default */ else { /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ - path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, - LUA_PATHSEP AUXMARK LUA_PATHSEP); + path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, + LUA_PATH_SEP AUXMARK LUA_PATH_SEP); luaL_gsub(L, path, AUXMARK, def); lua_remove(L, -2); } @@ -608,59 +655,71 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname, static const luaL_Reg pk_funcs[] = { {"loadlib", ll_loadlib}, + {"searchpath", ll_searchpath}, +#if defined(LUA_COMPAT_MODULE) {"seeall", ll_seeall}, +#endif {NULL, NULL} }; static const luaL_Reg ll_funcs[] = { +#if defined(LUA_COMPAT_MODULE) {"module", ll_module}, +#endif {"require", ll_require}, {NULL, NULL} }; -static const lua_CFunction loaders[] = - {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; - - -LUALIB_API int luaopen_package (lua_State *L) { +static void createsearcherstable (lua_State *L) { + static const lua_CFunction searchers[] = + {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; int i; - /* create new type _LOADLIB */ - luaL_newmetatable(L, "_LOADLIB"); - lua_pushcfunction(L, gctm); - lua_setfield(L, -2, "__gc"); - /* create `package' table */ - luaL_register(L, LUA_LOADLIBNAME, pk_funcs); -#if defined(LUA_COMPAT_LOADLIB) - lua_getfield(L, -1, "loadlib"); - lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); -#endif - lua_pushvalue(L, -1); - lua_replace(L, LUA_ENVIRONINDEX); - /* create `loaders' table */ - lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); - /* fill it with pre-defined loaders */ - for (i=0; loaders[i] != NULL; i++) { - lua_pushcfunction(L, loaders[i]); + /* create 'searchers' table */ + lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); + /* fill it with pre-defined searchers */ + for (i=0; searchers[i] != NULL; i++) { + lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ + lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i+1); } - lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ - setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ - setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ +} + + +LUAMOD_API int luaopen_package (lua_State *L) { + /* create table CLIBS to keep track of loaded C libraries */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); + lua_createtable(L, 0, 1); /* metatable for CLIBS */ + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ + lua_setmetatable(L, -2); + /* create `package' table */ + luaL_newlib(L, pk_funcs); + createsearcherstable(L); +#if defined(LUA_COMPAT_LOADERS) + lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ + lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */ +#endif + lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ + /* set field 'path' */ + setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT); + /* set field 'cpath' */ + setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT); /* store config information */ - lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" + LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); lua_setfield(L, -2, "config"); /* set field `loaded' */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); lua_setfield(L, -2, "loaded"); /* set field `preload' */ - lua_newtable(L); + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); lua_setfield(L, -2, "preload"); - lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_register(L, NULL, ll_funcs); /* open lib into global table */ - lua_pop(L, 1); + lua_pushglobaltable(L); + lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ + luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ + lua_pop(L, 1); /* pop global table */ return 1; /* return 'package' table */ } diff --git a/src/mod/languages/mod_lua/lua/lobject.c b/src/mod/languages/mod_lua/lua/lobject.c index 4ff50732a4..c152785a5a 100644 --- a/src/mod/languages/mod_lua/lua/lobject.c +++ b/src/mod/languages/mod_lua/lua/lobject.c @@ -1,10 +1,9 @@ /* -** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lobject.c,v 2.58 2013/02/20 14:08:56 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ -#include #include #include #include @@ -15,6 +14,8 @@ #include "lua.h" +#include "lctype.h" +#include "ldebug.h" #include "ldo.h" #include "lmem.h" #include "lobject.h" @@ -24,7 +25,7 @@ -const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; +LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; /* @@ -33,25 +34,25 @@ const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; ** eeeee != 0 and (xxx) otherwise. */ int luaO_int2fb (unsigned int x) { - int e = 0; /* expoent */ - while (x >= 16) { + int e = 0; /* exponent */ + if (x < 8) return x; + while (x >= 0x10) { x = (x+1) >> 1; e++; } - if (x < 8) return x; - else return ((e+1) << 3) | (cast_int(x) - 8); + return ((e+1) << 3) | (cast_int(x) - 8); } /* converts back */ int luaO_fb2int (int x) { - int e = (x >> 3) & 31; + int e = (x >> 3) & 0x1f; if (e == 0) return x; - else return ((x & 7)+8) << (e - 1); + else return ((x & 7) + 8) << (e - 1); } -int luaO_log2 (unsigned int x) { +int luaO_ceillog2 (unsigned int x) { static const lu_byte log_2[256] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, @@ -62,109 +63,169 @@ int luaO_log2 (unsigned int x) { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 }; - int l = -1; + int l = 0; + x--; while (x >= 256) { l += 8; x >>= 8; } return l + log_2[x]; - } -int luaO_rawequalObj (const TValue *t1, const TValue *t2) { - if (ttype(t1) != ttype(t2)) return 0; - else switch (ttype(t1)) { - case LUA_TNIL: - return 1; - case LUA_TNUMBER: - return luai_numeq(nvalue(t1), nvalue(t2)); - case LUA_TBOOLEAN: - return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ - case LUA_TLIGHTUSERDATA: - return pvalue(t1) == pvalue(t2); - default: - lua_assert(iscollectable(t1)); - return gcvalue(t1) == gcvalue(t2); +lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) { + switch (op) { + case LUA_OPADD: return luai_numadd(NULL, v1, v2); + case LUA_OPSUB: return luai_numsub(NULL, v1, v2); + case LUA_OPMUL: return luai_nummul(NULL, v1, v2); + case LUA_OPDIV: return luai_numdiv(NULL, v1, v2); + case LUA_OPMOD: return luai_nummod(NULL, v1, v2); + case LUA_OPPOW: return luai_numpow(NULL, v1, v2); + case LUA_OPUNM: return luai_numunm(NULL, v1); + default: lua_assert(0); return 0; } } -int luaO_str2d (const char *s, lua_Number *result) { +int luaO_hexavalue (int c) { + if (lisdigit(c)) return c - '0'; + else return ltolower(c) - 'a' + 10; +} + + +#if !defined(lua_strx2number) + +#include + + +static int isneg (const char **s) { + if (**s == '-') { (*s)++; return 1; } + else if (**s == '+') (*s)++; + return 0; +} + + +static lua_Number readhexa (const char **s, lua_Number r, int *count) { + for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */ + r = (r * cast_num(16.0)) + cast_num(luaO_hexavalue(cast_uchar(**s))); + (*count)++; + } + return r; +} + + +/* +** convert an hexadecimal numeric string to a number, following +** C99 specification for 'strtod' +*/ +static lua_Number lua_strx2number (const char *s, char **endptr) { + lua_Number r = 0.0; + int e = 0, i = 0; + int neg = 0; /* 1 if number is negative */ + *endptr = cast(char *, s); /* nothing is valid yet */ + while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ + neg = isneg(&s); /* check signal */ + if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ + return 0.0; /* invalid format (no '0x') */ + s += 2; /* skip '0x' */ + r = readhexa(&s, r, &i); /* read integer part */ + if (*s == '.') { + s++; /* skip dot */ + r = readhexa(&s, r, &e); /* read fractional part */ + } + if (i == 0 && e == 0) + return 0.0; /* invalid format (no digit) */ + e *= -4; /* each fractional digit divides value by 2^-4 */ + *endptr = cast(char *, s); /* valid up to here */ + if (*s == 'p' || *s == 'P') { /* exponent part? */ + int exp1 = 0; + int neg1; + s++; /* skip 'p' */ + neg1 = isneg(&s); /* signal */ + if (!lisdigit(cast_uchar(*s))) + goto ret; /* must have at least one digit */ + while (lisdigit(cast_uchar(*s))) /* read exponent */ + exp1 = exp1 * 10 + *(s++) - '0'; + if (neg1) exp1 = -exp1; + e += exp1; + } + *endptr = cast(char *, s); /* valid up to here */ + ret: + if (neg) r = -r; + return l_mathop(ldexp)(r, e); +} + +#endif + + +int luaO_str2d (const char *s, size_t len, lua_Number *result) { char *endptr; - *result = lua_str2number(s, &endptr); - if (endptr == s) return 0; /* conversion failed */ - if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ - *result = cast_num(strtoul(s, &endptr, 16)); - if (*endptr == '\0') return 1; /* most common case */ - while (isspace(cast(unsigned char, *endptr))) endptr++; - if (*endptr != '\0') return 0; /* invalid trailing characters? */ - return 1; + if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */ + return 0; + else if (strpbrk(s, "xX")) /* hexa? */ + *result = lua_strx2number(s, &endptr); + else + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* nothing recognized */ + while (lisspace(cast_uchar(*endptr))) endptr++; + return (endptr == s + len); /* OK if no trailing characters */ } -static void pushstr (lua_State *L, const char *str) { - setsvalue2s(L, L->top, luaS_new(L, str)); - incr_top(L); +static void pushstr (lua_State *L, const char *str, size_t l) { + setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); } /* this function handles only `%d', `%c', %f, %p, and `%s' formats */ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { - int n = 1; - pushstr(L, ""); + int n = 0; for (;;) { const char *e = strchr(fmt, '%'); if (e == NULL) break; - setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); - incr_top(L); + luaD_checkstack(L, 2); /* fmt + item */ + pushstr(L, fmt, e - fmt); switch (*(e+1)) { case 's': { const char *s = va_arg(argp, char *); if (s == NULL) s = "(null)"; - pushstr(L, s); + pushstr(L, s, strlen(s)); break; } case 'c': { - char buff[2]; - buff[0] = cast(char, va_arg(argp, int)); - buff[1] = '\0'; - pushstr(L, buff); + char buff; + buff = cast(char, va_arg(argp, int)); + pushstr(L, &buff, 1); break; } case 'd': { - setnvalue(L->top, cast_num(va_arg(argp, int))); - incr_top(L); + setnvalue(L->top++, cast_num(va_arg(argp, int))); break; } case 'f': { - setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); - incr_top(L); + setnvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); break; } case 'p': { char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ - sprintf(buff, "%p", va_arg(argp, void *)); - pushstr(L, buff); + int l = sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff, l); break; } case '%': { - pushstr(L, "%"); + pushstr(L, "%", 1); break; } default: { - char buff[3]; - buff[0] = '%'; - buff[1] = *(e+1); - buff[2] = '\0'; - pushstr(L, buff); - break; + luaG_runerror(L, + "invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"), + *(e + 1)); } } n += 2; fmt = e+2; } - pushstr(L, fmt); - luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); - L->top -= n; + luaD_checkstack(L, 1); + pushstr(L, fmt, strlen(fmt)); + if (n > 0) luaV_concat(L, n + 1); return svalue(L->top - 1); } @@ -179,36 +240,48 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { } +/* number of chars of a literal string without the ending \0 */ +#define LL(x) (sizeof(x)/sizeof(char) - 1) + +#define RETS "..." +#define PRE "[string \"" +#define POS "\"]" + +#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) + void luaO_chunkid (char *out, const char *source, size_t bufflen) { - if (*source == '=') { - strncpy(out, source+1, bufflen); /* remove first char */ - out[bufflen-1] = '\0'; /* ensures null termination */ + size_t l = strlen(source); + if (*source == '=') { /* 'literal' source */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* truncate it */ + addstr(out, source + 1, bufflen - 1); + *out = '\0'; + } } - else { /* out = "source", or "...source" */ - if (*source == '@') { - size_t l; - source++; /* skip the `@' */ - bufflen -= sizeof(" '...' "); - l = strlen(source); - strcpy(out, ""); - if (l > bufflen) { - source += (l-bufflen); /* get last part of file name */ - strcat(out, "..."); - } - strcat(out, source); + else if (*source == '@') { /* file name */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* add '...' before rest of name */ + addstr(out, RETS, LL(RETS)); + bufflen -= LL(RETS); + memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char)); } - else { /* out = [string "string"] */ - size_t len = strcspn(source, "\n\r"); /* stop at first newline */ - bufflen -= sizeof(" [string \"...\"] "); - if (len > bufflen) len = bufflen; - strcpy(out, "[string \""); - if (source[len] != '\0') { /* must truncate? */ - strncat(out, source, len); - strcat(out, "..."); - } - else - strcat(out, source); - strcat(out, "\"]"); + } + else { /* string; format as [string "source"] */ + const char *nl = strchr(source, '\n'); /* find first new line (if any) */ + addstr(out, PRE, LL(PRE)); /* add prefix */ + bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */ + if (l < bufflen && nl == NULL) { /* small one-line source? */ + addstr(out, source, l); /* keep it */ } + else { + if (nl != NULL) l = nl - source; /* stop at first newline */ + if (l > bufflen) l = bufflen; + addstr(out, source, l); + addstr(out, RETS, LL(RETS)); + } + memcpy(out, POS, (LL(POS) + 1) * sizeof(char)); } } + diff --git a/src/mod/languages/mod_lua/lua/lobject.h b/src/mod/languages/mod_lua/lua/lobject.h index f1e447ef3b..dd23b9143c 100644 --- a/src/mod/languages/mod_lua/lua/lobject.h +++ b/src/mod/languages/mod_lua/lua/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** $Id: lobject.h,v 2.71 2012/09/11 18:21:44 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -16,18 +16,52 @@ #include "lua.h" -/* tags for values visible from Lua */ -#define LAST_TAG LUA_TTHREAD - -#define NUM_TAGS (LAST_TAG+1) - - /* ** Extra tags for non-values */ -#define LUA_TPROTO (LAST_TAG+1) -#define LUA_TUPVAL (LAST_TAG+2) -#define LUA_TDEADKEY (LAST_TAG+3) +#define LUA_TPROTO LUA_NUMTAGS +#define LUA_TUPVAL (LUA_NUMTAGS+1) +#define LUA_TDEADKEY (LUA_NUMTAGS+2) + +/* +** number of all possible tags (including LUA_TNONE but excluding DEADKEY) +*/ +#define LUA_TOTALTAGS (LUA_TUPVAL+2) + + +/* +** tags for Tagged Values have the following use of bits: +** bits 0-3: actual tag (a LUA_T* value) +** bits 4-5: variant bits +** bit 6: whether value is collectable +*/ + +#define VARBITS (3 << 4) + + +/* +** LUA_TFUNCTION variants: +** 0 - Lua function +** 1 - light C function +** 2 - regular C function (closure) +*/ + +/* Variant tags for functions */ +#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ +#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ +#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ + + +/* Variant tags for strings */ +#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ +#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ + + +/* Bit mark for collectable types */ +#define BIT_ISCOLLECTABLE (1 << 6) + +/* mark a tag as collectable */ +#define ctb(t) ((t) | BIT_ISCOLLECTABLE) /* @@ -52,120 +86,165 @@ typedef struct GCheader { - /* ** Union of all Lua values */ -typedef union { - GCObject *gc; - void *p; - lua_Number n; - int b; -} Value; +typedef union Value Value; + + +#define numfield lua_Number n; /* numbers */ + /* -** Tagged Values +** Tagged Values. This is the basic representation of values in Lua, +** an actual value plus a tag with its type. */ -#define TValuefields Value value; int tt +#define TValuefields Value value_; int tt_ -typedef struct lua_TValue { - TValuefields; -} TValue; +typedef struct lua_TValue TValue; + + +/* macro defining a nil value */ +#define NILCONSTANT {NULL}, LUA_TNIL + + +#define val_(o) ((o)->value_) +#define num_(o) (val_(o).n) + + +/* raw type tag of a TValue */ +#define rttype(o) ((o)->tt_) + +/* tag with no variants (bits 0-3) */ +#define novariant(x) ((x) & 0x0F) + +/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ +#define ttype(o) (rttype(o) & 0x3F) + +/* type tag of a TValue with no variants (bits 0-3) */ +#define ttypenv(o) (novariant(rttype(o))) /* Macros to test type */ -#define ttisnil(o) (ttype(o) == LUA_TNIL) -#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) -#define ttisstring(o) (ttype(o) == LUA_TSTRING) -#define ttistable(o) (ttype(o) == LUA_TTABLE) -#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) -#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) -#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) -#define ttisthread(o) (ttype(o) == LUA_TTHREAD) -#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) +#define checktag(o,t) (rttype(o) == (t)) +#define checktype(o,t) (ttypenv(o) == (t)) +#define ttisnumber(o) checktag((o), LUA_TNUMBER) +#define ttisnil(o) checktag((o), LUA_TNIL) +#define ttisboolean(o) checktag((o), LUA_TBOOLEAN) +#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) +#define ttisstring(o) checktype((o), LUA_TSTRING) +#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) +#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) +#define ttistable(o) checktag((o), ctb(LUA_TTABLE)) +#define ttisfunction(o) checktype(o, LUA_TFUNCTION) +#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) +#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) +#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) +#define ttislcf(o) checktag((o), LUA_TLCF) +#define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA)) +#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) +#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) + +#define ttisequal(o1,o2) (rttype(o1) == rttype(o2)) /* Macros to access values */ -#define ttype(o) ((o)->tt) -#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) -#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) -#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) -#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define nvalue(o) check_exp(ttisnumber(o), num_(o)) +#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) +#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) +#define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts) #define tsvalue(o) (&rawtsvalue(o)->tsv) -#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u) #define uvalue(o) (&rawuvalue(o)->uv) -#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) -#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) -#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) -#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) +#define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl) +#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l) +#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c) +#define fvalue(o) check_exp(ttislcf(o), val_(o).f) +#define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h) +#define bvalue(o) check_exp(ttisboolean(o), val_(o).b) +#define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th) +/* a dead value may get the 'gc' field, but cannot access its contents */ +#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) -/* -** for internal debug only -*/ -#define checkconsistency(obj) \ - lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) + + +/* Macros for internal tests */ +#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) #define checkliveness(g,obj) \ - lua_assert(!iscollectable(obj) || \ - ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + lua_longassert(!iscollectable(obj) || \ + (righttt(obj) && !isdead(g,gcvalue(obj)))) /* Macros to set values */ -#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) +#define settt_(o,t) ((o)->tt_=(t)) #define setnvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); } + +#define setnilvalue(obj) settt_(obj, LUA_TNIL) + +#define setfvalue(obj,x) \ + { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } #define setpvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } #define setbvalue(obj,x) \ - { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } + +#define setgcovalue(L,obj,x) \ + { TValue *io=(obj); GCObject *i_g=(x); \ + val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); } #define setsvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ - checkliveness(G(L),i_o); } + { TValue *io=(obj); \ + TString *x_ = (x); \ + val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \ + checkliveness(G(L),io); } #define setuvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ - checkliveness(G(L),i_o); } + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \ + checkliveness(G(L),io); } #define setthvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ - checkliveness(G(L),i_o); } + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \ + checkliveness(G(L),io); } -#define setclvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ - checkliveness(G(L),i_o); } +#define setclLvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \ + checkliveness(G(L),io); } + +#define setclCvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \ + checkliveness(G(L),io); } #define sethvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ - checkliveness(G(L),i_o); } - -#define setptvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ - checkliveness(G(L),i_o); } + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \ + checkliveness(G(L),io); } +#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) #define setobj(L,obj1,obj2) \ - { const TValue *o2=(obj2); TValue *o1=(obj1); \ - o1->value = o2->value; o1->tt=o2->tt; \ - checkliveness(G(L),o1); } + { const TValue *io2=(obj2); TValue *io1=(obj1); \ + io1->value_ = io2->value_; io1->tt_ = io2->tt_; \ + checkliveness(G(L),io1); } /* -** different types of sets, according to destination +** different types of assignments, according to destination */ /* from stack to (same) stack */ @@ -183,47 +262,204 @@ typedef struct lua_TValue { #define setobj2n setobj #define setsvalue2n setsvalue -#define setttype(obj, tt) (ttype(obj) = (tt)) + +/* check whether a number is valid (useful only for NaN trick) */ +#define luai_checknum(L,o,c) { /* empty */ } -#define iscollectable(o) (ttype(o) >= LUA_TSTRING) +/* +** {====================================================== +** NaN Trick +** ======================================================= +*/ +#if defined(LUA_NANTRICK) +/* +** numbers are represented in the 'd_' field. All other values have the +** value (NNMARK | tag) in 'tt__'. A number with such pattern would be +** a "signaled NaN", which is never generated by regular operations by +** the CPU (nor by 'strtod') +*/ + +/* allows for external implementation for part of the trick */ +#if !defined(NNMARK) /* { */ + + +#if !defined(LUA_IEEEENDIAN) +#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN' +#endif + + +#define NNMARK 0x7FF7A500 +#define NNMASK 0x7FFFFF00 + +#undef TValuefields +#undef NILCONSTANT + +#if (LUA_IEEEENDIAN == 0) /* { */ + +/* little endian */ +#define TValuefields \ + union { struct { Value v__; int tt__; } i; double d__; } u +#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}} +/* field-access macros */ +#define v_(o) ((o)->u.i.v__) +#define d_(o) ((o)->u.d__) +#define tt_(o) ((o)->u.i.tt__) + +#else /* }{ */ + +/* big endian */ +#define TValuefields \ + union { struct { int tt__; Value v__; } i; double d__; } u +#define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}} +/* field-access macros */ +#define v_(o) ((o)->u.i.v__) +#define d_(o) ((o)->u.d__) +#define tt_(o) ((o)->u.i.tt__) + +#endif /* } */ + +#endif /* } */ + + +/* correspondence with standard representation */ +#undef val_ +#define val_(o) v_(o) +#undef num_ +#define num_(o) d_(o) + + +#undef numfield +#define numfield /* no such field; numbers are the entire struct */ + +/* basic check to distinguish numbers from non-numbers */ +#undef ttisnumber +#define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK) + +#define tag2tt(t) (NNMARK | (t)) + +#undef rttype +#define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff) + +#undef settt_ +#define settt_(o,t) (tt_(o) = tag2tt(t)) + +#undef setnvalue +#define setnvalue(obj,x) \ + { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); } + +#undef setobj +#define setobj(L,obj1,obj2) \ + { const TValue *o2_=(obj2); TValue *o1_=(obj1); \ + o1_->u = o2_->u; \ + checkliveness(G(L),o1_); } + + +/* +** these redefinitions are not mandatory, but these forms are more efficient +*/ + +#undef checktag +#undef checktype +#define checktag(o,t) (tt_(o) == tag2tt(t)) +#define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS)) + +#undef ttisequal +#define ttisequal(o1,o2) \ + (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2))) + + +#undef luai_checknum +#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } + +#endif +/* }====================================================== */ + + + +/* +** {====================================================== +** types and prototypes +** ======================================================= +*/ + + +union Value { + GCObject *gc; /* collectable objects */ + void *p; /* light userdata */ + int b; /* booleans */ + lua_CFunction f; /* light C functions */ + numfield /* numbers */ +}; + + +struct lua_TValue { + TValuefields; +}; typedef TValue *StkId; /* index to stack elements */ + + /* -** String headers for string table +** Header for string value; string bytes follow the end of this structure */ typedef union TString { L_Umaxalign dummy; /* ensures maximum alignment for strings */ struct { CommonHeader; - lu_byte reserved; + lu_byte extra; /* reserved words for short strings; "has hash" for longs */ unsigned int hash; - size_t len; + size_t len; /* number of characters in string */ } tsv; } TString; +/* get the actual string (array of bytes) from a TString */ #define getstr(ts) cast(const char *, (ts) + 1) + +/* get the actual string (array of bytes) from a Lua value */ #define svalue(o) getstr(rawtsvalue(o)) - +/* +** Header for userdata; memory area follows the end of this structure +*/ typedef union Udata { L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ struct { CommonHeader; struct Table *metatable; struct Table *env; - size_t len; + size_t len; /* number of bytes */ } uv; } Udata; +/* +** Description of an upvalue for function prototypes +*/ +typedef struct Upvaldesc { + TString *name; /* upvalue name (for debug information) */ + lu_byte instack; /* whether it is in stack */ + lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ +} Upvaldesc; + + +/* +** Description of a local variable for function prototypes +** (used for debug information) +*/ +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + /* ** Function Prototypes @@ -233,11 +469,12 @@ typedef struct Proto { TValue *k; /* constants used by the function */ Instruction *code; struct Proto **p; /* functions defined inside the function */ - int *lineinfo; /* map from opcodes to source lines */ - struct LocVar *locvars; /* information about local variables */ - TString **upvalues; /* upvalue names */ - TString *source; - int sizeupvalues; + int *lineinfo; /* map from opcodes to source lines (debug information) */ + LocVar *locvars; /* information about local variables (debug information) */ + Upvaldesc *upvalues; /* upvalue information */ + union Closure *cache; /* last created closure with this prototype */ + TString *source; /* used for debug information */ + int sizeupvalues; /* size of 'upvalues' */ int sizek; /* size of `k' */ int sizecode; int sizelineinfo; @@ -246,31 +483,16 @@ typedef struct Proto { int linedefined; int lastlinedefined; GCObject *gclist; - lu_byte nups; /* number of upvalues */ - lu_byte numparams; + lu_byte numparams; /* number of fixed parameters */ lu_byte is_vararg; - lu_byte maxstacksize; + lu_byte maxstacksize; /* maximum stack used by this function */ } Proto; -/* masks for new-style vararg */ -#define VARARG_HASARG 1 -#define VARARG_ISVARARG 2 -#define VARARG_NEEDSARG 4 - - -typedef struct LocVar { - TString *varname; - int startpc; /* first point where variable is active */ - int endpc; /* first point where variable is dead */ -} LocVar; - - /* -** Upvalues +** Lua Upvalues */ - typedef struct UpVal { CommonHeader; TValue *v; /* points to stack or to its own value */ @@ -289,20 +511,19 @@ typedef struct UpVal { */ #define ClosureHeader \ - CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ - struct Table *env + CommonHeader; lu_byte nupvalues; GCObject *gclist typedef struct CClosure { ClosureHeader; lua_CFunction f; - TValue upvalue[1]; + TValue upvalue[1]; /* list of upvalues */ } CClosure; typedef struct LClosure { ClosureHeader; struct Proto *p; - UpVal *upvals[1]; + UpVal *upvals[1]; /* list of upvalues */ } LClosure; @@ -312,8 +533,9 @@ typedef union Closure { } Closure; -#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) -#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) +#define isLfunction(o) ttisLclosure(o) + +#define getproto(o) (clLvalue(o)->p) /* @@ -337,7 +559,7 @@ typedef struct Node { typedef struct Table { CommonHeader; - lu_byte flags; /* 1<

lsizenode)) +/* +** (address of) a fixed nil value +*/ #define luaO_nilobject (&luaO_nilobject_) -LUAI_DATA const TValue luaO_nilobject_; -#define ceillog2(x) (luaO_log2((x)-1) + 1) +LUAI_DDEC const TValue luaO_nilobject_; + -LUAI_FUNC int luaO_log2 (unsigned int x); LUAI_FUNC int luaO_int2fb (unsigned int x); LUAI_FUNC int luaO_fb2int (int x); -LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); -LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC int luaO_ceillog2 (unsigned int x); +LUAI_FUNC lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2); +LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result); +LUAI_FUNC int luaO_hexavalue (int c); LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); diff --git a/src/mod/languages/mod_lua/lua/lopcodes.c b/src/mod/languages/mod_lua/lua/lopcodes.c index 4cc745230b..ef73692754 100644 --- a/src/mod/languages/mod_lua/lua/lopcodes.c +++ b/src/mod/languages/mod_lua/lua/lopcodes.c @@ -1,5 +1,6 @@ /* -** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lopcodes.c,v 1.49 2012/05/14 13:34:18 roberto Exp $ +** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -13,15 +14,16 @@ /* ORDER OP */ -const char *const luaP_opnames[NUM_OPCODES+1] = { +LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { "MOVE", "LOADK", + "LOADKX", "LOADBOOL", "LOADNIL", "GETUPVAL", - "GETGLOBAL", + "GETTABUP", "GETTABLE", - "SETGLOBAL", + "SETTABUP", "SETUPVAL", "SETTABLE", "NEWTABLE", @@ -47,27 +49,29 @@ const char *const luaP_opnames[NUM_OPCODES+1] = { "RETURN", "FORLOOP", "FORPREP", + "TFORCALL", "TFORLOOP", "SETLIST", - "CLOSE", "CLOSURE", "VARARG", + "EXTRAARG", NULL }; #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) -const lu_byte luaP_opmodes[NUM_OPCODES] = { +LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { /* T A B C mode opcode */ - opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ - ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ - ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ @@ -86,17 +90,18 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = { ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ - ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ - ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ - ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ + ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ }; diff --git a/src/mod/languages/mod_lua/lua/lopcodes.h b/src/mod/languages/mod_lua/lua/lopcodes.h index 41224d6ee1..07d2b3f39a 100644 --- a/src/mod/languages/mod_lua/lua/lopcodes.h +++ b/src/mod/languages/mod_lua/lua/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lopcodes.h,v 1.142 2011/07/15 12:50:29 roberto Exp $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -17,6 +17,7 @@ `A' : 8 bits `B' : 9 bits `C' : 9 bits + 'Ax' : 26 bits ('A', 'B', and 'C' together) `Bx' : 18 bits (`B' and `C' together) `sBx' : signed Bx @@ -28,7 +29,7 @@ ===========================================================================*/ -enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ +enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ /* @@ -38,6 +39,7 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ #define SIZE_B 9 #define SIZE_Bx (SIZE_C + SIZE_B) #define SIZE_A 8 +#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A) #define SIZE_OP 6 @@ -46,6 +48,7 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ #define POS_C (POS_A + SIZE_A) #define POS_B (POS_C + SIZE_C) #define POS_Bx POS_C +#define POS_Ax POS_A /* @@ -61,6 +64,12 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ #define MAXARG_sBx MAX_INT #endif +#if SIZE_Ax < LUAI_BITSINT-1 +#define MAXARG_Ax ((1<>POS_A) & MASK1(SIZE_A,0))) -#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ - ((cast(Instruction, u)<>pos) & MASK1(size,0))) +#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ + ((cast(Instruction, v)<>POS_B) & MASK1(SIZE_B,0))) -#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ - ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) -#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ - ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) -#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ - ((cast(Instruction, b)<= R(A) + 1 */ OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ -OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ -OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ +OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ +OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ -OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ -OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ +OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ @@ -197,39 +212,44 @@ OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) =) R(A)*/ -OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ -OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */ + +OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ } OpCode; -#define NUM_OPCODES (cast(int, OP_VARARG) + 1) +#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1) /*=========================================================================== Notes: - (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, - and can be 0: OP_CALL then sets `top' to last_result+1, so - next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then `top' is + set to last_result+1, so next open instruction (OP_CALL, OP_RETURN, + OP_SETLIST) may use `top'. (*) In OP_VARARG, if (B == 0) then use actual number of varargs and - set top (like in OP_CALL with C == 0). + set top (like in OP_CALL with C == 0). - (*) In OP_RETURN, if (B == 0) then return up to `top' + (*) In OP_RETURN, if (B == 0) then return up to `top'. - (*) In OP_SETLIST, if (B == 0) then B = `top'; - if (C == 0) then next `instruction' is real C + (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next + 'instruction' is EXTRAARG(real C). + + (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. (*) For comparisons, A specifies what condition the test should accept - (true or false). + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump. - (*) All `skips' (pc++) assume that next instruction is a jump ===========================================================================*/ @@ -239,8 +259,8 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ ** bits 2-3: C arg mode ** bits 4-5: B arg mode ** bit 6: instruction set register A -** bit 7: operator is a test -*/ +** bit 7: operator is a test (next instruction must be a jump) +*/ enum OpArgMask { OpArgN, /* argument is not used */ @@ -249,7 +269,7 @@ enum OpArgMask { OpArgK /* argument is a constant or register/constant */ }; -LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; +LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; #define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) #define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) @@ -258,7 +278,7 @@ LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; #define testTMode(m) (luaP_opmodes[m] & (1 << 7)) -LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ +LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ /* number of list items to accumulate before a SETLIST instruction */ diff --git a/src/mod/languages/mod_lua/lua/loslib.c b/src/mod/languages/mod_lua/lua/loslib.c index da06a572ac..5170fd0d0f 100644 --- a/src/mod/languages/mod_lua/lua/loslib.c +++ b/src/mod/languages/mod_lua/lua/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** $Id: loslib.c,v 1.40 2012/10/19 15:54:02 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -20,37 +20,85 @@ #include "lualib.h" -static int os_pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} +/* +** list of valid conversion specifiers for the 'strftime' function +*/ +#if !defined(LUA_STRFTIMEOPTIONS) + +#if !defined(LUA_USE_POSIX) +#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" } +#else +#define LUA_STRFTIMEOPTIONS \ + { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \ + "", "E", "cCxXyY", \ + "O", "deHImMSuUVwWy" } +#endif + +#endif + + + +/* +** By default, Lua uses tmpnam except when POSIX is available, where it +** uses mkstemp. +*/ +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#elif !defined(lua_tmpnam) + +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } + +#endif + + +/* +** By default, Lua uses gmtime/localtime, except when POSIX is available, +** where it uses gmtime_r/localtime_r +*/ +#if defined(LUA_USE_GMTIME_R) + +#define l_gmtime(t,r) gmtime_r(t,r) +#define l_localtime(t,r) localtime_r(t,r) + +#elif !defined(l_gmtime) + +#define l_gmtime(t,r) ((void)r, gmtime(t)) +#define l_localtime(t,r) ((void)r, localtime(t)) + +#endif + static int os_execute (lua_State *L) { - lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); - return 1; + const char *cmd = luaL_optstring(L, 1, NULL); + int stat = system(cmd); + if (cmd != NULL) + return luaL_execresult(L, stat); + else { + lua_pushboolean(L, stat); /* true if there is a shell */ + return 1; + } } static int os_remove (lua_State *L) { const char *filename = luaL_checkstring(L, 1); - return os_pushresult(L, remove(filename) == 0, filename); + return luaL_fileresult(L, remove(filename) == 0, filename); } static int os_rename (lua_State *L) { const char *fromname = luaL_checkstring(L, 1); const char *toname = luaL_checkstring(L, 2); - return os_pushresult(L, rename(fromname, toname) == 0, fromname); + return luaL_fileresult(L, rename(fromname, toname) == 0, NULL); } @@ -107,11 +155,10 @@ static int getboolfield (lua_State *L, const char *key) { static int getfield (lua_State *L, const char *key, int d) { - int res; + int res, isnum; lua_getfield(L, -1, key); - if (lua_isnumber(L, -1)) - res = (int)lua_tointeger(L, -1); - else { + res = (int)lua_tointegerx(L, -1, &isnum); + if (!isnum) { if (d < 0) return luaL_error(L, "field " LUA_QS " missing in date table", key); res = d; @@ -121,16 +168,40 @@ static int getfield (lua_State *L, const char *key, int d) { } +static const char *checkoption (lua_State *L, const char *conv, char *buff) { + static const char *const options[] = LUA_STRFTIMEOPTIONS; + unsigned int i; + for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) { + if (*conv != '\0' && strchr(options[i], *conv) != NULL) { + buff[1] = *conv; + if (*options[i + 1] == '\0') { /* one-char conversion specifier? */ + buff[2] = '\0'; /* end buffer */ + return conv + 1; + } + else if (*(conv + 1) != '\0' && + strchr(options[i + 1], *(conv + 1)) != NULL) { + buff[2] = *(conv + 1); /* valid two-char conversion specifier */ + buff[3] = '\0'; /* end buffer */ + return conv + 2; + } + } + } + luaL_argerror(L, 1, + lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); + return conv; /* to avoid warnings */ +} + + static int os_date (lua_State *L) { const char *s = luaL_optstring(L, 1, "%c"); time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); - struct tm *stm; + struct tm tmr, *stm; if (*s == '!') { /* UTC? */ - stm = gmtime(&t); + stm = l_gmtime(&t, &tmr); s++; /* skip `!' */ } else - stm = localtime(&t); + stm = l_localtime(&t, &tmr); if (stm == NULL) /* invalid date? */ lua_pushnil(L); else if (strcmp(s, "*t") == 0) { @@ -146,17 +217,17 @@ static int os_date (lua_State *L) { setboolfield(L, "isdst", stm->tm_isdst); } else { - char cc[3]; + char cc[4]; luaL_Buffer b; - cc[0] = '%'; cc[2] = '\0'; + cc[0] = '%'; luaL_buffinit(L, &b); - for (; *s; s++) { - if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ - luaL_addchar(&b, *s); + while (*s) { + if (*s != '%') /* no conversion specifier? */ + luaL_addchar(&b, *s++); else { size_t reslen; char buff[200]; /* should be big enough for any conversion result */ - cc[1] = *(++s); + s = checkoption(L, s + 1, cc); reslen = strftime(buff, sizeof(buff), cc, stm); luaL_addlstring(&b, buff, reslen); } @@ -214,9 +285,18 @@ static int os_setlocale (lua_State *L) { static int os_exit (lua_State *L) { - exit(luaL_optint(L, 1, EXIT_SUCCESS)); + int status; + if (lua_isboolean(L, 1)) + status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE); + else + status = luaL_optint(L, 1, EXIT_SUCCESS); + if (lua_toboolean(L, 2)) + lua_close(L); + if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */ + return 0; } + static const luaL_Reg syslib[] = { {"clock", os_clock}, {"date", os_date}, @@ -236,8 +316,8 @@ static const luaL_Reg syslib[] = { -LUALIB_API int luaopen_os (lua_State *L) { - luaL_register(L, LUA_OSLIBNAME, syslib); +LUAMOD_API int luaopen_os (lua_State *L) { + luaL_newlib(L, syslib); return 1; } diff --git a/src/mod/languages/mod_lua/lua/lparser.c b/src/mod/languages/mod_lua/lua/lparser.c index 1e2a9a88b7..d8f5b4ffc5 100644 --- a/src/mod/languages/mod_lua/lua/lparser.c +++ b/src/mod/languages/mod_lua/lua/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** $Id: lparser.c,v 2.130 2013/02/06 13:37:39 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -27,11 +27,13 @@ +/* maximum number of local variables per function (must be smaller + than 250, due to the bytecode format) */ +#define MAXVARS 200 + + #define hasmultret(k) ((k) == VCALL || (k) == VVARARG) -#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) - -#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) /* @@ -39,10 +41,11 @@ */ typedef struct BlockCnt { struct BlockCnt *previous; /* chain */ - int breaklist; /* list of jumps out of this loop */ - lu_byte nactvar; /* # active locals outside the breakable structure */ + short firstlabel; /* index of first label in this block */ + short firstgoto; /* index of first pending goto in this block */ + lu_byte nactvar; /* # active locals outside the block */ lu_byte upval; /* true if some variable in the block is an upvalue */ - lu_byte isbreakable; /* true if `block' is a loop */ + lu_byte isloop; /* true if `block' is a loop */ } BlockCnt; @@ -50,11 +53,13 @@ typedef struct BlockCnt { /* ** prototypes for recursive non-terminal functions */ -static void chunk (LexState *ls); +static void statement (LexState *ls); static void expr (LexState *ls, expdesc *v); static void anchor_token (LexState *ls) { + /* last token from outer function must be EOS */ + lua_assert(ls->fs != NULL || ls->t.token == TK_EOS); if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { TString *ts = ls->t.seminfo.ts; luaX_newstring(ls, getstr(ts), ts->tsv.len); @@ -62,18 +67,34 @@ static void anchor_token (LexState *ls) { } -static void error_expected (LexState *ls, int token) { - luaX_syntaxerror(ls, - luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +/* semantic error */ +static l_noret semerror (LexState *ls, const char *msg) { + ls->t.token = 0; /* remove 'near to' from final message */ + luaX_syntaxerror(ls, msg); } -static void errorlimit (FuncState *fs, int limit, const char *what) { - const char *msg = (fs->f->linedefined == 0) ? - luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : - luaO_pushfstring(fs->L, "function at line %d has more than %d %s", - fs->f->linedefined, limit, what); - luaX_lexerror(fs->ls, msg, 0); +static l_noret error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); +} + + +static l_noret errorlimit (FuncState *fs, int limit, const char *what) { + lua_State *L = fs->ls->L; + const char *msg; + int line = fs->f->linedefined; + const char *where = (line == 0) + ? "main function" + : luaO_pushfstring(L, "function at line %d", line); + msg = luaO_pushfstring(L, "too many %s (limit is %d) in %s", + what, limit, where); + luaX_syntaxerror(fs->ls, msg); +} + + +static void checklimit (FuncState *fs, int v, int l, const char *what) { + if (v > l) errorlimit(fs, l, what); } @@ -91,6 +112,7 @@ static void check (LexState *ls, int c) { error_expected(ls, c); } + static void checknext (LexState *ls, int c) { check(ls, c); luaX_next(ls); @@ -107,7 +129,7 @@ static void check_match (LexState *ls, int what, int who, int where) { error_expected(ls, what); else { luaX_syntaxerror(ls, luaO_pushfstring(ls->L, - LUA_QS " expected (to close " LUA_QS " at line %d)", + "%s expected (to close %s at line %d)", luaX_token2str(ls, what), luaX_token2str(ls, who), where)); } } @@ -126,7 +148,7 @@ static TString *str_checkname (LexState *ls) { static void init_exp (expdesc *e, expkind k, int i) { e->f = e->t = NO_JUMP; e->k = k; - e->u.s.info = i; + e->u.info = i; } @@ -135,7 +157,7 @@ static void codestring (LexState *ls, expdesc *e, TString *s) { } -static void checkname(LexState *ls, expdesc *e) { +static void checkname (LexState *ls, expdesc *e) { codestring(ls, e, str_checkname(ls)); } @@ -145,7 +167,7 @@ static int registerlocalvar (LexState *ls, TString *varname) { Proto *f = fs->f; int oldsize = f->sizelocvars; luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, - LocVar, SHRT_MAX, "too many local variables"); + LocVar, SHRT_MAX, "local variables"); while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; f->locvars[fs->nlocvars].varname = varname; luaC_objbarrier(ls->L, f, varname); @@ -153,14 +175,30 @@ static int registerlocalvar (LexState *ls, TString *varname) { } -#define new_localvarliteral(ls,v,n) \ - new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) - - -static void new_localvar (LexState *ls, TString *name, int n) { +static void new_localvar (LexState *ls, TString *name) { FuncState *fs = ls->fs; - luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); - fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); + Dyndata *dyd = ls->dyd; + int reg = registerlocalvar(ls, name); + checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, + MAXVARS, "local variables"); + luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, + dyd->actvar.size, Vardesc, MAX_INT, "local variables"); + dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg); +} + + +static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { + new_localvar(ls, luaX_newstring(ls, name, sz)); +} + +#define new_localvarliteral(ls,v) \ + new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1) + + +static LocVar *getlocvar (FuncState *fs, int i) { + int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; + lua_assert(idx < fs->nlocvars); + return &fs->f->locvars[idx]; } @@ -168,77 +206,88 @@ static void adjustlocalvars (LexState *ls, int nvars) { FuncState *fs = ls->fs; fs->nactvar = cast_byte(fs->nactvar + nvars); for (; nvars; nvars--) { - getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc; } } -static void removevars (LexState *ls, int tolevel) { - FuncState *fs = ls->fs; +static void removevars (FuncState *fs, int tolevel) { + fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); while (fs->nactvar > tolevel) - getlocvar(fs, --fs->nactvar).endpc = fs->pc; + getlocvar(fs, --fs->nactvar)->endpc = fs->pc; } -static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { +static int searchupvalue (FuncState *fs, TString *name) { int i; + Upvaldesc *up = fs->f->upvalues; + for (i = 0; i < fs->nups; i++) { + if (luaS_eqstr(up[i].name, name)) return i; + } + return -1; /* not found */ +} + + +static int newupvalue (FuncState *fs, TString *name, expdesc *v) { Proto *f = fs->f; int oldsize = f->sizeupvalues; - for (i=0; inups; i++) { - if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { - lua_assert(f->upvalues[i] == name); - return i; - } - } - /* new one */ - luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); - luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, - TString *, MAX_INT, ""); - while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; - f->upvalues[f->nups] = name; - luaC_objbarrier(fs->L, f, name); - lua_assert(v->k == VLOCAL || v->k == VUPVAL); - fs->upvalues[f->nups].k = cast_byte(v->k); - fs->upvalues[f->nups].info = cast_byte(v->u.s.info); - return f->nups++; + checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); + luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, + Upvaldesc, MAXUPVAL, "upvalues"); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; + f->upvalues[fs->nups].instack = (v->k == VLOCAL); + f->upvalues[fs->nups].idx = cast_byte(v->u.info); + f->upvalues[fs->nups].name = name; + luaC_objbarrier(fs->ls->L, f, name); + return fs->nups++; } static int searchvar (FuncState *fs, TString *n) { int i; - for (i=fs->nactvar-1; i >= 0; i--) { - if (n == getlocvar(fs, i).varname) + for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) { + if (luaS_eqstr(n, getlocvar(fs, i)->varname)) return i; } return -1; /* not found */ } +/* + Mark block where variable at given level was defined + (to emit close instructions later). +*/ static void markupval (FuncState *fs, int level) { BlockCnt *bl = fs->bl; - while (bl && bl->nactvar > level) bl = bl->previous; - if (bl) bl->upval = 1; + while (bl->nactvar > level) bl = bl->previous; + bl->upval = 1; } +/* + Find variable with given name 'n'. If it is an upvalue, add this + upvalue into all intermediate functions. +*/ static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { - if (fs == NULL) { /* no more levels? */ - init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ - return VGLOBAL; - } + if (fs == NULL) /* no more levels? */ + return VVOID; /* default is global */ else { - int v = searchvar(fs, n); /* look up at current level */ - if (v >= 0) { - init_exp(var, VLOCAL, v); + int v = searchvar(fs, n); /* look up locals at current level */ + if (v >= 0) { /* found? */ + init_exp(var, VLOCAL, v); /* variable is local */ if (!base) markupval(fs, v); /* local will be used as an upval */ return VLOCAL; } - else { /* not found at current level; try upper one */ - if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) - return VGLOBAL; - var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ - var->k = VUPVAL; /* upvalue in this level */ + else { /* not found as local at current level; try upvalues */ + int idx = searchupvalue(fs, n); /* try existing upvalues */ + if (idx < 0) { /* not found? */ + if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */ + return VVOID; /* not found; is a global */ + /* else was LOCAL or UPVAL */ + idx = newupvalue(fs, n, var); /* will be a new upvalue */ + } + init_exp(var, VUPVAL, idx); return VUPVAL; } } @@ -248,8 +297,13 @@ static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { static void singlevar (LexState *ls, expdesc *var) { TString *varname = str_checkname(ls); FuncState *fs = ls->fs; - if (singlevaraux(fs, varname, var, 1) == VGLOBAL) - var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ + if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ + expdesc key; + singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ + lua_assert(var->k == VLOCAL || var->k == VUPVAL); + codestring(ls, &key, varname); /* key is variable name */ + luaK_indexed(fs, var, &key); /* env[varname] */ + } } @@ -274,18 +328,118 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { static void enterlevel (LexState *ls) { - if (++ls->L->nCcalls > LUAI_MAXCCALLS) - luaX_lexerror(ls, "chunk has too many syntax levels", 0); + lua_State *L = ls->L; + ++L->nCcalls; + checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); } #define leavelevel(ls) ((ls)->L->nCcalls--) -static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { - bl->breaklist = NO_JUMP; - bl->isbreakable = isbreakable; +static void closegoto (LexState *ls, int g, Labeldesc *label) { + int i; + FuncState *fs = ls->fs; + Labellist *gl = &ls->dyd->gt; + Labeldesc *gt = &gl->arr[g]; + lua_assert(luaS_eqstr(gt->name, label->name)); + if (gt->nactvar < label->nactvar) { + TString *vname = getlocvar(fs, gt->nactvar)->varname; + const char *msg = luaO_pushfstring(ls->L, + " at line %d jumps into the scope of local " LUA_QS, + getstr(gt->name), gt->line, getstr(vname)); + semerror(ls, msg); + } + luaK_patchlist(fs, gt->pc, label->pc); + /* remove goto from pending list */ + for (i = g; i < gl->n - 1; i++) + gl->arr[i] = gl->arr[i + 1]; + gl->n--; +} + + +/* +** try to close a goto with existing labels; this solves backward jumps +*/ +static int findlabel (LexState *ls, int g) { + int i; + BlockCnt *bl = ls->fs->bl; + Dyndata *dyd = ls->dyd; + Labeldesc *gt = &dyd->gt.arr[g]; + /* check labels in current block for a match */ + for (i = bl->firstlabel; i < dyd->label.n; i++) { + Labeldesc *lb = &dyd->label.arr[i]; + if (luaS_eqstr(lb->name, gt->name)) { /* correct label? */ + if (gt->nactvar > lb->nactvar && + (bl->upval || dyd->label.n > bl->firstlabel)) + luaK_patchclose(ls->fs, gt->pc, lb->nactvar); + closegoto(ls, g, lb); /* close it */ + return 1; + } + } + return 0; /* label not found; cannot close goto */ +} + + +static int newlabelentry (LexState *ls, Labellist *l, TString *name, + int line, int pc) { + int n = l->n; + luaM_growvector(ls->L, l->arr, n, l->size, + Labeldesc, SHRT_MAX, "labels/gotos"); + l->arr[n].name = name; + l->arr[n].line = line; + l->arr[n].nactvar = ls->fs->nactvar; + l->arr[n].pc = pc; + l->n++; + return n; +} + + +/* +** check whether new label 'lb' matches any pending gotos in current +** block; solves forward jumps +*/ +static void findgotos (LexState *ls, Labeldesc *lb) { + Labellist *gl = &ls->dyd->gt; + int i = ls->fs->bl->firstgoto; + while (i < gl->n) { + if (luaS_eqstr(gl->arr[i].name, lb->name)) + closegoto(ls, i, lb); + else + i++; + } +} + + +/* +** "export" pending gotos to outer level, to check them against +** outer labels; if the block being exited has upvalues, and +** the goto exits the scope of any variable (which can be the +** upvalue), close those variables being exited. +*/ +static void movegotosout (FuncState *fs, BlockCnt *bl) { + int i = bl->firstgoto; + Labellist *gl = &fs->ls->dyd->gt; + /* correct pending gotos to current block and try to close it + with visible labels */ + while (i < gl->n) { + Labeldesc *gt = &gl->arr[i]; + if (gt->nactvar > bl->nactvar) { + if (bl->upval) + luaK_patchclose(fs, gt->pc, bl->nactvar); + gt->nactvar = bl->nactvar; + } + if (!findlabel(fs->ls, i)) + i++; /* move to next one */ + } +} + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { + bl->isloop = isloop; bl->nactvar = fs->nactvar; + bl->firstlabel = fs->ls->dyd->label.n; + bl->firstgoto = fs->ls->dyd->gt.n; bl->upval = 0; bl->previous = fs->bl; fs->bl = bl; @@ -293,63 +447,108 @@ static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { } +/* +** create a label named "break" to resolve break statements +*/ +static void breaklabel (LexState *ls) { + TString *n = luaS_new(ls->L, "break"); + int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); + findgotos(ls, &ls->dyd->label.arr[l]); +} + +/* +** generates an error for an undefined 'goto'; choose appropriate +** message when label name is a reserved word (which can only be 'break') +*/ +static l_noret undefgoto (LexState *ls, Labeldesc *gt) { + const char *msg = isreserved(gt->name) + ? "<%s> at line %d not inside a loop" + : "no visible label " LUA_QS " for at line %d"; + msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); + semerror(ls, msg); +} + + static void leaveblock (FuncState *fs) { BlockCnt *bl = fs->bl; + LexState *ls = fs->ls; + if (bl->previous && bl->upval) { + /* create a 'jump to here' to close upvalues */ + int j = luaK_jump(fs); + luaK_patchclose(fs, j, bl->nactvar); + luaK_patchtohere(fs, j); + } + if (bl->isloop) + breaklabel(ls); /* close pending breaks */ fs->bl = bl->previous; - removevars(fs->ls, bl->nactvar); - if (bl->upval) - luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); - /* a block either controls scope or breaks (never both) */ - lua_assert(!bl->isbreakable || !bl->upval); + removevars(fs, bl->nactvar); lua_assert(bl->nactvar == fs->nactvar); fs->freereg = fs->nactvar; /* free registers */ - luaK_patchtohere(fs, bl->breaklist); + ls->dyd->label.n = bl->firstlabel; /* remove local labels */ + if (bl->previous) /* inner block? */ + movegotosout(fs, bl); /* update pending gotos to outer block */ + else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ + undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ } -static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { - FuncState *fs = ls->fs; - Proto *f = fs->f; - int oldsize = f->sizep; - int i; - luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, - MAXARG_Bx, "constant table overflow"); - while (oldsize < f->sizep) f->p[oldsize++] = NULL; - f->p[fs->np++] = func->f; - luaC_objbarrier(ls->L, f, func->f); - init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); - for (i=0; if->nups; i++) { - OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; - luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); - } -} - - -static void open_func (LexState *ls, FuncState *fs) { +/* +** adds a new prototype into list of prototypes +*/ +static Proto *addprototype (LexState *ls) { + Proto *clp; lua_State *L = ls->L; - Proto *f = luaF_newproto(L); - fs->f = f; + FuncState *fs = ls->fs; + Proto *f = fs->f; /* prototype of current function */ + if (fs->np >= f->sizep) { + int oldsize = f->sizep; + luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + } + f->p[fs->np++] = clp = luaF_newproto(L); + luaC_objbarrier(L, f, clp); + return clp; +} + + +/* +** codes instruction to create new closure in parent function. +** The OP_CLOSURE instruction must use the last available register, +** so that, if it invokes the GC, the GC knows which registers +** are in use at that time. +*/ +static void codeclosure (LexState *ls, expdesc *v) { + FuncState *fs = ls->fs->prev; + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); + luaK_exp2nextreg(fs, v); /* fix it at the last register */ +} + + +static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { + lua_State *L = ls->L; + Proto *f; fs->prev = ls->fs; /* linked list of funcstates */ fs->ls = ls; - fs->L = L; ls->fs = fs; fs->pc = 0; - fs->lasttarget = -1; + fs->lasttarget = 0; fs->jpc = NO_JUMP; fs->freereg = 0; fs->nk = 0; fs->np = 0; + fs->nups = 0; fs->nlocvars = 0; fs->nactvar = 0; + fs->firstlocal = ls->dyd->actvar.n; fs->bl = NULL; + f = fs->f; f->source = ls->source; f->maxstacksize = 2; /* registers 0/1 are always valid */ - fs->h = luaH_new(L, 0, 0); - /* anchor table of constants and prototype (to avoid being collected) */ + fs->h = luaH_new(L); + /* anchor table of constants (to avoid being collected) */ sethvalue2s(L, L->top, fs->h); incr_top(L); - setptvalue2s(L, L->top, f); - incr_top(L); + enterblock(fs, bl, 0); } @@ -357,8 +556,8 @@ static void close_func (LexState *ls) { lua_State *L = ls->L; FuncState *fs = ls->fs; Proto *f = fs->f; - removevars(ls, 0); luaK_ret(fs, 0, 0); /* final return */ + leaveblock(fs); luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); f->sizecode = fs->pc; luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); @@ -369,32 +568,14 @@ static void close_func (LexState *ls) { f->sizep = fs->np; luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); f->sizelocvars = fs->nlocvars; - luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); - f->sizeupvalues = f->nups; - lua_assert(luaG_checkcode(f)); + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); + f->sizeupvalues = fs->nups; lua_assert(fs->bl == NULL); ls->fs = fs->prev; - L->top -= 2; /* remove table and prototype from the stack */ - /* last token read was anchored in defunct function; must reanchor it */ - if (fs) anchor_token(ls); -} - - -Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { - struct LexState lexstate; - struct FuncState funcstate; - lexstate.buff = buff; - luaX_setinput(L, &lexstate, z, luaS_new(L, name)); - open_func(&lexstate, &funcstate); - funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ - luaX_next(&lexstate); /* read first token */ - chunk(&lexstate); - check(&lexstate, TK_EOS); - close_func(&lexstate); - lua_assert(funcstate.prev == NULL); - lua_assert(funcstate.f->nups == 0); - lua_assert(lexstate.fs == NULL); - return funcstate.f; + /* last token read was anchored in defunct function; must re-anchor it */ + anchor_token(ls); + L->top--; /* pop table of constants */ + luaC_checkGC(L); } @@ -404,11 +585,39 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { /*============================================================*/ -static void field (LexState *ls, expdesc *v) { - /* field -> ['.' | ':'] NAME */ +/* +** check whether current token is in the follow set of a block. +** 'until' closes syntactical blocks, but do not close scope, +** so it handled in separate. +*/ +static int block_follow (LexState *ls, int withuntil) { + switch (ls->t.token) { + case TK_ELSE: case TK_ELSEIF: + case TK_END: case TK_EOS: + return 1; + case TK_UNTIL: return withuntil; + default: return 0; + } +} + + +static void statlist (LexState *ls) { + /* statlist -> { stat [`;'] } */ + while (!block_follow(ls, 1)) { + if (ls->t.token == TK_RETURN) { + statement(ls); + return; /* 'return' must be last statement */ + } + statement(ls); + } +} + + +static void fieldsel (LexState *ls, expdesc *v) { + /* fieldsel -> ['.' | ':'] NAME */ FuncState *fs = ls->fs; expdesc key; - luaK_exp2anyreg(fs, v); + luaK_exp2anyregup(fs, v); luaX_next(ls); /* skip the dot or colon */ checkname(ls, &key); luaK_indexed(fs, v, &key); @@ -447,7 +656,7 @@ static void recfield (LexState *ls, struct ConsControl *cc) { expdesc key, val; int rkkey; if (ls->t.token == TK_NAME) { - luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); checkname(ls, &key); } else /* ls->t.token == '[' */ @@ -456,7 +665,7 @@ static void recfield (LexState *ls, struct ConsControl *cc) { checknext(ls, '='); rkkey = luaK_exp2RK(fs, &key); expr(ls, &val); - luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); fs->freereg = reg; /* free registers */ } @@ -466,7 +675,7 @@ static void closelistfield (FuncState *fs, struct ConsControl *cc) { luaK_exp2nextreg(fs, &cc->v); cc->v.k = VVOID; if (cc->tostore == LFIELDS_PER_FLUSH) { - luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ cc->tostore = 0; /* no more items pending */ } } @@ -476,27 +685,51 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) { if (cc->tostore == 0) return; if (hasmultret(cc->v.k)) { luaK_setmultret(fs, &cc->v); - luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET); cc->na--; /* do not count last expression (unknown number of elements) */ } else { if (cc->v.k != VVOID) luaK_exp2nextreg(fs, &cc->v); - luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); } } static void listfield (LexState *ls, struct ConsControl *cc) { + /* listfield -> exp */ expr(ls, &cc->v); - luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); cc->na++; cc->tostore++; } +static void field (LexState *ls, struct ConsControl *cc) { + /* field -> listfield | recfield */ + switch(ls->t.token) { + case TK_NAME: { /* may be 'listfield' or 'recfield' */ + if (luaX_lookahead(ls) != '=') /* expression? */ + listfield(ls, cc); + else + recfield(ls, cc); + break; + } + case '[': { + recfield(ls, cc); + break; + } + default: { + listfield(ls, cc); + break; + } + } +} + + static void constructor (LexState *ls, expdesc *t) { - /* constructor -> ?? */ + /* constructor -> '{' [ field { sep field } [sep] ] '}' + sep -> ',' | ';' */ FuncState *fs = ls->fs; int line = ls->linenumber; int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); @@ -505,30 +738,13 @@ static void constructor (LexState *ls, expdesc *t) { cc.t = t; init_exp(t, VRELOCABLE, pc); init_exp(&cc.v, VVOID, 0); /* no value (yet) */ - luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ checknext(ls, '{'); do { lua_assert(cc.v.k == VVOID || cc.tostore > 0); if (ls->t.token == '}') break; closelistfield(fs, &cc); - switch(ls->t.token) { - case TK_NAME: { /* may be listfields or recfields */ - luaX_lookahead(ls); - if (ls->lookahead.token != '=') /* expression? */ - listfield(ls, &cc); - else - recfield(ls, &cc); - break; - } - case '[': { /* constructor_item -> recfield */ - recfield(ls, &cc); - break; - } - default: { /* constructor_part -> listfield */ - listfield(ls, &cc); - break; - } - } + field(ls, &cc); } while (testnext(ls, ',') || testnext(ls, ';')); check_match(ls, '}', '{', line); lastlistfield(fs, &cc); @@ -550,17 +766,13 @@ static void parlist (LexState *ls) { do { switch (ls->t.token) { case TK_NAME: { /* param -> NAME */ - new_localvar(ls, str_checkname(ls), nparams++); + new_localvar(ls, str_checkname(ls)); + nparams++; break; } case TK_DOTS: { /* param -> `...' */ luaX_next(ls); -#if defined(LUA_COMPAT_VARARG) - /* use `arg' as default name */ - new_localvarliteral(ls, "arg", nparams++); - f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; -#endif - f->is_vararg |= VARARG_ISVARARG; + f->is_vararg = 1; break; } default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); @@ -568,33 +780,35 @@ static void parlist (LexState *ls) { } while (!f->is_vararg && testnext(ls, ',')); } adjustlocalvars(ls, nparams); - f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + f->numparams = cast_byte(fs->nactvar); luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ } -static void body (LexState *ls, expdesc *e, int needself, int line) { - /* body -> `(' parlist `)' chunk END */ +static void body (LexState *ls, expdesc *e, int ismethod, int line) { + /* body -> `(' parlist `)' block END */ FuncState new_fs; - open_func(ls, &new_fs); + BlockCnt bl; + new_fs.f = addprototype(ls); new_fs.f->linedefined = line; + open_func(ls, &new_fs, &bl); checknext(ls, '('); - if (needself) { - new_localvarliteral(ls, "self", 0); + if (ismethod) { + new_localvarliteral(ls, "self"); /* create 'self' parameter */ adjustlocalvars(ls, 1); } parlist(ls); checknext(ls, ')'); - chunk(ls); + statlist(ls); new_fs.f->lastlinedefined = ls->linenumber; check_match(ls, TK_END, TK_FUNCTION, line); + codeclosure(ls, e); close_func(ls); - pushclosure(ls, &new_fs, e); } -static int explist1 (LexState *ls, expdesc *v) { - /* explist1 -> expr { `,' expr } */ +static int explist (LexState *ls, expdesc *v) { + /* explist -> expr { `,' expr } */ int n = 1; /* at least one expression */ expr(ls, v); while (testnext(ls, ',')) { @@ -606,20 +820,17 @@ static int explist1 (LexState *ls, expdesc *v) { } -static void funcargs (LexState *ls, expdesc *f) { +static void funcargs (LexState *ls, expdesc *f, int line) { FuncState *fs = ls->fs; expdesc args; int base, nparams; - int line = ls->linenumber; switch (ls->t.token) { - case '(': { /* funcargs -> `(' [ explist1 ] `)' */ - if (line != ls->lastline) - luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + case '(': { /* funcargs -> `(' [ explist ] `)' */ luaX_next(ls); if (ls->t.token == ')') /* arg list is empty? */ args.k = VVOID; else { - explist1(ls, &args); + explist(ls, &args); luaK_setmultret(fs, &args); } check_match(ls, ')', '(', line); @@ -636,11 +847,10 @@ static void funcargs (LexState *ls, expdesc *f) { } default: { luaX_syntaxerror(ls, "function arguments expected"); - return; } } lua_assert(f->k == VNONRELOC); - base = f->u.s.info; /* base register for call */ + base = f->u.info; /* base register for call */ if (hasmultret(args.k)) nparams = LUA_MULTRET; /* open call */ else { @@ -664,8 +874,8 @@ static void funcargs (LexState *ls, expdesc *f) { */ -static void prefixexp (LexState *ls, expdesc *v) { - /* prefixexp -> NAME | '(' expr ')' */ +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> NAME | '(' expr ')' */ switch (ls->t.token) { case '(': { int line = ls->linenumber; @@ -681,26 +891,26 @@ static void prefixexp (LexState *ls, expdesc *v) { } default: { luaX_syntaxerror(ls, "unexpected symbol"); - return; } } } -static void primaryexp (LexState *ls, expdesc *v) { - /* primaryexp -> - prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ +static void suffixedexp (LexState *ls, expdesc *v) { + /* suffixedexp -> + primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ FuncState *fs = ls->fs; - prefixexp(ls, v); + int line = ls->linenumber; + primaryexp(ls, v); for (;;) { switch (ls->t.token) { - case '.': { /* field */ - field(ls, v); + case '.': { /* fieldsel */ + fieldsel(ls, v); break; } case '[': { /* `[' exp1 `]' */ expdesc key; - luaK_exp2anyreg(fs, v); + luaK_exp2anyregup(fs, v); yindex(ls, &key); luaK_indexed(fs, v, &key); break; @@ -710,12 +920,12 @@ static void primaryexp (LexState *ls, expdesc *v) { luaX_next(ls); checkname(ls, &key); luaK_self(fs, v, &key); - funcargs(ls, v); + funcargs(ls, v, line); break; } case '(': case TK_STRING: case '{': { /* funcargs */ luaK_exp2nextreg(fs, v); - funcargs(ls, v); + funcargs(ls, v, line); break; } default: return; @@ -725,8 +935,8 @@ static void primaryexp (LexState *ls, expdesc *v) { static void simpleexp (LexState *ls, expdesc *v) { - /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | - constructor | FUNCTION body | primaryexp */ + /* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... | + constructor | FUNCTION body | suffixedexp */ switch (ls->t.token) { case TK_NUMBER: { init_exp(v, VKNUM, 0); @@ -753,7 +963,6 @@ static void simpleexp (LexState *ls, expdesc *v) { FuncState *fs = ls->fs; check_condition(ls, fs->f->is_vararg, "cannot use " LUA_QL("...") " outside a vararg function"); - fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } @@ -767,7 +976,7 @@ static void simpleexp (LexState *ls, expdesc *v) { return; } default: { - primaryexp(ls, v); + suffixedexp(ls, v); return; } } @@ -811,11 +1020,11 @@ static const struct { lu_byte left; /* left priority for each binary operator */ lu_byte right; /* right priority */ } priority[] = { /* ORDER OPR */ - {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ - {10, 9}, {5, 4}, /* power and concat (right associative) */ - {3, 3}, {3, 3}, /* equality and inequality */ - {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ - {2, 2}, {1, 1} /* logical (and/or) */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `*' `/' `%' */ + {10, 9}, {5, 4}, /* ^, .. (right associative) */ + {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ + {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ + {2, 2}, {1, 1} /* and, or */ }; #define UNARY_PRIORITY 8 /* priority for unary operators */ @@ -825,15 +1034,16 @@ static const struct { ** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */ -static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { +static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { BinOpr op; UnOpr uop; enterlevel(ls); uop = getunopr(ls->t.token); if (uop != OPR_NOUNOPR) { + int line = ls->linenumber; luaX_next(ls); subexpr(ls, v, UNARY_PRIORITY); - luaK_prefix(ls->fs, uop, v); + luaK_prefix(ls->fs, uop, v, line); } else simpleexp(ls, v); /* expand while operators have priorities higher than `limit' */ @@ -841,11 +1051,12 @@ static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { while (op != OPR_NOBINOPR && priority[op].left > limit) { expdesc v2; BinOpr nextop; + int line = ls->linenumber; luaX_next(ls); luaK_infix(ls->fs, op, v); /* read sub-expression with higher priority */ nextop = subexpr(ls, &v2, priority[op].right); - luaK_posfix(ls->fs, op, v, &v2); + luaK_posfix(ls->fs, op, v, &v2, line); op = nextop; } leavelevel(ls); @@ -868,23 +1079,12 @@ static void expr (LexState *ls, expdesc *v) { */ -static int block_follow (int token) { - switch (token) { - case TK_ELSE: case TK_ELSEIF: case TK_END: - case TK_UNTIL: case TK_EOS: - return 1; - default: return 0; - } -} - - static void block (LexState *ls) { - /* block -> chunk */ + /* block -> statlist */ FuncState *fs = ls->fs; BlockCnt bl; enterblock(fs, &bl, 0); - chunk(ls); - lua_assert(bl.breaklist == NO_JUMP); + statlist(ls); leaveblock(fs); } @@ -900,29 +1100,34 @@ struct LHS_assign { /* -** check whether, in an assignment to a local variable, the local variable -** is needed in a previous assignment (to a table). If so, save original -** local value in a safe place and use this safe copy in the previous -** assignment. +** check whether, in an assignment to an upvalue/local variable, the +** upvalue/local variable is begin used in a previous assignment to a +** table. If so, save original upvalue/local value in a safe place and +** use this safe copy in the previous assignment. */ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { FuncState *fs = ls->fs; int extra = fs->freereg; /* eventual position to save local variable */ int conflict = 0; - for (; lh; lh = lh->prev) { - if (lh->v.k == VINDEXED) { - if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + for (; lh; lh = lh->prev) { /* check all previous assignments */ + if (lh->v.k == VINDEXED) { /* assigning to a table? */ + /* table is the upvalue/local being assigned now? */ + if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) { conflict = 1; - lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + lh->v.u.ind.vt = VLOCAL; + lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ } - if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + /* index is the local being assigned? (index cannot be upvalue) */ + if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { conflict = 1; - lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ } } } if (conflict) { - luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + /* copy upvalue/local value to a temporary (in position 'extra') */ + OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, op, extra, v->u.info, 0); luaK_reserveregs(fs, 1); } } @@ -930,22 +1135,21 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { expdesc e; - check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, - "syntax error"); - if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + check_condition(ls, vkisvar(lh->v.k), "syntax error"); + if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ struct LHS_assign nv; nv.prev = lh; - primaryexp(ls, &nv.v); - if (nv.v.k == VLOCAL) + suffixedexp(ls, &nv.v); + if (nv.v.k != VINDEXED) check_conflict(ls, lh, &nv.v); - luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, - "variables in assignment"); + checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, + "C levels"); assignment(ls, &nv, nvars+1); } - else { /* assignment -> `=' explist1 */ + else { /* assignment -> `=' explist */ int nexps; checknext(ls, '='); - nexps = explist1(ls, &e); + nexps = explist(ls, &e); if (nexps != nvars) { adjust_assign(ls, nvars, nexps, &e); if (nexps > nvars) @@ -972,19 +1176,57 @@ static int cond (LexState *ls) { } -static void breakstat (LexState *ls) { - FuncState *fs = ls->fs; - BlockCnt *bl = fs->bl; - int upval = 0; - while (bl && !bl->isbreakable) { - upval |= bl->upval; - bl = bl->previous; +static void gotostat (LexState *ls, int pc) { + int line = ls->linenumber; + TString *label; + int g; + if (testnext(ls, TK_GOTO)) + label = str_checkname(ls); + else { + luaX_next(ls); /* skip break */ + label = luaS_new(ls->L, "break"); } - if (!bl) - luaX_syntaxerror(ls, "no loop to break"); - if (upval) - luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); - luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); + g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); + findlabel(ls, g); /* close it if label already defined */ +} + + +/* check for repeated labels on the same block */ +static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { + int i; + for (i = fs->bl->firstlabel; i < ll->n; i++) { + if (luaS_eqstr(label, ll->arr[i].name)) { + const char *msg = luaO_pushfstring(fs->ls->L, + "label " LUA_QS " already defined on line %d", + getstr(label), ll->arr[i].line); + semerror(fs->ls, msg); + } + } +} + + +/* skip no-op statements */ +static void skipnoopstat (LexState *ls) { + while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) + statement(ls); +} + + +static void labelstat (LexState *ls, TString *label, int line) { + /* label -> '::' NAME '::' */ + FuncState *fs = ls->fs; + Labellist *ll = &ls->dyd->label; + int l; /* index of new label being created */ + checkrepeated(fs, ll, label); /* check for repeated labels */ + checknext(ls, TK_DBCOLON); /* skip double colon */ + /* create new entry for this label */ + l = newlabelentry(ls, ll, label, line, fs->pc); + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ + /* assume that locals are already out of scope */ + ll->arr[l].nactvar = fs->bl->nactvar; + } + findgotos(ls, &ll->arr[l]); } @@ -1000,7 +1242,7 @@ static void whilestat (LexState *ls, int line) { enterblock(fs, &bl, 1); checknext(ls, TK_DO); block(ls); - luaK_patchlist(fs, luaK_jump(fs), whileinit); + luaK_jumpto(fs, whileinit); check_match(ls, TK_END, TK_WHILE, line); leaveblock(fs); luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ @@ -1016,30 +1258,25 @@ static void repeatstat (LexState *ls, int line) { enterblock(fs, &bl1, 1); /* loop block */ enterblock(fs, &bl2, 0); /* scope block */ luaX_next(ls); /* skip REPEAT */ - chunk(ls); + statlist(ls); check_match(ls, TK_UNTIL, TK_REPEAT, line); condexit = cond(ls); /* read condition (inside scope block) */ - if (!bl2.upval) { /* no upvalues? */ - leaveblock(fs); /* finish scope */ - luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ - } - else { /* complete semantics when there are upvalues */ - breakstat(ls); /* if condition then break */ - luaK_patchtohere(ls->fs, condexit); /* else... */ - leaveblock(fs); /* finish scope... */ - luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ - } + if (bl2.upval) /* upvalues? */ + luaK_patchclose(fs, condexit, bl2.nactvar); + leaveblock(fs); /* finish scope */ + luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ leaveblock(fs); /* finish loop */ } static int exp1 (LexState *ls) { expdesc e; - int k; + int reg; expr(ls, &e); - k = e.k; luaK_exp2nextreg(ls->fs, &e); - return k; + lua_assert(e.k == VNONRELOC); + reg = e.u.info; + return reg; } @@ -1057,10 +1294,15 @@ static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { block(ls); leaveblock(fs); /* end of scope for declared variables */ luaK_patchtohere(fs, prep); - endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : - luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); - luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ - luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); + if (isnum) /* numeric for? */ + endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); + else { /* generic for */ + luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); + luaK_fixline(fs, line); + endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); + } + luaK_patchlist(fs, endfor, prep + 1); + luaK_fixline(fs, line); } @@ -1068,10 +1310,10 @@ static void fornum (LexState *ls, TString *varname, int line) { /* fornum -> NAME = exp1,exp1[,exp1] forbody */ FuncState *fs = ls->fs; int base = fs->freereg; - new_localvarliteral(ls, "(for index)", 0); - new_localvarliteral(ls, "(for limit)", 1); - new_localvarliteral(ls, "(for step)", 2); - new_localvar(ls, varname, 3); + new_localvarliteral(ls, "(for index)"); + new_localvarliteral(ls, "(for limit)"); + new_localvarliteral(ls, "(for step)"); + new_localvar(ls, varname); checknext(ls, '='); exp1(ls); /* initial value */ checknext(ls, ','); @@ -1079,7 +1321,7 @@ static void fornum (LexState *ls, TString *varname, int line) { if (testnext(ls, ',')) exp1(ls); /* optional step */ else { /* default step = 1 */ - luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_codek(fs, fs->freereg, luaK_numberK(fs, 1)); luaK_reserveregs(fs, 1); } forbody(ls, base, line, 1, 1); @@ -1087,23 +1329,25 @@ static void fornum (LexState *ls, TString *varname, int line) { static void forlist (LexState *ls, TString *indexname) { - /* forlist -> NAME {,NAME} IN explist1 forbody */ + /* forlist -> NAME {,NAME} IN explist forbody */ FuncState *fs = ls->fs; expdesc e; - int nvars = 0; + int nvars = 4; /* gen, state, control, plus at least one declared var */ int line; int base = fs->freereg; /* create control variables */ - new_localvarliteral(ls, "(for generator)", nvars++); - new_localvarliteral(ls, "(for state)", nvars++); - new_localvarliteral(ls, "(for control)", nvars++); + new_localvarliteral(ls, "(for generator)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for control)"); /* create declared variables */ - new_localvar(ls, indexname, nvars++); - while (testnext(ls, ',')) - new_localvar(ls, str_checkname(ls), nvars++); + new_localvar(ls, indexname); + while (testnext(ls, ',')) { + new_localvar(ls, str_checkname(ls)); + nvars++; + } checknext(ls, TK_IN); line = ls->linenumber; - adjust_assign(ls, 3, explist1(ls, &e), &e); + adjust_assign(ls, 3, explist(ls, &e), &e); luaK_checkstack(fs, 3); /* extra space to call generator */ forbody(ls, base, line, nvars - 3, 0); } @@ -1127,65 +1371,77 @@ static void forstat (LexState *ls, int line) { } -static int test_then_block (LexState *ls) { +static void test_then_block (LexState *ls, int *escapelist) { /* test_then_block -> [IF | ELSEIF] cond THEN block */ - int condexit; + BlockCnt bl; + FuncState *fs = ls->fs; + expdesc v; + int jf; /* instruction to skip 'then' code (if condition is false) */ luaX_next(ls); /* skip IF or ELSEIF */ - condexit = cond(ls); + expr(ls, &v); /* read condition */ checknext(ls, TK_THEN); - block(ls); /* `then' part */ - return condexit; + if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { + luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ + enterblock(fs, &bl, 0); /* must enter block before 'goto' */ + gotostat(ls, v.t); /* handle goto/break */ + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ + leaveblock(fs); + return; /* and that is it */ + } + else /* must skip over 'then' part if condition is false */ + jf = luaK_jump(fs); + } + else { /* regular case (not goto/break) */ + luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ + enterblock(fs, &bl, 0); + jf = v.f; + } + statlist(ls); /* `then' part */ + leaveblock(fs); + if (ls->t.token == TK_ELSE || + ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */ + luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */ + luaK_patchtohere(fs, jf); } static void ifstat (LexState *ls, int line) { /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ FuncState *fs = ls->fs; - int flist; - int escapelist = NO_JUMP; - flist = test_then_block(ls); /* IF cond THEN block */ - while (ls->t.token == TK_ELSEIF) { - luaK_concat(fs, &escapelist, luaK_jump(fs)); - luaK_patchtohere(fs, flist); - flist = test_then_block(ls); /* ELSEIF cond THEN block */ - } - if (ls->t.token == TK_ELSE) { - luaK_concat(fs, &escapelist, luaK_jump(fs)); - luaK_patchtohere(fs, flist); - luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + int escapelist = NO_JUMP; /* exit list for finished parts */ + test_then_block(ls, &escapelist); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) + test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */ + if (testnext(ls, TK_ELSE)) block(ls); /* `else' part */ - } - else - luaK_concat(fs, &escapelist, flist); - luaK_patchtohere(fs, escapelist); check_match(ls, TK_END, TK_IF, line); + luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ } static void localfunc (LexState *ls) { - expdesc v, b; + expdesc b; FuncState *fs = ls->fs; - new_localvar(ls, str_checkname(ls), 0); - init_exp(&v, VLOCAL, fs->freereg); - luaK_reserveregs(fs, 1); - adjustlocalvars(ls, 1); - body(ls, &b, 0, ls->linenumber); - luaK_storevar(fs, &v, &b); + new_localvar(ls, str_checkname(ls)); /* new local variable */ + adjustlocalvars(ls, 1); /* enter its scope */ + body(ls, &b, 0, ls->linenumber); /* function created in next register */ /* debug information will only see the variable after this point! */ - getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; + getlocvar(fs, b.u.info)->startpc = fs->pc; } static void localstat (LexState *ls) { - /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + /* stat -> LOCAL NAME {`,' NAME} [`=' explist] */ int nvars = 0; int nexps; expdesc e; do { - new_localvar(ls, str_checkname(ls), nvars++); + new_localvar(ls, str_checkname(ls)); + nvars++; } while (testnext(ls, ',')); if (testnext(ls, '=')) - nexps = explist1(ls, &e); + nexps = explist(ls, &e); else { e.k = VVOID; nexps = 0; @@ -1196,26 +1452,26 @@ static void localstat (LexState *ls) { static int funcname (LexState *ls, expdesc *v) { - /* funcname -> NAME {field} [`:' NAME] */ - int needself = 0; + /* funcname -> NAME {fieldsel} [`:' NAME] */ + int ismethod = 0; singlevar(ls, v); while (ls->t.token == '.') - field(ls, v); + fieldsel(ls, v); if (ls->t.token == ':') { - needself = 1; - field(ls, v); + ismethod = 1; + fieldsel(ls, v); } - return needself; + return ismethod; } static void funcstat (LexState *ls, int line) { /* funcstat -> FUNCTION funcname body */ - int needself; + int ismethod; expdesc v, b; luaX_next(ls); /* skip FUNCTION */ - needself = funcname(ls, &v); - body(ls, &b, needself, line); + ismethod = funcname(ls, &v); + body(ls, &b, ismethod, line); luaK_storevar(ls->fs, &v, &b); luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ } @@ -1225,26 +1481,27 @@ static void exprstat (LexState *ls) { /* stat -> func | assignment */ FuncState *fs = ls->fs; struct LHS_assign v; - primaryexp(ls, &v.v); - if (v.v.k == VCALL) /* stat -> func */ - SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ - else { /* stat -> assignment */ + suffixedexp(ls, &v.v); + if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ v.prev = NULL; assignment(ls, &v, 1); } + else { /* stat -> func */ + check_condition(ls, v.v.k == VCALL, "syntax error"); + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + } } static void retstat (LexState *ls) { - /* stat -> RETURN explist */ + /* stat -> RETURN [explist] [';'] */ FuncState *fs = ls->fs; expdesc e; int first, nret; /* registers with returned values */ - luaX_next(ls); /* skip RETURN */ - if (block_follow(ls->t.token) || ls->t.token == ';') + if (block_follow(ls, 1) || ls->t.token == ';') first = nret = 0; /* return no values */ else { - nret = explist1(ls, &e); /* optional return values */ + nret = explist(ls, &e); /* optional return values */ if (hasmultret(e.k)) { luaK_setmultret(fs, &e); if (e.k == VCALL && nret == 1) { /* tail call? */ @@ -1265,37 +1522,43 @@ static void retstat (LexState *ls) { } } luaK_ret(fs, first, nret); + testnext(ls, ';'); /* skip optional semicolon */ } -static int statement (LexState *ls) { +static void statement (LexState *ls) { int line = ls->linenumber; /* may be needed for error messages */ + enterlevel(ls); switch (ls->t.token) { + case ';': { /* stat -> ';' (empty statement) */ + luaX_next(ls); /* skip ';' */ + break; + } case TK_IF: { /* stat -> ifstat */ ifstat(ls, line); - return 0; + break; } case TK_WHILE: { /* stat -> whilestat */ whilestat(ls, line); - return 0; + break; } case TK_DO: { /* stat -> DO block END */ luaX_next(ls); /* skip DO */ block(ls); check_match(ls, TK_END, TK_DO, line); - return 0; + break; } case TK_FOR: { /* stat -> forstat */ forstat(ls, line); - return 0; + break; } case TK_REPEAT: { /* stat -> repeatstat */ repeatstat(ls, line); - return 0; + break; } - case TK_FUNCTION: { - funcstat(ls, line); /* stat -> funcstat */ - return 0; + case TK_FUNCTION: { /* stat -> funcstat */ + funcstat(ls, line); + break; } case TK_LOCAL: { /* stat -> localstat */ luaX_next(ls); /* skip LOCAL */ @@ -1303,37 +1566,73 @@ static int statement (LexState *ls) { localfunc(ls); else localstat(ls); - return 0; + break; + } + case TK_DBCOLON: { /* stat -> label */ + luaX_next(ls); /* skip double colon */ + labelstat(ls, str_checkname(ls), line); + break; } case TK_RETURN: { /* stat -> retstat */ + luaX_next(ls); /* skip RETURN */ retstat(ls); - return 1; /* must be last statement */ + break; } - case TK_BREAK: { /* stat -> breakstat */ - luaX_next(ls); /* skip BREAK */ - breakstat(ls); - return 1; /* must be last statement */ + case TK_BREAK: /* stat -> breakstat */ + case TK_GOTO: { /* stat -> 'goto' NAME */ + gotostat(ls, luaK_jump(ls->fs)); + break; } - default: { + default: { /* stat -> func | assignment */ exprstat(ls); - return 0; /* to avoid warnings */ + break; } } -} - - -static void chunk (LexState *ls) { - /* chunk -> { stat [`;'] } */ - int islast = 0; - enterlevel(ls); - while (!islast && !block_follow(ls->t.token)) { - islast = statement(ls); - testnext(ls, ';'); - lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && - ls->fs->freereg >= ls->fs->nactvar); - ls->fs->freereg = ls->fs->nactvar; /* free registers */ - } + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ leavelevel(ls); } /* }====================================================================== */ + + +/* +** compiles the main function, which is a regular vararg function with an +** upvalue named LUA_ENV +*/ +static void mainfunc (LexState *ls, FuncState *fs) { + BlockCnt bl; + expdesc v; + open_func(ls, fs, &bl); + fs->f->is_vararg = 1; /* main function is always vararg */ + init_exp(&v, VLOCAL, 0); /* create and... */ + newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ + luaX_next(ls); /* read first token */ + statlist(ls); /* parse main body */ + check(ls, TK_EOS); + close_func(ls); +} + + +Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar) { + LexState lexstate; + FuncState funcstate; + Closure *cl = luaF_newLclosure(L, 1); /* create main closure */ + /* anchor closure (to avoid being collected) */ + setclLvalue(L, L->top, cl); + incr_top(L); + funcstate.f = cl->l.p = luaF_newproto(L); + funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ + lexstate.buff = buff; + lexstate.dyd = dyd; + dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; + luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); + mainfunc(&lexstate, &funcstate); + lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); + /* all scopes should be correctly finished */ + lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); + return cl; /* it's on the stack too */ +} + diff --git a/src/mod/languages/mod_lua/lua/lparser.h b/src/mod/languages/mod_lua/lua/lparser.h index 18836afd1c..301167d4f5 100644 --- a/src/mod/languages/mod_lua/lua/lparser.h +++ b/src/mod/languages/mod_lua/lua/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lparser.h,v 1.70 2012/05/08 13:53:33 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -23,34 +23,72 @@ typedef enum { VFALSE, VK, /* info = index of constant in `k' */ VKNUM, /* nval = numerical value */ + VNONRELOC, /* info = result register */ VLOCAL, /* info = local register */ - VUPVAL, /* info = index of upvalue in `upvalues' */ - VGLOBAL, /* info = index of table; aux = index of global name in `k' */ - VINDEXED, /* info = table register; aux = index register (or `k') */ + VUPVAL, /* info = index of upvalue in 'upvalues' */ + VINDEXED, /* t = table register/upvalue; idx = index R/K */ VJMP, /* info = instruction pc */ VRELOCABLE, /* info = instruction pc */ - VNONRELOC, /* info = result register */ VCALL, /* info = instruction pc */ VVARARG /* info = instruction pc */ } expkind; + +#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) +#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) + typedef struct expdesc { expkind k; union { - struct { int info, aux; } s; - lua_Number nval; + struct { /* for indexed variables (VINDEXED) */ + short idx; /* index (R/K) */ + lu_byte t; /* table (register or upvalue) */ + lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ + } ind; + int info; /* for generic use */ + lua_Number nval; /* for VKNUM */ } u; int t; /* patch list of `exit when true' */ int f; /* patch list of `exit when false' */ } expdesc; -typedef struct upvaldesc { - lu_byte k; - lu_byte info; -} upvaldesc; +/* description of active local variable */ +typedef struct Vardesc { + short idx; /* variable index in stack */ +} Vardesc; +/* description of pending goto statements and label statements */ +typedef struct Labeldesc { + TString *name; /* label identifier */ + int pc; /* position in code */ + int line; /* line where it appeared */ + lu_byte nactvar; /* local level where it appears in current block */ +} Labeldesc; + + +/* list of labels or gotos */ +typedef struct Labellist { + Labeldesc *arr; /* array */ + int n; /* number of entries in use */ + int size; /* array size */ +} Labellist; + + +/* dynamic structures used by the parser */ +typedef struct Dyndata { + struct { /* list of active local variables */ + Vardesc *arr; + int n; + int size; + } actvar; + Labellist gt; /* list of pending gotos */ + Labellist label; /* list of active labels */ +} Dyndata; + + +/* control of blocks */ struct BlockCnt; /* defined in lparser.c */ @@ -60,23 +98,22 @@ typedef struct FuncState { Table *h; /* table to find (and reuse) elements in `k' */ struct FuncState *prev; /* enclosing function */ struct LexState *ls; /* lexical state */ - struct lua_State *L; /* copy of the Lua state */ struct BlockCnt *bl; /* chain of current blocks */ int pc; /* next position to code (equivalent to `ncode') */ - int lasttarget; /* `pc' of last `jump target' */ + int lasttarget; /* 'label' of last 'jump label' */ int jpc; /* list of pending jumps to `pc' */ - int freereg; /* first free register */ int nk; /* number of elements in `k' */ int np; /* number of elements in `p' */ - short nlocvars; /* number of elements in `locvars' */ + int firstlocal; /* index of first local var (in Dyndata array) */ + short nlocvars; /* number of elements in 'f->locvars' */ lu_byte nactvar; /* number of active local variables */ - upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ - unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ + lu_byte nups; /* number of upvalues */ + lu_byte freereg; /* first free register */ } FuncState; -LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - const char *name); +LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar); #endif diff --git a/src/mod/languages/mod_lua/lua/lstate.c b/src/mod/languages/mod_lua/lua/lstate.c index 4313b83a0c..207a106d5b 100644 --- a/src/mod/languages/mod_lua/lua/lstate.c +++ b/src/mod/languages/mod_lua/lua/lstate.c @@ -1,17 +1,19 @@ /* -** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** $Id: lstate.c,v 2.99 2012/10/02 17:40:53 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ #include +#include #define lstate_c #define LUA_CORE #include "lua.h" +#include "lapi.h" #include "ldebug.h" #include "ldo.h" #include "lfunc.h" @@ -24,119 +26,236 @@ #include "ltm.h" -#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) -#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) -#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) +#if !defined(LUAI_GCPAUSE) +#define LUAI_GCPAUSE 200 /* 200% */ +#endif + +#if !defined(LUAI_GCMAJOR) +#define LUAI_GCMAJOR 200 /* 200% */ +#endif + +#if !defined(LUAI_GCMUL) +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ +#endif + + +#define MEMERRMSG "not enough memory" + + +/* +** a macro to help the creation of a unique random seed when a state is +** created; the seed is used to randomize hashes. +*/ +#if !defined(luai_makeseed) +#include +#define luai_makeseed() cast(unsigned int, time(NULL)) +#endif + + + +/* +** thread state + extra space +*/ +typedef struct LX { +#if defined(LUAI_EXTRASPACE) + char buff[LUAI_EXTRASPACE]; +#endif + lua_State l; +} LX; /* ** Main thread combines a thread state and the global state */ typedef struct LG { - lua_State l; + LX l; global_State g; } LG; - -static void stack_init (lua_State *L1, lua_State *L) { - /* initialize CallInfo array */ - L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); - L1->ci = L1->base_ci; - L1->size_ci = BASIC_CI_SIZE; - L1->end_ci = L1->base_ci + L1->size_ci - 1; - /* initialize stack array */ - L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); - L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; - L1->top = L1->stack; - L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; - /* initialize first ci */ - L1->ci->func = L1->top; - setnilvalue(L1->top++); /* `function' entry for this `ci' */ - L1->base = L1->ci->base = L1->top; - L1->ci->top = L1->top + LUA_MINSTACK; -} + +#define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) -static void freestack (lua_State *L, lua_State *L1) { - luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); - luaM_freearray(L, L1->stack, L1->stacksize, TValue); +/* +** Compute an initial seed as random as possible. In ANSI, rely on +** Address Space Layout Randomization (if present) to increase +** randomness.. +*/ +#define addbuff(b,p,e) \ + { size_t t = cast(size_t, e); \ + memcpy(buff + p, &t, sizeof(t)); p += sizeof(t); } + +static unsigned int makeseed (lua_State *L) { + char buff[4 * sizeof(size_t)]; + unsigned int h = luai_makeseed(); + int p = 0; + addbuff(buff, p, L); /* heap variable */ + addbuff(buff, p, &h); /* local variable */ + addbuff(buff, p, luaO_nilobject); /* global variable */ + addbuff(buff, p, &lua_newstate); /* public function */ + lua_assert(p == sizeof(buff)); + return luaS_hash(buff, p, h); } /* -** open parts that may cause memory-allocation errors +** set GCdebt to a new value keeping the value (totalbytes + GCdebt) +** invariant +*/ +void luaE_setdebt (global_State *g, l_mem debt) { + g->totalbytes -= (debt - g->GCdebt); + g->GCdebt = debt; +} + + +CallInfo *luaE_extendCI (lua_State *L) { + CallInfo *ci = luaM_new(L, CallInfo); + lua_assert(L->ci->next == NULL); + L->ci->next = ci; + ci->previous = L->ci; + ci->next = NULL; + return ci; +} + + +void luaE_freeCI (lua_State *L) { + CallInfo *ci = L->ci; + CallInfo *next = ci->next; + ci->next = NULL; + while ((ci = next) != NULL) { + next = ci->next; + luaM_free(L, ci); + } +} + + +static void stack_init (lua_State *L1, lua_State *L) { + int i; CallInfo *ci; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); + L1->stacksize = BASIC_STACK_SIZE; + for (i = 0; i < BASIC_STACK_SIZE; i++) + setnilvalue(L1->stack + i); /* erase new stack */ + L1->top = L1->stack; + L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; + /* initialize first ci */ + ci = &L1->base_ci; + ci->next = ci->previous = NULL; + ci->callstatus = 0; + ci->func = L1->top; + setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ + ci->top = L1->top + LUA_MINSTACK; + L1->ci = ci; +} + + +static void freestack (lua_State *L) { + if (L->stack == NULL) + return; /* stack not completely built yet */ + L->ci = &L->base_ci; /* free the entire 'ci' list */ + luaE_freeCI(L); + luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ +} + + +/* +** Create registry table and its predefined values +*/ +static void init_registry (lua_State *L, global_State *g) { + TValue mt; + /* create registry */ + Table *registry = luaH_new(L); + sethvalue(L, &g->l_registry, registry); + luaH_resize(L, registry, LUA_RIDX_LAST, 0); + /* registry[LUA_RIDX_MAINTHREAD] = L */ + setthvalue(L, &mt, L); + luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt); + /* registry[LUA_RIDX_GLOBALS] = table of globals */ + sethvalue(L, &mt, luaH_new(L)); + luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt); +} + + +/* +** open parts of the state that may cause memory-allocation errors */ static void f_luaopen (lua_State *L, void *ud) { global_State *g = G(L); UNUSED(ud); stack_init(L, L); /* init stack */ - sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ - sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + init_registry(L, g); luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ luaT_init(L); luaX_init(L); - luaS_fix(luaS_newliteral(L, MEMERRMSG)); - g->GCthreshold = 4*g->totalbytes; + /* pre-create memory-error message */ + g->memerrmsg = luaS_newliteral(L, MEMERRMSG); + luaS_fix(g->memerrmsg); /* it should never be collected */ + g->gcrunning = 1; /* allow gc */ } +/* +** preinitialize a state with consistent values without allocating +** any memory (to avoid errors) +*/ static void preinit_state (lua_State *L, global_State *g) { G(L) = g; L->stack = NULL; + L->ci = NULL; L->stacksize = 0; L->errorJmp = NULL; + L->nCcalls = 0; L->hook = NULL; L->hookmask = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; - L->size_ci = 0; - L->nCcalls = L->baseCcalls = 0; - L->status = 0; - L->base_ci = L->ci = NULL; - L->savedpc = NULL; + L->nny = 1; + L->status = LUA_OK; L->errfunc = 0; - setnilvalue(gt(L)); } static void close_state (lua_State *L) { global_State *g = G(L); luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_freeall(L); /* collect all objects */ - lua_assert(g->rootgc == obj2gco(L)); - lua_assert(g->strt.nuse == 0); - luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaC_freeallobjects(L); /* collect all objects */ + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); luaZ_freebuffer(L, &g->buff); - freestack(L, L); - lua_assert(g->totalbytes == sizeof(LG)); - (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); + freestack(L); + lua_assert(gettotalbytes(g) == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ } -lua_State *luaE_newthread (lua_State *L) { - lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); - luaC_link(L, obj2gco(L1), LUA_TTHREAD); +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th; + setthvalue(L, L->top, L1); + api_incr_top(L); preinit_state(L1, G(L)); - stack_init(L1, L); /* init stack */ - setobj2n(L, gt(L1), gt(L)); /* share table of globals */ L1->hookmask = L->hookmask; L1->basehookcount = L->basehookcount; L1->hook = L->hook; resethookcount(L1); - lua_assert(iswhite(obj2gco(L1))); + luai_userstatethread(L, L1); + stack_init(L1, L); /* init stack */ + lua_unlock(L); return L1; } void luaE_freethread (lua_State *L, lua_State *L1) { + LX *l = fromstate(L1); luaF_close(L1, L1->stack); /* close all upvalues for this thread */ lua_assert(L1->openupval == NULL); - luai_userstatefree(L1); - freestack(L, L1); - luaM_freemem(L, fromstate(L1), state_size(lua_State)); + luai_userstatefree(L, L1); + freestack(L1); + luaM_free(L, l); } @@ -144,42 +263,45 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { int i; lua_State *L; global_State *g; - void *l = (*f)(ud, NULL, 0, state_size(LG)); + LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); if (l == NULL) return NULL; - L = tostate(l); - g = &((LG *)L)->g; + L = &l->l.l; + g = &l->g; L->next = NULL; L->tt = LUA_TTHREAD; g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); L->marked = luaC_white(g); - set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + g->gckind = KGC_NORMAL; preinit_state(L, g); g->frealloc = f; g->ud = ud; g->mainthread = L; + g->seed = makeseed(L); g->uvhead.u.l.prev = &g->uvhead; g->uvhead.u.l.next = &g->uvhead; - g->GCthreshold = 0; /* mark it as unfinished state */ + g->gcrunning = 0; /* no GC while building state */ + g->GCestimate = 0; g->strt.size = 0; g->strt.nuse = 0; g->strt.hash = NULL; - setnilvalue(registry(L)); + setnilvalue(&g->l_registry); luaZ_initbuffer(L, &g->buff); g->panic = NULL; + g->version = lua_version(NULL); g->gcstate = GCSpause; - g->rootgc = obj2gco(L); - g->sweepstrgc = 0; - g->sweepgc = &g->rootgc; - g->gray = NULL; - g->grayagain = NULL; - g->weak = NULL; - g->tmudata = NULL; + g->allgc = NULL; + g->finobj = NULL; + g->tobefnz = NULL; + g->sweepgc = g->sweepfin = NULL; + g->gray = g->grayagain = NULL; + g->weak = g->ephemeron = g->allweak = NULL; g->totalbytes = sizeof(LG); + g->GCdebt = 0; g->gcpause = LUAI_GCPAUSE; + g->gcmajorinc = LUAI_GCMAJOR; g->gcstepmul = LUAI_GCMUL; - g->gcdept = 0; - for (i=0; imt[i] = NULL; - if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { /* memory allocation error: free partial state */ close_state(L); L = NULL; @@ -190,25 +312,11 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { } -static void callallgcTM (lua_State *L, void *ud) { - UNUSED(ud); - luaC_callGCTM(L); /* call GC metamethods for all udata */ -} - - LUA_API void lua_close (lua_State *L) { L = G(L)->mainthread; /* only the main thread can be closed */ lua_lock(L); - luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ - L->errfunc = 0; /* no error function during GC metamethods */ - do { /* repeat until no more errors */ - L->ci = L->base_ci; - L->base = L->top = L->ci->base; - L->nCcalls = L->baseCcalls = 0; - } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); - lua_assert(G(L)->tmudata == NULL); luai_userstateclose(L); close_state(L); } + diff --git a/src/mod/languages/mod_lua/lua/lstate.h b/src/mod/languages/mod_lua/lua/lstate.h index 3bc575b6bc..c8a31f5c0b 100644 --- a/src/mod/languages/mod_lua/lua/lstate.h +++ b/src/mod/languages/mod_lua/lua/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** $Id: lstate.h,v 2.82 2012/07/02 13:37:04 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -14,26 +14,47 @@ #include "lzio.h" +/* + +** Some notes about garbage-collected objects: All objects in Lua must +** be kept somehow accessible until being freed. +** +** Lua keeps most objects linked in list g->allgc. The link uses field +** 'next' of the CommonHeader. +** +** Strings are kept in several lists headed by the array g->strt.hash. +** +** Open upvalues are not subject to independent garbage collection. They +** are collected together with their respective threads. Lua keeps a +** double-linked list with all open upvalues (g->uvhead) so that it can +** mark objects referred by them. (They are always gray, so they must +** be remarked in the atomic step. Usually their contents would be marked +** when traversing the respective threads, but the thread may already be +** dead, while the upvalue is still accessible through closures.) +** +** Objects with finalizers are kept in the list g->finobj. +** +** The list g->tobefnz links all objects being finalized. + +*/ + struct lua_longjmp; /* defined in ldo.c */ -/* table of globals */ -#define gt(L) (&L->l_gt) - -/* registry */ -#define registry(L) (&G(L)->l_registry) - /* extra stack space to handle TM calls and some other extras */ #define EXTRA_STACK 5 -#define BASIC_CI_SIZE 8 - #define BASIC_STACK_SIZE (2*LUA_MINSTACK) +/* kinds of Garbage Collection */ +#define KGC_NORMAL 0 +#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */ +#define KGC_GEN 2 /* generational collection */ + typedef struct stringtable { GCObject **hash; @@ -43,54 +64,87 @@ typedef struct stringtable { /* -** informations about a call +** information about a call */ typedef struct CallInfo { - StkId base; /* base for this function */ StkId func; /* function index in the stack */ StkId top; /* top for this function */ - const Instruction *savedpc; - int nresults; /* expected number of results from this function */ - int tailcalls; /* number of tail calls lost under this entry */ + struct CallInfo *previous, *next; /* dynamic call link */ + short nresults; /* expected number of results from this function */ + lu_byte callstatus; + ptrdiff_t extra; + union { + struct { /* only for Lua functions */ + StkId base; /* base for this function */ + const Instruction *savedpc; + } l; + struct { /* only for C functions */ + int ctx; /* context info. in case of yields */ + lua_CFunction k; /* continuation in case of yields */ + ptrdiff_t old_errfunc; + lu_byte old_allowhook; + lu_byte status; + } c; + } u; } CallInfo; +/* +** Bits in CallInfo status +*/ +#define CIST_LUA (1<<0) /* call is running a Lua function */ +#define CIST_HOOKED (1<<1) /* call is running a debug hook */ +#define CIST_REENTRY (1<<2) /* call is running on same invocation of + luaV_execute of previous call */ +#define CIST_YIELDED (1<<3) /* call reentered after suspension */ +#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ +#define CIST_STAT (1<<5) /* call has an error status (pcall) */ +#define CIST_TAIL (1<<6) /* call was tail called */ +#define CIST_HOOKYIELD (1<<7) /* last hook called yielded */ -#define curr_func(L) (clvalue(L->ci->func)) -#define ci_func(ci) (clvalue((ci)->func)) -#define f_isLua(ci) (!ci_func(ci)->c.isC) -#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + +#define isLua(ci) ((ci)->callstatus & CIST_LUA) /* ** `global state', shared by all threads of this state */ typedef struct global_State { - stringtable strt; /* hash table for strings */ lua_Alloc frealloc; /* function to reallocate memory */ void *ud; /* auxiliary data to `frealloc' */ + lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */ + l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ + lu_mem GCmemtrav; /* memory traversed by the GC */ + lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ + stringtable strt; /* hash table for strings */ + TValue l_registry; + unsigned int seed; /* randomized seed for hashes */ lu_byte currentwhite; lu_byte gcstate; /* state of garbage collector */ + lu_byte gckind; /* kind of GC running */ + lu_byte gcrunning; /* true if GC is running */ int sweepstrgc; /* position of sweep in `strt' */ - GCObject *rootgc; /* list of all collectable objects */ - GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *allgc; /* list of all collectable objects */ + GCObject *finobj; /* list of collectable objects with finalizers */ + GCObject **sweepgc; /* current position of sweep in list 'allgc' */ + GCObject **sweepfin; /* current position of sweep in list 'finobj' */ GCObject *gray; /* list of gray objects */ GCObject *grayagain; /* list of objects to be traversed atomically */ - GCObject *weak; /* list of weak tables (to be cleared) */ - GCObject *tmudata; /* last element of list of userdata to be GC */ - Mbuffer buff; /* temporary buffer for string concatentation */ - lu_mem GCthreshold; - lu_mem totalbytes; /* number of bytes currently allocated */ - lu_mem estimate; /* an estimate of number of bytes actually in use */ - lu_mem gcdept; /* how much GC is `behind schedule' */ + GCObject *weak; /* list of tables with weak values */ + GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ + GCObject *allweak; /* list of all-weak tables */ + GCObject *tobefnz; /* list of userdata to be GC */ + UpVal uvhead; /* head of double-linked list of all open upvalues */ + Mbuffer buff; /* temporary buffer for string concatenation */ int gcpause; /* size of pause between successive GCs */ + int gcmajorinc; /* pause between major collections (only in gen. mode) */ int gcstepmul; /* GC `granularity' */ lua_CFunction panic; /* to be called in unprotected errors */ - TValue l_registry; struct lua_State *mainthread; - UpVal uvhead; /* head of double-linked list of all open upvalues */ - struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + const lua_Number *version; /* pointer to version number */ + TString *memerrmsg; /* memory-error message */ TString *tmname[TM_N]; /* array with tag-method names */ + struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ } global_State; @@ -101,29 +155,24 @@ struct lua_State { CommonHeader; lu_byte status; StkId top; /* first free slot in the stack */ - StkId base; /* base of current function */ global_State *l_G; CallInfo *ci; /* call info for current function */ - const Instruction *savedpc; /* `savedpc' of current function */ + const Instruction *oldpc; /* last pc traced */ StkId stack_last; /* last free slot in the stack */ StkId stack; /* stack base */ - CallInfo *end_ci; /* points after end of ci array*/ - CallInfo *base_ci; /* array of CallInfo's */ int stacksize; - int size_ci; /* size of array `base_ci' */ + unsigned short nny; /* number of non-yieldable calls in stack */ unsigned short nCcalls; /* number of nested C calls */ - unsigned short baseCcalls; /* nested C calls when resuming coroutine */ lu_byte hookmask; lu_byte allowhook; int basehookcount; int hookcount; lua_Hook hook; - TValue l_gt; /* table of globals */ - TValue env; /* temporary place for environments */ GCObject *openupval; /* list of open upvalues in this stack */ GCObject *gclist; struct lua_longjmp *errorJmp; /* current error recover point */ ptrdiff_t errfunc; /* current error handling function (stack index) */ + CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ }; @@ -134,7 +183,7 @@ struct lua_State { ** Union of all collectable objects */ union GCObject { - GCheader gch; + GCheader gch; /* common header */ union TString ts; union Udata u; union Closure cl; @@ -145,25 +194,35 @@ union GCObject { }; +#define gch(o) (&(o)->gch) + /* macros to convert a GCObject into a specific value */ -#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define rawgco2ts(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts)) #define gco2ts(o) (&rawgco2ts(o)->tsv) #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) #define gco2u(o) (&rawgco2u(o)->uv) -#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) -#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l)) +#define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c)) +#define gco2cl(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl)) +#define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) -#define ngcotouv(o) \ - check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) /* macro to convert any Lua object into a GCObject */ #define obj2gco(v) (cast(GCObject *, (v))) -LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +/* actual number of total bytes allocated */ +#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt) + +LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); +LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); +LUAI_FUNC void luaE_freeCI (lua_State *L); + #endif diff --git a/src/mod/languages/mod_lua/lua/lstring.c b/src/mod/languages/mod_lua/lua/lstring.c index 49113151cc..8b5af0b2e7 100644 --- a/src/mod/languages/mod_lua/lua/lstring.c +++ b/src/mod/languages/mod_lua/lua/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lstring.c,v 2.26 2013/01/08 13:50:10 roberto Exp $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -18,78 +18,157 @@ #include "lstring.h" +/* +** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to +** compute its hash +*/ +#if !defined(LUAI_HASHLIMIT) +#define LUAI_HASHLIMIT 5 +#endif -void luaS_resize (lua_State *L, int newsize) { - GCObject **newhash; - stringtable *tb; - int i; - if (G(L)->gcstate == GCSsweepstring) - return; /* cannot resize during GC traverse */ - newhash = luaM_newvector(L, newsize, GCObject *); - tb = &G(L)->strt; - for (i=0; isize; i++) { - GCObject *p = tb->hash[i]; - while (p) { /* for each node in the list */ - GCObject *next = p->gch.next; /* save next */ - unsigned int h = gco2ts(p)->hash; - int h1 = lmod(h, newsize); /* new position */ - lua_assert(cast_int(h%newsize) == lmod(h, newsize)); - p->gch.next = newhash[h1]; /* chain it */ - newhash[h1] = p; - p = next; - } - } - luaM_freearray(L, tb->hash, tb->size, TString *); - tb->size = newsize; - tb->hash = newhash; + +/* +** equality for long strings +*/ +int luaS_eqlngstr (TString *a, TString *b) { + size_t len = a->tsv.len; + lua_assert(a->tsv.tt == LUA_TLNGSTR && b->tsv.tt == LUA_TLNGSTR); + return (a == b) || /* same instance or... */ + ((len == b->tsv.len) && /* equal length and ... */ + (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ } -static TString *newlstr (lua_State *L, const char *str, size_t l, - unsigned int h) { +/* +** equality for strings +*/ +int luaS_eqstr (TString *a, TString *b) { + return (a->tsv.tt == b->tsv.tt) && + (a->tsv.tt == LUA_TSHRSTR ? eqshrstr(a, b) : luaS_eqlngstr(a, b)); +} + + +unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { + unsigned int h = seed ^ cast(unsigned int, l); + size_t l1; + size_t step = (l >> LUAI_HASHLIMIT) + 1; + for (l1 = l; l1 >= step; l1 -= step) + h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1])); + return h; +} + + +/* +** resizes the string table +*/ +void luaS_resize (lua_State *L, int newsize) { + int i; + stringtable *tb = &G(L)->strt; + /* cannot resize while GC is traversing strings */ + luaC_runtilstate(L, ~bitmask(GCSsweepstring)); + if (newsize > tb->size) { + luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *); + for (i = tb->size; i < newsize; i++) tb->hash[i] = NULL; + } + /* rehash */ + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + tb->hash[i] = NULL; + while (p) { /* for each node in the list */ + GCObject *next = gch(p)->next; /* save next */ + unsigned int h = lmod(gco2ts(p)->hash, newsize); /* new position */ + gch(p)->next = tb->hash[h]; /* chain it */ + tb->hash[h] = p; + resetoldbit(p); /* see MOVE OLD rule */ + p = next; + } + } + if (newsize < tb->size) { + /* shrinking slice must be empty */ + lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL); + luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *); + } + tb->size = newsize; +} + + +/* +** creates a new string object +*/ +static TString *createstrobj (lua_State *L, const char *str, size_t l, + int tag, unsigned int h, GCObject **list) { TString *ts; - stringtable *tb; - if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) - luaM_toobig(L); - ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + size_t totalsize; /* total size of TString object */ + totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); + ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts; ts->tsv.len = l; ts->tsv.hash = h; - ts->tsv.marked = luaC_white(G(L)); - ts->tsv.tt = LUA_TSTRING; - ts->tsv.reserved = 0; + ts->tsv.extra = 0; memcpy(ts+1, str, l*sizeof(char)); ((char *)(ts+1))[l] = '\0'; /* ending 0 */ - tb = &G(L)->strt; - h = lmod(h, tb->size); - ts->tsv.next = tb->hash[h]; /* chain new entry */ - tb->hash[h] = obj2gco(ts); - tb->nuse++; - if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) - luaS_resize(L, tb->size*2); /* too crowded */ return ts; } -TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { +/* +** creates a new short string, inserting it into string table +*/ +static TString *newshrstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + GCObject **list; /* (pointer to) list where it will be inserted */ + stringtable *tb = &G(L)->strt; + TString *s; + if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + list = &tb->hash[lmod(h, tb->size)]; + s = createstrobj(L, str, l, LUA_TSHRSTR, h, list); + tb->nuse++; + return s; +} + + +/* +** checks whether short string exists and reuses it or creates a new one +*/ +static TString *internshrstr (lua_State *L, const char *str, size_t l) { GCObject *o; - unsigned int h = cast(unsigned int, l); /* seed */ - size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ - size_t l1; - for (l1=l; l1>=step; l1-=step) /* compute hash */ - h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); - for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + global_State *g = G(L); + unsigned int h = luaS_hash(str, l, g->seed); + for (o = g->strt.hash[lmod(h, g->strt.size)]; o != NULL; - o = o->gch.next) { + o = gch(o)->next) { TString *ts = rawgco2ts(o); - if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { - /* string may be dead */ - if (isdead(G(L), o)) changewhite(o); + if (h == ts->tsv.hash && + l == ts->tsv.len && + (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { + if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */ + changewhite(o); /* resurrect it */ return ts; } } - return newlstr(L, str, l, h); /* not found */ + return newshrstr(L, str, l, h); /* not found; create a new string */ +} + + +/* +** new string (with explicit length) +*/ +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + if (l <= LUAI_MAXSHORTLEN) /* short string? */ + return internshrstr(L, str, l); + else { + if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL); + } +} + + +/* +** new zero-terminated string +*/ +TString *luaS_new (lua_State *L, const char *str) { + return luaS_newlstr(L, str, strlen(str)); } @@ -97,15 +176,10 @@ Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { Udata *u; if (s > MAX_SIZET - sizeof(Udata)) luaM_toobig(L); - u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); - u->uv.marked = luaC_white(G(L)); /* is not finalized */ - u->uv.tt = LUA_TUSERDATA; + u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u; u->uv.len = s; u->uv.metatable = NULL; u->uv.env = e; - /* chain it on udata list (after main thread) */ - u->uv.next = G(L)->mainthread->next; - G(L)->mainthread->next = obj2gco(u); return u; } diff --git a/src/mod/languages/mod_lua/lua/lstring.h b/src/mod/languages/mod_lua/lua/lstring.h index 73a2ff8b38..d312ff3d2b 100644 --- a/src/mod/languages/mod_lua/lua/lstring.h +++ b/src/mod/languages/mod_lua/lua/lstring.h @@ -1,5 +1,5 @@ /* -** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lstring.h,v 1.49 2012/02/01 21:57:15 roberto Exp $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -7,7 +7,6 @@ #ifndef lstring_h #define lstring_h - #include "lgc.h" #include "lobject.h" #include "lstate.h" @@ -17,15 +16,31 @@ #define sizeudata(u) (sizeof(union Udata)+(u)->len) -#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ (sizeof(s)/sizeof(char))-1)) #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +/* +** test whether a string is a reserved word +*/ +#define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) + + +/* +** equality for short strings, which are always internalized +*/ +#define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) + + +LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); +LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); +LUAI_FUNC int luaS_eqstr (TString *a, TString *b); LUAI_FUNC void luaS_resize (lua_State *L, int newsize); LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); +LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); #endif diff --git a/src/mod/languages/mod_lua/lua/lstrlib.c b/src/mod/languages/mod_lua/lua/lstrlib.c index 1b4763d4ee..fcc61c9a62 100644 --- a/src/mod/languages/mod_lua/lua/lstrlib.c +++ b/src/mod/languages/mod_lua/lua/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** $Id: lstrlib.c,v 1.178 2012/08/14 18:12:34 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -20,47 +20,58 @@ #include "lualib.h" +/* +** maximum number of captures that a pattern can do during +** pattern-matching. This limit is arbitrary. +*/ +#if !defined(LUA_MAXCAPTURES) +#define LUA_MAXCAPTURES 32 +#endif + + /* macro to `unsign' a character */ -#define uchar(c) ((unsigned char)(c)) +#define uchar(c) ((unsigned char)(c)) static int str_len (lua_State *L) { size_t l; luaL_checklstring(L, 1, &l); - lua_pushinteger(L, l); + lua_pushinteger(L, (lua_Integer)l); return 1; } -static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { - /* relative string position: negative means back from end */ - if (pos < 0) pos += (ptrdiff_t)len + 1; - return (pos >= 0) ? pos : 0; +/* translate a relative string position: negative means back from end */ +static size_t posrelat (ptrdiff_t pos, size_t len) { + if (pos >= 0) return (size_t)pos; + else if (0u - (size_t)pos > len) return 0; + else return len - ((size_t)-pos) + 1; } static int str_sub (lua_State *L) { size_t l; const char *s = luaL_checklstring(L, 1, &l); - ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); - ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + size_t start = posrelat(luaL_checkinteger(L, 2), l); + size_t end = posrelat(luaL_optinteger(L, 3, -1), l); if (start < 1) start = 1; - if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (end > l) end = l; if (start <= end) - lua_pushlstring(L, s+start-1, end-start+1); + lua_pushlstring(L, s + start - 1, end - start + 1); else lua_pushliteral(L, ""); return 1; } static int str_reverse (lua_State *L) { - size_t l; + size_t l, i; luaL_Buffer b; const char *s = luaL_checklstring(L, 1, &l); - luaL_buffinit(L, &b); - while (l--) luaL_addchar(&b, s[l]); - luaL_pushresult(&b); + char *p = luaL_buffinitsize(L, &b, l); + for (i = 0; i < l; i++) + p[i] = s[l - i - 1]; + luaL_pushresultsize(&b, l); return 1; } @@ -70,10 +81,10 @@ static int str_lower (lua_State *L) { size_t i; luaL_Buffer b; const char *s = luaL_checklstring(L, 1, &l); - luaL_buffinit(L, &b); + char *p = luaL_buffinitsize(L, &b, l); for (i=0; i> 1) + static int str_rep (lua_State *L) { - size_t l; - luaL_Buffer b; + size_t l, lsep; const char *s = luaL_checklstring(L, 1, &l); int n = luaL_checkint(L, 2); - luaL_buffinit(L, &b); - while (n-- > 0) - luaL_addlstring(&b, s, l); - luaL_pushresult(&b); + const char *sep = luaL_optlstring(L, 3, "", &lsep); + if (n <= 0) lua_pushliteral(L, ""); + else if (l + lsep < l || l + lsep >= MAXSIZE / n) /* may overflow? */ + return luaL_error(L, "resulting string too large"); + else { + size_t totallen = n * l + (n - 1) * lsep; + luaL_Buffer b; + char *p = luaL_buffinitsize(L, &b, totallen); + while (n-- > 1) { /* first n-1 copies (followed by separator) */ + memcpy(p, s, l * sizeof(char)); p += l; + if (lsep > 0) { /* avoid empty 'memcpy' (may be expensive) */ + memcpy(p, sep, lsep * sizeof(char)); p += lsep; + } + } + memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */ + luaL_pushresultsize(&b, totallen); + } return 1; } @@ -106,15 +133,15 @@ static int str_rep (lua_State *L) { static int str_byte (lua_State *L) { size_t l; const char *s = luaL_checklstring(L, 1, &l); - ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); - ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + size_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + size_t pose = posrelat(luaL_optinteger(L, 3, posi), l); int n, i; - if (posi <= 0) posi = 1; - if ((size_t)pose > l) pose = l; + if (posi < 1) posi = 1; + if (pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ n = (int)(pose - posi + 1); - if (posi + n <= pose) /* overflow? */ - luaL_error(L, "string slice too long"); + if (posi + n <= pose) /* (size_t -> int) overflow? */ + return luaL_error(L, "string slice too long"); luaL_checkstack(L, n, "string slice too long"); for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) - return luaL_error(ms->L, "invalid capture index"); + return luaL_error(ms->L, "invalid capture index %%%d", l + 1); return l; } @@ -202,16 +242,16 @@ static int capture_to_close (MatchState *ms) { static const char *classend (MatchState *ms, const char *p) { switch (*p++) { case L_ESC: { - if (*p == '\0') + if (p == ms->p_end) luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); return p+1; } case '[': { if (*p == '^') p++; do { /* look for a `]' */ - if (*p == '\0') + if (p == ms->p_end) luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); - if (*(p++) == L_ESC && *p != '\0') + if (*(p++) == L_ESC && p < ms->p_end) p++; /* skip escapes (e.g. `%]') */ } while (*p != ']'); return p+1; @@ -229,13 +269,14 @@ static int match_class (int c, int cl) { case 'a' : res = isalpha(c); break; case 'c' : res = iscntrl(c); break; case 'd' : res = isdigit(c); break; + case 'g' : res = isgraph(c); break; case 'l' : res = islower(c); break; case 'p' : res = ispunct(c); break; case 's' : res = isspace(c); break; case 'u' : res = isupper(c); break; case 'w' : res = isalnum(c); break; case 'x' : res = isxdigit(c); break; - case 'z' : res = (c == 0); break; + case 'z' : res = (c == 0); break; /* deprecated option */ default: return (cl == c); } return (islower(cl) ? res : !res); @@ -265,23 +306,27 @@ static int matchbracketclass (int c, const char *p, const char *ec) { } -static int singlematch (int c, const char *p, const char *ep) { - switch (*p) { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class(c, uchar(*(p+1))); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); +static int singlematch (MatchState *ms, const char *s, const char *p, + const char *ep) { + if (s >= ms->src_end) + return 0; + else { + int c = uchar(*s); + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } } } -static const char *match (MatchState *ms, const char *s, const char *p); - - static const char *matchbalance (MatchState *ms, const char *s, const char *p) { - if (*p == 0 || *(p+1) == 0) - luaL_error(ms->L, "unbalanced pattern"); + if (p >= ms->p_end - 1) + luaL_error(ms->L, "malformed pattern " + "(missing arguments to " LUA_QL("%%b") ")"); if (*s != *p) return NULL; else { int b = *p; @@ -301,7 +346,7 @@ static const char *matchbalance (MatchState *ms, const char *s, static const char *max_expand (MatchState *ms, const char *s, const char *p, const char *ep) { ptrdiff_t i = 0; /* counts maximum expand for item */ - while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + while (singlematch(ms, s + i, p, ep)) i++; /* keeps trying to match with the maximum repetitions */ while (i>=0) { @@ -319,7 +364,7 @@ static const char *min_expand (MatchState *ms, const char *s, const char *res = match(ms, s, ep+1); if (res != NULL) return res; - else if (ssrc_end && singlematch(uchar(*s), p, ep)) + else if (singlematch(ms, s, p, ep)) s++; /* try with one more repetition */ else return NULL; } @@ -363,80 +408,105 @@ static const char *match_capture (MatchState *ms, const char *s, int l) { static const char *match (MatchState *ms, const char *s, const char *p) { + if (ms->matchdepth-- == 0) + luaL_error(ms->L, "pattern too complex"); init: /* using goto's to optimize tail recursion */ - switch (*p) { - case '(': { /* start capture */ - if (*(p+1) == ')') /* position capture? */ - return start_capture(ms, s, p+2, CAP_POSITION); - else - return start_capture(ms, s, p+1, CAP_UNFINISHED); - } - case ')': { /* end capture */ - return end_capture(ms, s, p+1); - } - case L_ESC: { - switch (*(p+1)) { - case 'b': { /* balanced string? */ - s = matchbalance(ms, s, p+2); - if (s == NULL) return NULL; - p+=4; goto init; /* else return match(ms, s, p+4); */ - } - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - luaL_error(ms->L, "missing " LUA_QL("[") " after " - LUA_QL("%%f") " in pattern"); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s-1); - if (matchbracketclass(uchar(previous), p, ep-1) || - !matchbracketclass(uchar(*s), p, ep-1)) return NULL; - p=ep; goto init; /* else return match(ms, s, ep); */ - } - default: { - if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ - s = match_capture(ms, s, uchar(*(p+1))); - if (s == NULL) return NULL; - p+=2; goto init; /* else return match(ms, s, p+2) */ - } - goto dflt; /* case default */ - } + if (p != ms->p_end) { /* end of pattern? */ + switch (*p) { + case '(': { /* start capture */ + if (*(p + 1) == ')') /* position capture? */ + s = start_capture(ms, s, p + 2, CAP_POSITION); + else + s = start_capture(ms, s, p + 1, CAP_UNFINISHED); + break; } - } - case '\0': { /* end of pattern */ - return s; /* match succeeded */ - } - case '$': { - if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ - return (s == ms->src_end) ? s : NULL; /* check end of string */ - else goto dflt; - } - default: dflt: { /* it is a pattern item */ - const char *ep = classend(ms, p); /* points to what is next */ - int m = ssrc_end && singlematch(uchar(*s), p, ep); - switch (*ep) { - case '?': { /* optional */ - const char *res; - if (m && ((res=match(ms, s+1, ep+1)) != NULL)) - return res; - p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + case ')': { /* end capture */ + s = end_capture(ms, s, p + 1); + break; + } + case '$': { + if ((p + 1) != ms->p_end) /* is the `$' the last char in pattern? */ + goto dflt; /* no; go to default */ + s = (s == ms->src_end) ? s : NULL; /* check end of string */ + break; + } + case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ + switch (*(p + 1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p + 2); + if (s != NULL) { + p += 4; goto init; /* return match(ms, s, p + 4); */ + } /* else fail (s == NULL) */ + break; + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s - 1); + if (!matchbracketclass(uchar(previous), p, ep - 1) && + matchbracketclass(uchar(*s), p, ep - 1)) { + p = ep; goto init; /* return match(ms, s, ep); */ + } + s = NULL; /* match failed */ + break; + } + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p + 1))); + if (s != NULL) { + p += 2; goto init; /* return match(ms, s, p + 2) */ + } + break; + } + default: goto dflt; } - case '*': { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); + break; + } + default: dflt: { /* pattern class plus optional suffix */ + const char *ep = classend(ms, p); /* points to optional suffix */ + /* does not match at least once? */ + if (!singlematch(ms, s, p, ep)) { + if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */ + p = ep + 1; goto init; /* return match(ms, s, ep + 1); */ + } + else /* '+' or no suffix */ + s = NULL; /* fail */ } - case '+': { /* 1 or more repetitions */ - return (m ? max_expand(ms, s+1, p, ep) : NULL); - } - case '-': { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); - } - default: { - if (!m) return NULL; - s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + else { /* matched once */ + switch (*ep) { /* handle optional suffix */ + case '?': { /* optional */ + const char *res; + if ((res = match(ms, s + 1, ep + 1)) != NULL) + s = res; + else { + p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */ + } + break; + } + case '+': /* 1 or more repetitions */ + s++; /* 1 match already done */ + /* go through */ + case '*': /* 0 or more repetitions */ + s = max_expand(ms, s, p, ep); + break; + case '-': /* 0 or more repetitions (minimum) */ + s = min_expand(ms, s, p, ep); + break; + default: /* no suffix */ + s++; p = ep; goto init; /* return match(ms, s + 1, ep); */ + } } + break; } } } + ms->matchdepth++; + return s; } @@ -492,37 +562,58 @@ static int push_captures (MatchState *ms, const char *s, const char *e) { } +/* check whether pattern has no special characters */ +static int nospecials (const char *p, size_t l) { + size_t upto = 0; + do { + if (strpbrk(p + upto, SPECIALS)) + return 0; /* pattern has a special character */ + upto += strlen(p + upto) + 1; /* may have more after \0 */ + } while (upto <= l); + return 1; /* no special chars found */ +} + + static int str_find_aux (lua_State *L, int find) { - size_t l1, l2; - const char *s = luaL_checklstring(L, 1, &l1); - const char *p = luaL_checklstring(L, 2, &l2); - ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; - if (init < 0) init = 0; - else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; - if (find && (lua_toboolean(L, 4) || /* explicit request? */ - strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + size_t ls, lp; + const char *s = luaL_checklstring(L, 1, &ls); + const char *p = luaL_checklstring(L, 2, &lp); + size_t init = posrelat(luaL_optinteger(L, 3, 1), ls); + if (init < 1) init = 1; + else if (init > ls + 1) { /* start after string's end? */ + lua_pushnil(L); /* cannot find anything */ + return 1; + } + /* explicit request or no special characters? */ + if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { /* do a plain search */ - const char *s2 = lmemfind(s+init, l1-init, p, l2); + const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp); if (s2) { - lua_pushinteger(L, s2-s+1); - lua_pushinteger(L, s2-s+l2); + lua_pushinteger(L, s2 - s + 1); + lua_pushinteger(L, s2 - s + lp); return 2; } } else { MatchState ms; - int anchor = (*p == '^') ? (p++, 1) : 0; - const char *s1=s+init; + const char *s1 = s + init - 1; + int anchor = (*p == '^'); + if (anchor) { + p++; lp--; /* skip anchor character */ + } ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = s; - ms.src_end = s+l1; + ms.src_end = s + ls; + ms.p_end = p + lp; do { const char *res; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); if ((res=match(&ms, s1, p)) != NULL) { if (find) { - lua_pushinteger(L, s1-s+1); /* start */ - lua_pushinteger(L, res-s); /* end */ + lua_pushinteger(L, s1 - s + 1); /* start */ + lua_pushinteger(L, res - s); /* end */ return push_captures(&ms, NULL, 0) + 2; } else @@ -547,18 +638,21 @@ static int str_match (lua_State *L) { static int gmatch_aux (lua_State *L) { MatchState ms; - size_t ls; + size_t ls, lp; const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); - const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp); const char *src; ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = s; ms.src_end = s+ls; + ms.p_end = p + lp; for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); src <= ms.src_end; src++) { const char *e; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); if ((e = match(&ms, src, p)) != NULL) { lua_Integer newstart = e-s; if (e == src) newstart++; /* empty match? go at least one position */ @@ -581,12 +675,6 @@ static int gmatch (lua_State *L) { } -static int gfind_nodef (lua_State *L) { - return luaL_error(L, LUA_QL("string.gfind") " was renamed to " - LUA_QL("string.gmatch")); -} - - static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, const char *e) { size_t l, i; @@ -596,8 +684,12 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, luaL_addchar(b, news[i]); else { i++; /* skip ESC */ - if (!isdigit(uchar(news[i]))) + if (!isdigit(uchar(news[i]))) { + if (news[i] != L_ESC) + luaL_error(ms->L, "invalid use of " LUA_QL("%c") + " in replacement string", L_ESC); luaL_addchar(b, news[i]); + } else if (news[i] == '0') luaL_addlstring(b, s, e - s); else { @@ -610,14 +702,9 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e) { + const char *e, int tr) { lua_State *L = ms->L; - switch (lua_type(L, 3)) { - case LUA_TNUMBER: - case LUA_TSTRING: { - add_s(ms, b, s, e); - return; - } + switch (tr) { case LUA_TFUNCTION: { int n; lua_pushvalue(L, 3); @@ -630,41 +717,51 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, lua_gettable(L, 3); break; } + default: { /* LUA_TNUMBER or LUA_TSTRING */ + add_s(ms, b, s, e); + return; + } } if (!lua_toboolean(L, -1)) { /* nil or false? */ lua_pop(L, 1); lua_pushlstring(L, s, e - s); /* keep original text */ } else if (!lua_isstring(L, -1)) - luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ } static int str_gsub (lua_State *L) { - size_t srcl; + size_t srcl, lp; const char *src = luaL_checklstring(L, 1, &srcl); - const char *p = luaL_checkstring(L, 2); - int tr = lua_type(L, 3); - int max_s = luaL_optint(L, 4, srcl+1); - int anchor = (*p == '^') ? (p++, 1) : 0; - int n = 0; + const char *p = luaL_checklstring(L, 2, &lp); + int tr = lua_type(L, 3); + size_t max_s = luaL_optinteger(L, 4, srcl+1); + int anchor = (*p == '^'); + size_t n = 0; MatchState ms; luaL_Buffer b; luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, "string/function/table expected"); luaL_buffinit(L, &b); + if (anchor) { + p++; lp--; /* skip anchor character */ + } ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = src; ms.src_end = src+srcl; + ms.p_end = p + lp; while (n < max_s) { const char *e; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); e = match(&ms, src, p); if (e) { n++; - add_value(&ms, &b, src, e); + add_value(&ms, &b, src, e, tr); } if (e && e>src) /* non empty match? */ src = e; /* skip it */ @@ -682,6 +779,46 @@ static int str_gsub (lua_State *L) { /* }====================================================== */ + +/* +** {====================================================== +** STRING FORMAT +** ======================================================= +*/ + +/* +** LUA_INTFRMLEN is the length modifier for integer conversions in +** 'string.format'; LUA_INTFRM_T is the integer type corresponding to +** the previous length +*/ +#if !defined(LUA_INTFRMLEN) /* { */ +#if defined(LUA_USE_LONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif +#endif /* } */ + + +/* +** LUA_FLTFRMLEN is the length modifier for float conversions in +** 'string.format'; LUA_FLTFRM_T is the float type corresponding to +** the previous length +*/ +#if !defined(LUA_FLTFRMLEN) + +#define LUA_FLTFRMLEN "" +#define LUA_FLTFRM_T double + +#endif + + /* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ #define MAX_ITEM 512 /* valid flags in a format specification */ @@ -698,25 +835,20 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { const char *s = luaL_checklstring(L, arg, &l); luaL_addchar(b, '"'); while (l--) { - switch (*s) { - case '"': case '\\': case '\n': { - luaL_addchar(b, '\\'); - luaL_addchar(b, *s); - break; - } - case '\r': { - luaL_addlstring(b, "\\r", 2); - break; - } - case '\0': { - luaL_addlstring(b, "\\000", 4); - break; - } - default: { - luaL_addchar(b, *s); - break; - } + if (*s == '"' || *s == '\\' || *s == '\n') { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); } + else if (*s == '\0' || iscntrl(uchar(*s))) { + char buff[10]; + if (!isdigit(uchar(*(s+1)))) + sprintf(buff, "\\%d", (int)uchar(*s)); + else + sprintf(buff, "\\%03d", (int)uchar(*s)); + luaL_addstring(b, buff); + } + else + luaL_addchar(b, *s); s++; } luaL_addchar(b, '"'); @@ -725,7 +857,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) luaL_error(L, "invalid format (repeated flags)"); if (isdigit(uchar(*p))) p++; /* skip width */ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ @@ -737,23 +869,28 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { if (isdigit(uchar(*p))) luaL_error(L, "invalid format (width or precision too long)"); *(form++) = '%'; - strncpy(form, strfrmt, p - strfrmt + 1); + memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char)); form += p - strfrmt + 1; *form = '\0'; return p; } -static void addintlen (char *form) { +/* +** add length modifier into formats +*/ +static void addlenmod (char *form, const char *lenmod) { size_t l = strlen(form); + size_t lm = strlen(lenmod); char spec = form[l - 1]; - strcpy(form + l - 1, LUA_INTFRMLEN); - form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; - form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; + strcpy(form + l - 1, lenmod); + form[l + lm - 1] = spec; + form[l + lm] = '\0'; } static int str_format (lua_State *L) { + int top = lua_gettop(L); int arg = 1; size_t sfl; const char *strfrmt = luaL_checklstring(L, arg, &sfl); @@ -767,45 +904,61 @@ static int str_format (lua_State *L) { luaL_addchar(&b, *strfrmt++); /* %% */ else { /* format item */ char form[MAX_FORMAT]; /* to store the format (`%...') */ - char buff[MAX_ITEM]; /* to store the formatted item */ - arg++; + char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ + int nb = 0; /* number of bytes in added item */ + if (++arg > top) + luaL_argerror(L, arg, "no value"); strfrmt = scanformat(L, strfrmt, form); switch (*strfrmt++) { case 'c': { - sprintf(buff, form, (int)luaL_checknumber(L, arg)); + nb = sprintf(buff, form, luaL_checkint(L, arg)); break; } - case 'd': case 'i': { - addintlen(form); - sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + case 'd': case 'i': { + lua_Number n = luaL_checknumber(L, arg); + LUA_INTFRM_T ni = (LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, + "not a number in proper range"); + addlenmod(form, LUA_INTFRMLEN); + nb = sprintf(buff, form, ni); break; } - case 'o': case 'u': case 'x': case 'X': { - addintlen(form); - sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + case 'o': case 'u': case 'x': case 'X': { + lua_Number n = luaL_checknumber(L, arg); + unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, + "not a non-negative number in proper range"); + addlenmod(form, LUA_INTFRMLEN); + nb = sprintf(buff, form, ni); break; } - case 'e': case 'E': case 'f': + case 'e': case 'E': case 'f': +#if defined(LUA_USE_AFORMAT) + case 'a': case 'A': +#endif case 'g': case 'G': { - sprintf(buff, form, (double)luaL_checknumber(L, arg)); + addlenmod(form, LUA_FLTFRMLEN); + nb = sprintf(buff, form, (LUA_FLTFRM_T)luaL_checknumber(L, arg)); break; } case 'q': { addquoted(L, &b, arg); - continue; /* skip the 'addsize' at the end */ + break; } case 's': { size_t l; - const char *s = luaL_checklstring(L, arg, &l); + const char *s = luaL_tolstring(L, arg, &l); if (!strchr(form, '.') && l >= 100) { /* no precision and string is too long to be formatted; keep original string */ - lua_pushvalue(L, arg); luaL_addvalue(&b); - continue; /* skip the `addsize' at the end */ + break; } else { - sprintf(buff, form, s); + nb = sprintf(buff, form, s); + lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ break; } } @@ -814,13 +967,15 @@ static int str_format (lua_State *L) { LUA_QL("format"), *(strfrmt - 1)); } } - luaL_addlstring(&b, buff, strlen(buff)); + luaL_addsize(&b, nb); } } luaL_pushresult(&b); return 1; } +/* }====================================================== */ + static const luaL_Reg strlib[] = { {"byte", str_byte}, @@ -828,7 +983,6 @@ static const luaL_Reg strlib[] = { {"dump", str_dump}, {"find", str_find}, {"format", str_format}, - {"gfind", gfind_nodef}, {"gmatch", gmatch}, {"gsub", str_gsub}, {"len", str_len}, @@ -843,13 +997,13 @@ static const luaL_Reg strlib[] = { static void createmetatable (lua_State *L) { - lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_createtable(L, 0, 1); /* table to be metatable for strings */ lua_pushliteral(L, ""); /* dummy string */ - lua_pushvalue(L, -2); - lua_setmetatable(L, -2); /* set string metatable */ + lua_pushvalue(L, -2); /* copy table */ + lua_setmetatable(L, -2); /* set table as metatable for strings */ lua_pop(L, 1); /* pop dummy string */ - lua_pushvalue(L, -2); /* string library... */ - lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pushvalue(L, -2); /* get string library */ + lua_setfield(L, -2, "__index"); /* metatable.__index = string */ lua_pop(L, 1); /* pop metatable */ } @@ -857,12 +1011,8 @@ static void createmetatable (lua_State *L) { /* ** Open string library */ -LUALIB_API int luaopen_string (lua_State *L) { - luaL_register(L, LUA_STRLIBNAME, strlib); -#if defined(LUA_COMPAT_GFIND) - lua_getfield(L, -1, "gmatch"); - lua_setfield(L, -2, "gfind"); -#endif +LUAMOD_API int luaopen_string (lua_State *L) { + luaL_newlib(L, strlib); createmetatable(L); return 1; } diff --git a/src/mod/languages/mod_lua/lua/ltable.c b/src/mod/languages/mod_lua/lua/ltable.c index ec84f4fabc..420391fc74 100644 --- a/src/mod/languages/mod_lua/lua/ltable.c +++ b/src/mod/languages/mod_lua/lua/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** $Id: ltable.c,v 2.72 2012/09/11 19:37:16 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -18,7 +18,6 @@ ** Hence even when the load factor reaches 100%, performance remains good. */ -#include #include #define ltable_c @@ -32,14 +31,16 @@ #include "lmem.h" #include "lobject.h" #include "lstate.h" +#include "lstring.h" #include "ltable.h" +#include "lvm.h" /* ** max size of array part is 2^MAXBITS */ -#if LUAI_BITSINT > 26 -#define MAXBITS 26 +#if LUAI_BITSINT >= 32 +#define MAXBITS 30 #else #define MAXBITS (LUAI_BITSINT-2) #endif @@ -47,10 +48,10 @@ #define MAXASIZE (1 << MAXBITS) -#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) - -#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) -#define hashboolean(t,p) hashpow2(t, p) +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) /* @@ -63,18 +64,13 @@ #define hashpointer(t,p) hashmod(t, IntPoint(p)) -/* -** number of ints inside a lua_Number -*/ -#define numints cast_int(sizeof(lua_Number)/sizeof(int)) - - - #define dummynode (&dummynode_) +#define isdummy(n) ((n) == dummynode) + static const Node dummynode_ = { - {{NULL}, LUA_TNIL}, /* value */ - {{{NULL}, LUA_TNIL, NULL}} /* key */ + {NILCONSTANT}, /* value */ + {{NILCONSTANT, NULL}} /* key */ }; @@ -82,13 +78,14 @@ static const Node dummynode_ = { ** hash for lua_Numbers */ static Node *hashnum (const Table *t, lua_Number n) { - unsigned int a[numints]; int i; - if (luai_numeq(n, 0)) /* avoid problems with -0 */ - return gnode(t, 0); - memcpy(a, &n, sizeof(a)); - for (i = 1; i < numints; i++) a[0] += a[i]; - return hashmod(t, a[0]); + luai_hashnum(i, n); + if (i < 0) { + if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */ + i = 0; /* handle INT_MIN */ + i = -i; /* must be a positive value */ + } + return hashmod(t, i); } @@ -101,12 +98,22 @@ static Node *mainposition (const Table *t, const TValue *key) { switch (ttype(key)) { case LUA_TNUMBER: return hashnum(t, nvalue(key)); - case LUA_TSTRING: + case LUA_TLNGSTR: { + TString *s = rawtsvalue(key); + if (s->tsv.extra == 0) { /* no hash? */ + s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash); + s->tsv.extra = 1; /* now it has its hash */ + } + return hashstr(t, rawtsvalue(key)); + } + case LUA_TSHRSTR: return hashstr(t, rawtsvalue(key)); case LUA_TBOOLEAN: return hashboolean(t, bvalue(key)); case LUA_TLIGHTUSERDATA: return hashpointer(t, pvalue(key)); + case LUA_TLCF: + return hashpointer(t, fvalue(key)); default: return hashpointer(t, gcvalue(key)); } @@ -132,7 +139,7 @@ static int arrayindex (const TValue *key) { /* ** returns the index of a `key' for table traversals. First goes all ** elements in the array part, then elements in the hash part. The -** beginning of a traversal is signalled by -1. +** beginning of a traversal is signaled by -1. */ static int findindex (lua_State *L, Table *t, StkId key) { int i; @@ -142,19 +149,19 @@ static int findindex (lua_State *L, Table *t, StkId key) { return i-1; /* yes; that's the index (corrected to C) */ else { Node *n = mainposition(t, key); - do { /* check whether `key' is somewhere in the chain */ + for (;;) { /* check whether `key' is somewhere in the chain */ /* key may be dead already, but it is ok to use it in `next' */ - if (luaO_rawequalObj(key2tval(n), key) || - (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && - gcvalue(gkey(n)) == gcvalue(key))) { + if (luaV_rawequalobj(gkey(n), key) || + (ttisdeadkey(gkey(n)) && iscollectable(key) && + deadvalue(gkey(n)) == gcvalue(key))) { i = cast_int(n - gnode(t, 0)); /* key index in hash table */ /* hash elements are numbered after array ones */ return i + t->sizearray; } else n = gnext(n); - } while (n); - luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ - return 0; /* to avoid warnings */ + if (n == NULL) + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + } } } @@ -170,7 +177,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) { } for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ - setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key, gkey(gnode(t, i))); setobj2s(L, key+1, gval(gnode(t, i))); return 1; } @@ -211,7 +218,7 @@ static int computesizes (int nums[], int *narray) { static int countint (const TValue *key, int *nums) { int k = arrayindex(key); if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ - nums[ceillog2(k)]++; /* count as such */ + nums[luaO_ceillog2(k)]++; /* count as such */ return 1; } else @@ -251,7 +258,7 @@ static int numusehash (const Table *t, int *nums, int *pnasize) { while (i--) { Node *n = &t->node[i]; if (!ttisnil(gval(n))) { - ause += countint(key2tval(n), nums); + ause += countint(gkey(n), nums); totaluse++; } } @@ -277,7 +284,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { } else { int i; - lsize = ceillog2(size); + lsize = luaO_ceillog2(size); if (lsize > MAXBITS) luaG_runerror(L, "table overflow"); size = twoto(lsize); @@ -294,7 +301,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { } -static void resize (lua_State *L, Table *t, int nasize, int nhsize) { +void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { int i; int oldasize = t->sizearray; int oldhsize = t->lsizenode; @@ -302,13 +309,13 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) { if (nasize > oldasize) /* array part must grow? */ setarrayvector(L, t, nasize); /* create new hash part with appropriate size */ - setnodevector(L, t, nhsize); + setnodevector(L, t, nhsize); if (nasize < oldasize) { /* array part must shrink? */ t->sizearray = nasize; /* re-insert elements from vanishing slice */ for (i=nasize; iarray[i])) - setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + luaH_setint(L, t, i + 1, &t->array[i]); } /* shrink array */ luaM_reallocvector(L, t->array, oldasize, nasize, TValue); @@ -316,23 +323,26 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) { /* re-insert elements from hash part */ for (i = twoto(oldhsize) - 1; i >= 0; i--) { Node *old = nold+i; - if (!ttisnil(gval(old))) - setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + if (!ttisnil(gval(old))) { + /* doesn't need barrier/invalidate cache, as entry was + already present in the table */ + setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); + } } - if (nold != dummynode) - luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ + if (!isdummy(nold)) + luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */ } void luaH_resizearray (lua_State *L, Table *t, int nasize) { - int nsize = (t->node == dummynode) ? 0 : sizenode(t); - resize(L, t, nasize, nsize); + int nsize = isdummy(t->node) ? 0 : sizenode(t); + luaH_resize(L, t, nasize, nsize); } static void rehash (lua_State *L, Table *t, const TValue *ek) { int nasize, na; - int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int nums[MAXBITS+1]; /* nums[i] = number of keys with 2^(i-1) < k <= 2^i */ int i; int totaluse; for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ @@ -345,7 +355,7 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { /* compute new size for array part */ na = computesizes(nums, &nasize); /* resize the table to new computed sizes */ - resize(L, t, nasize, totaluse - na); + luaH_resize(L, t, nasize, totaluse - na); } @@ -355,32 +365,28 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { */ -Table *luaH_new (lua_State *L, int narray, int nhash) { - Table *t = luaM_new(L, Table); - luaC_link(L, obj2gco(t), LUA_TTABLE); +Table *luaH_new (lua_State *L) { + Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h; t->metatable = NULL; t->flags = cast_byte(~0); - /* temporary values (kept only if some malloc fails) */ t->array = NULL; t->sizearray = 0; - t->lsizenode = 0; - t->node = cast(Node *, dummynode); - setarrayvector(L, t, narray); - setnodevector(L, t, nhash); + setnodevector(L, t, 0); return t; } void luaH_free (lua_State *L, Table *t) { - if (t->node != dummynode) - luaM_freearray(L, t->node, sizenode(t), Node); - luaM_freearray(L, t->array, t->sizearray, TValue); + if (!isdummy(t->node)) + luaM_freearray(L, t->node, cast(size_t, sizenode(t))); + luaM_freearray(L, t->array, t->sizearray); luaM_free(L, t); } static Node *getfreepos (Table *t) { - while (t->lastfree-- > t->node) { + while (t->lastfree > t->node) { + t->lastfree--; if (ttisnil(gkey(t->lastfree))) return t->lastfree; } @@ -390,23 +396,28 @@ static Node *getfreepos (Table *t) { /* -** inserts a new key into a hash table; first, check whether key's main -** position is free. If not, check whether colliding node is in its main -** position or not: if it is not, move colliding node to an empty place and -** put new key in its main position; otherwise (colliding node is in its main -** position), new key goes to an empty position. +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. */ -static TValue *newkey (lua_State *L, Table *t, const TValue *key) { - Node *mp = mainposition(t, key); - if (!ttisnil(gval(mp)) || mp == dummynode) { +TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp; + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(L, nvalue(key))) + luaG_runerror(L, "table index is NaN"); + mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ Node *othern; Node *n = getfreepos(t); /* get a free place */ if (n == NULL) { /* cannot find a free place? */ rehash(L, t, key); /* grow table */ - return luaH_set(L, t, key); /* re-insert key into grown table */ + /* whatever called 'newkey' take care of TM cache and GC barrier */ + return luaH_set(L, t, key); /* insert key into grown table */ } - lua_assert(n != dummynode); - othern = mainposition(t, key2tval(mp)); + lua_assert(!isdummy(n)); + othern = mainposition(t, gkey(mp)); if (othern != mp) { /* is colliding node out of its main position? */ /* yes; move colliding node into free position */ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ @@ -422,8 +433,8 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { mp = n; } } - gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; - luaC_barriert(L, t, key); + setobj2t(L, gkey(mp), key); + luaC_barrierback(L, obj2gco(t), key); lua_assert(ttisnil(gval(mp))); return gval(mp); } @@ -432,7 +443,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { /* ** search function for integers */ -const TValue *luaH_getnum (Table *t, int key) { +const TValue *luaH_getint (Table *t, int key) { /* (1 <= key && key <= t->sizearray) */ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) return &t->array[key-1]; @@ -450,12 +461,13 @@ const TValue *luaH_getnum (Table *t, int key) { /* -** search function for strings +** search function for short strings */ const TValue *luaH_getstr (Table *t, TString *key) { Node *n = hashstr(t, key); + lua_assert(key->tsv.tt == LUA_TSHRSTR); do { /* check whether `key' is somewhere in the chain */ - if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + if (ttisshrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)), key)) return gval(n); /* that's it */ else n = gnext(n); } while (n); @@ -468,20 +480,20 @@ const TValue *luaH_getstr (Table *t, TString *key) { */ const TValue *luaH_get (Table *t, const TValue *key) { switch (ttype(key)) { + case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); case LUA_TNIL: return luaO_nilobject; - case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); case LUA_TNUMBER: { int k; lua_Number n = nvalue(key); lua_number2int(k, n); - if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ - return luaH_getnum(t, k); /* use specialized version */ + if (luai_numeq(cast_num(k), n)) /* index is int? */ + return luaH_getint(t, k); /* use specialized version */ /* else go through */ } default: { Node *n = mainposition(t, key); do { /* check whether `key' is somewhere in the chain */ - if (luaO_rawequalObj(key2tval(n), key)) + if (luaV_rawequalobj(gkey(n), key)) return gval(n); /* that's it */ else n = gnext(n); } while (n); @@ -491,41 +503,29 @@ const TValue *luaH_get (Table *t, const TValue *key) { } +/* +** beware: when using this function you probably need to check a GC +** barrier and invalidate the TM cache. +*/ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { const TValue *p = luaH_get(t, key); - t->flags = 0; if (p != luaO_nilobject) return cast(TValue *, p); - else { - if (ttisnil(key)) luaG_runerror(L, "table index is nil"); - else if (ttisnumber(key) && luai_numisnan(nvalue(key))) - luaG_runerror(L, "table index is NaN"); - return newkey(L, t, key); - } + else return luaH_newkey(L, t, key); } -TValue *luaH_setnum (lua_State *L, Table *t, int key) { - const TValue *p = luaH_getnum(t, key); +void luaH_setint (lua_State *L, Table *t, int key, TValue *value) { + const TValue *p = luaH_getint(t, key); + TValue *cell; if (p != luaO_nilobject) - return cast(TValue *, p); + cell = cast(TValue *, p); else { TValue k; setnvalue(&k, cast_num(key)); - return newkey(L, t, &k); - } -} - - -TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { - const TValue *p = luaH_getstr(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - TValue k; - setsvalue(L, &k, key); - return newkey(L, t, &k); + cell = luaH_newkey(L, t, &k); } + setobj2t(L, cell, value); } @@ -533,20 +533,20 @@ static int unbound_search (Table *t, unsigned int j) { unsigned int i = j; /* i is zero or a present index */ j++; /* find `i' and `j' such that i is present and j is not */ - while (!ttisnil(luaH_getnum(t, j))) { + while (!ttisnil(luaH_getint(t, j))) { i = j; j *= 2; if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ /* table was built with bad purposes: resort to linear search */ i = 1; - while (!ttisnil(luaH_getnum(t, i))) i++; + while (!ttisnil(luaH_getint(t, i))) i++; return i - 1; } } /* now do a binary search between them */ while (j - i > 1) { unsigned int m = (i+j)/2; - if (ttisnil(luaH_getnum(t, m))) j = m; + if (ttisnil(luaH_getint(t, m))) j = m; else i = m; } return i; @@ -570,7 +570,7 @@ int luaH_getn (Table *t) { return i; } /* else must find a boundary in hash part */ - else if (t->node == dummynode) /* hash part is empty? */ + else if (isdummy(t->node)) /* hash part is empty? */ return j; /* that is easy... */ else return unbound_search(t, j); } @@ -583,6 +583,6 @@ Node *luaH_mainposition (const Table *t, const TValue *key) { return mainposition(t, key); } -int luaH_isdummy (Node *n) { return n == dummynode; } +int luaH_isdummy (Node *n) { return isdummy(n); } #endif diff --git a/src/mod/languages/mod_lua/lua/ltable.h b/src/mod/languages/mod_lua/lua/ltable.h index f5b9d5ead0..2f6f5c2dc8 100644 --- a/src/mod/languages/mod_lua/lua/ltable.h +++ b/src/mod/languages/mod_lua/lua/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: ltable.h,v 2.16 2011/08/17 20:26:47 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -11,20 +11,21 @@ #define gnode(t,i) (&(t)->node[i]) -#define gkey(n) (&(n)->i_key.nk) +#define gkey(n) (&(n)->i_key.tvk) #define gval(n) (&(n)->i_val) #define gnext(n) ((n)->i_key.nk.next) -#define key2tval(n) (&(n)->i_key.tvk) +#define invalidateTMcache(t) ((t)->flags = 0) -LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); -LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getint (Table *t, int key); +LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); -LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); -LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC Table *luaH_new (lua_State *L); +LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); LUAI_FUNC void luaH_free (lua_State *L, Table *t); LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); diff --git a/src/mod/languages/mod_lua/lua/ltablib.c b/src/mod/languages/mod_lua/lua/ltablib.c index b6d9cb4ac7..ad798b4e2a 100644 --- a/src/mod/languages/mod_lua/lua/ltablib.c +++ b/src/mod/languages/mod_lua/lua/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** $Id: ltablib.c,v 1.65 2013/03/07 18:17:24 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -16,43 +16,11 @@ #include "lualib.h" -#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n)) -static int foreachi (lua_State *L) { - int i; - int n = aux_getn(L, 1); - luaL_checktype(L, 2, LUA_TFUNCTION); - for (i=1; i <= n; i++) { - lua_pushvalue(L, 2); /* function */ - lua_pushinteger(L, i); /* 1st argument */ - lua_rawgeti(L, 1, i); /* 2nd argument */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 1); /* remove nil result */ - } - return 0; -} - - -static int foreach (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TFUNCTION); - lua_pushnil(L); /* first key */ - while (lua_next(L, 1)) { - lua_pushvalue(L, 2); /* function */ - lua_pushvalue(L, -3); /* key */ - lua_pushvalue(L, -3); /* value */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 2); /* remove value and result */ - } - return 0; -} - +#if defined(LUA_COMPAT_MAXN) static int maxn (lua_State *L) { lua_Number max = 0; luaL_checktype(L, 1, LUA_TTABLE); @@ -67,24 +35,7 @@ static int maxn (lua_State *L) { lua_pushnumber(L, max); return 1; } - - -static int getn (lua_State *L) { - lua_pushinteger(L, aux_getn(L, 1)); - return 1; -} - - -static int setn (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); -#ifndef luaL_setn - luaL_setn(L, 1, luaL_checkint(L, 2)); -#else - luaL_error(L, LUA_QL("setn") " is obsolete"); #endif - lua_pushvalue(L, 1); - return 1; -} static int tinsert (lua_State *L) { @@ -98,7 +49,7 @@ static int tinsert (lua_State *L) { case 3: { int i; pos = luaL_checkint(L, 2); /* 2nd argument is the position */ - if (pos > e) e = pos; /* `grow' array if necessary */ + luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); for (i = e; i > pos; i--) { /* move up elements */ lua_rawgeti(L, 1, i-1); lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ @@ -109,25 +60,23 @@ static int tinsert (lua_State *L) { return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); } } - luaL_setn(L, 1, e); /* new size */ lua_rawseti(L, 1, pos); /* t[pos] = v */ return 0; } static int tremove (lua_State *L) { - int e = aux_getn(L, 1); - int pos = luaL_optint(L, 2, e); - if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ - return 0; /* nothing to remove */ - luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + int size = aux_getn(L, 1); + int pos = luaL_optint(L, 2, size); + if (pos != size) /* validate 'pos' if given */ + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); lua_rawgeti(L, 1, pos); /* result = t[pos] */ - for ( ;pos 0) { /* at least one element? */ + int i; + lua_pushvalue(L, 1); + lua_rawseti(L, -2, 1); /* insert first element */ + lua_replace(L, 1); /* move table into index 1 */ + for (i = n; i >= 2; i--) /* assign other elements */ + lua_rawseti(L, 1, i); + } + return 1; /* return table */ +} + + +static int unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + +/* }====================================================== */ + + /* ** {====================================================== ** Quicksort ** (based on `Algorithms in MODULA-3', Robert Sedgewick; ** Addison-Wesley, 1993.) +** ======================================================= */ @@ -187,7 +178,7 @@ static int sort_comp (lua_State *L, int a, int b) { return res; } else /* a < b? */ - return lua_lessthan(L, a, b); + return lua_compare(L, a, b, LUA_OPLT); } static void auxsort (lua_State *L, int l, int u) { @@ -224,12 +215,12 @@ static void auxsort (lua_State *L, int l, int u) { for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ /* repeat ++i until a[i] >= P */ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>u) luaL_error(L, "invalid order function for sorting"); + if (i>=u) luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[i] */ } /* repeat --j until a[j] <= P */ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (jmetatable; break; @@ -68,7 +70,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { mt = uvalue(o)->metatable; break; default: - mt = G(L)->mt[ttype(o)]; + mt = G(L)->mt[ttypenv(o)]; } return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); } diff --git a/src/mod/languages/mod_lua/lua/ltm.h b/src/mod/languages/mod_lua/lua/ltm.h index 64343b781b..89bdc19a1e 100644 --- a/src/mod/languages/mod_lua/lua/ltm.h +++ b/src/mod/languages/mod_lua/lua/ltm.h @@ -1,5 +1,5 @@ /* -** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: ltm.h,v 2.11 2011/02/28 17:32:10 roberto Exp $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -20,6 +20,7 @@ typedef enum { TM_NEWINDEX, TM_GC, TM_MODE, + TM_LEN, TM_EQ, /* last tag method with `fast' access */ TM_ADD, TM_SUB, @@ -28,7 +29,6 @@ typedef enum { TM_MOD, TM_POW, TM_UNM, - TM_LEN, TM_LT, TM_LE, TM_CONCAT, @@ -43,7 +43,10 @@ typedef enum { #define fasttm(l,et,e) gfasttm(G(l), et, e) -LUAI_DATA const char *const luaT_typenames[]; +#define ttypename(x) luaT_typenames_[(x) + 1] +#define objtypename(x) ttypename(ttypenv(x)) + +LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); diff --git a/src/mod/languages/mod_lua/lua/lua.2010.vcxproj b/src/mod/languages/mod_lua/lua/lua.2010.vcxproj index dbf8aefb92..eb3f805b97 100644 --- a/src/mod/languages/mod_lua/lua/lua.2010.vcxproj +++ b/src/mod/languages/mod_lua/lua/lua.2010.vcxproj @@ -126,7 +126,10 @@ + + + @@ -157,6 +160,7 @@ + @@ -172,6 +176,7 @@ + diff --git a/src/mod/languages/mod_lua/lua/lua.2012.vcxproj b/src/mod/languages/mod_lua/lua/lua.2012.vcxproj index 17f7b5eae4..ee6ce3b5d0 100644 --- a/src/mod/languages/mod_lua/lua/lua.2012.vcxproj +++ b/src/mod/languages/mod_lua/lua/lua.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -130,7 +130,10 @@ + + + @@ -161,6 +164,7 @@ + @@ -176,6 +180,7 @@ + @@ -188,4 +193,4 @@ - + \ No newline at end of file diff --git a/src/mod/languages/mod_lua/lua/lua.c b/src/mod/languages/mod_lua/lua/lua.c index 3a46609328..6a00712920 100644 --- a/src/mod/languages/mod_lua/lua/lua.c +++ b/src/mod/languages/mod_lua/lua/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** $Id: lua.c,v 1.206 2012/09/29 20:07:06 roberto Exp $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -18,6 +18,72 @@ #include "lualib.h" +#if !defined(LUA_PROMPT) +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " +#endif + +#if !defined(LUA_PROGNAME) +#define LUA_PROGNAME "lua" +#endif + +#if !defined(LUA_MAXINPUT) +#define LUA_MAXINPUT 512 +#endif + +#if !defined(LUA_INIT) +#define LUA_INIT "LUA_INIT" +#endif + +#define LUA_INITVERSION \ + LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + + +/* +** lua_stdin_is_tty detects whether the standard input is a 'tty' (that +** is, whether we're running lua interactively). +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +** lua_readline defines how to show a prompt and then read a line from +** the standard input. +** lua_saveline defines how to "save" a read line in a "history". +** lua_freeline defines how to free a line read by lua_readline. +*/ +#if defined(LUA_USE_READLINE) + +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) + +#elif !defined(lua_readline) + +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } + +#endif + + + static lua_State *globalL = NULL; @@ -39,77 +105,87 @@ static void laction (int i) { } -static void print_usage (void) { - fprintf(stderr, - "usage: %s [options] [script [args]].\n" +static void print_usage (const char *badoption) { + luai_writestringerror("%s: ", progname); + if (badoption[1] == 'e' || badoption[1] == 'l') + luai_writestringerror("'%s' needs argument\n", badoption); + else + luai_writestringerror("unrecognized option '%s'\n", badoption); + luai_writestringerror( + "usage: %s [options] [script [args]]\n" "Available options are:\n" " -e stat execute string " LUA_QL("stat") "\n" - " -l name require library " LUA_QL("name") "\n" " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -l name require library " LUA_QL("name") "\n" " -v show version information\n" + " -E ignore environment variables\n" " -- stop handling options\n" - " - execute stdin and stop handling options\n" + " - stop handling options and execute stdin\n" , progname); - fflush(stderr); } static void l_message (const char *pname, const char *msg) { - if (pname) fprintf(stderr, "%s: ", pname); - fprintf(stderr, "%s\n", msg); - fflush(stderr); + if (pname) luai_writestringerror("%s: ", pname); + luai_writestringerror("%s\n", msg); } static int report (lua_State *L, int status) { - if (status && !lua_isnil(L, -1)) { + if (status != LUA_OK && !lua_isnil(L, -1)) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error object is not a string)"; l_message(progname, msg); lua_pop(L, 1); + /* force a complete garbage collection in case of errors */ + lua_gc(L, LUA_GCCOLLECT, 0); } return status; } -static int traceback (lua_State *L) { - if (!lua_isstring(L, 1)) /* 'message' not a string? */ - return 1; /* keep it intact */ - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { +/* the next function is called unprotected, so it must avoid errors */ +static void finalreport (lua_State *L, int status) { + if (status != LUA_OK) { + const char *msg = (lua_type(L, -1) == LUA_TSTRING) ? lua_tostring(L, -1) + : NULL; + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); lua_pop(L, 1); - return 1; } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); - return 1; +} + + +static int traceback (lua_State *L) { + const char *msg = lua_tostring(L, 1); + if (msg) + luaL_traceback(L, L, msg, 1); + else if (!lua_isnoneornil(L, 1)) { /* is there an error object? */ + if (!luaL_callmeta(L, 1, "__tostring")) /* try its 'tostring' metamethod */ + lua_pushliteral(L, "(no error message)"); } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ return 1; } -static int docall (lua_State *L, int narg, int clear) { +static int docall (lua_State *L, int narg, int nres) { int status; int base = lua_gettop(L) - narg; /* function index */ lua_pushcfunction(L, traceback); /* push traceback function */ lua_insert(L, base); /* put it under chunk and args */ + globalL = L; /* to be available to 'laction' */ signal(SIGINT, laction); - status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + status = lua_pcall(L, narg, nres, base); signal(SIGINT, SIG_DFL); lua_remove(L, base); /* remove traceback function */ - /* force a complete garbage collection in case of errors */ - if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); return status; } static void print_version (void) { - l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); + luai_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT)); + luai_writeline(); } @@ -132,40 +208,47 @@ static int getargs (lua_State *L, char **argv, int n) { static int dofile (lua_State *L, const char *name) { - int status = luaL_loadfile(L, name) || docall(L, 0, 1); + int status = luaL_loadfile(L, name); + if (status == LUA_OK) status = docall(L, 0, 0); return report(L, status); } static int dostring (lua_State *L, const char *s, const char *name) { - int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + int status = luaL_loadbuffer(L, s, strlen(s), name); + if (status == LUA_OK) status = docall(L, 0, 0); return report(L, status); } static int dolibrary (lua_State *L, const char *name) { + int status; lua_getglobal(L, "require"); lua_pushstring(L, name); - return report(L, docall(L, 1, 1)); + status = docall(L, 1, 1); /* call 'require(name)' */ + if (status == LUA_OK) + lua_setglobal(L, name); /* global[name] = require return */ + return report(L, status); } static const char *get_prompt (lua_State *L, int firstline) { const char *p; - lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); p = lua_tostring(L, -1); if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); - lua_pop(L, 1); /* remove global */ return p; } +/* mark in error messages for incomplete statements */ +#define EOFMARK "" +#define marklen (sizeof(EOFMARK)/sizeof(char) - 1) static int incomplete (lua_State *L, int status) { if (status == LUA_ERRSYNTAX) { size_t lmsg; const char *msg = lua_tolstring(L, -1, &lmsg); - const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); - if (strstr(msg, LUA_QL("")) == tp) { + if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) { lua_pop(L, 1); return 1; } @@ -179,7 +262,9 @@ static int pushline (lua_State *L, int firstline) { char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); - if (lua_readline(L, b, prmt) == 0) + int readstatus = lua_readline(L, b, prmt); + lua_pop(L, 1); /* remove result from 'get_prompt' */ + if (readstatus == 0) return 0; /* no input */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ @@ -199,7 +284,9 @@ static int loadline (lua_State *L) { if (!pushline(L, 1)) return -1; /* no input */ for (;;) { /* repeat until gets a complete line */ - status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + size_t l; + const char *line = lua_tolstring(L, 1, &l); + status = luaL_loadbuffer(L, line, l, "=stdin"); if (!incomplete(L, status)) break; /* cannot try to add lines? */ if (!pushline(L, 0)) /* no more input? */ return -1; @@ -218,20 +305,20 @@ static void dotty (lua_State *L) { const char *oldprogname = progname; progname = NULL; while ((status = loadline(L)) != -1) { - if (status == 0) status = docall(L, 0, 0); + if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET); report(L, status); - if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */ + luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); lua_getglobal(L, "print"); lua_insert(L, 1); - if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK) l_message(progname, lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)", lua_tostring(L, -1))); } } lua_settop(L, 0); /* clear stack */ - fputs("\n", stdout); - fflush(stdout); + luai_writeline(); progname = oldprogname; } @@ -242,49 +329,63 @@ static int handle_script (lua_State *L, char **argv, int n) { int narg = getargs(L, argv, n); /* collect arguments */ lua_setglobal(L, "arg"); fname = argv[n]; - if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) fname = NULL; /* stdin */ status = luaL_loadfile(L, fname); lua_insert(L, -(narg+1)); - if (status == 0) - status = docall(L, narg, 0); + if (status == LUA_OK) + status = docall(L, narg, LUA_MULTRET); else - lua_pop(L, narg); + lua_pop(L, narg); return report(L, status); } /* check that argument has no extra characters at the end */ -#define notail(x) {if ((x)[2] != '\0') return -1;} +#define noextrachars(x) {if ((x)[2] != '\0') return -1;} -static int collectargs (char **argv, int *pi, int *pv, int *pe) { +/* indices of various argument indicators in array args */ +#define has_i 0 /* -i */ +#define has_v 1 /* -v */ +#define has_e 2 /* -e */ +#define has_E 3 /* -E */ + +#define num_has 4 /* number of 'has_*' */ + + +static int collectargs (char **argv, int *args) { int i; for (i = 1; argv[i] != NULL; i++) { if (argv[i][0] != '-') /* not an option? */ return i; switch (argv[i][1]) { /* option */ case '-': - notail(argv[i]); + noextrachars(argv[i]); return (argv[i+1] != NULL ? i+1 : 0); case '\0': return i; + case 'E': + args[has_E] = 1; + break; case 'i': - notail(argv[i]); - *pi = 1; /* go through */ + noextrachars(argv[i]); + args[has_i] = 1; /* go through */ case 'v': - notail(argv[i]); - *pv = 1; + noextrachars(argv[i]); + args[has_v] = 1; break; case 'e': - *pe = 1; /* go through */ - case 'l': - if (argv[i][2] == '\0') { - i++; - if (argv[i] == NULL) return -1; + args[has_e] = 1; /* go through */ + case 'l': /* both options need an argument */ + if (argv[i][2] == '\0') { /* no concatenated argument? */ + i++; /* try next 'argv' */ + if (argv[i] == NULL || argv[i][0] == '-') + return -(i - 1); /* no next argument or it is another option */ } break; - default: return -1; /* invalid option */ + default: /* invalid option; return its index... */ + return -i; /* ...as a negative value */ } } return 0; @@ -294,99 +395,103 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) { static int runargs (lua_State *L, char **argv, int n) { int i; for (i = 1; i < n; i++) { - if (argv[i] == NULL) continue; lua_assert(argv[i][0] == '-'); switch (argv[i][1]) { /* option */ case 'e': { const char *chunk = argv[i] + 2; if (*chunk == '\0') chunk = argv[++i]; lua_assert(chunk != NULL); - if (dostring(L, chunk, "=(command line)") != 0) - return 1; + if (dostring(L, chunk, "=(command line)") != LUA_OK) + return 0; break; } case 'l': { const char *filename = argv[i] + 2; if (*filename == '\0') filename = argv[++i]; lua_assert(filename != NULL); - if (dolibrary(L, filename)) - return 1; /* stop if file fails */ + if (dolibrary(L, filename) != LUA_OK) + return 0; /* stop if file fails */ break; } default: break; } } - return 0; + return 1; } static int handle_luainit (lua_State *L) { - const char *init = getenv(LUA_INIT); - if (init == NULL) return 0; /* status OK */ + const char *name = "=" LUA_INITVERSION; + const char *init = getenv(name + 1); + if (init == NULL) { + name = "=" LUA_INIT; + init = getenv(name + 1); /* try alternative name */ + } + if (init == NULL) return LUA_OK; else if (init[0] == '@') return dofile(L, init+1); else - return dostring(L, init, "=" LUA_INIT); + return dostring(L, init, name); } -struct Smain { - int argc; - char **argv; - int status; -}; - - static int pmain (lua_State *L) { - struct Smain *s = (struct Smain *)lua_touserdata(L, 1); - char **argv = s->argv; + int argc = (int)lua_tointeger(L, 1); + char **argv = (char **)lua_touserdata(L, 2); int script; - int has_i = 0, has_v = 0, has_e = 0; - globalL = L; + int args[num_has]; + args[has_i] = args[has_v] = args[has_e] = args[has_E] = 0; if (argv[0] && argv[0][0]) progname = argv[0]; + script = collectargs(argv, args); + if (script < 0) { /* invalid arg? */ + print_usage(argv[-script]); + return 0; + } + if (args[has_v]) print_version(); + if (args[has_E]) { /* option '-E'? */ + lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */ + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + } + /* open standard libraries */ + luaL_checkversion(L); lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ luaL_openlibs(L); /* open libraries */ lua_gc(L, LUA_GCRESTART, 0); - s->status = handle_luainit(L); - if (s->status != 0) return 0; - script = collectargs(argv, &has_i, &has_v, &has_e); - if (script < 0) { /* invalid args? */ - print_usage(); - s->status = 1; - return 0; - } - if (has_v) print_version(); - s->status = runargs(L, argv, (script > 0) ? script : s->argc); - if (s->status != 0) return 0; - if (script) - s->status = handle_script(L, argv, script); - if (s->status != 0) return 0; - if (has_i) + if (!args[has_E] && handle_luainit(L) != LUA_OK) + return 0; /* error running LUA_INIT */ + /* execute arguments -e and -l */ + if (!runargs(L, argv, (script > 0) ? script : argc)) return 0; + /* execute main script (if there is one) */ + if (script && handle_script(L, argv, script) != LUA_OK) return 0; + if (args[has_i]) /* -i option? */ dotty(L); - else if (script == 0 && !has_e && !has_v) { + else if (script == 0 && !args[has_e] && !args[has_v]) { /* no arguments? */ if (lua_stdin_is_tty()) { print_version(); dotty(L); } else dofile(L, NULL); /* executes stdin as a file */ } - return 0; + lua_pushboolean(L, 1); /* signal no errors */ + return 1; } int main (int argc, char **argv) { - int status; - struct Smain s; - lua_State *L = lua_open(); /* create state */ + int status, result; + lua_State *L = luaL_newstate(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } - s.argc = argc; - s.argv = argv; - status = lua_cpcall(L, &pmain, &s); - report(L, status); + /* call 'pmain' in protected mode */ + lua_pushcfunction(L, &pmain); + lua_pushinteger(L, argc); /* 1st argument */ + lua_pushlightuserdata(L, argv); /* 2nd argument */ + status = lua_pcall(L, 2, 1, 0); + result = lua_toboolean(L, -1); /* get result */ + finalreport(L, status); lua_close(L); - return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; + return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/mod/languages/mod_lua/lua/lua.h b/src/mod/languages/mod_lua/lua/lua.h index e4bdfd3b94..eb0482b8f4 100644 --- a/src/mod/languages/mod_lua/lua/lua.h +++ b/src/mod/languages/mod_lua/lua/lua.h @@ -1,6 +1,6 @@ /* -** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ -** Lua - An Extensible Extension Language +** $Id: lua.h,v 1.285 2013/03/15 13:04:22 roberto Exp $ +** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file */ @@ -16,35 +16,39 @@ #include "luaconf.h" -#define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.4" -#define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "2" +#define LUA_VERSION_NUM 502 +#define LUA_VERSION_RELEASE "2" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2013 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" -/* mark for precompiled code (`Lua') */ -#define LUA_SIGNATURE "\033Lua" +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\033Lua" -/* option for multiple returns in `lua_pcall' and `lua_call' */ +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ #define LUA_MULTRET (-1) /* ** pseudo-indices */ -#define LUA_REGISTRYINDEX (-10000) -#define LUA_ENVIRONINDEX (-10001) -#define LUA_GLOBALSINDEX (-10002) -#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) +#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) -/* thread status; 0 is OK */ +/* thread status */ +#define LUA_OK 0 #define LUA_YIELD 1 #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 -#define LUA_ERRERR 5 +#define LUA_ERRGCMM 5 +#define LUA_ERRERR 6 typedef struct lua_State lua_State; @@ -81,12 +85,32 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); #define LUA_TUSERDATA 7 #define LUA_TTHREAD 8 +#define LUA_NUMTAGS 9 + /* minimum Lua stack available to a C function */ #define LUA_MINSTACK 20 +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + + + /* ** generic extra include file */ @@ -95,13 +119,10 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); #endif -/* type of numbers in Lua */ -typedef LUA_NUMBER lua_Number; - - -/* type for integer functions */ -typedef LUA_INTEGER lua_Integer; - +/* +** RCS ident string +*/ +extern const char lua_ident[]; /* @@ -114,15 +135,20 @@ LUA_API lua_State *(lua_newthread) (lua_State *L); LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); +LUA_API const lua_Number *(lua_version) (lua_State *L); + + /* ** basic stack manipulation */ +LUA_API int (lua_absindex) (lua_State *L, int idx); LUA_API int (lua_gettop) (lua_State *L); LUA_API void (lua_settop) (lua_State *L, int idx); LUA_API void (lua_pushvalue) (lua_State *L, int idx); LUA_API void (lua_remove) (lua_State *L, int idx); LUA_API void (lua_insert) (lua_State *L, int idx); LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); LUA_API int (lua_checkstack) (lua_State *L, int sz); LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); @@ -139,29 +165,49 @@ LUA_API int (lua_isuserdata) (lua_State *L, int idx); LUA_API int (lua_type) (lua_State *L, int idx); LUA_API const char *(lua_typename) (lua_State *L, int tp); -LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); - -LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); -LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Unsigned (lua_tounsignedx) (lua_State *L, int idx, int *isnum); LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); -LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API size_t (lua_rawlen) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API void *(lua_touserdata) (lua_State *L, int idx); LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); LUA_API const void *(lua_topointer) (lua_State *L, int idx); +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPDIV 3 +#define LUA_OPMOD 4 +#define LUA_OPPOW 5 +#define LUA_OPUNM 6 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + /* ** push functions (C -> stack) */ -LUA_API void (lua_pushnil) (lua_State *L); -LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); -LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); -LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); -LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushunsigned) (lua_State *L, lua_Unsigned n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, va_list argp); LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); @@ -174,35 +220,47 @@ LUA_API int (lua_pushthread) (lua_State *L); /* ** get functions (Lua -> stack) */ +LUA_API void (lua_getglobal) (lua_State *L, const char *var); LUA_API void (lua_gettable) (lua_State *L, int idx); LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawget) (lua_State *L, int idx); LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawgetp) (lua_State *L, int idx, const void *p); LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); LUA_API int (lua_getmetatable) (lua_State *L, int objindex); -LUA_API void (lua_getfenv) (lua_State *L, int idx); +LUA_API void (lua_getuservalue) (lua_State *L, int idx); /* ** set functions (stack -> Lua) */ +LUA_API void (lua_setglobal) (lua_State *L, const char *var); LUA_API void (lua_settable) (lua_State *L, int idx); LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawset) (lua_State *L, int idx); LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API int (lua_setfenv) (lua_State *L, int idx); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); /* -** `load' and `call' functions (load and run Lua code) +** 'load' and 'call' functions (load and run Lua code) */ -LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); -LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); -LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_getctx) (lua_State *L, int *ctx); + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + int ctx, lua_CFunction k); +#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, - const char *chunkname); + const char *chunkname, + const char *mode); LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); @@ -210,8 +268,10 @@ LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); /* ** coroutine functions */ -LUA_API int (lua_yield) (lua_State *L, int nresults); -LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_yieldk) (lua_State *L, int nresults, int ctx, + lua_CFunction k); +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); LUA_API int (lua_status) (lua_State *L); /* @@ -226,6 +286,10 @@ LUA_API int (lua_status) (lua_State *L); #define LUA_GCSTEP 5 #define LUA_GCSETPAUSE 6 #define LUA_GCSETSTEPMUL 7 +#define LUA_GCSETMAJORINC 8 +#define LUA_GCISRUNNING 9 +#define LUA_GCGEN 10 +#define LUA_GCINC 11 LUA_API int (lua_gc) (lua_State *L, int what, int data); @@ -239,18 +303,23 @@ LUA_API int (lua_error) (lua_State *L); LUA_API int (lua_next) (lua_State *L, int idx); LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); -LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); -/* +/* ** =============================================================== ** some useful macros ** =============================================================== */ +#define lua_tonumber(L,i) lua_tonumberx(L,i,NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,i,NULL) +#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL) + #define lua_pop(L,n) lua_settop(L, -(n)-1) #define lua_newtable(L) lua_createtable(L, 0, 0) @@ -259,8 +328,6 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) -#define lua_strlen(L,i) lua_objlen(L, (i)) - #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) @@ -273,31 +340,13 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); #define lua_pushliteral(L, s) \ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) -#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) -#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_pushglobaltable(L) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS) #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) -/* -** compatibility macros and functions -*/ - -#define lua_open() luaL_newstate() - -#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) - -#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) - -#define lua_Chunkreader lua_Reader -#define lua_Chunkwriter lua_Writer - - -/* hack */ -LUA_API void lua_setlevel (lua_State *from, lua_State *to); - - /* ** {====================================================================== ** Debug API @@ -312,7 +361,7 @@ LUA_API void lua_setlevel (lua_State *from, lua_State *to); #define LUA_HOOKRET 1 #define LUA_HOOKLINE 2 #define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILRET 4 +#define LUA_HOOKTAILCALL 4 /* @@ -326,43 +375,50 @@ LUA_API void lua_setlevel (lua_State *from, lua_State *to); typedef struct lua_Debug lua_Debug; /* activation record */ -/* Functions to be called by the debuger in specific events */ +/* Functions to be called by the debugger in specific events */ typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); -LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); -LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); -LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); -LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); -LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); -LUA_API lua_Hook lua_gethook (lua_State *L); -LUA_API int lua_gethookmask (lua_State *L); -LUA_API int lua_gethookcount (lua_State *L); +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); struct lua_Debug { int event; const char *name; /* (n) */ - const char *namewhat; /* (n) `global', `local', `field', `method' */ - const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ const char *source; /* (S) */ int currentline; /* (l) */ - int nups; /* (u) number of upvalues */ int linedefined; /* (S) */ int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ char short_src[LUA_IDSIZE]; /* (S) */ /* private part */ - int i_ci; /* active function */ + struct CallInfo *i_ci; /* active function */ }; /* }====================================================================== */ /****************************************************************************** -* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2013 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/mod/languages/mod_lua/lua/lua.hpp b/src/mod/languages/mod_lua/lua/lua.hpp new file mode 100644 index 0000000000..ec417f5946 --- /dev/null +++ b/src/mod/languages/mod_lua/lua/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/src/mod/languages/mod_lua/lua/luac.c b/src/mod/languages/mod_lua/lua/luac.c index d07017391b..5081836d4c 100644 --- a/src/mod/languages/mod_lua/lua/luac.c +++ b/src/mod/languages/mod_lua/lua/luac.c @@ -1,5 +1,5 @@ /* -** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** $Id: luac.c,v 1.69 2011/11/29 17:46:33 lhf Exp $ ** Lua compiler (saves bytecodes to files; also list bytecodes) ** See Copyright Notice in lua.h */ @@ -15,16 +15,15 @@ #include "lua.h" #include "lauxlib.h" -#include "ldo.h" -#include "lfunc.h" -#include "lmem.h" #include "lobject.h" -#include "lopcodes.h" -#include "lstring.h" +#include "lstate.h" #include "lundump.h" +static void PrintFunction(const Proto* f, int full); +#define luaU_print PrintFunction + #define PROGNAME "luac" /* default program name */ -#define OUTPUT PROGNAME ".out" /* default output file */ +#define OUTPUT PROGNAME ".out" /* default output file */ static int listing=0; /* list bytecodes? */ static int dumping=1; /* dump bytecodes? */ @@ -52,20 +51,20 @@ static void usage(const char* message) else fprintf(stderr,"%s: %s\n",progname,message); fprintf(stderr, - "usage: %s [options] [filenames].\n" - "Available options are:\n" - " - process stdin\n" - " -l list\n" - " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" - " -p parse only\n" - " -s strip debug information\n" - " -v show version information\n" - " -- stop handling options\n", - progname,Output); + "usage: %s [options] [filenames]\n" + "Available options are:\n" + " -l list (use -l -l for full listing)\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n" + " - stop handling options and process stdin\n" + ,progname,Output); exit(EXIT_FAILURE); } -#define IS(s) (strcmp(argv[i],s)==0) +#define IS(s) (strcmp(argv[i],s)==0) static int doargs(int argc, char* argv[]) { @@ -89,7 +88,8 @@ static int doargs(int argc, char* argv[]) else if (IS("-o")) /* output file */ { output=argv[++i]; - if (output==NULL || *output==0) usage(LUA_QL("-o") " needs argument"); + if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) + usage(LUA_QL("-o") " needs argument"); if (IS("-")) output=NULL; } else if (IS("-p")) /* parse only */ @@ -108,13 +108,30 @@ static int doargs(int argc, char* argv[]) } if (version) { - printf("%s %s\n",LUA_RELEASE,LUA_COPYRIGHT); + printf("%s\n",LUA_COPYRIGHT); if (version==argc-1) exit(EXIT_SUCCESS); } return i; } -#define toproto(L,i) (clvalue(L->top+(i))->l.p) +#define FUNCTION "(function()end)();" + +static const char* reader(lua_State *L, void *ud, size_t *size) +{ + UNUSED(L); + if ((*(int*)ud)--) + { + *size=sizeof(FUNCTION)-1; + return FUNCTION; + } + else + { + *size=0; + return NULL; + } +} + +#define toproto(L,i) getproto(L->top+(i)) static const Proto* combine(lua_State* L, int n) { @@ -122,24 +139,16 @@ static const Proto* combine(lua_State* L, int n) return toproto(L,-1); else { - int i,pc; - Proto* f=luaF_newproto(L); - setptvalue2s(L,L->top,f); incr_top(L); - f->source=luaS_newliteral(L,"=(" PROGNAME ")"); - f->maxstacksize=1; - pc=2*n+1; - f->code=luaM_newvector(L,pc,Instruction); - f->sizecode=pc; - f->p=luaM_newvector(L,n,Proto*); - f->sizep=n; - pc=0; + Proto* f; + int i=n; + if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1)); + f=toproto(L,-1); for (i=0; ip[i]=toproto(L,i-n-1); - f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); - f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0; } - f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + f->sizelineinfo=0; return f; } } @@ -150,23 +159,17 @@ static int writer(lua_State* L, const void* p, size_t size, void* u) return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); } -struct Smain { - int argc; - char** argv; -}; - static int pmain(lua_State* L) { - struct Smain* s = (struct Smain*)lua_touserdata(L, 1); - int argc=s->argc; - char** argv=s->argv; + int argc=(int)lua_tointeger(L,1); + char** argv=(char**)lua_touserdata(L,2); const Proto* f; int i; if (!lua_checkstack(L,argc)) fatal("too many input files"); for (i=0; i1); @@ -186,15 +189,244 @@ static int pmain(lua_State* L) int main(int argc, char* argv[]) { lua_State* L; - struct Smain s; int i=doargs(argc,argv); argc-=i; argv+=i; if (argc<=0) usage("no input files given"); - L=lua_open(); - if (L==NULL) fatal("not enough memory for state"); - s.argc=argc; - s.argv=argv; - if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + L=luaL_newstate(); + if (L==NULL) fatal("cannot create state: not enough memory"); + lua_pushcfunction(L,&pmain); + lua_pushinteger(L,argc); + lua_pushlightuserdata(L,argv); + if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1)); lua_close(L); return EXIT_SUCCESS; } + +/* +** $Id: print.c,v 1.68 2011/09/30 10:21:20 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" + +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + printf("%c",'"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +#define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-") +#define MYK(x) (-1-(x)) + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c); + break; + case iABx: + printf("%d",a); + if (getBMode(o)==OpArgK) printf(" %d",MYK(bx)); + if (getBMode(o)==OpArgU) printf(" %d",bx); + break; + case iAsBx: + printf("%d %d",a,sbx); + break; + case iAx: + printf("%d",MYK(ax)); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s",UPVALNAME(b)); + break; + case OP_GETTABUP: + printf("\t; %s",UPVALNAME(b)); + if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABUP: + printf("\t; %s",UPVALNAME(a)); + if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); } + if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); } + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + case OP_TFORLOOP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); else printf("\t; %d",c); + break; + case OP_EXTRAARG: + printf("\t; "); PrintConstant(f,ax); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) ((x==1)?"":"s") +#define S(x) (int)(x),SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=f->source ? getstr(f->source) : "=?"; + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + (int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->sizeupvalues)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintDebug(const Proto* f) +{ + int i,n; + n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } + n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + for (i=0; iupvalues[i].instack,f->upvalues[i].idx); + } +} + +static void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) PrintDebug(f); + for (i=0; ip[i],full); +} diff --git a/src/mod/languages/mod_lua/lua/luaconf.h b/src/mod/languages/mod_lua/lua/luaconf.h index ca2849b5b6..88f4c6aaa2 100644 --- a/src/mod/languages/mod_lua/lua/luaconf.h +++ b/src/mod/languages/mod_lua/lua/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** $Id: luaconf.h,v 1.176 2013/03/16 21:10:18 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -24,30 +24,44 @@ ** CHANGE it (define it) if you want Lua to avoid the use of any ** non-ansi feature or library. */ -#if defined(__STRICT_ANSI__) +#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__) #define LUA_ANSI #endif -#if !defined(LUA_ANSI) && defined(_WIN32) -#define LUA_WIN +#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_WIN /* enable goodies for regular Windows platforms */ #endif +#if defined(LUA_WIN) +#define LUA_DL_DLL +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#endif + + + #if defined(LUA_USE_LINUX) #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ #define LUA_USE_READLINE /* needs some extra libraries */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ #endif #if defined(LUA_USE_MACOSX) #define LUA_USE_POSIX -#define LUA_DL_DYLD /* does not need extra library */ +#define LUA_USE_DLOPEN /* does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ #endif /* -@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@@ LUA_USE_POSIX includes all functionality listed as X/Open System @* Interfaces Extension (XSI). ** CHANGE it (define it) if your system is XSI compatible. */ @@ -56,20 +70,10 @@ #define LUA_USE_ISATTY #define LUA_USE_POPEN #define LUA_USE_ULONGJMP +#define LUA_USE_GMTIME_R #endif -/* -@@ LUA_PATH and LUA_CPATH are the names of the environment variables that -@* Lua check to set its paths. -@@ LUA_INIT is the name of the environment variable that Lua -@* checks for initialization code. -** CHANGE them if you want different names. -*/ -#define LUA_PATH "LUA_PATH" -#define LUA_CPATH "LUA_CPATH" -#define LUA_INIT "LUA_INIT" - /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @@ -80,7 +84,7 @@ ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ -#if defined(_WIN32) +#if defined(_WIN32) /* { */ /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. @@ -88,21 +92,23 @@ #define LUA_LDIR "!\\lua\\" #define LUA_CDIR "!\\" #define LUA_PATH_DEFAULT \ - ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" #define LUA_CPATH_DEFAULT \ - ".\\?.dll;" ".\\?51.dll;" LUA_CDIR"?.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\?51.dll;" LUA_CDIR"loadall.dll;" LUA_CDIR"clibs\\loadall.dll" + LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" -#else +#else /* }{ */ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" #define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR #define LUA_PATH_DEFAULT \ - "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" #define LUA_CPATH_DEFAULT \ - "./?.so;" "./lib?51.so;" LUA_CDIR"?.so;" LUA_CDIR"lib?51.so;" LUA_CDIR"loadall.so" -#endif + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif /* } */ /* @@ -118,82 +124,71 @@ /* -@@ LUA_PATHSEP is the character that separates templates in a path. -@@ LUA_PATH_MARK is the string that marks the substitution points in a -@* template. -@@ LUA_EXECDIR in a Windows path is replaced by the executable's -@* directory. -@@ LUA_IGMARK is a mark to ignore all before it when bulding the -@* luaopen_ function name. -** CHANGE them if for some reason your system cannot use those -** characters. (E.g., if one of those characters is a common character -** in file/directory names.) Probably you do not need to change them. +@@ LUA_ENV is the name of the variable that holds the current +@@ environment, used to access global names. +** CHANGE it if you do not like this name. */ -#define LUA_PATHSEP ";" -#define LUA_PATH_MARK "?" -#define LUA_EXECDIR "!" -#define LUA_IGMARK "-" - - -/* -@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. -** CHANGE that if ptrdiff_t is not adequate on your machine. (On most -** machines, ptrdiff_t gives a good choice between int or long.) -*/ -#define LUA_INTEGER ptrdiff_t +#define LUA_ENV "_ENV" /* @@ LUA_API is a mark for all core API functions. -@@ LUALIB_API is a mark for all standard library functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. ** CHANGE them if you need to define those functions in some special way. ** For instance, if you want to create one Windows DLL with the core and ** the libraries, you may want to use the following definition (define ** LUA_BUILD_AS_DLL to get it). */ -#if defined(LUA_BUILD_AS_DLL) +#if defined(LUA_BUILD_AS_DLL) /* { */ -#if defined(LUA_CORE) || defined(LUA_LIB) +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ #define LUA_API __declspec(dllexport) -#else +#else /* }{ */ #define LUA_API __declspec(dllimport) -#endif +#endif /* } */ -#else +#else /* }{ */ #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY) && (defined(LUA_CORE) || defined(LUA_LIB)) -#define LUA_API __attribute__((visibility("default"))) +#define LUA_API __attribute__((visibility("default"))) #else -#define LUA_API extern -#endif +#define LUA_API extern #endif +#endif /* } */ + + /* more often than not the libs go together with the core */ #define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API /* @@ LUAI_FUNC is a mark for all extern functions that are not to be @* exported to outside modules. -@@ LUAI_DATA is a mark for all extern (const) variables that are not to -@* be exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +@* that are not to be exported to outside modules (LUAI_DDEF for +@* definitions and LUAI_DDEC for declarations). ** CHANGE them if you need to mark them in some special way. Elf/gcc ** (versions 3.2 and later) mark them as "hidden" to optimize access -** when Lua is compiled as a shared library. +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. */ -#if defined(luaall_c) -#define LUAI_FUNC static -#define LUAI_DATA /* empty */ - -#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ - defined(__ELF__) +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ #define LUAI_FUNC __attribute__((visibility("hidden"))) extern -#define LUAI_DATA LUAI_FUNC +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ -#else +#else /* }{ */ #define LUAI_FUNC extern -#define LUAI_DATA extern -#endif +#define LUAI_DDEC extern +#define LUAI_DDEF /* empty */ +#endif /* } */ @@ -213,177 +208,110 @@ #define LUA_IDSIZE 60 +/* +@@ luai_writestring/luai_writeline define how 'print' prints its results. +** They are only used in libraries and the stand-alone program. (The #if +** avoids including 'stdio.h' everywhere.) +*/ +#if defined(LUA_LIB) || defined(lua_c) +#include +#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout)) +#endif + +/* +@@ luai_writestringerror defines how to print error messages. +** (A format string with one argument is enough for Lua...) +*/ +#define luai_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) + + +/* +@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, +** strings that are internalized. (Cannot be smaller than reserved words +** or tags for metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#define LUAI_MAXSHORTLEN 40 + + + /* ** {================================================================== -** Stand-alone configuration +** Compatibility with previous versions ** =================================================================== */ -#if defined(lua_c) || defined(luaall_c) +/* +@@ LUA_COMPAT_ALL controls all compatibility options. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_ALL) /* { */ /* -@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that -@* is, whether we're running lua interactively). -** CHANGE it if you have a better definition for non-POSIX/non-Windows -** systems. +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. */ -#if defined(LUA_USE_ISATTY) -#include -#define lua_stdin_is_tty() isatty(0) -#elif defined(LUA_WIN) -#include -#include -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) -#else -#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ -#endif +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_pcall(L,1,0,0)) /* -@@ LUA_PROMPT is the default prompt used by stand-alone Lua. -@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. -** CHANGE them if you want different prompts. (You can also change the -** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. */ -#define LUA_PROMPT "> " -#define LUA_PROMPT2 ">> " - +#define LUA_COMPAT_LOG10 /* -@@ LUA_PROGNAME is the default name for the stand-alone Lua program. -** CHANGE it if your stand-alone interpreter has a different name and -** your system is not able to detect that name automatically. +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. */ -#define LUA_PROGNAME "lua" - +#define LUA_COMPAT_LOADSTRING /* -@@ LUA_MAXINPUT is the maximum length for an input line in the -@* stand-alone interpreter. -** CHANGE it if you need longer lines. +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. */ -#define LUA_MAXINPUT 512 - +#define LUA_COMPAT_MAXN /* -@@ lua_readline defines how to show a prompt and then read a line from -@* the standard input. -@@ lua_saveline defines how to "save" a read line in a "history". -@@ lua_freeline defines how to free a line read by lua_readline. -** CHANGE them if you want to improve this functionality (e.g., by using -** GNU readline and history facilities). +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. */ -#if defined(LUA_USE_READLINE) -#include -#include -#include -#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) -#define lua_saveline(L,idx) \ - if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ - add_history(lua_tostring(L, idx)); /* add it to history */ -#define lua_freeline(L,b) ((void)L, free(b)) -#else -#define lua_readline(L,b,p) \ - ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ - fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ -#define lua_saveline(L,idx) { (void)L; (void)idx; } -#define lua_freeline(L,b) { (void)L; (void)b; } -#endif +#define lua_strlen(L,i) lua_rawlen(L, (i)) -#endif +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ /* }================================================================== */ -/* -@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles -@* as a percentage. -** CHANGE it if you want the GC to run faster or slower (higher values -** mean larger pauses which mean slower collection.) You can also change -** this value dynamically. -*/ -#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ - - -/* -@@ LUAI_GCMUL defines the default speed of garbage collection relative to -@* memory allocation as a percentage. -** CHANGE it if you want to change the granularity of the garbage -** collection. (Higher values mean coarser collections. 0 represents -** infinity, where each step performs a full collection.) You can also -** change this value dynamically. -*/ -#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ - - - -/* -@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. -** CHANGE it (define it) if you want exact compatibility with the -** behavior of setn/getn in Lua 5.0. -*/ -#undef LUA_COMPAT_GETN - -/* -@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. -** CHANGE it to undefined as soon as you do not need a global 'loadlib' -** function (the function is still available as 'package.loadlib'). -*/ -#undef LUA_COMPAT_LOADLIB - -/* -@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. -** CHANGE it to undefined as soon as your programs use only '...' to -** access vararg parameters (instead of the old 'arg' table). -*/ -#define LUA_COMPAT_VARARG - -/* -@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. -** CHANGE it to undefined as soon as your programs use 'math.fmod' or -** the new '%' operator instead of 'math.mod'. -*/ -#define LUA_COMPAT_MOD - -/* -@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting -@* facility. -** CHANGE it to 2 if you want the old behaviour, or undefine it to turn -** off the advisory error when nesting [[...]]. -*/ -#define LUA_COMPAT_LSTR 1 - -/* -@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. -** CHANGE it to undefined as soon as you rename 'string.gfind' to -** 'string.gmatch'. -*/ -#define LUA_COMPAT_GFIND - -/* -@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' -@* behavior. -** CHANGE it to undefined as soon as you replace to 'luaL_register' -** your uses of 'luaL_openlib' -*/ -#define LUA_COMPAT_OPENLIB - - - -/* -@@ luai_apicheck is the assert macro used by the Lua-C API. -** CHANGE luai_apicheck if you want Lua to perform some checks in the -** parameters it gets from API calls. This may slow down the interpreter -** a bit, but may be quite useful when debugging C code that interfaces -** with Lua. A useful redefinition is to use assert.h. -*/ -#if defined(LUA_USE_APICHECK) -#include -#define luai_apicheck(L,o) { (void)L; assert(o); } -#else -#define luai_apicheck(L,o) { (void)L; } -#endif - /* @@ LUAI_BITSINT defines the number of bits in an int. @@ -391,107 +319,62 @@ ** your machine. Probably you do not need to change this. */ /* avoid overflows in comparison */ -#if INT_MAX-20 < 32760 +#if INT_MAX-20 < 32760 /* { */ #define LUAI_BITSINT 16 -#elif INT_MAX > 2147483640L +#elif INT_MAX > 2147483640L /* }{ */ /* int has at least 32 bits */ #define LUAI_BITSINT 32 -#else +#else /* }{ */ #error "you must define LUA_BITSINT with number of bits in an integer" -#endif +#endif /* } */ /* -@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. -@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUA_INT32 is an signed integer with exactly 32 bits. @@ LUAI_UMEM is an unsigned integer big enough to count the total @* memory used by Lua. @@ LUAI_MEM is a signed integer big enough to count the total memory @* used by Lua. ** CHANGE here if for some weird reason the default definitions are not -** good enough for your machine. (The definitions in the 'else' -** part always works, but may waste space on machines with 64-bit -** longs.) Probably you do not need to change this. +** good enough for your machine. Probably you do not need to change +** this. */ -#if LUAI_BITSINT >= 32 -#define LUAI_UINT32 unsigned int -#define LUAI_INT32 int -#define LUAI_MAXINT32 INT_MAX +#if LUAI_BITSINT >= 32 /* { */ +#define LUA_INT32 int #define LUAI_UMEM size_t #define LUAI_MEM ptrdiff_t -#else +#else /* }{ */ /* 16-bit ints */ -#define LUAI_UINT32 unsigned long -#define LUAI_INT32 long -#define LUAI_MAXINT32 LONG_MAX +#define LUA_INT32 long #define LUAI_UMEM unsigned long #define LUAI_MEM long +#endif /* } */ + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua to consume unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 #endif - -/* -@@ LUAI_MAXCALLS limits the number of nested calls. -** CHANGE it if you need really deep recursive calls. This limit is -** arbitrary; its only purpose is to stop infinite recursion before -** exhausting memory. -*/ -#define LUAI_MAXCALLS 20000 +/* reserve some space for error handling */ +#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) -/* -@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function -@* can use. -** CHANGE it if you need lots of (Lua) stack space for your C -** functions. This limit is arbitrary; its only purpose is to stop C -** functions to consume unlimited stack space. (must be smaller than -** -LUA_REGISTRYINDEX) -*/ -#define LUAI_MAXCSTACK 8000 - - - -/* -** {================================================================== -** CHANGE (to smaller values) the following definitions if your system -** has a small C stack. (Or you may want to change them to larger -** values if your system has a large C stack and these limits are -** too rigid for you.) Some of these constants control the size of -** stack-allocated arrays used by the compiler or the interpreter, while -** others limit the maximum number of recursive calls that the compiler -** or the interpreter can perform. Values too large may cause a C stack -** overflow for some forms of deep constructs. -** =================================================================== -*/ - - -/* -@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and -@* syntactical nested non-terminals in a program. -*/ -#define LUAI_MAXCCALLS 200 - - -/* -@@ LUAI_MAXVARS is the maximum number of local variables per function -@* (must be smaller than 250). -*/ -#define LUAI_MAXVARS 200 - - -/* -@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function -@* (must be smaller than 250). -*/ -#define LUAI_MAXUPVALUES 60 /* @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. */ #define LUAL_BUFFERSIZE BUFSIZ -/* }================================================================== */ - @@ -519,238 +402,144 @@ @@ LUA_NUMBER_FMT is the format for writing numbers. @@ lua_number2str converts a number to a string. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. -@@ lua_str2number converts a string to a number. */ #define LUA_NUMBER_SCAN "%lf" #define LUA_NUMBER_FMT "%.14g" #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ + + +/* +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations +*/ +#define l_mathop(x) (x) + + +/* +@@ lua_str2number converts a decimal numeric string to a number. +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' does both conversions. C89, however, has no function +** to convert floating hexadecimal strings to numbers. For these +** systems, you can leave 'lua_strx2number' undefined and Lua will +** provide its own implementation. +*/ #define lua_str2number(s,p) strtod((s), (p)) +#if defined(LUA_USE_STRTODHEX) +#define lua_strx2number(s,p) strtod((s), (p)) +#endif + /* @@ The luai_num* macros define the primitive operations over numbers. */ -#if defined(LUA_CORE) + +/* the following operations need the math library */ +#if defined(lobject_c) || defined(lvm_c) #include -#define luai_numadd(a,b) ((a)+(b)) -#define luai_numsub(a,b) ((a)-(b)) -#define luai_nummul(a,b) ((a)*(b)) -#define luai_numdiv(a,b) ((a)/(b)) -#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) -#define luai_numpow(a,b) (pow(a,b)) -#define luai_numunm(a) (-(a)) -#define luai_numeq(a,b) ((a)==(b)) -#define luai_numlt(a,b) ((a)<(b)) -#define luai_numle(a,b) ((a)<=(b)) -#define luai_numisnan(a) (!luai_numeq((a), (a))) +#define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b)) +#define luai_numpow(L,a,b) (l_mathop(pow)(a,b)) #endif +/* these are quite standard operations */ +#if defined(LUA_CORE) +#define luai_numadd(L,a,b) ((a)+(b)) +#define luai_numsub(L,a,b) ((a)-(b)) +#define luai_nummul(L,a,b) ((a)*(b)) +#define luai_numdiv(L,a,b) ((a)/(b)) +#define luai_numunm(L,a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(L,a,b) ((a)<(b)) +#define luai_numle(L,a,b) ((a)<=(b)) +#define luai_numisnan(L,a) (!luai_numeq((a), (a))) +#endif + + /* -@@ lua_number2int is a macro to convert lua_Number to int. -@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. -** CHANGE them if you know a faster way to convert a lua_Number to -** int (with any rounding method and without throwing errors) in your -** system. In Pentium machines, a naive typecast from double to int -** in C is extremely slow, so any alternative is worth trying. +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + +/* +@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned. +** It must have at least 32 bits. +*/ +#define LUA_UNSIGNED unsigned LUA_INT32 + + + +/* +** Some tricks with doubles */ -/* On a Pentium, resort to a trick */ -#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ - (defined(__i386) || defined (_M_IX86) || defined(__i386__)) +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** The next definitions activate some tricks to speed up the +** conversion from doubles to integer types, mainly to LUA_UNSIGNED. +** +@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a +** DirectX idiosyncrasy. +** +@@ LUA_IEEE754TRICK uses a trick that should work on any machine +** using IEEE754 with a 32-bit integer type. +** +@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be +** defined when LUA_INTEGER is a 32-bit integer. +** +@@ LUA_IEEEENDIAN is the endianness of doubles in your machine +** (0 for little endian, 1 for big endian); if not defined, Lua will +** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). +** +@@ LUA_NANTRICK controls the use of a trick to pack all types into +** a single double value, using NaN values to represent non-number +** values. The trick only works on 32-bit machines (ints and pointers +** are 32-bit values) with numbers represented as IEEE 754-2008 doubles +** with conventional endianess (12345678 or 87654321), in CPUs that do +** not produce signaling NaN values (all NaNs are quiet). +*/ -/* On a Microsoft compiler, use assembler */ -#if defined(_MSC_VER) +/* Microsoft compiler on a Pentium (32 bit) ? */ +#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ -#define lua_number2int(i,d) __asm fld d __asm fistp i -#define lua_number2integer(i,n) lua_number2int(i, n) - -/* the next trick should work on any Pentium, but sometimes clashes - with a DirectX idiosyncrasy */ -#else - -union luai_Cast { double l_d; long l_l; }; -#define lua_number2int(i,d) \ - { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } -#define lua_number2integer(i,n) lua_number2int(i, n) - -#endif +#define LUA_MSASMTRICK +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK -/* this option always works, but may be slow */ -#else -#define lua_number2int(i,d) ((i)=(int)(d)) -#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) +/* pentium 32 bits? */ +#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ -#endif +#define LUA_IEEE754TRICK +#define LUA_IEEELL +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + +/* pentium 64 bits? */ +#elif defined(__x86_64) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 0 + +#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 1 + +#else /* }{ */ + +/* assume IEEE754 and a 32-bit integer type */ +#define LUA_IEEE754TRICK + +#endif /* } */ + +#endif /* } */ /* }================================================================== */ -/* -@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. -** CHANGE it if your system requires alignments larger than double. (For -** instance, if your system supports long doubles and they must be -** aligned in 16-byte boundaries, then you should add long double in the -** union.) Probably you do not need to change this. -*/ -#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } - - -/* -@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. -** CHANGE them if you prefer to use longjmp/setjmp even with C++ -** or if want/don't to use _longjmp/_setjmp instead of regular -** longjmp/setjmp. By default, Lua handles errors with exceptions when -** compiling as C++ code, with _longjmp/_setjmp when asked to use them, -** and with longjmp/setjmp otherwise. -*/ -#if defined(__cplusplus) -/* C++ exceptions */ -#define LUAI_THROW(L,c) throw(c) -#define LUAI_TRY(L,c,a) try { a } catch(...) \ - { if ((c)->status == 0) (c)->status = -1; } -#define luai_jmpbuf int /* dummy variable */ - -#elif defined(LUA_USE_ULONGJMP) -/* in Unix, try _longjmp/_setjmp (more efficient) */ -#define LUAI_THROW(L,c) _longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#else -/* default handling with long jumps */ -#define LUAI_THROW(L,c) longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#endif - - -/* -@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern -@* can do during pattern-matching. -** CHANGE it if you need more captures. This limit is arbitrary. -*/ -#define LUA_MAXCAPTURES 32 - - -/* -@@ lua_tmpnam is the function that the OS library uses to create a -@* temporary name. -@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. -** CHANGE them if you have an alternative to tmpnam (which is considered -** insecure) or if you want the original tmpnam anyway. By default, Lua -** uses tmpnam except when POSIX is available, where it uses mkstemp. -*/ -#if defined(loslib_c) || defined(luaall_c) - -#if defined(LUA_USE_MKSTEMP) -#include -#define LUA_TMPNAMBUFSIZE 32 -#define lua_tmpnam(b,e) { \ - strcpy(b, "/tmp/lua_XXXXXX"); \ - e = mkstemp(b); \ - if (e != -1) close(e); \ - e = (e == -1); } - -#else -#define LUA_TMPNAMBUFSIZE L_tmpnam -#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } -#endif - -#endif - - -/* -@@ lua_popen spawns a new process connected to the current one through -@* the file streams. -** CHANGE it if you have a way to implement it in your system. -*/ -#if defined(LUA_USE_POPEN) - -#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) -#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) - -#elif defined(LUA_WIN) - -#define lua_popen(L,c,m) ((void)L, _popen(c,m)) -#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) - -#else - -#define lua_popen(L,c,m) ((void)((void)c, m), \ - luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) -#define lua_pclose(L,file) ((void)((void)L, file), 0) - -#endif - -/* -@@ LUA_DL_* define which dynamic-library system Lua should use. -** CHANGE here if Lua has problems choosing the appropriate -** dynamic-library system for your platform (either Windows' DLL, Mac's -** dyld, or Unix's dlopen). If your system is some kind of Unix, there -** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for -** it. To use dlopen you also need to adapt the src/Makefile (probably -** adding -ldl to the linker options), so Lua does not select it -** automatically. (When you change the makefile to add -ldl, you must -** also add -DLUA_USE_DLOPEN.) -** If you do not want any kind of dynamic library, undefine all these -** options. -** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. -*/ -#if defined(LUA_USE_DLOPEN) -#define LUA_DL_DLOPEN -#endif - -#if defined(LUA_WIN) -#define LUA_DL_DLL -#endif - - -/* -@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State -@* (the data goes just *before* the lua_State pointer). -** CHANGE (define) this if you really need that. This value must be -** a multiple of the maximum alignment required for your machine. -*/ -#define LUAI_EXTRASPACE 0 - - -/* -@@ luai_userstate* allow user-specific actions on threads. -** CHANGE them if you defined LUAI_EXTRASPACE and need to do something -** extra when a thread is created/deleted/resumed/yielded. -*/ -#define luai_userstateopen(L) ((void)L) -#define luai_userstateclose(L) ((void)L) -#define luai_userstatethread(L,L1) ((void)L) -#define luai_userstatefree(L) ((void)L) -#define luai_userstateresume(L,n) ((void)L) -#define luai_userstateyield(L,n) ((void)L) - - -/* -@@ LUA_INTFRMLEN is the length modifier for integer conversions -@* in 'string.format'. -@@ LUA_INTFRM_T is the integer type correspoding to the previous length -@* modifier. -** CHANGE them if your system supports long long or does not support long. -*/ - -#if defined(LUA_USELONGLONG) - -#define LUA_INTFRMLEN "ll" -#define LUA_INTFRM_T long long - -#else - -#define LUA_INTFRMLEN "l" -#define LUA_INTFRM_T long - -#endif - /* =================================================================== */ diff --git a/src/mod/languages/mod_lua/lua/lualib.h b/src/mod/languages/mod_lua/lua/lualib.h index 469417f670..9fd126bf78 100644 --- a/src/mod/languages/mod_lua/lua/lualib.h +++ b/src/mod/languages/mod_lua/lua/lualib.h @@ -1,5 +1,5 @@ /* -** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lualib.h,v 1.43 2011/12/08 12:11:37 roberto Exp $ ** Lua standard libraries ** See Copyright Notice in lua.h */ @@ -11,41 +11,43 @@ #include "lua.h" -/* Key to file-handle type */ -#define LUA_FILEHANDLE "FILE*" +LUAMOD_API int (luaopen_base) (lua_State *L); #define LUA_COLIBNAME "coroutine" -LUALIB_API int (luaopen_base) (lua_State *L); +LUAMOD_API int (luaopen_coroutine) (lua_State *L); #define LUA_TABLIBNAME "table" -LUALIB_API int (luaopen_table) (lua_State *L); +LUAMOD_API int (luaopen_table) (lua_State *L); #define LUA_IOLIBNAME "io" -LUALIB_API int (luaopen_io) (lua_State *L); +LUAMOD_API int (luaopen_io) (lua_State *L); #define LUA_OSLIBNAME "os" -LUALIB_API int (luaopen_os) (lua_State *L); +LUAMOD_API int (luaopen_os) (lua_State *L); #define LUA_STRLIBNAME "string" -LUALIB_API int (luaopen_string) (lua_State *L); +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_BITLIBNAME "bit32" +LUAMOD_API int (luaopen_bit32) (lua_State *L); #define LUA_MATHLIBNAME "math" -LUALIB_API int (luaopen_math) (lua_State *L); +LUAMOD_API int (luaopen_math) (lua_State *L); #define LUA_DBLIBNAME "debug" -LUALIB_API int (luaopen_debug) (lua_State *L); +LUAMOD_API int (luaopen_debug) (lua_State *L); #define LUA_LOADLIBNAME "package" -LUALIB_API int (luaopen_package) (lua_State *L); +LUAMOD_API int (luaopen_package) (lua_State *L); /* open all previous libraries */ -LUALIB_API void (luaL_openlibs) (lua_State *L); +LUALIB_API void (luaL_openlibs) (lua_State *L); -#ifndef lua_assert +#if !defined(lua_assert) #define lua_assert(x) ((void)0) #endif diff --git a/src/mod/languages/mod_lua/lua/lundump.c b/src/mod/languages/mod_lua/lua/lundump.c index 8010a45795..54de011a45 100644 --- a/src/mod/languages/mod_lua/lua/lundump.c +++ b/src/mod/languages/mod_lua/lua/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** $Id: lundump.c,v 2.22 2012/05/08 13:53:33 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -27,28 +27,24 @@ typedef struct { const char* name; } LoadState; -#ifdef LUAC_TRUST_BINARIES -#define IF(c,s) -#define error(S,s) -#else -#define IF(c,s) if (c) error(S,s) - -static void error(LoadState* S, const char* why) +static l_noret error(LoadState* S, const char* why) { - luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaO_pushfstring(S->L,"%s: %s precompiled chunk",S->name,why); luaD_throw(S->L,LUA_ERRSYNTAX); } -#endif #define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) -#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadByte(S) (lu_byte)LoadChar(S) #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) #define LoadVector(S,b,n,size) LoadMem(S,b,n,size) +#if !defined(luai_verifycode) +#define luai_verifycode(L,b,f) /* empty */ +#endif + static void LoadBlock(LoadState* S, void* b, size_t size) { - size_t r=luaZ_read(S->Z,b,size); - IF (r!=0, "unexpected end"); + if (luaZ_read(S->Z,b,size)!=0) error(S,"truncated"); } static int LoadChar(LoadState* S) @@ -62,7 +58,7 @@ static int LoadInt(LoadState* S) { int x; LoadVar(S,x); - IF (x<0, "bad integer"); + if (x<0) error(S,"corrupted"); return x; } @@ -82,7 +78,7 @@ static TString* LoadString(LoadState* S) else { char* s=luaZ_openspace(S->L,S->b,size); - LoadBlock(S,s,size); + LoadBlock(S,s,size*sizeof(char)); return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ } } @@ -95,7 +91,7 @@ static void LoadCode(LoadState* S, Proto* f) LoadVector(S,f->code,n,sizeof(Instruction)); } -static Proto* LoadFunction(LoadState* S, TString* p); +static void LoadFunction(LoadState* S, Proto* f); static void LoadConstants(LoadState* S, Proto* f) { @@ -111,10 +107,10 @@ static void LoadConstants(LoadState* S, Proto* f) switch (t) { case LUA_TNIL: - setnilvalue(o); + setnilvalue(o); break; case LUA_TBOOLEAN: - setbvalue(o,LoadChar(S)!=0); + setbvalue(o,LoadChar(S)); break; case LUA_TNUMBER: setnvalue(o,LoadNumber(S)); @@ -122,21 +118,38 @@ static void LoadConstants(LoadState* S, Proto* f) case LUA_TSTRING: setsvalue2n(S->L,o,LoadString(S)); break; - default: - error(S,"bad constant"); - break; + default: lua_assert(0); } } n=LoadInt(S); f->p=luaM_newvector(S->L,n,Proto*); f->sizep=n; for (i=0; ip[i]=NULL; - for (i=0; ip[i]=LoadFunction(S,f->source); + for (i=0; ip[i]=luaF_newproto(S->L); + LoadFunction(S,f->p[i]); + } +} + +static void LoadUpvalues(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,Upvaldesc); + f->sizeupvalues=n; + for (i=0; iupvalues[i].name=NULL; + for (i=0; iupvalues[i].instack=LoadByte(S); + f->upvalues[i].idx=LoadByte(S); + } } static void LoadDebug(LoadState* S, Proto* f) { int i,n; + f->source=LoadString(S); n=LoadInt(S); f->lineinfo=luaM_newvector(S->L,n,int); f->sizelineinfo=n; @@ -152,49 +165,48 @@ static void LoadDebug(LoadState* S, Proto* f) f->locvars[i].endpc=LoadInt(S); } n=LoadInt(S); - f->upvalues=luaM_newvector(S->L,n,TString*); - f->sizeupvalues=n; - for (i=0; iupvalues[i]=NULL; - for (i=0; iupvalues[i]=LoadString(S); + for (i=0; iupvalues[i].name=LoadString(S); } -static Proto* LoadFunction(LoadState* S, TString* p) +static void LoadFunction(LoadState* S, Proto* f) { - Proto* f; - if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); - f=luaF_newproto(S->L); - setptvalue2s(S->L,S->L->top,f); incr_top(S->L); - f->source=LoadString(S); if (f->source==NULL) f->source=p; f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); - f->nups=LoadByte(S); f->numparams=LoadByte(S); f->is_vararg=LoadByte(S); f->maxstacksize=LoadByte(S); LoadCode(S,f); LoadConstants(S,f); + LoadUpvalues(S,f); LoadDebug(S,f); - IF (!luaG_checkcode(f), "bad code"); - S->L->top--; - S->L->nCcalls--; - return f; } +/* the code below must be consistent with the code in luaU_header */ +#define N0 LUAC_HEADERSIZE +#define N1 (sizeof(LUA_SIGNATURE)-sizeof(char)) +#define N2 N1+2 +#define N3 N2+6 + static void LoadHeader(LoadState* S) { - char h[LUAC_HEADERSIZE]; - char s[LUAC_HEADERSIZE]; + lu_byte h[LUAC_HEADERSIZE]; + lu_byte s[LUAC_HEADERSIZE]; luaU_header(h); - LoadBlock(S,s,LUAC_HEADERSIZE); - IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); + memcpy(s,h,sizeof(char)); /* first char already read */ + LoadBlock(S,s+sizeof(char),LUAC_HEADERSIZE-sizeof(char)); + if (memcmp(h,s,N0)==0) return; + if (memcmp(h,s,N1)!=0) error(S,"not a"); + if (memcmp(h,s,N2)!=0) error(S,"version mismatch in"); + if (memcmp(h,s,N3)!=0) error(S,"incompatible"); else error(S,"corrupted"); } /* ** load precompiled chunk */ -Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) { LoadState S; + Closure* cl; if (*name=='@' || *name=='=') S.name=name+1; else if (*name==LUA_SIGNATURE[0]) @@ -205,23 +217,42 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) S.Z=Z; S.b=buff; LoadHeader(&S); - return LoadFunction(&S,luaS_newliteral(L,"=?")); + cl=luaF_newLclosure(L,1); + setclLvalue(L,L->top,cl); incr_top(L); + cl->l.p=luaF_newproto(L); + LoadFunction(&S,cl->l.p); + if (cl->l.p->sizeupvalues != 1) + { + Proto* p=cl->l.p; + cl=luaF_newLclosure(L,cl->l.p->sizeupvalues); + cl->l.p=p; + setclLvalue(L,L->top-1,cl); + } + luai_verifycode(L,buff,cl->l.p); + return cl; } +#define MYINT(s) (s[0]-'0') +#define VERSION MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR) +#define FORMAT 0 /* this is the official format */ + /* -* make header +* make header for precompiled chunks +* if you change the code below be sure to update LoadHeader and FORMAT above +* and LUAC_HEADERSIZE in lundump.h */ -void luaU_header (char* h) +void luaU_header (lu_byte* h) { int x=1; - memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); - h+=sizeof(LUA_SIGNATURE)-1; - *h++=(char)LUAC_VERSION; - *h++=(char)LUAC_FORMAT; - *h++=(char)*(char*)&x; /* endianness */ - *h++=(char)sizeof(int); - *h++=(char)sizeof(size_t); - *h++=(char)sizeof(Instruction); - *h++=(char)sizeof(lua_Number); - *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-sizeof(char)); + h+=sizeof(LUA_SIGNATURE)-sizeof(char); + *h++=cast_byte(VERSION); + *h++=cast_byte(FORMAT); + *h++=cast_byte(*(char*)&x); /* endianness */ + *h++=cast_byte(sizeof(int)); + *h++=cast_byte(sizeof(size_t)); + *h++=cast_byte(sizeof(Instruction)); + *h++=cast_byte(sizeof(lua_Number)); + *h++=cast_byte(((lua_Number)0.5)==0); /* is lua_Number integral? */ + memcpy(h,LUAC_TAIL,sizeof(LUAC_TAIL)-sizeof(char)); } diff --git a/src/mod/languages/mod_lua/lua/lundump.h b/src/mod/languages/mod_lua/lua/lundump.h index c80189dbff..2b8accecb8 100644 --- a/src/mod/languages/mod_lua/lua/lundump.h +++ b/src/mod/languages/mod_lua/lua/lundump.h @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lundump.h,v 1.39 2012/05/08 13:53:33 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -11,26 +11,18 @@ #include "lzio.h" /* load one chunk; from lundump.c */ -LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); +LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); /* make header; from lundump.c */ -LUAI_FUNC void luaU_header (char* h); +LUAI_FUNC void luaU_header (lu_byte* h); /* dump one chunk; from ldump.c */ LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); -#ifdef luac_c -/* print one chunk; from print.c */ -LUAI_FUNC void luaU_print (const Proto* f, int full); -#endif +/* data to catch conversion errors */ +#define LUAC_TAIL "\x19\x93\r\n\x1a\n" -/* for header of binary files -- this is Lua 5.1 */ -#define LUAC_VERSION 0x51 - -/* for header of binary files -- this is the official format */ -#define LUAC_FORMAT 0 - -/* size of header of binary files */ -#define LUAC_HEADERSIZE 12 +/* size in bytes of header of binary files */ +#define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) #endif diff --git a/src/mod/languages/mod_lua/lua/lvm.c b/src/mod/languages/mod_lua/lua/lvm.c index ee3256ab94..657d5c456a 100644 --- a/src/mod/languages/mod_lua/lua/lvm.c +++ b/src/mod/languages/mod_lua/lua/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** $Id: lvm.c,v 2.155 2013/03/16 21:10:18 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -35,7 +35,7 @@ const TValue *luaV_tonumber (const TValue *obj, TValue *n) { lua_Number num; if (ttisnumber(obj)) return obj; - if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + if (ttisstring(obj) && luaO_str2d(svalue(obj), tsvalue(obj)->len, &num)) { setnvalue(n, num); return n; } @@ -50,58 +50,60 @@ int luaV_tostring (lua_State *L, StkId obj) { else { char s[LUAI_MAXNUMBER2STR]; lua_Number n = nvalue(obj); - lua_number2str(s, n); - setsvalue2s(L, obj, luaS_new(L, s)); + int l = lua_number2str(s, n); + setsvalue2s(L, obj, luaS_newlstr(L, s, l)); return 1; } } -static void traceexec (lua_State *L, const Instruction *pc) { +static void traceexec (lua_State *L) { + CallInfo *ci = L->ci; lu_byte mask = L->hookmask; - const Instruction *oldpc = L->savedpc; - L->savedpc = pc; - if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { - resethookcount(L); - luaD_callhook(L, LUA_HOOKCOUNT, -1); + int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); + if (counthook) + resethookcount(L); /* reset count */ + if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ + return; /* do not call hook again (VM yielded, so it did not move) */ } + if (counthook) + luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ if (mask & LUA_MASKLINE) { - Proto *p = ci_func(L->ci)->l.p; - int npc = pcRel(pc, p); - int newline = getline(p, npc); - /* call linehook when enter a new function, when jump back (loop), - or when enter a new line */ - if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) - luaD_callhook(L, LUA_HOOKLINE, newline); + Proto *p = ci_func(ci)->p; + int npc = pcRel(ci->u.l.savedpc, p); + int newline = getfuncline(p, npc); + if (npc == 0 || /* call linehook when enter a new function, */ + ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ + newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ + luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ + } + L->oldpc = ci->u.l.savedpc; + if (L->status == LUA_YIELD) { /* did hook yield? */ + if (counthook) + L->hookcount = 1; /* undo decrement to zero */ + ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ + ci->func = L->top - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); } } -static void callTMres (lua_State *L, StkId res, const TValue *f, - const TValue *p1, const TValue *p2) { - ptrdiff_t result = savestack(L, res); - setobj2s(L, L->top, f); /* push function */ - setobj2s(L, L->top+1, p1); /* 1st argument */ - setobj2s(L, L->top+2, p2); /* 2nd argument */ - luaD_checkstack(L, 3); - L->top += 3; - luaD_call(L, L->top - 3, 1); - res = restorestack(L, result); - L->top--; - setobjs2s(L, res, L->top); -} - - - static void callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, const TValue *p3) { - setobj2s(L, L->top, f); /* push function */ - setobj2s(L, L->top+1, p1); /* 1st argument */ - setobj2s(L, L->top+2, p2); /* 2nd argument */ - setobj2s(L, L->top+3, p3); /* 3th argument */ - luaD_checkstack(L, 4); - L->top += 4; - luaD_call(L, L->top - 4, 0); + const TValue *p2, TValue *p3, int hasres) { + ptrdiff_t result = savestack(L, p3); + setobj2s(L, L->top++, f); /* push function */ + setobj2s(L, L->top++, p1); /* 1st argument */ + setobj2s(L, L->top++, p2); /* 2nd argument */ + if (!hasres) /* no result? 'p3' is third argument */ + setobj2s(L, L->top++, p3); /* 3rd argument */ + /* metamethod may yield only when called from Lua code */ + luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); + if (hasres) { /* if has result, move it to its place */ + p3 = restorestack(L, result); + setobjs2s(L, p3, --L->top); + } } @@ -112,7 +114,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); const TValue *res = luaH_get(h, key); /* do a primitive get */ - if (!ttisnil(res) || /* result is no nil? */ + if (!ttisnil(res) || /* result is not nil? */ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ setobj2s(L, val, res); return; @@ -122,10 +124,10 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) luaG_typeerror(L, t, "index"); if (ttisfunction(tm)) { - callTMres(L, val, tm, t, key); + callTM(L, tm, t, key, val, 1); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat with 'tm' */ } luaG_runerror(L, "loop in gettable"); } @@ -137,22 +139,34 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { const TValue *tm; if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); - TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ - if (!ttisnil(oldval) || /* result is no nil? */ - (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ - setobj2t(L, oldval, val); - luaC_barriert(L, h, val); + TValue *oldval = cast(TValue *, luaH_get(h, key)); + /* if previous value is not nil, there must be a previous entry + in the table; moreover, a metamethod has no relevance */ + if (!ttisnil(oldval) || + /* previous value is nil; must check the metamethod */ + ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL && + /* no metamethod; is there a previous entry in the table? */ + (oldval != luaO_nilobject || + /* no previous entry; must create one. (The next test is + always true; we only need the assignment.) */ + (oldval = luaH_newkey(L, h, key), 1)))) { + /* no metamethod and (now) there is an entry with given key */ + setobj2t(L, oldval, val); /* assign new value to that entry */ + invalidateTMcache(h); + luaC_barrierback(L, obj2gco(h), val); return; } - /* else will try the tag method */ + /* else will try the metamethod */ } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) - luaG_typeerror(L, t, "index"); + else /* not a table; check metamethod */ + if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + /* there is a metamethod */ if (ttisfunction(tm)) { - callTM(L, tm, t, key, val); + callTM(L, tm, t, key, val, 0); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat with 'tm' */ } luaG_runerror(L, "loop in settable"); } @@ -164,12 +178,12 @@ static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ if (ttisnil(tm)) return 0; - callTMres(L, res, tm, p1, p2); + callTM(L, tm, p1, p2, res, 1); return 1; } -static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, +static const TValue *get_equalTM (lua_State *L, Table *mt1, Table *mt2, TMS event) { const TValue *tm1 = fasttm(L, mt1, event); const TValue *tm2; @@ -177,7 +191,7 @@ static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ tm2 = fasttm(L, mt2, event); if (tm2 == NULL) return NULL; /* no metamethod */ - if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + if (luaV_rawequalobj(tm1, tm2)) /* same metamethods? */ return tm1; return NULL; } @@ -185,14 +199,10 @@ static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event) { - const TValue *tm1 = luaT_gettmbyobj(L, p1, event); - const TValue *tm2; - if (ttisnil(tm1)) return -1; /* no metamethod? */ - tm2 = luaT_gettmbyobj(L, p2, event); - if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ - return -1; - callTMres(L, L->top, tm1, p1, p2); - return !l_isfalse(L->top); + if (!call_binTM(L, p1, p2, L->top, event)) + return -1; /* no metamethod */ + else + return !l_isfalse(L->top); } @@ -220,125 +230,261 @@ static int l_strcmp (const TString *ls, const TString *rs) { int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { int res; - if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); - else if (ttisnumber(l)) - return luai_numlt(nvalue(l), nvalue(r)); - else if (ttisstring(l)) + if (ttisnumber(l) && ttisnumber(r)) + return luai_numlt(L, nvalue(l), nvalue(r)); + else if (ttisstring(l) && ttisstring(r)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; - else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) - return res; - return luaG_ordererror(L, l, r); + else if ((res = call_orderTM(L, l, r, TM_LT)) < 0) + luaG_ordererror(L, l, r); + return res; } -static int lessequal (lua_State *L, const TValue *l, const TValue *r) { +int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { int res; - if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); - else if (ttisnumber(l)) - return luai_numle(nvalue(l), nvalue(r)); - else if (ttisstring(l)) + if (ttisnumber(l) && ttisnumber(r)) + return luai_numle(L, nvalue(l), nvalue(r)); + else if (ttisstring(l) && ttisstring(r)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; - else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */ return res; - else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ - return !res; - return luaG_ordererror(L, l, r); + else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */ + luaG_ordererror(L, l, r); + return !res; } -int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { +/* +** equality of Lua values. L == NULL means raw equality (no metamethods) +*/ +int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) { const TValue *tm; - lua_assert(ttype(t1) == ttype(t2)); + lua_assert(ttisequal(t1, t2)); switch (ttype(t1)) { case LUA_TNIL: return 1; case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TLCF: return fvalue(t1) == fvalue(t2); + case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2)); + case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2)); case LUA_TUSERDATA: { if (uvalue(t1) == uvalue(t2)) return 1; - tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, - TM_EQ); + else if (L == NULL) return 0; + tm = get_equalTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ); break; /* will try TM */ } case LUA_TTABLE: { if (hvalue(t1) == hvalue(t2)) return 1; - tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + else if (L == NULL) return 0; + tm = get_equalTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); break; /* will try TM */ } - default: return gcvalue(t1) == gcvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); } if (tm == NULL) return 0; /* no TM? */ - callTMres(L, L->top, tm, t1, t2); /* call TM */ + callTM(L, tm, t1, t2, L->top, 1); /* call TM */ return !l_isfalse(L->top); } -void luaV_concat (lua_State *L, int total, int last) { +void luaV_concat (lua_State *L, int total) { + lua_assert(total >= 2); do { - StkId top = L->base + last + 1; + StkId top = L->top; int n = 2; /* number of elements handled in this pass (at least 2) */ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); - } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ - (void)tostring(L, top - 2); /* result is first op (as string) */ + } + else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ + (void)tostring(L, top - 2); /* result is first operand */ + else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { + setobjs2s(L, top - 2, top - 1); /* result is second op. */ + } else { - /* at least two string values; get as many as possible */ + /* at least two non-empty string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; int i; /* collect total length */ - for (n = 1; n < total && tostring(L, top-n-1); n++) { - size_t l = tsvalue(top-n-1)->len; - if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + for (i = 1; i < total && tostring(L, top-i-1); i++) { + size_t l = tsvalue(top-i-1)->len; + if (l >= (MAX_SIZET/sizeof(char)) - tl) + luaG_runerror(L, "string length overflow"); tl += l; } buffer = luaZ_openspace(L, &G(L)->buff, tl); tl = 0; - for (i=n; i>0; i--) { /* concat all strings */ + n = i; + do { /* concat all strings */ size_t l = tsvalue(top-i)->len; - memcpy(buffer+tl, svalue(top-i), l); + memcpy(buffer+tl, svalue(top-i), l * sizeof(char)); tl += l; - } + } while (--i > 0); setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); } - total -= n-1; /* got `n' strings to create 1 new */ - last -= n-1; + total -= n-1; /* got 'n' strings to create 1 new */ + L->top -= n-1; /* popped 'n' strings and pushed one */ } while (total > 1); /* repeat until only 1 result left */ } -static void Arith (lua_State *L, StkId ra, const TValue *rb, - const TValue *rc, TMS op) { +void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { + const TValue *tm; + switch (ttypenv(rb)) { + case LUA_TTABLE: { + Table *h = hvalue(rb); + tm = fasttm(L, h->metatable, TM_LEN); + if (tm) break; /* metamethod? break switch to call it */ + setnvalue(ra, cast_num(luaH_getn(h))); /* else primitive len */ + return; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + return; + } + default: { /* try metamethod */ + tm = luaT_gettmbyobj(L, rb, TM_LEN); + if (ttisnil(tm)) /* no metamethod? */ + luaG_typeerror(L, rb, "get length of"); + break; + } + } + callTM(L, tm, rb, rb, ra, 1); +} + + +void luaV_arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { TValue tempb, tempc; const TValue *b, *c; if ((b = luaV_tonumber(rb, &tempb)) != NULL && (c = luaV_tonumber(rc, &tempc)) != NULL) { - lua_Number nb = nvalue(b), nc = nvalue(c); - switch (op) { - case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; - case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; - case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; - case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; - case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; - case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; - case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; - default: lua_assert(0); break; - } + lua_Number res = luaO_arith(op - TM_ADD + LUA_OPADD, nvalue(b), nvalue(c)); + setnvalue(ra, res); } else if (!call_binTM(L, rb, rc, ra, op)) luaG_aritherror(L, rb, rc); } +/* +** check whether cached closure in prototype 'p' may be reused, that is, +** whether there is a cached closure with the same upvalues needed by +** new closure to be created. +*/ +static Closure *getcached (Proto *p, UpVal **encup, StkId base) { + Closure *c = p->cache; + if (c != NULL) { /* is there a cached closure? */ + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ + TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; + if (c->l.upvals[i]->v != v) + return NULL; /* wrong upvalue; cannot reuse closure */ + } + } + return c; /* return cached closure (or NULL if no cached closure) */ +} + + +/* +** create a new Lua closure, push it in the stack, and initialize +** its upvalues. Note that the call to 'luaC_barrierproto' must come +** before the assignment to 'p->cache', as the function needs the +** original value of that field. +*/ +static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, + StkId ra) { + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + Closure *ncl = luaF_newLclosure(L, nup); + ncl->l.p = p; + setclLvalue(L, ra, ncl); /* anchor new closure in stack */ + for (i = 0; i < nup; i++) { /* fill in its upvalues */ + if (uv[i].instack) /* upvalue refers to local variable? */ + ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); + else /* get upvalue from enclosing function */ + ncl->l.upvals[i] = encup[uv[i].idx]; + } + luaC_barrierproto(L, p, ncl); + p->cache = ncl; /* save it on cache for reuse */ +} + + +/* +** finish execution of an opcode interrupted by an yield +*/ +void luaV_finishOp (lua_State *L) { + CallInfo *ci = L->ci; + StkId base = ci->u.l.base; + Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ + OpCode op = GET_OPCODE(inst); + switch (op) { /* finish its execution */ + case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: + case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN: + case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { + setobjs2s(L, base + GETARG_A(inst), --L->top); + break; + } + case OP_LE: case OP_LT: case OP_EQ: { + int res = !l_isfalse(L->top - 1); + L->top--; + /* metamethod should not be called when operand is K */ + lua_assert(!ISK(GETARG_B(inst))); + if (op == OP_LE && /* "<=" using "<" instead? */ + ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) + res = !res; /* invert result */ + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); + if (res != GETARG_A(inst)) /* condition failed? */ + ci->u.l.savedpc++; /* skip jump instruction */ + break; + } + case OP_CONCAT: { + StkId top = L->top - 1; /* top when 'call_binTM' was called */ + int b = GETARG_B(inst); /* first element to concatenate */ + int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ + setobj2s(L, top - 2, top); /* put TM result in proper position */ + if (total > 1) { /* are there elements to concat? */ + L->top = top - 1; /* top is one after last element (at top-2) */ + luaV_concat(L, total); /* concat them (may yield again) */ + } + /* move final result to final position */ + setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); + L->top = ci->top; /* restore top */ + break; + } + case OP_TFORCALL: { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP); + L->top = ci->top; /* correct top */ + break; + } + case OP_CALL: { + if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */ + L->top = ci->top; /* adjust results */ + break; + } + case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: + break; + default: lua_assert(0); + } +} + + /* ** some macros for common tasks in `luaV_execute' */ -#define runtime_check(L, c) { if (!(c)) break; } +#if !defined luai_runtimecheck +#define luai_runtimecheck(L, c) /* void */ +#endif + #define RA(i) (base+GETARG_A(i)) /* to be used after possible stack reallocation */ @@ -348,13 +494,27 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb, ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) #define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) -#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) +#define KBx(i) \ + (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++))) -#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} +/* execute a jump instruction */ +#define dojump(ci,i,e) \ + { int a = GETARG_A(i); \ + if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \ + ci->u.l.savedpc += GETARG_sBx(i) + e; } + +/* for test instructions, execute the jump instruction that follows it */ +#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } -#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } +#define Protect(x) { {x;}; base = ci->u.l.base; } + +#define checkGC(L,c) \ + Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \ + luaC_step(L); \ + L->top = ci->top;}) /* restore top */ \ + luai_threadyield(L); ) #define arith_op(op,tm) { \ @@ -362,401 +522,345 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb, TValue *rc = RKC(i); \ if (ttisnumber(rb) && ttisnumber(rc)) { \ lua_Number nb = nvalue(rb), nc = nvalue(rc); \ - setnvalue(ra, op(nb, nc)); \ + setnvalue(ra, op(L, nb, nc)); \ } \ - else \ - Protect(Arith(L, ra, rb, rc, tm)); \ - } + else { Protect(luaV_arith(L, ra, rb, rc, tm)); } } +#define vmdispatch(o) switch(o) +#define vmcase(l,b) case l: {b} break; +#define vmcasenb(l,b) case l: {b} /* nb = no break */ -void luaV_execute (lua_State *L, int nexeccalls) { +void luaV_execute (lua_State *L) { + CallInfo *ci = L->ci; LClosure *cl; - StkId base; TValue *k; - const Instruction *pc; - reentry: /* entry point */ - lua_assert(isLua(L->ci)); - pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; - base = L->base; + StkId base; + newframe: /* reentry point when frame changes (call/return) */ + lua_assert(ci == L->ci); + cl = clLvalue(ci->func); k = cl->p->k; + base = ci->u.l.base; /* main loop of interpreter */ for (;;) { - const Instruction i = *pc++; + Instruction i = *(ci->u.l.savedpc++); StkId ra; if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { - traceexec(L, pc); - if (L->status == LUA_YIELD) { /* did hook yield? */ - L->savedpc = pc - 1; - return; - } - base = L->base; + Protect(traceexec(L)); } - /* warning!! several calls may realloc the stack and invalidate `ra' */ + /* WARNING: several calls may realloc the stack and invalidate `ra' */ ra = RA(i); - lua_assert(base == L->base && L->base == L->ci->base); - lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); - lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); - switch (GET_OPCODE(i)) { - case OP_MOVE: { + lua_assert(base == ci->u.l.base); + lua_assert(base <= L->top && L->top < L->stack + L->stacksize); + vmdispatch (GET_OPCODE(i)) { + vmcase(OP_MOVE, setobjs2s(L, ra, RB(i)); - continue; - } - case OP_LOADK: { - setobj2s(L, ra, KBx(i)); - continue; - } - case OP_LOADBOOL: { + ) + vmcase(OP_LOADK, + TValue *rb = k + GETARG_Bx(i); + setobj2s(L, ra, rb); + ) + vmcase(OP_LOADKX, + TValue *rb; + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + rb = k + GETARG_Ax(*ci->u.l.savedpc++); + setobj2s(L, ra, rb); + ) + vmcase(OP_LOADBOOL, setbvalue(ra, GETARG_B(i)); - if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ - continue; - } - case OP_LOADNIL: { - TValue *rb = RB(i); + if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ + ) + vmcase(OP_LOADNIL, + int b = GETARG_B(i); do { - setnilvalue(rb--); - } while (rb >= ra); - continue; - } - case OP_GETUPVAL: { + setnilvalue(ra++); + } while (b--); + ) + vmcase(OP_GETUPVAL, int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); - continue; - } - case OP_GETGLOBAL: { - TValue g; - TValue *rb = KBx(i); - sethvalue(L, &g, cl->env); - lua_assert(ttisstring(rb)); - Protect(luaV_gettable(L, &g, rb, ra)); - continue; - } - case OP_GETTABLE: { + ) + vmcase(OP_GETTABUP, + int b = GETARG_B(i); + Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); + ) + vmcase(OP_GETTABLE, Protect(luaV_gettable(L, RB(i), RKC(i), ra)); - continue; - } - case OP_SETGLOBAL: { - TValue g; - sethvalue(L, &g, cl->env); - lua_assert(ttisstring(KBx(i))); - Protect(luaV_settable(L, &g, KBx(i), ra)); - continue; - } - case OP_SETUPVAL: { + ) + vmcase(OP_SETTABUP, + int a = GETARG_A(i); + Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); + ) + vmcase(OP_SETUPVAL, UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, ra); luaC_barrier(L, uv, ra); - continue; - } - case OP_SETTABLE: { + ) + vmcase(OP_SETTABLE, Protect(luaV_settable(L, ra, RKB(i), RKC(i))); - continue; - } - case OP_NEWTABLE: { + ) + vmcase(OP_NEWTABLE, int b = GETARG_B(i); int c = GETARG_C(i); - sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); - Protect(luaC_checkGC(L)); - continue; - } - case OP_SELF: { + Table *t = luaH_new(L); + sethvalue(L, ra, t); + if (b != 0 || c != 0) + luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); + checkGC(L, ra + 1); + ) + vmcase(OP_SELF, StkId rb = RB(i); setobjs2s(L, ra+1, rb); Protect(luaV_gettable(L, rb, RKC(i), ra)); - continue; - } - case OP_ADD: { + ) + vmcase(OP_ADD, arith_op(luai_numadd, TM_ADD); - continue; - } - case OP_SUB: { + ) + vmcase(OP_SUB, arith_op(luai_numsub, TM_SUB); - continue; - } - case OP_MUL: { + ) + vmcase(OP_MUL, arith_op(luai_nummul, TM_MUL); - continue; - } - case OP_DIV: { + ) + vmcase(OP_DIV, arith_op(luai_numdiv, TM_DIV); - continue; - } - case OP_MOD: { + ) + vmcase(OP_MOD, arith_op(luai_nummod, TM_MOD); - continue; - } - case OP_POW: { + ) + vmcase(OP_POW, arith_op(luai_numpow, TM_POW); - continue; - } - case OP_UNM: { + ) + vmcase(OP_UNM, TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Number nb = nvalue(rb); - setnvalue(ra, luai_numunm(nb)); + setnvalue(ra, luai_numunm(L, nb)); } else { - Protect(Arith(L, ra, rb, rb, TM_UNM)); + Protect(luaV_arith(L, ra, rb, rb, TM_UNM)); } - continue; - } - case OP_NOT: { - int res = l_isfalse(RB(i)); /* next assignment may change this value */ + ) + vmcase(OP_NOT, + TValue *rb = RB(i); + int res = l_isfalse(rb); /* next assignment may change this value */ setbvalue(ra, res); - continue; - } - case OP_LEN: { - const TValue *rb = RB(i); - switch (ttype(rb)) { - case LUA_TTABLE: { - setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); - break; - } - case LUA_TSTRING: { - setnvalue(ra, cast_num(tsvalue(rb)->len)); - break; - } - default: { /* try metamethod */ - Protect( - if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) - luaG_typeerror(L, rb, "get length of"); - ) - } - } - continue; - } - case OP_CONCAT: { + ) + vmcase(OP_LEN, + Protect(luaV_objlen(L, ra, RB(i))); + ) + vmcase(OP_CONCAT, int b = GETARG_B(i); int c = GETARG_C(i); - Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); - setobjs2s(L, RA(i), base+b); - continue; - } - case OP_JMP: { - dojump(L, pc, GETARG_sBx(i)); - continue; - } - case OP_EQ: { + StkId rb; + L->top = base + c + 1; /* mark the end of concat operands */ + Protect(luaV_concat(L, c - b + 1)); + ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ + rb = b + base; + setobjs2s(L, ra, rb); + checkGC(L, (ra >= rb ? ra + 1 : rb)); + L->top = ci->top; /* restore top */ + ) + vmcase(OP_JMP, + dojump(ci, i, 0); + ) + vmcase(OP_EQ, TValue *rb = RKB(i); TValue *rc = RKC(i); Protect( - if (equalobj(L, rb, rc) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); + if (cast_int(equalobj(L, rb, rc)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); ) - pc++; - continue; - } - case OP_LT: { + ) + vmcase(OP_LT, Protect( - if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); + if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); ) - pc++; - continue; - } - case OP_LE: { + ) + vmcase(OP_LE, Protect( - if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) - dojump(L, pc, GETARG_sBx(*pc)); + if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); ) - pc++; - continue; - } - case OP_TEST: { - if (l_isfalse(ra) != GETARG_C(i)) - dojump(L, pc, GETARG_sBx(*pc)); - pc++; - continue; - } - case OP_TESTSET: { + ) + vmcase(OP_TEST, + if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + vmcase(OP_TESTSET, TValue *rb = RB(i); - if (l_isfalse(rb) != GETARG_C(i)) { + if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) + ci->u.l.savedpc++; + else { setobjs2s(L, ra, rb); - dojump(L, pc, GETARG_sBx(*pc)); + donextjump(ci); } - pc++; - continue; - } - case OP_CALL: { + ) + vmcase(OP_CALL, int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; if (b != 0) L->top = ra+b; /* else previous instruction set top */ - L->savedpc = pc; - switch (luaD_precall(L, ra, nresults)) { - case PCRLUA: { - nexeccalls++; - goto reentry; /* restart luaV_execute over new Lua function */ - } - case PCRC: { - /* it was a C function (`precall' called it); adjust results */ - if (nresults >= 0) L->top = L->ci->top; - base = L->base; - continue; - } - default: { - return; /* yield */ - } + if (luaD_precall(L, ra, nresults)) { /* C function? */ + if (nresults >= 0) L->top = ci->top; /* adjust results */ + base = ci->u.l.base; } - } - case OP_TAILCALL: { + else { /* Lua function */ + ci = L->ci; + ci->callstatus |= CIST_REENTRY; + goto newframe; /* restart luaV_execute over new Lua function */ + } + ) + vmcase(OP_TAILCALL, int b = GETARG_B(i); if (b != 0) L->top = ra+b; /* else previous instruction set top */ - L->savedpc = pc; lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); - switch (luaD_precall(L, ra, LUA_MULTRET)) { - case PCRLUA: { - /* tail call: put new frame in place of previous one */ - CallInfo *ci = L->ci - 1; /* previous frame */ - int aux; - StkId func = ci->func; - StkId pfunc = (ci+1)->func; /* previous function index */ - if (L->openupval) luaF_close(L, ci->base); - L->base = ci->base = ci->func + ((ci+1)->base - pfunc); - for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ - setobjs2s(L, func+aux, pfunc+aux); - ci->top = L->top = func+aux; /* correct top */ - lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); - ci->savedpc = L->savedpc; - ci->tailcalls++; /* one more call lost */ - L->ci--; /* remove new frame */ - goto reentry; - } - case PCRC: { /* it was a C function (`precall' called it) */ - base = L->base; - continue; - } - default: { - return; /* yield */ - } + if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ + base = ci->u.l.base; + else { + /* tail call: put called frame (n) in place of caller one (o) */ + CallInfo *nci = L->ci; /* called frame */ + CallInfo *oci = nci->previous; /* caller frame */ + StkId nfunc = nci->func; /* called function */ + StkId ofunc = oci->func; /* caller function */ + /* last stack slot filled by 'precall' */ + StkId lim = nci->u.l.base + getproto(nfunc)->numparams; + int aux; + /* close all upvalues from previous call */ + if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); + /* move new frame into old one */ + for (aux = 0; nfunc + aux < lim; aux++) + setobjs2s(L, ofunc + aux, nfunc + aux); + oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ + oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ + oci->u.l.savedpc = nci->u.l.savedpc; + oci->callstatus |= CIST_TAIL; /* function was tail called */ + ci = L->ci = oci; /* remove new frame */ + lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); + goto newframe; /* restart luaV_execute over new Lua function */ } - } - case OP_RETURN: { + ) + vmcasenb(OP_RETURN, int b = GETARG_B(i); if (b != 0) L->top = ra+b-1; - if (L->openupval) luaF_close(L, base); - L->savedpc = pc; + if (cl->p->sizep > 0) luaF_close(L, base); b = luaD_poscall(L, ra); - if (--nexeccalls == 0) /* was previous function running `here'? */ - return; /* no: return */ - else { /* yes: continue its execution */ - if (b) L->top = L->ci->top; - lua_assert(isLua(L->ci)); - lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); - goto reentry; + if (!(ci->callstatus & CIST_REENTRY)) /* 'ci' still the called one */ + return; /* external invocation: return */ + else { /* invocation via reentry: continue execution */ + ci = L->ci; + if (b) L->top = ci->top; + lua_assert(isLua(ci)); + lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); + goto newframe; /* restart luaV_execute over new Lua function */ } - } - case OP_FORLOOP: { + ) + vmcase(OP_FORLOOP, lua_Number step = nvalue(ra+2); - lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ lua_Number limit = nvalue(ra+1); - if (luai_numlt(0, step) ? luai_numle(idx, limit) - : luai_numle(limit, idx)) { - dojump(L, pc, GETARG_sBx(i)); /* jump back */ + if (luai_numlt(L, 0, step) ? luai_numle(L, idx, limit) + : luai_numle(L, limit, idx)) { + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ setnvalue(ra, idx); /* update internal index... */ setnvalue(ra+3, idx); /* ...and external index */ } - continue; - } - case OP_FORPREP: { + ) + vmcase(OP_FORPREP, const TValue *init = ra; const TValue *plimit = ra+1; const TValue *pstep = ra+2; - L->savedpc = pc; /* next steps may throw errors */ if (!tonumber(init, ra)) luaG_runerror(L, LUA_QL("for") " initial value must be a number"); else if (!tonumber(plimit, ra+1)) luaG_runerror(L, LUA_QL("for") " limit must be a number"); else if (!tonumber(pstep, ra+2)) luaG_runerror(L, LUA_QL("for") " step must be a number"); - setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); - dojump(L, pc, GETARG_sBx(i)); - continue; - } - case OP_TFORLOOP: { + setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); + ci->u.l.savedpc += GETARG_sBx(i); + ) + vmcasenb(OP_TFORCALL, StkId cb = ra + 3; /* call base */ setobjs2s(L, cb+2, ra+2); setobjs2s(L, cb+1, ra+1); setobjs2s(L, cb, ra); - L->top = cb+3; /* func. + 2 args (state and index) */ - Protect(luaD_call(L, cb, GETARG_C(i))); - L->top = L->ci->top; - cb = RA(i) + 3; /* previous call may change the stack */ - if (!ttisnil(cb)) { /* continue loop? */ - setobjs2s(L, cb-1, cb); /* save control variable */ - dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + L->top = cb + 3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i), 1)); + L->top = ci->top; + i = *(ci->u.l.savedpc++); /* go to next instruction */ + ra = RA(i); + lua_assert(GET_OPCODE(i) == OP_TFORLOOP); + goto l_tforloop; + ) + vmcase(OP_TFORLOOP, + l_tforloop: + if (!ttisnil(ra + 1)) { /* continue loop? */ + setobjs2s(L, ra, ra + 1); /* save control variable */ + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ } - pc++; - continue; - } - case OP_SETLIST: { + ) + vmcase(OP_SETLIST, int n = GETARG_B(i); int c = GETARG_C(i); int last; Table *h; - if (n == 0) { - n = cast_int(L->top - ra) - 1; - L->top = L->ci->top; + if (n == 0) n = cast_int(L->top - ra) - 1; + if (c == 0) { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + c = GETARG_Ax(*ci->u.l.savedpc++); } - if (c == 0) c = cast_int(*pc++); - runtime_check(L, ttistable(ra)); + luai_runtimecheck(L, ttistable(ra)); h = hvalue(ra); last = ((c-1)*LFIELDS_PER_FLUSH) + n; if (last > h->sizearray) /* needs more space? */ - luaH_resizearray(L, h, last); /* pre-alloc it at once */ + luaH_resizearray(L, h, last); /* pre-allocate it at once */ for (; n > 0; n--) { TValue *val = ra+n; - setobj2t(L, luaH_setnum(L, h, last--), val); - luaC_barriert(L, h, val); + luaH_setint(L, h, last--, val); + luaC_barrierback(L, obj2gco(h), val); } - continue; - } - case OP_CLOSE: { - luaF_close(L, ra); - continue; - } - case OP_CLOSURE: { - Proto *p; - Closure *ncl; - int nup, j; - p = cl->p->p[GETARG_Bx(i)]; - nup = p->nups; - ncl = luaF_newLclosure(L, nup, cl->env); - ncl->l.p = p; - for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; - else { - lua_assert(GET_OPCODE(*pc) == OP_MOVE); - ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); - } - } - setclvalue(L, ra, ncl); - Protect(luaC_checkGC(L)); - continue; - } - case OP_VARARG: { + L->top = ci->top; /* correct top (in case of previous open call) */ + ) + vmcase(OP_CLOSURE, + Proto *p = cl->p->p[GETARG_Bx(i)]; + Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */ + if (ncl == NULL) /* no match? */ + pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ + else + setclLvalue(L, ra, ncl); /* push cashed closure */ + checkGC(L, ra + 1); + ) + vmcase(OP_VARARG, int b = GETARG_B(i) - 1; int j; - CallInfo *ci = L->ci; - int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; - if (b == LUA_MULTRET) { + int n = cast_int(base - ci->func) - cl->p->numparams - 1; + if (b < 0) { /* B == 0? */ + b = n; /* get all var. arguments */ Protect(luaD_checkstack(L, n)); ra = RA(i); /* previous call may change the stack */ - b = n; L->top = ra + n; } for (j = 0; j < b; j++) { if (j < n) { - setobjs2s(L, ra + j, ci->base - n + j); + setobjs2s(L, ra + j, base - n + j); } else { setnilvalue(ra + j); } } - continue; - } + ) + vmcase(OP_EXTRAARG, + lua_assert(0); + ) } } } diff --git a/src/mod/languages/mod_lua/lua/lvm.h b/src/mod/languages/mod_lua/lua/lvm.h index bfe4f5678d..07e25f9c64 100644 --- a/src/mod/languages/mod_lua/lua/lvm.h +++ b/src/mod/languages/mod_lua/lua/lvm.h @@ -1,5 +1,5 @@ /* -** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lvm.h,v 2.18 2013/01/08 14:06:55 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -13,24 +13,32 @@ #include "ltm.h" -#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) +#define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) -#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ - (((o) = luaV_tonumber(o,n)) != NULL)) +#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) -#define equalobj(L,o1,o2) \ - (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) +#define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) + +#define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) + + +/* not to called directly */ +LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val); LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val); -LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); -LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); +LUAI_FUNC void luaV_finishOp (lua_State *L); +LUAI_FUNC void luaV_execute (lua_State *L); +LUAI_FUNC void luaV_concat (lua_State *L, int total); +LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op); +LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); #endif diff --git a/src/mod/languages/mod_lua/lua/lzio.c b/src/mod/languages/mod_lua/lua/lzio.c index 293edd59b0..8b77054e0b 100644 --- a/src/mod/languages/mod_lua/lua/lzio.c +++ b/src/mod/languages/mod_lua/lua/lzio.c @@ -1,6 +1,6 @@ /* -** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ -** a generic input stream interface +** $Id: lzio.c,v 1.35 2012/05/14 13:34:18 roberto Exp $ +** Buffered streams ** See Copyright Notice in lua.h */ @@ -25,23 +25,11 @@ int luaZ_fill (ZIO *z) { lua_unlock(L); buff = z->reader(L, z->data, &size); lua_lock(L); - if (buff == NULL || size == 0) return EOZ; - z->n = size - 1; + if (buff == NULL || size == 0) + return EOZ; + z->n = size - 1; /* discount char being returned */ z->p = buff; - return char2int(*(z->p++)); -} - - -int luaZ_lookahead (ZIO *z) { - if (z->n == 0) { - if (luaZ_fill(z) == EOZ) - return EOZ; - else { - z->n++; /* luaZ_fill removed first byte; put back it */ - z->p--; - } - } - return char2int(*z->p); + return cast_uchar(*(z->p++)); } @@ -58,8 +46,14 @@ void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { size_t luaZ_read (ZIO *z, void *b, size_t n) { while (n) { size_t m; - if (luaZ_lookahead(z) == EOZ) - return n; /* return number of missing bytes */ + if (z->n == 0) { /* no bytes in buffer? */ + if (luaZ_fill(z) == EOZ) /* try to read more */ + return n; /* no more input; return number of missing bytes */ + else { + z->n++; /* luaZ_fill consumed first byte; put it back */ + z->p--; + } + } m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ memcpy(b, z->p, m); z->n -= m; diff --git a/src/mod/languages/mod_lua/lua/lzio.h b/src/mod/languages/mod_lua/lua/lzio.h index 51d695d8c1..08682301e8 100644 --- a/src/mod/languages/mod_lua/lua/lzio.h +++ b/src/mod/languages/mod_lua/lua/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lzio.h,v 1.26 2011/07/15 12:48:03 roberto Exp $ ** Buffered streams ** See Copyright Notice in lua.h */ @@ -17,9 +17,8 @@ typedef struct Zio ZIO; -#define char2int(c) cast(int, cast(unsigned char, (c))) +#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) -#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) typedef struct Mbuffer { char *buffer; @@ -47,7 +46,6 @@ LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data); LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ -LUAI_FUNC int luaZ_lookahead (ZIO *z); @@ -56,7 +54,7 @@ LUAI_FUNC int luaZ_lookahead (ZIO *z); struct Zio { size_t n; /* bytes still unread */ const char *p; /* current position in buffer */ - lua_Reader reader; + lua_Reader reader; /* reader function */ void* data; /* additional data */ lua_State *L; /* Lua state (for reader) */ }; diff --git a/src/mod/languages/mod_lua/mod_lua.2012.vcxproj b/src/mod/languages/mod_lua/mod_lua.2012.vcxproj index c1261f9167..30ba641933 100644 --- a/src/mod/languages/mod_lua/mod_lua.2012.vcxproj +++ b/src/mod/languages/mod_lua/mod_lua.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -135,7 +135,12 @@ - + + 4244;4127; 4505;%(DisableSpecificWarnings) + 4244;4127; 4505;%(DisableSpecificWarnings) + 4244;4127; 4505;%(DisableSpecificWarnings) + 4244;4127; 4505;%(DisableSpecificWarnings) + 6385;%(DisableSpecificWarnings) diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp index a21643bc97..95e6adbc9f 100644 --- a/src/mod/languages/mod_lua/mod_lua.cpp +++ b/src/mod/languages/mod_lua/mod_lua.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -45,7 +45,6 @@ SWITCH_MODULE_DEFINITION_EX(mod_lua, mod_lua_load, mod_lua_shutdown, NULL, SMODF static struct { switch_memory_pool_t *pool; char *xml_handler; - switch_event_node_t *node; } globals; int luaopen_freeswitch(lua_State * L); @@ -66,7 +65,7 @@ static void lua_uninit(lua_State * L) static int traceback(lua_State * L) { - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + lua_getglobal(L, "debug"); if (!lua_istable(L, -1)) { lua_pop(L, 1); return 1; @@ -82,7 +81,7 @@ static int traceback(lua_State * L) return 1; } -int docall(lua_State * L, int narg, int nresults, int perror) +int docall(lua_State * L, int narg, int nresults, int perror, int fatal) { int status; int base = lua_gettop(L) - narg; /* function index */ @@ -103,9 +102,13 @@ int docall(lua_State * L, int narg, int nresults, int perror) if (!zstr(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err); } - //lua_pop(L, 1); /* pop error message from the stack */ + // pass error up to top - lua_error(L); + if (fatal) { + lua_error(L); + } else { + lua_pop(L, 1); /* pop error message from the stack */ + } } return status; @@ -114,7 +117,7 @@ int docall(lua_State * L, int narg, int nresults, int perror) static lua_State *lua_init(void) { - lua_State *L = lua_open(); + lua_State *L = luaL_newstate(); int error = 0; if (L) { @@ -124,7 +127,7 @@ static lua_State *lua_init(void) luaopen_freeswitch(L); lua_gc(L, LUA_GCRESTART, 0); lua_atpanic(L, panic); - error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0); + error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0, 1); } return L; } @@ -143,10 +146,10 @@ static int lua_parse_and_execute(lua_State * L, char *input_code) if (*input_code == '~') { char *buff = input_code + 1; - error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0); //lua_pcall(L, 0, 0, 0); + error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0, 1); //lua_pcall(L, 0, 0, 0); } else if (!strncasecmp(input_code, "#!/lua", 6)) { char *buff = input_code + 6; - error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0); //lua_pcall(L, 0, 0, 0); + error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0, 1); //lua_pcall(L, 0, 0, 0); } else { char *args = strchr(input_code, ' '); if (args) { @@ -170,14 +173,14 @@ static int lua_parse_and_execute(lua_State * L, char *input_code) } if (code) { - error = luaL_loadbuffer(L, code, strlen(code), "line") || docall(L, 0, 0, 0); + error = luaL_loadbuffer(L, code, strlen(code), "line") || docall(L, 0, 0, 0, 1); switch_safe_free(code); } } else { // Force empty argv table char *code = NULL; code = switch_mprintf("argv = {[0]='%s'};", input_code); - error = luaL_loadbuffer(L, code, strlen(code), "line") || docall(L, 0, 0, 0); + error = luaL_loadbuffer(L, code, strlen(code), "line") || docall(L, 0, 0, 0, 1); switch_safe_free(code); } @@ -189,7 +192,7 @@ static int lua_parse_and_execute(lua_State * L, char *input_code) switch_assert(fdup); file = fdup; } - error = luaL_loadfile(L, file) || docall(L, 0, 0, 0); + error = luaL_loadfile(L, file) || docall(L, 0, 0, 0, 1); switch_safe_free(fdup); } } @@ -267,7 +270,7 @@ static switch_xml_t lua_fetch(const char *section, return NULL; } - lua_getfield(L, LUA_GLOBALSINDEX, "XML_STRING"); + lua_getglobal(L, "XML_STRING"); str = lua_tostring(L, 1); if (str) { @@ -339,12 +342,16 @@ static switch_status_t do_config(void) char *script = (char *) switch_xml_attr_soft(hook, "script"); switch_event_types_t evtype; + if (!zstr(script)) { + script = switch_core_strdup(globals.pool, script); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "hook params: '%s' | '%s' | '%s'\n", event, subclass, script); if (switch_name_event(event,&evtype) == SWITCH_STATUS_SUCCESS) { if (!zstr(script)) { - if (switch_event_bind_removable(modname, evtype, !zstr(subclass) ? subclass : SWITCH_EVENT_SUBCLASS_ANY, - lua_event_handler, script, &globals.node) == SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, evtype, !zstr(subclass) ? subclass : SWITCH_EVENT_SUBCLASS_ANY, + lua_event_handler, script) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "event handler for '%s' set to '%s'\n", switch_event_name(evtype), script); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set event handler: unsuccessful bind\n"); @@ -578,7 +585,7 @@ SWITCH_STANDARD_DIALPLAN(lua_dialplan_hunt) lua_parse_and_execute(L, cmd); /* expecting ACTIONS = { {"app1", "app_data1"}, { "app2" }, "app3" } -- each of three is valid */ - lua_getfield(L, LUA_GLOBALSINDEX, "ACTIONS"); + lua_getglobal(L, "ACTIONS"); if (!lua_istable(L, 1)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Global variable ACTIONS may only be a table\n"); @@ -691,7 +698,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown) { - switch_event_unbind(&globals.node); + switch_event_unbind_callback(lua_event_handler); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 591cef641a..21e22ed53d 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -6299,10 +6299,10 @@ static int _wrap_msleep(lua_State* L) { int SWIG_arg = -1; unsigned int arg1 ; - SWIG_check_num_args("msleep",1,1) - if(!lua_isnumber(L,1)) SWIG_fail_arg("msleep",1,"unsigned int"); + SWIG_check_num_args("switch_msleep",1,1) + if(!lua_isnumber(L,1)) SWIG_fail_arg("switch_msleep",1,"unsigned int"); arg1 = (unsigned int)lua_tonumber(L, 1); - msleep(arg1); + switch_msleep(arg1); SWIG_arg=0; return SWIG_arg; @@ -7913,7 +7913,7 @@ static swig_lua_class _wrap_class_LUA_Dbh = { "Dbh", &SWIGTYPE_p_LUA__Dbh,_wrap_ } #endif -static const struct luaL_reg swig_commands[] = { +static const struct luaL_Reg swig_commands[] = { { "setGlobalVariable", _wrap_setGlobalVariable}, { "getGlobalVariable", _wrap_getGlobalVariable}, { "consoleLog", _wrap_consoleLog}, @@ -8325,7 +8325,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) { int i; /* start with global table */ - lua_pushvalue(L,LUA_GLOBALSINDEX); + lua_pushglobaltable(L); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); diff --git a/src/mod/languages/mod_managed/Makefile b/src/mod/languages/mod_managed/Makefile index ec44ff5131..4a34afbc8f 100644 --- a/src/mod/languages/mod_managed/Makefile +++ b/src/mod/languages/mod_managed/Makefile @@ -34,7 +34,7 @@ swigclean: clean rm -f freeswitch_wrap.cxx freeswitch_wrap.cpp managed/swig.cs freeswitch_wrap.cxx: - swig -I../../../include -v -O -c++ -csharp -namespace FreeSWITCH.Native -dllimport mod_managed -DSWIG_CSHARP_NO_STRING_HELPER freeswitch.i + swig2.0 -I../../../include -v -O -c++ -csharp -namespace FreeSWITCH.Native -dllimport mod_managed -DSWIG_CSHARP_NO_STRING_HELPER freeswitch.i rm -f ./managed/swig.cs cat *.cs > ./managed/swig.cs rm -f *.cs diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx index 9afb1d2758..ec672e735f 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx @@ -1930,6 +1930,56 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_TRANS_get() { } +SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get() { + int jresult ; + int result; + + result = (int)(2); + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_JITTER_VARIANCE_THRESHOLD_get() { + double jresult ; + double result; + + result = (double)(400.0); + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_IPDV_THRESHOLD_get() { + double jresult ; + double result; + + result = (double)(1.0); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_LOST_BURST_ANALYZE_get() { + int jresult ; + int result; + + result = (int)(500); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_LOST_BURST_CAPTURE_get() { + int jresult ; + int result; + + result = (int)(1024); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_digit_set(void * jarg1, char jarg2) { switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ; char arg2 ; @@ -3320,6 +3370,440 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_largest_jb_size_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_proc_time_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->last_proc_time = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_proc_time_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->last_proc_time); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_n_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_n = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_n_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_n); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_add_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_add = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_add_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_add); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_addsq_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_addsq = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_addsq_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_addsq); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_min_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->min_variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_min_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->min_variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_max_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->max_variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_max_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->max_variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_std_deviation_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->std_deviation = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_std_deviation_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->std_deviation); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_lossrate_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->lossrate = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_lossrate_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->lossrate); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_burstrate_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->burstrate = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_burstrate_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->burstrate); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_mean_interval_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->mean_interval = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_mean_interval_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->mean_interval); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_loss_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int *arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int *)jarg2; + { + size_t ii; + int *b = (int *) arg1->loss; + for (ii = 0; ii < (size_t)1024; ii++) b[ii] = *((int *) arg2 + ii); + } +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_loss_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int *result = 0 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int *)(int *) ((arg1)->loss); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_loss_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->last_loss = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_loss_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->last_loss); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_recved_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->recved = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_recved_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->recved); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_processed_seq_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->last_processed_seq = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_processed_seq_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->last_processed_seq); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_flaws_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->flaws = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_flaws_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = ((arg1)->flaws); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_flaw_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->last_flaw = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_flaw_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = ((arg1)->last_flaw); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_R_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->R = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_R_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->R); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_mos_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->mos = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_mos_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->mos); + jresult = result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtp_numbers_t() { void * jresult ; switch_rtp_numbers_t *result = 0 ; @@ -6320,6 +6804,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_thread_data_t_alloc_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_pool_set(void * jarg1, void * jarg2) { + switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; + + arg1 = (switch_thread_data_t *)jarg1; + arg2 = (switch_memory_pool_t *)jarg2; + if (arg1) (arg1)->pool = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_pool_get(void * jarg1) { + void * jresult ; + switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_memory_pool_t *result = 0 ; + + arg1 = (switch_thread_data_t *)jarg1; + result = (switch_memory_pool_t *) ((arg1)->pool); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_thread_data_t() { void * jresult ; switch_thread_data_t *result = 0 ; @@ -6604,6 +7110,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_hup_profile_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_direction_set(void * jarg1, int jarg2) { + switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_device_node_t *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_node_t_direction_get(void * jarg1) { + int jresult ; + switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_device_node_t *)jarg1; + result = (switch_call_direction_t) ((arg1)->direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_parent_set(void * jarg1, void * jarg2) { switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; switch_device_record_s *arg2 = (switch_device_record_s *) 0 ; @@ -6688,6 +7216,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->total_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->total_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6710,6 +7282,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->offhook_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->offhook_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6732,6 +7348,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_get(voi } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->active_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->active_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6754,6 +7414,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->held_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->held_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6776,6 +7480,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->hup_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->hup_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6798,6 +7546,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ringing_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ringing_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6820,6 +7612,72 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->early_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->early_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ring_wait = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ring_wait); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_stats_t() { void * jresult ; switch_device_stats_t *result = 0 ; @@ -6942,6 +7800,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_stats_get(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_stats_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_stats_t *arg2 = (switch_device_stats_t *) 0 ; + + arg1 = (switch_device_record_t *)jarg1; + arg2 = (switch_device_stats_t *)jarg2; + if (arg1) (arg1)->last_stats = *arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_stats_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_stats_t *result = 0 ; + + arg1 = (switch_device_record_t *)jarg1; + result = (switch_device_stats_t *)& ((arg1)->last_stats); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_state_set(void * jarg1, int jarg2) { switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; switch_device_state_t arg2 ; @@ -7070,6 +7950,146 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_call_time_get(v } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->ring_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->ring_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->hold_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->hold_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_call_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->call_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_call_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->call_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_list_set(void * jarg1, void * jarg2) { switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; device_uuid_node_s *arg2 = (device_uuid_node_s *) 0 ; @@ -7158,6 +8178,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_pool_get(void * jarg } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_user_data_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (switch_device_record_t *)jarg1; + arg2 = (void *)jarg2; + if (arg1) (arg1)->user_data = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_user_data_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + void *result = 0 ; + + arg1 = (switch_device_record_t *)jarg1; + result = (void *) ((arg1)->user_data); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_record_t() { void * jresult ; switch_device_record_t *result = 0 ; @@ -8428,19 +9470,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_set_pre_buffer_framecoun } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_port_allocator_new(unsigned short jarg1, unsigned short jarg2, unsigned long jarg3, void * jarg4) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_port_allocator_new(char * jarg1, unsigned short jarg2, unsigned short jarg3, unsigned long jarg4, void * jarg5) { int jresult ; - switch_port_t arg1 ; + char *arg1 = (char *) 0 ; switch_port_t arg2 ; - switch_port_flag_t arg3 ; - switch_core_port_allocator_t **arg4 = (switch_core_port_allocator_t **) 0 ; + switch_port_t arg3 ; + switch_port_flag_t arg4 ; + switch_core_port_allocator_t **arg5 = (switch_core_port_allocator_t **) 0 ; switch_status_t result; - arg1 = (switch_port_t)jarg1; + arg1 = (char *)jarg1; arg2 = (switch_port_t)jarg2; - arg3 = (switch_port_flag_t)jarg3; - arg4 = (switch_core_port_allocator_t **)jarg4; - result = (switch_status_t)switch_core_port_allocator_new(arg1,arg2,arg3,arg4); + arg3 = (switch_port_t)jarg3; + arg4 = (switch_port_flag_t)jarg4; + arg5 = (switch_core_port_allocator_t **)jarg5; + result = (switch_status_t)switch_core_port_allocator_new((char const *)arg1,arg2,arg3,arg4,arg5); jresult = result; return jresult; } @@ -9436,6 +10480,18 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_switchname() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_domain(int jarg1) { + char * jresult ; + switch_bool_t arg1 ; + char *result = 0 ; + + arg1 = (switch_bool_t)jarg1; + result = (char *)switch_core_get_domain(arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_set_variable(char * jarg1, char * jarg2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -9722,6 +10778,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_exec(void * jarg1, void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_video_reset(void * jarg1) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + switch_core_session_video_reset(arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_get_flags(void * jarg1, char * jarg2, char * jarg3, void * jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -9802,27 +10866,31 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_receive_event(void * jarg1 } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_private(void * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_private_class(void * jarg1, int jarg2) { void * jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_pvt_class_t arg2 ; void *result = 0 ; arg1 = (switch_core_session_t *)jarg1; - result = (void *)switch_core_session_get_private(arg1); + arg2 = (switch_pvt_class_t)jarg2; + result = (void *)switch_core_session_get_private_class(arg1,arg2); jresult = (void *)result; return jresult; } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_private(void * jarg1, void * jarg2) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_private_class(void * jarg1, void * jarg2, int jarg3) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; void *arg2 = (void *) 0 ; + switch_pvt_class_t arg3 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (void *)jarg2; - result = (switch_status_t)switch_core_session_set_private(arg1,arg2); + arg3 = (switch_pvt_class_t)jarg3; + result = (switch_status_t)switch_core_session_set_private_class(arg1,arg2,arg3); jresult = result; return jresult; } @@ -11071,14 +12139,14 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_db_test_reactive(void * jarg1, ch } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, char * jarg2, int jarg3, void * jarg4, char * jarg5, unsigned char jarg6, unsigned long jarg7, unsigned int jarg8, void * jarg9) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, char * jarg2, int jarg3, void * jarg4, char * jarg5, unsigned long jarg6, unsigned long jarg7, unsigned int jarg8, void * jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; int arg3 ; switch_file_handle_t *arg4 = (switch_file_handle_t *) 0 ; char *arg5 = (char *) 0 ; - uint8_t arg6 ; + uint32_t arg6 ; uint32_t arg7 ; unsigned int arg8 ; switch_memory_pool_t *arg9 = (switch_memory_pool_t *) 0 ; @@ -11089,7 +12157,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, ch arg3 = (int)jarg3; arg4 = (switch_file_handle_t *)jarg4; arg5 = (char *)jarg5; - arg6 = (uint8_t)jarg6; + arg6 = (uint32_t)jarg6; arg7 = (uint32_t)jarg7; arg8 = (unsigned int)jarg8; arg9 = (switch_memory_pool_t *)jarg9; @@ -12149,9 +13217,9 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_monotonic(int jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_timerfd(int jarg1) { - switch_bool_t arg1 ; + int arg1 ; - arg1 = (switch_bool_t)jarg1; + arg1 = (int)jarg1; switch_time_set_timerfd(arg1); } @@ -13605,6 +14673,96 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_stream_system_fork(char * jarg1, void * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ice_direction(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_call_direction_t)switch_ice_direction(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_debug_pool(void * jarg1) { + switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ; + + arg1 = (switch_stream_handle_t *)jarg1; + switch_core_session_debug_pool(arg1); +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_major() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_major(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_minor() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_minor(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_micro() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_micro(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_revision() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_revision(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_revision_human() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_revision_human(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_full() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_full(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_full_human() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_full_human(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -13788,6 +14946,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interf } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_json_api_interface_set(void * jarg1, void * jarg2) { + switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; + switch_json_api_interface_t *arg2 = (switch_json_api_interface_t *) 0 ; + + arg1 = (switch_loadable_module_interface *)jarg1; + arg2 = (switch_json_api_interface_t *)jarg2; + if (arg1) (arg1)->json_api_interface = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_json_api_interface_get(void * jarg1) { + void * jresult ; + switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; + switch_json_api_interface_t *result = 0 ; + + arg1 = (switch_loadable_module_interface *)jarg1; + result = (switch_json_api_interface_t *) ((arg1)->json_api_interface); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_file_interface_set(void * jarg1, void * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; switch_file_interface_t *arg2 = (switch_file_interface_t *) 0 ; @@ -14233,6 +15413,18 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_api_interface(ch } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_json_api_interface(char * jarg1) { + void * jresult ; + char *arg1 = (char *) 0 ; + switch_json_api_interface_t *result = 0 ; + + arg1 = (char *)jarg1; + result = (switch_json_api_interface_t *)switch_loadable_module_get_json_api_interface((char const *)arg1); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_file_interface(char * jarg1) { void * jresult ; char *arg1 = (char *) 0 ; @@ -14379,6 +15571,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_api_execute(char * jarg1, char * jarg2, } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_json_api_execute(void * jarg1, void * jarg2, void * jarg3) { + int jresult ; + cJSON *arg1 = (cJSON *) 0 ; + switch_core_session_t *arg2 = (switch_core_session_t *) 0 ; + cJSON **arg3 = (cJSON **) 0 ; + switch_status_t result; + + arg1 = (cJSON *)jarg1; + arg2 = (switch_core_session_t *)jarg2; + arg3 = (cJSON **)jarg3; + result = (switch_status_t)switch_json_api_execute(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_load_module(char * jarg1, char * jarg2, int jarg3, void * jarg4) { int jresult ; char *arg1 = (char *) 0 ; @@ -14507,6 +15715,40 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_codec_ready(void * jarg1) { } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_get_secondary_recover_callback(char * jarg1) { + void * jresult ; + char *arg1 = (char *) 0 ; + switch_core_recover_callback_t result; + + arg1 = (char *)jarg1; + result = (switch_core_recover_callback_t)switch_core_get_secondary_recover_callback((char const *)arg1); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_register_secondary_recover_callback(char * jarg1, void * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_core_recover_callback_t arg2 = (switch_core_recover_callback_t) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_core_recover_callback_t)jarg2; + result = (switch_status_t)switch_core_register_secondary_recover_callback((char const *)arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_unregister_secondary_recover_callback(char * jarg1) { + char *arg1 = (char *) 0 ; + + arg1 = (char *)jarg1; + switch_core_unregister_secondary_recover_callback((char const *)arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CMD_CHUNK_LEN_get() { int jresult ; int result; @@ -14624,6 +15866,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_console_run_complete_func(char * jarg1, } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_push_match_unique(void * jarg1, char * jarg2) { + switch_console_callback_match_t **arg1 = (switch_console_callback_match_t **) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_console_callback_match_t **)jarg1; + arg2 = (char *)jarg2; + switch_console_push_match_unique(arg1,(char const *)arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_push_match(void * jarg1, char * jarg2) { switch_console_callback_match_t **arg1 = (switch_console_callback_match_t **) 0 ; char *arg2 = (char *) 0 ; @@ -15359,6 +16611,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_true(char * jarg1) { } +SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_true_byte(char * jarg1) { + unsigned char jresult ; + char *arg1 = (char *) 0 ; + switch_byte_t result; + + arg1 = (char *)jarg1; + result = (switch_byte_t)switch_true_byte((char const *)arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_false(char * jarg1) { int jresult ; char *arg1 = (char *) 0 ; @@ -15405,6 +16669,26 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_find_local_ip(char * jarg1, int jarg2, } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_find_interface_ip(char * jarg1, int jarg2, void * jarg3, char * jarg4, int jarg5) { + int jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + int *arg3 = (int *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (int *)jarg3; + arg4 = (char *)jarg4; + arg5 = (int)jarg5; + result = (switch_status_t)switch_find_interface_ip(arg1,arg2,arg3,(char const *)arg4,arg5); + jresult = result; + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_get_addr(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { char * jresult ; char *arg1 = (char *) 0 ; @@ -17483,6 +18767,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_direction_get(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_set(void * jarg1, int jarg2) { + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_caller_profile *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->logical_direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_get(void * jarg1) { + int jresult ; + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_caller_profile *)jarg1; + result = (switch_call_direction_t) ((arg1)->logical_direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_soft_set(void * jarg1, void * jarg2) { switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; profile_node_t *arg2 = (profile_node_t *) 0 ; @@ -18459,6 +19765,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_user_data_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_pmap_set(void * jarg1, void * jarg2) { + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *arg2 = (payload_map_t *) 0 ; + + arg1 = (switch_frame *)jarg1; + arg2 = (payload_map_t *)jarg2; + if (arg1) (arg1)->pmap = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_pmap_get(void * jarg1) { + void * jresult ; + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *result = 0 ; + + arg1 = (switch_frame *)jarg1; + result = (payload_map_t *) ((arg1)->pmap); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_frame() { void * jresult ; switch_frame *result = 0 ; @@ -20827,24 +22155,24 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_native_rate_get(v } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_channels_set(void * jarg1, unsigned char jarg2) { +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_channels_set(void * jarg1, unsigned long jarg2) { switch_file_handle *arg1 = (switch_file_handle *) 0 ; - uint8_t arg2 ; + uint32_t arg2 ; arg1 = (switch_file_handle *)jarg1; - arg2 = (uint8_t)jarg2; + arg2 = (uint32_t)jarg2; if (arg1) (arg1)->channels = arg2; } -SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_file_handle_channels_get(void * jarg1) { - unsigned char jresult ; +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_channels_get(void * jarg1) { + unsigned long jresult ; switch_file_handle *arg1 = (switch_file_handle *) 0 ; - uint8_t result; + uint32_t result; arg1 = (switch_file_handle *)jarg1; - result = (uint8_t) ((arg1)->channels); - jresult = result; + result = (uint32_t) ((arg1)->channels); + jresult = (unsigned long)result; return jresult; } @@ -21672,6 +23000,50 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle__params_get(void * jarg1 } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_channels_set(void * jarg1, unsigned long jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_file_handle *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->cur_channels = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_cur_channels_get(void * jarg1) { + unsigned long jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t result; + + arg1 = (switch_file_handle *)jarg1; + result = (uint32_t) ((arg1)->cur_channels); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_samplerate_set(void * jarg1, unsigned long jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_file_handle *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->cur_samplerate = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_cur_samplerate_get(void * jarg1) { + unsigned long jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t result; + + arg1 = (switch_file_handle *)jarg1; + result = (uint32_t) ((arg1)->cur_samplerate); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_file_handle() { void * jresult ; switch_file_handle *result = 0 ; @@ -26566,6 +27938,243 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_api_interface(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_interface_name_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->interface_name = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->interface_name, (const char *)arg2); + } else { + arg1->interface_name = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_interface_name_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->interface_name); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_desc_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->desc = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->desc, (const char *)arg2); + } else { + arg1->desc = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_desc_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->desc); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_function_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_function_t arg2 = (switch_json_api_function_t) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_json_api_function_t)jarg2; + if (arg1) (arg1)->function = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_function_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_function_t result; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_json_api_function_t) ((arg1)->function); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_syntax_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->syntax = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->syntax, (const char *)arg2); + } else { + arg1->syntax = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_syntax_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->syntax); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_rwlock_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_thread_rwlock_t *arg2 = (switch_thread_rwlock_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_thread_rwlock_t *)jarg2; + if (arg1) (arg1)->rwlock = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_rwlock_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_thread_rwlock_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_thread_rwlock_t *) ((arg1)->rwlock); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_refs_set(void * jarg1, int jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + int arg2 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->refs = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_json_api_interface_refs_get(void * jarg1) { + int jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + int result; + + arg1 = (switch_json_api_interface *)jarg1; + result = (int) ((arg1)->refs); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_reflock_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_mutex_t *)jarg2; + if (arg1) (arg1)->reflock = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_reflock_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_mutex_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_mutex_t *) ((arg1)->reflock); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_parent_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_loadable_module_interface_t *arg2 = (switch_loadable_module_interface_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_loadable_module_interface_t *)jarg2; + if (arg1) (arg1)->parent = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_parent_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_loadable_module_interface_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_loadable_module_interface_t *) ((arg1)->parent); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_next_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_interface *arg2 = (switch_json_api_interface *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_json_api_interface *)jarg2; + if (arg1) (arg1)->next = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_next_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_interface *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_json_api_interface *) ((arg1)->next); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_json_api_interface() { + void * jresult ; + switch_json_api_interface *result = 0 ; + + result = (switch_json_api_interface *)new switch_json_api_interface(); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_json_api_interface(void * jarg1) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + delete arg1; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_session_set(void * jarg1, void * jarg2) { switch_slin_data *arg1 = (switch_slin_data *) 0 ; switch_core_session_t *arg2 = (switch_core_session_t *) 0 ; @@ -28570,6 +30179,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_direction(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_logical_direction(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_call_direction_t)switch_channel_logical_direction(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_set_direction(void * jarg1, int jarg2) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + switch_channel_set_direction(arg1,arg2); +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_session(void * jarg1) { void * jresult ; switch_channel_t *arg1 = (switch_channel_t *) 0 ; @@ -30383,6 +32014,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_serialize_json(void * jarg1, void } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_serialize_json_obj(void * jarg1, void * jarg2) { + int jresult ; + switch_event_t *arg1 = (switch_event_t *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + switch_status_t result; + + arg1 = (switch_event_t *)jarg1; + arg2 = (cJSON **)jarg2; + result = (switch_status_t)switch_event_serialize_json_obj(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_json(void * jarg1, char * jarg2) { int jresult ; switch_event_t **arg1 = (switch_event_t **) 0 ; @@ -30587,6 +32232,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_add_presence_data_cols(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_add_presence_data_cols(void * jarg1, void * jarg2, char * jarg3) { + switch_event_t *arg1 = (switch_event_t *) 0 ; + cJSON *arg2 = (cJSON *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_event_t *)jarg1; + arg2 = (cJSON *)jarg2; + arg3 = (char *)jarg3; + switch_json_add_presence_data_cols(arg1,arg2,(char const *)arg3); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned long jarg1) { uint32_t arg1 ; @@ -30595,6 +32252,334 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_event_channel_broadcast(char * jarg1, void * jarg2, char * jarg3, unsigned long jarg4) { + unsigned long jresult ; + char *arg1 = (char *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + char *arg3 = (char *) 0 ; + switch_event_channel_id_t arg4 ; + uint32_t result; + + arg1 = (char *)jarg1; + arg2 = (cJSON **)jarg2; + arg3 = (char *)jarg3; + arg4 = (switch_event_channel_id_t)jarg4; + result = (uint32_t)switch_event_channel_broadcast((char const *)arg1,arg2,(char const *)arg3,arg4); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_event_channel_unbind(char * jarg1, void * jarg2) { + unsigned long jresult ; + char *arg1 = (char *) 0 ; + switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ; + uint32_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_event_channel_func_t)jarg2; + result = (uint32_t)switch_event_channel_unbind((char const *)arg1,arg2); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_channel_bind(char * jarg1, void * jarg2, void * jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ; + switch_event_channel_id_t *arg3 = (switch_event_channel_id_t *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_event_channel_func_t)jarg2; + arg3 = (switch_event_channel_id_t *)jarg3; + result = (switch_status_t)switch_event_channel_bind((char const *)arg1,arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_NO_EVENT_CHANNEL_ID_get() { + int jresult ; + int result; + + result = (int)(0); + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EVENT_CHANNEL_GLOBAL_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("__global__"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_clear(void * jarg1) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + result = (switch_status_t)switch_live_array_clear(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_bootstrap(void * jarg1, char * jarg2, unsigned long jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_event_channel_id_t arg3 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_event_channel_id_t)jarg3; + result = (switch_status_t)switch_live_array_bootstrap(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_destroy(void * jarg1) { + int jresult ; + switch_live_array_t **arg1 = (switch_live_array_t **) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t **)jarg1; + result = (switch_status_t)switch_live_array_destroy(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_create(char * jarg1, char * jarg2, unsigned long jarg3, void * jarg4) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_event_channel_id_t arg3 ; + switch_live_array_t **arg4 = (switch_live_array_t **) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_event_channel_id_t)jarg3; + arg4 = (switch_live_array_t **)jarg4; + result = (switch_status_t)switch_live_array_create((char const *)arg1,(char const *)arg2,arg3,arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_live_array_get(void * jarg1, char * jarg2) { + void * jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + cJSON *result = 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + result = (cJSON *)switch_live_array_get(arg1,(char const *)arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_live_array_get_idx(void * jarg1, int jarg2) { + void * jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + int arg2 ; + cJSON *result = 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (int)jarg2; + result = (cJSON *)switch_live_array_get_idx(arg1,arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_del(void * jarg1, char * jarg2) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + result = (switch_status_t)switch_live_array_del(arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_add(void * jarg1, char * jarg2, int jarg3, void * jarg4, int jarg5) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + cJSON **arg4 = (cJSON **) 0 ; + switch_bool_t arg5 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (int)jarg3; + arg4 = (cJSON **)jarg4; + arg5 = (switch_bool_t)jarg5; + result = (switch_status_t)switch_live_array_add(arg1,(char const *)arg2,arg3,arg4,arg5); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_visible(void * jarg1, int jarg2, int jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_bool_t arg2 ; + switch_bool_t arg3 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + arg3 = (switch_bool_t)jarg3; + result = (switch_status_t)switch_live_array_visible(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_isnew(void * jarg1) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + result = (switch_bool_t)switch_live_array_isnew(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_lock(void * jarg1) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + switch_live_array_lock(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_unlock(void * jarg1) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + switch_live_array_unlock(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_set_user_data(void * jarg1, void * jarg2) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (void *)jarg2; + switch_live_array_set_user_data(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_set_command_handler(void * jarg1, void * jarg2) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_live_array_command_handler_t arg2 = (switch_live_array_command_handler_t) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (switch_live_array_command_handler_t)jarg2; + switch_live_array_set_command_handler(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_parse_json(void * jarg1, unsigned long jarg2) { + cJSON *arg1 = (cJSON *) 0 ; + switch_event_channel_id_t arg2 ; + + arg1 = (cJSON *)jarg1; + arg2 = (switch_event_channel_id_t)jarg2; + switch_live_array_parse_json(arg1,arg2); +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_add_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_add_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_clear_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_clear_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_channel_permission_verify(char * jarg1, char * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (switch_bool_t)switch_event_channel_permission_verify((char const *)arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_modify(char * jarg1, char * jarg2, int jarg3) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t arg3 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_bool_t)jarg3; + switch_event_channel_permission_modify((char const *)arg1,(char const *)arg2,arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_clear(char * jarg1) { + char *arg1 = (char *) 0 ; + + arg1 = (char *)jarg1; + switch_event_channel_permission_clear((char const *)arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RESAMPLE_QUALITY_get() { int jresult ; int result; @@ -34267,7 +36252,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MAX_CAND_get() { int jresult ; int result; - result = (int)(25); + result = (int)(50); jresult = result; return jresult; } @@ -34283,7 +36268,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_cands_set(void * jarg1, void * jarg2) { icand_t (*inp)[2] = (icand_t (*)[2])(arg2); icand_t (*dest)[2] = (icand_t (*)[2])(arg1->cands); size_t ii = 0; - for (; ii < 25; ++ii) { + for (; ii < 50; ++ii) { icand_t *ip = inp[ii]; icand_t *dp = dest[ii]; size_t jj = 0; @@ -35304,16 +37289,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { - switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; - switch_payload_t arg2 ; - - arg1 = (switch_rtp_t *)jarg1; - arg2 = (switch_payload_t)jarg2; - switch_rtp_set_recv_pt(arg1,arg2); -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; @@ -35336,6 +37311,20 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_get_private(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_set_payload_map(void * jarg1, void * jarg2) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + payload_map_t **arg2 = (payload_map_t **) 0 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (payload_map_t **)jarg2; + result = (switch_status_t)switch_rtp_set_payload_map(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_intentional_bugs(void * jarg1, int jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_rtp_bug_flag_t arg2 ; @@ -35400,6 +37389,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_add_dtls(void * jarg1, void * jarg2 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_del_dtls(void * jarg1, int jarg2) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + dtls_type_t arg2 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (dtls_type_t)jarg2; + result = (switch_status_t)switch_rtp_del_dtls(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_has_dtls() { int jresult ; int result; @@ -38380,6 +40383,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_cmd_id_get(voi } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_repeat_set(void * jarg1, unsigned long jarg2) { + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_scheduler_task *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->repeat = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_repeat_get(void * jarg1) { + unsigned long jresult ; + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + uint32_t result; + + arg1 = (switch_scheduler_task *)jarg1; + result = (uint32_t) ((arg1)->repeat); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_group_set(void * jarg1, char * jarg2) { switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; char *arg2 = (char *) 0 ; @@ -38454,6 +40479,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_task_id_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_hash_set(void * jarg1, unsigned long jarg2) { + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + unsigned long arg2 ; + + arg1 = (switch_scheduler_task *)jarg1; + arg2 = (unsigned long)jarg2; + if (arg1) (arg1)->hash = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_hash_get(void * jarg1) { + unsigned long jresult ; + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + unsigned long result; + + arg1 = (switch_scheduler_task *)jarg1; + result = (unsigned long) ((arg1)->hash); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_scheduler_task() { void * jresult ; switch_scheduler_task *result = 0 ; @@ -38971,11 +41018,13 @@ SWIGEXPORT void SWIGSTDCALL CSharp_IvrMenu_Execute(void * jarg1, void * jarg2, c } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_Api() { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_Api(void * jarg1) { void * jresult ; + CoreSession *arg1 = (CoreSession *) NULL ; API *result = 0 ; - result = (API *)new API(); + arg1 = (CoreSession *)jarg1; + result = (API *)new API(arg1); jresult = (void *)result; return jresult; } @@ -40683,7 +42732,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_msleep(unsigned int jarg1) { unsigned int arg1 ; arg1 = (unsigned int)jarg1; - msleep(arg1); + switch_msleep(arg1); } diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 2c57e207a4..af537fa7d9 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,20 +8,25 @@ * interface file instead. * ----------------------------------------------------------------------------- */ +#define SWIGCSHARP + #ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - T *tt; + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); public: - SwigValueWrapper() : tt(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } - SwigValueWrapper(const T& t) : tt(new T(t)) { } - ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } - operator T&() const { return *tt; } - T *operator&() { return tt; } -private: - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } }; template T SwigValueInit() { @@ -71,6 +76,12 @@ template T SwigValueInit() { # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -190,12 +201,12 @@ static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { { SWIG_CSharpArgumentException, NULL }, { SWIG_CSharpArgumentNullException, NULL }, - { SWIG_CSharpArgumentOutOfRangeException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL } }; static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); @@ -203,7 +214,7 @@ static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { callback = SWIG_csharp_exceptions_argument[code].callback; } callback(msg, param_name); @@ -303,8 +314,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_FREESWITCH_PEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "27880"; - + result = (char *)("27880"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -314,8 +324,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_FREESWITCH_OID_PREFIX_get() { char * jresult ; char *result = 0 ; - result = (char *) ".1.3.6.1.4.1.27880"; - + result = (char *)(".1.3.6.1.4.1.27880"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -325,8 +334,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_FREESWITCH_ITAD_get() { char * jresult ; char *result = 0 ; - result = (char *) "543"; - + result = (char *)("543"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -336,8 +344,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp___EXTENSIONS___get() { int jresult ; int result; - result = (int) 1; - + result = (int)(1); jresult = result; return jresult; } @@ -347,8 +354,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp___BSD_VISIBLE_get() { int jresult ; int result; - result = (int) 1; - + result = (int)(1); jresult = result; return jresult; } @@ -358,8 +364,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ENT_ORIGINATE_DELIM_get() { char * jresult ; char *result = 0 ; - result = (char *) ":_:"; - + result = (char *)(":_:"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -369,8 +374,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BLANK_STRING_get() { char * jresult ; char *result = 0 ; - result = (char *) "\0"; - + result = (char *)("\0"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -380,8 +384,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_TON_UNDEF_get() { int jresult ; int result; - result = (int) 255; - + result = (int)(255); jresult = result; return jresult; } @@ -391,8 +394,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_NUMPLAN_UNDEF_get() { int jresult ; int result; - result = (int) 255; - + result = (int)(255); jresult = result; return jresult; } @@ -402,8 +404,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_ESC_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33["; - + result = (char *)("\33["); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -413,8 +414,7 @@ SWIGEXPORT char SWIGSTDCALL CSharp_SWITCH_SEQ_HOME_CHAR_get() { char jresult ; char result; - result = (char) 'H'; - + result = (char)('H'); jresult = result; return jresult; } @@ -424,8 +424,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_HOME_CHAR_STR_get() { char * jresult ; char *result = 0 ; - result = (char *) "H"; - + result = (char *)("H"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -435,8 +434,7 @@ SWIGEXPORT char SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARLINE_CHAR_get() { char jresult ; char result; - result = (char) '1'; - + result = (char)('1'); jresult = result; return jresult; } @@ -446,8 +444,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARLINE_CHAR_STR_get() { char * jresult ; char *result = 0 ; - result = (char *) "1"; - + result = (char *)("1"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -457,8 +454,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARLINEEND_CHAR_get() { char * jresult ; char *result = 0 ; - result = (char *) "K"; - + result = (char *)("K"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -468,8 +464,7 @@ SWIGEXPORT char SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARSCR_CHAR0_get() { char jresult ; char result; - result = (char) '2'; - + result = (char)('2'); jresult = result; return jresult; } @@ -479,8 +474,7 @@ SWIGEXPORT char SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARSCR_CHAR1_get() { char jresult ; char result; - result = (char) 'J'; - + result = (char)('J'); jresult = result; return jresult; } @@ -490,8 +484,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARSCR_CHAR_get() { char * jresult ; char *result = 0 ; - result = (char *) "2J"; - + result = (char *)("2J"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -501,8 +494,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_AND_COLOR_get() { char * jresult ; char *result = 0 ; - result = (char *) ";"; - + result = (char *)(";"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -512,8 +504,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_END_COLOR_get() { char * jresult ; char *result = 0 ; - result = (char *) "m"; - + result = (char *)("m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -523,8 +514,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_BLACK_get() { char * jresult ; char *result = 0 ; - result = (char *) "30"; - + result = (char *)("30"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -534,8 +524,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_RED_get() { char * jresult ; char *result = 0 ; - result = (char *) "31"; - + result = (char *)("31"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -545,8 +534,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_GREEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "32"; - + result = (char *)("32"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -556,8 +544,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_YELLOW_get() { char * jresult ; char *result = 0 ; - result = (char *) "33"; - + result = (char *)("33"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -567,8 +554,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_BLUE_get() { char * jresult ; char *result = 0 ; - result = (char *) "34"; - + result = (char *)("34"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -578,8 +564,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_MAGEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "35"; - + result = (char *)("35"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -589,8 +574,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_CYAN_get() { char * jresult ; char *result = 0 ; - result = (char *) "36"; - + result = (char *)("36"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -600,8 +584,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_F_WHITE_get() { char * jresult ; char *result = 0 ; - result = (char *) "37"; - + result = (char *)("37"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -611,8 +594,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_BLACK_get() { char * jresult ; char *result = 0 ; - result = (char *) "40"; - + result = (char *)("40"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -622,8 +604,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_RED_get() { char * jresult ; char *result = 0 ; - result = (char *) "41"; - + result = (char *)("41"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -633,8 +614,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_GREEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "42"; - + result = (char *)("42"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -644,8 +624,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_YELLOW_get() { char * jresult ; char *result = 0 ; - result = (char *) "43"; - + result = (char *)("43"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -655,8 +634,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_BLUE_get() { char * jresult ; char *result = 0 ; - result = (char *) "44"; - + result = (char *)("44"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -666,8 +644,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_MAGEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "45"; - + result = (char *)("45"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -677,8 +654,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_CYAN_get() { char * jresult ; char *result = 0 ; - result = (char *) "46"; - + result = (char *)("46"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -688,8 +664,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_B_WHITE_get() { char * jresult ; char *result = 0 ; - result = (char *) "47"; - + result = (char *)("47"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -699,8 +674,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FBLACK_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[30m"; - + result = (char *)("\33[30m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -710,8 +684,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FRED_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[31m"; - + result = (char *)("\33[31m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -721,8 +694,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FGREEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[32m"; - + result = (char *)("\33[32m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -732,8 +704,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FYELLOW_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[33m"; - + result = (char *)("\33[33m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -743,8 +714,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FBLUE_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[34m"; - + result = (char *)("\33[34m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -754,8 +724,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FMAGEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[35m"; - + result = (char *)("\33[35m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -765,8 +734,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FCYAN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[36m"; - + result = (char *)("\33[36m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -776,8 +744,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_FWHITE_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[37m"; - + result = (char *)("\33[37m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -787,8 +754,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BBLACK_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[40m"; - + result = (char *)("\33[40m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -798,8 +764,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BRED_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[41m"; - + result = (char *)("\33[41m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -809,8 +774,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BGREEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[42m"; - + result = (char *)("\33[42m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -820,8 +784,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BYELLOW_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[43m"; - + result = (char *)("\33[43m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -831,8 +794,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BBLUE_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[44m"; - + result = (char *)("\33[44m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -842,8 +804,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BMAGEN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[45m"; - + result = (char *)("\33[45m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -853,8 +814,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BCYAN_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[46m"; - + result = (char *)("\33[46m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -864,8 +824,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_BWHITE_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[47m"; - + result = (char *)("\33[47m"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -875,8 +834,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_HOME_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[H"; - + result = (char *)("\33[H"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -886,8 +844,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARLINE_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[1"; - + result = (char *)("\33[1"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -897,8 +854,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARLINEEND_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[K"; - + result = (char *)("\33[K"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -908,8 +864,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEQ_CLEARSCR_get() { char * jresult ; char *result = 0 ; - result = (char *) "\33[2J\33[H"; - + result = (char *)("\33[2J\33[H"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -919,8 +874,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_DEFAULT_CLID_NAME_get() { char * jresult ; char *result = 0 ; - result = (char *) "\0"; - + result = (char *)("\0"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -930,8 +884,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_DEFAULT_CLID_NUMBER_get() { char * jresult ; char *result = 0 ; - result = (char *) "0000000000"; - + result = (char *)("0000000000"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -941,8 +894,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_DEFAULT_DTMF_DURATION_get() { int jresult ; int result; - result = (int) 2000; - + result = (int)(2000); jresult = result; return jresult; } @@ -952,8 +904,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MIN_DTMF_DURATION_get() { int jresult ; int result; - result = (int) 400; - + result = (int)(400); jresult = result; return jresult; } @@ -963,8 +914,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_DTMF_DURATION_get() { int jresult ; int result; - result = (int) 192000; - + result = (int)(192000); jresult = result; return jresult; } @@ -974,8 +924,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PATH_SEPARATOR_get() { char * jresult ; char *result = 0 ; - result = (char *) "/"; - + result = (char *)("/"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -985,8 +934,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_URL_SEPARATOR_get() { char * jresult ; char *result = 0 ; - result = (char *) "://"; - + result = (char *)("://"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -996,8 +944,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE_get( char * jresult ; char *result = 0 ; - result = (char *) "ignore_display_updates"; - + result = (char *)("ignore_display_updates"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1007,8 +954,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_AUDIO_SPOOL_PATH_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "audio_spool_path"; - + result = (char *)("audio_spool_path"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1018,8 +964,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BRIDGE_HANGUP_CAUSE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bridge_hangup_cause"; - + result = (char *)("bridge_hangup_cause"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1029,8 +974,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_READ_TERMINATOR_USED_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "read_terminator_used"; - + result = (char *)("read_terminator_used"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1040,8 +984,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE_get( char * jresult ; char *result = 0 ; - result = (char *) "send_silence_when_idle"; - + result = (char *)("send_silence_when_idle"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1051,8 +994,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CURRENT_APPLICATION_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "current_application"; - + result = (char *)("current_application"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1062,8 +1004,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CURRENT_APPLICATION_DATA_VARIABLE_ge char * jresult ; char *result = 0 ; - result = (char *) "current_application_data"; - + result = (char *)("current_application_data"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1073,8 +1014,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABL char * jresult ; char *result = 0 ; - result = (char *) "current_application_response"; - + result = (char *)("current_application_response"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1084,8 +1024,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE_get char * jresult ; char *result = 0 ; - result = (char *) "passthru_ptime_mismatch"; - + result = (char *)("passthru_ptime_mismatch"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1095,8 +1034,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE_get char * jresult ; char *result = 0 ; - result = (char *) "enable_heartbeat_events"; - + result = (char *)("enable_heartbeat_events"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1106,8 +1044,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE_g char * jresult ; char *result = 0 ; - result = (char *) "bypass_media_after_bridge"; - + result = (char *)("bypass_media_after_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1117,8 +1054,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_READ_RESULT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "read_result"; - + result = (char *)("read_result"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1128,8 +1064,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ATT_XFER_RESULT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "att_xfer_result"; - + result = (char *)("att_xfer_result"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1139,8 +1074,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "copy_xml_cdr"; - + result = (char *)("copy_xml_cdr"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1150,8 +1084,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_JSON_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "copy_json_cdr"; - + result = (char *)("copy_json_cdr"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1161,8 +1094,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE char * jresult ; char *result = 0 ; - result = (char *) "proto_specific_hangup_cause"; - + result = (char *)("proto_specific_hangup_cause"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1172,8 +1104,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_HISTORY_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "transfer_history"; - + result = (char *)("transfer_history"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1183,8 +1114,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_SOURCE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "transfer_source"; - + result = (char *)("transfer_source"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1194,8 +1124,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SENSITIVE_DTMF_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "sensitive_dtmf"; - + result = (char *)("sensitive_dtmf"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1205,8 +1134,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_RECORD_POST_PROCESS_EXEC_APP_VARIABL char * jresult ; char *result = 0 ; - result = (char *) "record_post_process_exec_app"; - + result = (char *)("record_post_process_exec_app"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1216,8 +1144,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_RECORD_POST_PROCESS_EXEC_API_VARIABL char * jresult ; char *result = 0 ; - result = (char *) "record_post_process_exec_api"; - + result = (char *)("record_post_process_exec_api"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1227,8 +1154,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE_g char * jresult ; char *result = 0 ; - result = (char *) "execute_on_answer"; - + result = (char *)("execute_on_answer"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1238,8 +1164,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIAB char * jresult ; char *result = 0 ; - result = (char *) "execute_on_pre_answer"; - + result = (char *)("execute_on_pre_answer"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1249,8 +1174,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE_ge char * jresult ; char *result = 0 ; - result = (char *) "execute_on_media"; - + result = (char *)("execute_on_media"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1260,8 +1184,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE_get char * jresult ; char *result = 0 ; - result = (char *) "execute_on_ring"; - + result = (char *)("execute_on_ring"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1271,8 +1194,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIA char * jresult ; char *result = 0 ; - result = (char *) "execute_on_tone_detect"; - + result = (char *)("execute_on_tone_detect"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1282,8 +1204,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABL char * jresult ; char *result = 0 ; - result = (char *) "execute_on_originate"; - + result = (char *)("execute_on_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1293,8 +1214,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VA char * jresult ; char *result = 0 ; - result = (char *) "execute_on_post_originate"; - + result = (char *)("execute_on_post_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1304,8 +1224,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VAR char * jresult ; char *result = 0 ; - result = (char *) "execute_on_pre_originate"; - + result = (char *)("execute_on_pre_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1315,8 +1234,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIAB char * jresult ; char *result = 0 ; - result = (char *) "execute_on_pre_bridge"; - + result = (char *)("execute_on_pre_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1326,8 +1244,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_BRIDGE_VARIA char * jresult ; char *result = 0 ; - result = (char *) "execute_on_post_bridge"; - + result = (char *)("execute_on_post_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1337,8 +1254,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "api_on_answer"; - + result = (char *)("api_on_answer"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1348,8 +1264,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE_g char * jresult ; char *result = 0 ; - result = (char *) "api_on_pre_answer"; - + result = (char *)("api_on_pre_answer"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1359,8 +1274,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "api_on_media"; - + result = (char *)("api_on_media"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1370,8 +1284,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_RING_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "api_on_ring"; - + result = (char *)("api_on_ring"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1381,8 +1294,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE_ char * jresult ; char *result = 0 ; - result = (char *) "api_on_tone_detect"; - + result = (char *)("api_on_tone_detect"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1392,8 +1304,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_ge char * jresult ; char *result = 0 ; - result = (char *) "api_on_originate"; - + result = (char *)("api_on_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1403,8 +1314,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIAB char * jresult ; char *result = 0 ; - result = (char *) "api_on_post_originate"; - + result = (char *)("api_on_post_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1414,8 +1324,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABL char * jresult ; char *result = 0 ; - result = (char *) "api_on_pre_originate"; - + result = (char *)("api_on_pre_originate"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1425,8 +1334,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "call_timeout"; - + result = (char *)("call_timeout"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1436,8 +1344,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_HOLDING_UUID_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "holding_uuid"; - + result = (char *)("holding_uuid"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1447,8 +1354,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SOFT_HOLDING_UUID_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "soft_holding_uuid"; - + result = (char *)("soft_holding_uuid"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1458,8 +1364,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_API_BRIDGE_END_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "api_after_bridge"; - + result = (char *)("api_after_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1469,8 +1374,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_API_BRIDGE_START_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "api_before_bridge"; - + result = (char *)("api_before_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1480,8 +1384,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_API_HANGUP_HOOK_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "api_hangup_hook"; - + result = (char *)("api_hangup_hook"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1491,8 +1394,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_API_REPORTING_HOOK_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "api_reporting_hook"; - + result = (char *)("api_reporting_hook"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1502,8 +1404,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE_get( char * jresult ; char *result = 0 ; - result = (char *) "session_in_hangup_hook"; - + result = (char *)("session_in_hangup_hook"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1513,8 +1414,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROCESS_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "process_cdr"; - + result = (char *)("process_cdr"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1524,8 +1424,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SKIP_CDR_CAUSES_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "skip_cdr_causes"; - + result = (char *)("skip_cdr_causes"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1535,8 +1434,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_FORCE_PROCESS_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "force_process_cdr"; - + result = (char *)("force_process_cdr"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1546,8 +1444,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BRIDGE_CHANNEL_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bridge_channel"; - + result = (char *)("bridge_channel"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1557,8 +1454,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_NAME_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "channel_name"; - + result = (char *)("channel_name"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1568,8 +1464,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BRIDGE_UUID_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bridge_uuid"; - + result = (char *)("bridge_uuid"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1579,8 +1474,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CONTINUE_ON_FAILURE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "continue_on_fail"; - + result = (char *)("continue_on_fail"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1590,8 +1484,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PLAYBACK_TERMINATORS_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "playback_terminators"; - + result = (char *)("playback_terminators"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1601,8 +1494,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PLAYBACK_TERMINATOR_USED_get() { char * jresult ; char *result = 0 ; - result = (char *) "playback_terminator_used"; - + result = (char *)("playback_terminator_used"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1612,8 +1504,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CACHE_SPEECH_HANDLES_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "cache_speech_handles"; - + result = (char *)("cache_speech_handles"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1623,8 +1514,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME_get() char * jresult ; char *result = 0 ; - result = (char *) "__cache_speech_handles_obj__"; - + result = (char *)("__cache_speech_handles_obj__"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1634,8 +1524,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BYPASS_MEDIA_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bypass_media"; - + result = (char *)("bypass_media"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1645,8 +1534,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROXY_MEDIA_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "proxy_media"; - + result = (char *)("proxy_media"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1656,8 +1544,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ZRTP_PASSTHRU_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "zrtp_passthru"; - + result = (char *)("zrtp_passthru"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1667,8 +1554,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "endpoint_disposition"; - + result = (char *)("endpoint_disposition"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1678,8 +1564,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_HOLD_MUSIC_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "hold_music"; - + result = (char *)("hold_music"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1689,8 +1574,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TEMP_HOLD_MUSIC_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "temp_hold_music"; - + result = (char *)("temp_hold_music"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1700,8 +1584,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EXPORT_VARS_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "export_vars"; - + result = (char *)("export_vars"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1711,8 +1594,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BRIDGE_EXPORT_VARS_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bridge_export_vars"; - + result = (char *)("bridge_export_vars"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1722,8 +1604,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_R_SDP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "switch_r_sdp"; - + result = (char *)("switch_r_sdp"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1733,8 +1614,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_L_SDP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "switch_l_sdp"; - + result = (char *)("switch_l_sdp"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1744,8 +1624,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_B_SDP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "switch_m_sdp"; - + result = (char *)("switch_m_sdp"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1755,8 +1634,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_BRIDGE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "bridge_to"; - + result = (char *)("bridge_to"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1766,8 +1644,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LAST_BRIDGE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "last_bridge_to"; - + result = (char *)("last_bridge_to"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1777,8 +1654,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SIGNAL_BRIDGE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "signal_bridge_to"; - + result = (char *)("signal_bridge_to"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1788,8 +1664,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SIGNAL_BOND_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "signal_bond"; - + result = (char *)("signal_bond"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1799,8 +1674,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "originate_signal_bond"; - + result = (char *)("originate_signal_bond"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1810,8 +1684,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATOR_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "originator"; - + result = (char *)("originator"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1821,8 +1694,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATOR_CODEC_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "originator_codec"; - + result = (char *)("originator_codec"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1832,8 +1704,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE_get( char * jresult ; char *result = 0 ; - result = (char *) "originator_video_codec"; - + result = (char *)("originator_video_codec"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1843,8 +1714,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_MEDIA_IP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "local_media_ip"; - + result = (char *)("local_media_ip"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1854,8 +1724,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "local_media_port"; - + result = (char *)("local_media_port"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1865,8 +1734,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "advertised_media_ip"; - + result = (char *)("advertised_media_ip"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1876,8 +1744,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_MEDIA_IP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "remote_media_ip"; - + result = (char *)("remote_media_ip"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1887,8 +1754,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_MEDIA_PORT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "remote_media_port"; - + result = (char *)("remote_media_port"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1898,8 +1764,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_VIDEO_IP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "remote_video_ip"; - + result = (char *)("remote_video_ip"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1909,8 +1774,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_VIDEO_PORT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "remote_video_port"; - + result = (char *)("remote_video_port"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1920,8 +1784,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_VIDEO_IP_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "local_video_ip"; - + result = (char *)("local_video_ip"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1931,8 +1794,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_VIDEO_PORT_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "local_video_port"; - + result = (char *)("local_video_port"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1942,8 +1804,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "hangup_after_bridge"; - + result = (char *)("hangup_after_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1953,8 +1814,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "park_after_bridge"; - + result = (char *)("park_after_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1964,8 +1824,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "transfer_after_bridge"; - + result = (char *)("transfer_after_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1975,8 +1834,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "exec_after_bridge_app"; - + result = (char *)("exec_after_bridge_app"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1986,8 +1844,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE_get() char * jresult ; char *result = 0 ; - result = (char *) "exec_after_bridge_arg"; - + result = (char *)("exec_after_bridge_arg"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -1997,8 +1854,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_MAX_FORWARDS_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "max_forwards"; - + result = (char *)("max_forwards"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -2008,8 +1864,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_DISABLE_APP_LOG_VARIABLE_get() { char * jresult ; char *result = 0 ; - result = (char *) "disable_app_log"; - + result = (char *)("disable_app_log"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -2019,8 +1874,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SPEECH_KEY_get() { char * jresult ; char *result = 0 ; - result = (char *) "speech"; - + result = (char *)("speech"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -2030,8 +1884,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_UUID_BRIDGE_get() { char * jresult ; char *result = 0 ; - result = (char *) "uuid_bridge"; - + result = (char *)("uuid_bridge"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -2041,8 +1894,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_BITS_PER_BYTE_get() { int jresult ; int result; - result = (int) 8; - + result = (int)(8); jresult = result; return jresult; } @@ -2052,8 +1904,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_DEFAULT_FILE_BUFFER_LEN_get() { int jresult ; int result; - result = (int) 65536; - + result = (int)(65536); jresult = result; return jresult; } @@ -2063,8 +1914,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_DTMF_LOG_LEN_get() { int jresult ; int result; - result = (int) 1000; - + result = (int)(1000); jresult = result; return jresult; } @@ -2074,8 +1924,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_TRANS_get() { int jresult ; int result; - result = (int) 2000; - + result = (int)(2000); jresult = result; return jresult; } @@ -2085,8 +1934,47 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get() { int jresult ; int result; - result = (int) 2; + result = (int)(2); + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_JITTER_VARIANCE_THRESHOLD_get() { + double jresult ; + double result; + result = (double)(400.0); + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_IPDV_THRESHOLD_get() { + double jresult ; + double result; + + result = (double)(1.0); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_LOST_BURST_ANALYZE_get() { + int jresult ; + int result; + + result = (int)(500); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_LOST_BURST_CAPTURE_get() { + int jresult ; + int result; + + result = (int)(1024); jresult = result; return jresult; } @@ -2099,7 +1987,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_digit_set(void * jarg1, char ja arg1 = (switch_dtmf_t *)jarg1; arg2 = (char)jarg2; if (arg1) (arg1)->digit = arg2; - } @@ -2122,7 +2009,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_duration_set(void * jarg1, unsi arg1 = (switch_dtmf_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->duration = arg2; - } @@ -2145,7 +2031,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_flags_set(void * jarg1, int jar arg1 = (switch_dtmf_t *)jarg1; arg2 = (int32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -2168,7 +2053,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_source_set(void * jarg1, int ja arg1 = (switch_dtmf_t *)jarg1; arg2 = (switch_dtmf_source_t)jarg2; if (arg1) (arg1)->source = arg2; - } @@ -2199,7 +2083,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_dtmf_t(void * jarg1) { arg1 = (switch_dtmf_t *)jarg1; delete arg1; - } @@ -2210,7 +2093,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_buf_set(void * jarg1, void * arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t *)jarg2; if (arg1) (arg1)->buf = arg2; - } @@ -2233,7 +2115,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_buflen_set(void * jarg1, uns arg1 = (switch_bitpack_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->buflen = arg2; - } @@ -2256,7 +2137,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_cur_set(void * jarg1, void * arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t *)jarg2; if (arg1) (arg1)->cur = arg2; - } @@ -2279,7 +2159,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_bytes_set(void * jarg1, unsi arg1 = (switch_bitpack_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->bytes = arg2; - } @@ -2302,7 +2181,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_bits_tot_set(void * jarg1, u arg1 = (switch_bitpack_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->bits_tot = arg2; - } @@ -2325,7 +2203,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_bits_cur_set(void * jarg1, u arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->bits_cur = arg2; - } @@ -2348,7 +2225,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_bits_rem_set(void * jarg1, u arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->bits_rem = arg2; - } @@ -2371,7 +2247,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_frame_bits_set(void * jarg1, arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->frame_bits = arg2; - } @@ -2394,7 +2269,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_shiftby_set(void * jarg1, un arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->shiftby = arg2; - } @@ -2417,7 +2291,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_this_byte_set(void * jarg1, arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->this_byte = arg2; - } @@ -2440,7 +2313,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_under_set(void * jarg1, unsi arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->under = arg2; - } @@ -2463,7 +2335,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_over_set(void * jarg1, unsig arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_byte_t)jarg2; if (arg1) (arg1)->over = arg2; - } @@ -2486,7 +2357,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_bitpack_t_mode_set(void * jarg1, int j arg1 = (switch_bitpack_t *)jarg1; arg2 = (switch_bitpack_mode_t)jarg2; if (arg1) (arg1)->mode = arg2; - } @@ -2517,7 +2387,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_bitpack_t(void * jarg1) { arg1 = (switch_bitpack_t *)jarg1; delete arg1; - } @@ -2528,7 +2397,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_base_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->base_dir) delete [] arg1->base_dir; + delete [] arg1->base_dir; if (arg2) { arg1->base_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->base_dir, (const char *)arg2); @@ -2558,7 +2427,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_mod_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->mod_dir) delete [] arg1->mod_dir; + delete [] arg1->mod_dir; if (arg2) { arg1->mod_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->mod_dir, (const char *)arg2); @@ -2588,7 +2457,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_conf_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->conf_dir) delete [] arg1->conf_dir; + delete [] arg1->conf_dir; if (arg2) { arg1->conf_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->conf_dir, (const char *)arg2); @@ -2618,7 +2487,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_log_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->log_dir) delete [] arg1->log_dir; + delete [] arg1->log_dir; if (arg2) { arg1->log_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->log_dir, (const char *)arg2); @@ -2648,7 +2517,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_run_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->run_dir) delete [] arg1->run_dir; + delete [] arg1->run_dir; if (arg2) { arg1->run_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->run_dir, (const char *)arg2); @@ -2678,7 +2547,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_db_dir_set(void * jarg1, c arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->db_dir) delete [] arg1->db_dir; + delete [] arg1->db_dir; if (arg2) { arg1->db_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->db_dir, (const char *)arg2); @@ -2708,7 +2577,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_script_dir_set(void * jarg arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->script_dir) delete [] arg1->script_dir; + delete [] arg1->script_dir; if (arg2) { arg1->script_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->script_dir, (const char *)arg2); @@ -2738,7 +2607,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_temp_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->temp_dir) delete [] arg1->temp_dir; + delete [] arg1->temp_dir; if (arg2) { arg1->temp_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->temp_dir, (const char *)arg2); @@ -2768,7 +2637,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_htdocs_dir_set(void * jarg arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->htdocs_dir) delete [] arg1->htdocs_dir; + delete [] arg1->htdocs_dir; if (arg2) { arg1->htdocs_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->htdocs_dir, (const char *)arg2); @@ -2798,7 +2667,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_grammar_dir_set(void * jar arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->grammar_dir) delete [] arg1->grammar_dir; + delete [] arg1->grammar_dir; if (arg2) { arg1->grammar_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->grammar_dir, (const char *)arg2); @@ -2828,7 +2697,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_storage_dir_set(void * jar arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->storage_dir) delete [] arg1->storage_dir; + delete [] arg1->storage_dir; if (arg2) { arg1->storage_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->storage_dir, (const char *)arg2); @@ -2858,7 +2727,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_recordings_dir_set(void * arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->recordings_dir) delete [] arg1->recordings_dir; + delete [] arg1->recordings_dir; if (arg2) { arg1->recordings_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->recordings_dir, (const char *)arg2); @@ -2888,7 +2757,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_sounds_dir_set(void * jarg arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->sounds_dir) delete [] arg1->sounds_dir; + delete [] arg1->sounds_dir; if (arg2) { arg1->sounds_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->sounds_dir, (const char *)arg2); @@ -2918,7 +2787,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_lib_dir_set(void * jarg1, arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->lib_dir) delete [] arg1->lib_dir; + delete [] arg1->lib_dir; if (arg2) { arg1->lib_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->lib_dir, (const char *)arg2); @@ -2948,7 +2817,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_certs_dir_set(void * jarg1 arg1 = (switch_directories *)jarg1; arg2 = (char *)jarg2; { - if (arg1->certs_dir) delete [] arg1->certs_dir; + delete [] arg1->certs_dir; if (arg2) { arg1->certs_dir = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->certs_dir, (const char *)arg2); @@ -2986,7 +2855,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_directories(void * jarg1) { arg1 = (switch_directories *)jarg1; delete arg1; - } @@ -2995,7 +2863,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_SWITCH_GLOBAL_dirs_set(void * jarg1) { arg1 = (switch_directories *)jarg1; SWITCH_GLOBAL_dirs = *arg1; - } @@ -3016,7 +2883,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_filenames_conf_name_set(void * jarg1, arg1 = (switch_filenames *)jarg1; arg2 = (char *)jarg2; { - if (arg1->conf_name) delete [] arg1->conf_name; + delete [] arg1->conf_name; if (arg2) { arg1->conf_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->conf_name, (const char *)arg2); @@ -3054,7 +2921,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_filenames(void * jarg1) { arg1 = (switch_filenames *)jarg1; delete arg1; - } @@ -3063,7 +2929,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_SWITCH_GLOBAL_filenames_set(void * jarg1) { arg1 = (switch_filenames *)jarg1; SWITCH_GLOBAL_filenames = *arg1; - } @@ -3081,8 +2946,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_STACKS_get() { int jresult ; int result; - result = (int) 16; - + result = (int)(16); jresult = result; return jresult; } @@ -3092,8 +2956,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_THREAD_STACKSIZE_get() { int jresult ; int result; - result = (int) 240*1024; - + result = (int)(240*1024); jresult = result; return jresult; } @@ -3103,8 +2966,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_SYSTEM_THREAD_STACKSIZE_get() { int jresult ; int result; - result = (int) 8192*1024; - + result = (int)(8192*1024); jresult = result; return jresult; } @@ -3114,8 +2976,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_INTERVAL_get() { int jresult ; int result; - result = (int) 120; - + result = (int)(120); jresult = result; return jresult; } @@ -3125,8 +2986,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_INTERVAL_PAD_get() { int jresult ; int result; - result = (int) 10; - + result = (int)(10); jresult = result; return jresult; } @@ -3136,8 +2996,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_SAMPLE_LEN_get() { int jresult ; int result; - result = (int) 48; - + result = (int)(48); jresult = result; return jresult; } @@ -3147,8 +3006,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_BYTES_PER_SAMPLE_get() { int jresult ; int result; - result = (int) 2; - + result = (int)(2); jresult = result; return jresult; } @@ -3158,8 +3016,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RECOMMENDED_BUFFER_SIZE_get() { int jresult ; int result; - result = (int) 4096; - + result = (int)(4096); jresult = result; return jresult; } @@ -3169,8 +3026,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_CODECS_get() { int jresult ; int result; - result = (int) 50; - + result = (int)(50); jresult = result; return jresult; } @@ -3180,8 +3036,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_STATE_HANDLERS_get() { int jresult ; int result; - result = (int) 30; - + result = (int)(30); jresult = result; return jresult; } @@ -3191,8 +3046,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_QUEUE_LEN_get() { int jresult ; int result; - result = (int) 100000; - + result = (int)(100000); jresult = result; return jresult; } @@ -3202,8 +3056,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_MANAGEMENT_BUFFER_LEN_get() { int jresult ; int result; - result = (int) 1024*8; - + result = (int)(1024*8); jresult = result; return jresult; } @@ -3222,7 +3075,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_raw_bytes_set(void * jar } arg2 = *argp2; if (arg1) (arg1)->raw_bytes = arg2; - } @@ -3233,7 +3085,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_raw_bytes_get(void * j arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->raw_bytes); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3251,7 +3103,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_bytes_set(void * j } arg2 = *argp2; if (arg1) (arg1)->media_bytes = arg2; - } @@ -3262,7 +3113,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_bytes_get(void * arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->media_bytes); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3280,7 +3131,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_packet_count_set(void * } arg2 = *argp2; if (arg1) (arg1)->packet_count = arg2; - } @@ -3291,7 +3141,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_packet_count_get(void arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3309,7 +3159,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_set( } arg2 = *argp2; if (arg1) (arg1)->period_packet_count = arg2; - } @@ -3320,7 +3169,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_ge arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->period_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3338,7 +3187,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_packet_count_set(v } arg2 = *argp2; if (arg1) (arg1)->media_packet_count = arg2; - } @@ -3349,7 +3197,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_packet_count_get arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->media_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3367,7 +3215,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_skip_packet_count_set(vo } arg2 = *argp2; if (arg1) (arg1)->skip_packet_count = arg2; - } @@ -3378,7 +3225,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_skip_packet_count_get( arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->skip_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3396,7 +3243,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jb_packet_count_set(void } arg2 = *argp2; if (arg1) (arg1)->jb_packet_count = arg2; - } @@ -3407,7 +3253,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_jb_packet_count_get(vo arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->jb_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3425,7 +3271,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_dtmf_packet_count_set(vo } arg2 = *argp2; if (arg1) (arg1)->dtmf_packet_count = arg2; - } @@ -3436,7 +3281,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_dtmf_packet_count_get( arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->dtmf_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3454,7 +3299,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_cng_packet_count_set(voi } arg2 = *argp2; if (arg1) (arg1)->cng_packet_count = arg2; - } @@ -3465,7 +3309,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_cng_packet_count_get(v arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->cng_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3483,7 +3327,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_flush_packet_count_set(v } arg2 = *argp2; if (arg1) (arg1)->flush_packet_count = arg2; - } @@ -3494,7 +3337,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_flush_packet_count_get arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->flush_packet_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -3512,7 +3355,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_largest_jb_size_set(void } arg2 = *argp2; if (arg1) (arg1)->largest_jb_size = arg2; - } @@ -3523,7 +3365,441 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_largest_jb_size_get(vo arg1 = (switch_rtp_numbers_t *)jarg1; result = ((arg1)->largest_jb_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_proc_time_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->last_proc_time = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_proc_time_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->last_proc_time); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_n_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_n = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_n_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_n); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_add_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_add = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_add_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_add); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_addsq_set(void * jarg1, long long jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int64_t)jarg2; + if (arg1) (arg1)->jitter_addsq = arg2; +} + + +SWIGEXPORT long long SWIGSTDCALL CSharp_switch_rtp_numbers_t_jitter_addsq_get(void * jarg1) { + long long jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int64_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int64_t) ((arg1)->jitter_addsq); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_min_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->min_variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_min_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->min_variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_max_variance_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->max_variance = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_max_variance_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->max_variance); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_std_deviation_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->std_deviation = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_std_deviation_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->std_deviation); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_lossrate_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->lossrate = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_lossrate_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->lossrate); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_burstrate_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->burstrate = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_burstrate_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->burstrate); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_mean_interval_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->mean_interval = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_mean_interval_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->mean_interval); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_loss_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int *arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int *)jarg2; + { + size_t ii; + int *b = (int *) arg1->loss; + for (ii = 0; ii < (size_t)1024; ii++) b[ii] = *((int *) arg2 + ii); + } +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_loss_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int *result = 0 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int *)(int *) ((arg1)->loss); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_loss_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->last_loss = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_loss_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->last_loss); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_recved_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->recved = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_recved_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->recved); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_processed_seq_set(void * jarg1, int jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->last_processed_seq = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_processed_seq_get(void * jarg1) { + int jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + int result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (int) ((arg1)->last_processed_seq); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_flaws_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->flaws = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_flaws_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = ((arg1)->flaws); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_flaw_set(void * jarg1, void * jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->last_flaw = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_last_flaw_get(void * jarg1) { + void * jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + switch_size_t result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = ((arg1)->last_flaw); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_R_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->R = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_R_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->R); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_mos_set(void * jarg1, double jarg2) { + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double arg2 ; + + arg1 = (switch_rtp_numbers_t *)jarg1; + arg2 = (double)jarg2; + if (arg1) (arg1)->mos = arg2; +} + + +SWIGEXPORT double SWIGSTDCALL CSharp_switch_rtp_numbers_t_mos_get(void * jarg1) { + double jresult ; + switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; + double result; + + arg1 = (switch_rtp_numbers_t *)jarg1; + result = (double) ((arg1)->mos); + jresult = result; return jresult; } @@ -3543,7 +3819,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_numbers_t(void * jarg1) { arg1 = (switch_rtp_numbers_t *)jarg1; delete arg1; - } @@ -3554,7 +3829,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_packet_count_set(void * arg1 = (switch_rtcp_numbers_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->packet_count = arg2; - } @@ -3577,7 +3851,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_octet_count_set(void * arg1 = (switch_rtcp_numbers_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->octet_count = arg2; - } @@ -3600,7 +3873,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_peer_ssrc_set(void * ja arg1 = (switch_rtcp_numbers_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->peer_ssrc = arg2; - } @@ -3631,7 +3903,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtcp_numbers_t(void * jarg1) { arg1 = (switch_rtcp_numbers_t *)jarg1; delete arg1; - } @@ -3642,7 +3913,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_inbound_set(void * jarg1, arg1 = (switch_rtp_stats_t *)jarg1; arg2 = (switch_rtp_numbers_t *)jarg2; if (arg1) (arg1)->inbound = *arg2; - } @@ -3665,7 +3935,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_outbound_set(void * jarg1, arg1 = (switch_rtp_stats_t *)jarg1; arg2 = (switch_rtp_numbers_t *)jarg2; if (arg1) (arg1)->outbound = *arg2; - } @@ -3688,7 +3957,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_rtcp_set(void * jarg1, voi arg1 = (switch_rtp_stats_t *)jarg1; arg2 = (switch_rtcp_numbers_t *)jarg2; if (arg1) (arg1)->rtcp = *arg2; - } @@ -3711,7 +3979,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_read_count_set(void * jarg arg1 = (switch_rtp_stats_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->read_count = arg2; - } @@ -3742,7 +4009,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_stats_t(void * jarg1) { arg1 = (switch_rtp_stats_t *)jarg1; delete arg1; - } @@ -3750,8 +4016,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_CNG_PAYLOAD_get() { int jresult ; int result; - result = (int) 13; - + result = (int)(13); jresult = result; return jresult; } @@ -3764,7 +4029,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_version_set(void * jarg1, un arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->version = arg2; - } @@ -3787,7 +4051,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_p_set(void * jarg1, unsigned arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->p = arg2; - } @@ -3810,7 +4073,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_x_set(void * jarg1, unsigned arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->x = arg2; - } @@ -3833,7 +4095,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_cc_set(void * jarg1, unsigne arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->cc = arg2; - } @@ -3856,7 +4117,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_m_set(void * jarg1, unsigned arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->m = arg2; - } @@ -3879,7 +4139,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_pt_set(void * jarg1, unsigne arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->pt = arg2; - } @@ -3902,7 +4161,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_seq_set(void * jarg1, unsign arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->seq = arg2; - } @@ -3925,7 +4183,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_ts_set(void * jarg1, unsigne arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->ts = arg2; - } @@ -3948,7 +4205,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_t_ssrc_set(void * jarg1, unsig arg1 = (switch_rtp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->ssrc = arg2; - } @@ -3979,7 +4235,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_hdr_t(void * jarg1) { arg1 = (switch_rtp_hdr_t *)jarg1; delete arg1; - } @@ -3990,7 +4245,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_ext_t_length_set(void * jarg1, arg1 = (switch_rtp_hdr_ext_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->length = arg2; - } @@ -4013,7 +4267,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_hdr_ext_t_profile_set(void * jarg1 arg1 = (switch_rtp_hdr_ext_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->profile = arg2; - } @@ -4044,7 +4297,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_hdr_ext_t(void * jarg1) { arg1 = (switch_rtp_hdr_ext_t *)jarg1; delete arg1; - } @@ -4055,7 +4307,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_hdr_t_version_set(void * jarg1, u arg1 = (switch_rtcp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->version = arg2; - } @@ -4078,7 +4329,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_hdr_t_p_set(void * jarg1, unsigne arg1 = (switch_rtcp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->p = arg2; - } @@ -4101,7 +4351,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_hdr_t_count_set(void * jarg1, uns arg1 = (switch_rtcp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->count = arg2; - } @@ -4124,7 +4373,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_hdr_t_type_set(void * jarg1, unsi arg1 = (switch_rtcp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->type = arg2; - } @@ -4147,7 +4395,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_hdr_t_length_set(void * jarg1, un arg1 = (switch_rtcp_hdr_t *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->length = arg2; - } @@ -4178,27 +4425,25 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtcp_hdr_t(void * jarg1) { arg1 = (switch_rtcp_hdr_t *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_audio_buffer_header_t_ts_set(void * jarg1, unsigned long jarg2) { - audio_buffer_header_t *arg1 = (audio_buffer_header_t *) 0 ; + audio_buffer_header_s *arg1 = (audio_buffer_header_s *) 0 ; uint32_t arg2 ; - arg1 = (audio_buffer_header_t *)jarg1; + arg1 = (audio_buffer_header_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->ts = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_audio_buffer_header_t_ts_get(void * jarg1) { unsigned long jresult ; - audio_buffer_header_t *arg1 = (audio_buffer_header_t *) 0 ; + audio_buffer_header_s *arg1 = (audio_buffer_header_s *) 0 ; uint32_t result; - arg1 = (audio_buffer_header_t *)jarg1; + arg1 = (audio_buffer_header_s *)jarg1; result = (uint32_t) ((arg1)->ts); jresult = (unsigned long)result; return jresult; @@ -4206,22 +4451,21 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_audio_buffer_header_t_ts_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_audio_buffer_header_t_len_set(void * jarg1, unsigned long jarg2) { - audio_buffer_header_t *arg1 = (audio_buffer_header_t *) 0 ; + audio_buffer_header_s *arg1 = (audio_buffer_header_s *) 0 ; uint32_t arg2 ; - arg1 = (audio_buffer_header_t *)jarg1; + arg1 = (audio_buffer_header_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->len = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_audio_buffer_header_t_len_get(void * jarg1) { unsigned long jresult ; - audio_buffer_header_t *arg1 = (audio_buffer_header_t *) 0 ; + audio_buffer_header_s *arg1 = (audio_buffer_header_s *) 0 ; uint32_t result; - arg1 = (audio_buffer_header_t *)jarg1; + arg1 = (audio_buffer_header_s *)jarg1; result = (uint32_t) ((arg1)->len); jresult = (unsigned long)result; return jresult; @@ -4230,20 +4474,19 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_audio_buffer_header_t_len_get(void * SWIGEXPORT void * SWIGSTDCALL CSharp_new_audio_buffer_header_t() { void * jresult ; - audio_buffer_header_t *result = 0 ; + audio_buffer_header_s *result = 0 ; - result = (audio_buffer_header_t *)new audio_buffer_header_t(); + result = (audio_buffer_header_s *)new audio_buffer_header_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_audio_buffer_header_t(void * jarg1) { - audio_buffer_header_t *arg1 = (audio_buffer_header_t *) 0 ; + audio_buffer_header_s *arg1 = (audio_buffer_header_s *) 0 ; - arg1 = (audio_buffer_header_t *)jarg1; + arg1 = (audio_buffer_header_s *)jarg1; delete arg1; - } @@ -4254,7 +4497,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxVersion_set(void * arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint16_t)jarg2; if (arg1) (arg1)->T38FaxVersion = arg2; - } @@ -4277,7 +4519,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38MaxBitRate_set(void * arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->T38MaxBitRate = arg2; - } @@ -4300,7 +4541,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxFillBitRemoval_set arg1 = (switch_t38_options_t *)jarg1; arg2 = (switch_bool_t)jarg2; if (arg1) (arg1)->T38FaxFillBitRemoval = arg2; - } @@ -4323,7 +4563,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxTranscodingMMR_set arg1 = (switch_t38_options_t *)jarg1; arg2 = (switch_bool_t)jarg2; if (arg1) (arg1)->T38FaxTranscodingMMR = arg2; - } @@ -4346,7 +4585,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxTranscodingJBIG_se arg1 = (switch_t38_options_t *)jarg1; arg2 = (switch_bool_t)jarg2; if (arg1) (arg1)->T38FaxTranscodingJBIG = arg2; - } @@ -4398,7 +4636,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxMaxBuffer_set(void arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->T38FaxMaxBuffer = arg2; - } @@ -4421,7 +4658,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_T38FaxMaxDatagram_set(vo arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->T38FaxMaxDatagram = arg2; - } @@ -4531,7 +4767,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_remote_port_set(void * j arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint16_t)jarg2; if (arg1) (arg1)->remote_port = arg2; - } @@ -4583,7 +4818,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_t38_options_t_local_port_set(void * ja arg1 = (switch_t38_options_t *)jarg1; arg2 = (uint16_t)jarg2; if (arg1) (arg1)->local_port = arg2; - } @@ -4643,7 +4877,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_t38_options_t(void * jarg1) { arg1 = (switch_t38_options_t *)jarg1; delete arg1; - } @@ -4651,8 +4884,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MEDIA_TYPE_TOTAL_get() { int jresult ; int result; - result = (int) 2; - + result = (int)(2); jresult = result; return jresult; } @@ -4665,7 +4897,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_node_val_set(vo arg1 = (switch_console_callback_match_node *)jarg1; arg2 = (char *)jarg2; { - if (arg1->val) delete [] arg1->val; + delete [] arg1->val; if (arg2) { arg1->val = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->val, (const char *)arg2); @@ -4695,7 +4927,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_node_next_set(v arg1 = (switch_console_callback_match_node *)jarg1; arg2 = (switch_console_callback_match_node *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -4726,7 +4957,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_console_callback_match_node(voi arg1 = (switch_console_callback_match_node *)jarg1; delete arg1; - } @@ -4737,7 +4967,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_head_set(void * arg1 = (switch_console_callback_match *)jarg1; arg2 = (switch_console_callback_match_node *)jarg2; if (arg1) (arg1)->head = arg2; - } @@ -4760,7 +4989,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_end_set(void * arg1 = (switch_console_callback_match *)jarg1; arg2 = (switch_console_callback_match_node *)jarg2; if (arg1) (arg1)->end = arg2; - } @@ -4783,7 +5011,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_count_set(void arg1 = (switch_console_callback_match *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->count = arg2; - } @@ -4806,7 +5033,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_callback_match_dynamic_set(voi arg1 = (switch_console_callback_match *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->dynamic = arg2; - } @@ -4837,7 +5063,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_console_callback_match(void * j arg1 = (switch_console_callback_match *)jarg1; delete arg1; - } @@ -4845,8 +5070,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_DMACHINE_MAX_DIGIT_LEN_get() { int jresult ; int result; - result = (int) 512; - + result = (int)(512); jresult = result; return jresult; } @@ -4859,7 +5083,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_match_dmachine_set(void * arg1 = (switch_ivr_dmachine_match *)jarg1; arg2 = (switch_ivr_dmachine_t *)jarg2; if (arg1) (arg1)->dmachine = arg2; - } @@ -4911,7 +5134,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_match_match_key_set(void arg1 = (switch_ivr_dmachine_match *)jarg1; arg2 = (int32_t)jarg2; if (arg1) (arg1)->match_key = arg2; - } @@ -4934,7 +5156,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_match_type_set(void * jar arg1 = (switch_ivr_dmachine_match *)jarg1; arg2 = (dm_match_type_t)jarg2; if (arg1) (arg1)->type = arg2; - } @@ -4957,7 +5178,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_match_user_data_set(void arg1 = (switch_ivr_dmachine_match *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->user_data = arg2; - } @@ -4988,7 +5208,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_ivr_dmachine_match(void * jarg1 arg1 = (switch_ivr_dmachine_match *)jarg1; delete arg1; - } @@ -4996,8 +5215,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MAX_ARG_RECURSION_get() { int jresult ; int result; - result = (int) 25; - + result = (int)(25); jresult = result; return jresult; } @@ -5010,7 +5228,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_input_callback_set(void * arg1 = (switch_input_args_t *)jarg1; arg2 = (switch_input_callback_function_t)jarg2; if (arg1) (arg1)->input_callback = arg2; - } @@ -5033,7 +5250,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_buf_set(void * jarg1, voi arg1 = (switch_input_args_t *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->buf = arg2; - } @@ -5056,7 +5272,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_buflen_set(void * jarg1, arg1 = (switch_input_args_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->buflen = arg2; - } @@ -5079,7 +5294,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_read_frame_callback_set(v arg1 = (switch_input_args_t *)jarg1; arg2 = (switch_read_frame_callback_function_t)jarg2; if (arg1) (arg1)->read_frame_callback = arg2; - } @@ -5102,7 +5316,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_user_data_set(void * jarg arg1 = (switch_input_args_t *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->user_data = arg2; - } @@ -5125,7 +5338,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_dmachine_set(void * jarg1 arg1 = (switch_input_args_t *)jarg1; arg2 = (switch_ivr_dmachine_t *)jarg2; if (arg1) (arg1)->dmachine = arg2; - } @@ -5148,7 +5360,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_input_args_t_loops_set(void * jarg1, i arg1 = (switch_input_args_t *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->loops = arg2; - } @@ -5179,7 +5390,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_input_args_t(void * jarg1) { arg1 = (switch_input_args_t *)jarg1; delete arg1; - } @@ -5190,7 +5400,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_args_t_type_set(void * jarg1, int arg1 = (switch_say_args_t *)jarg1; arg2 = (switch_say_type_t)jarg2; if (arg1) (arg1)->type = arg2; - } @@ -5213,7 +5422,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_args_t_method_set(void * jarg1, in arg1 = (switch_say_args_t *)jarg1; arg2 = (switch_say_method_t)jarg2; if (arg1) (arg1)->method = arg2; - } @@ -5236,7 +5444,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_args_t_gender_set(void * jarg1, in arg1 = (switch_say_args_t *)jarg1; arg2 = (switch_say_gender_t)jarg2; if (arg1) (arg1)->gender = arg2; - } @@ -5296,7 +5503,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_say_args_t(void * jarg1) { arg1 = (switch_say_args_t *)jarg1; delete arg1; - } @@ -5304,30 +5510,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_API_VERSION_get() { int jresult ; int result; - result = (int) 5; - + result = (int)(5); jresult = result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_switch_api_version_set(void * jarg1, int jarg2) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; int arg2 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->switch_api_version = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_switch_api_version_get(void * jarg1) { int jresult ; - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; int result; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; result = (int) ((arg1)->switch_api_version); jresult = result; return jresult; @@ -5335,22 +5539,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_switch SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_load_set(void * jarg1, void * jarg2) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_load_t arg2 = (switch_module_load_t) 0 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; arg2 = (switch_module_load_t)jarg2; if (arg1) (arg1)->load = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_load_get(void * jarg1) { void * jresult ; - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_load_t result; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; result = (switch_module_load_t) ((arg1)->load); jresult = (void *)result; return jresult; @@ -5358,22 +5561,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_loa SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_shutdown_set(void * jarg1, void * jarg2) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_shutdown_t arg2 = (switch_module_shutdown_t) 0 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; arg2 = (switch_module_shutdown_t)jarg2; if (arg1) (arg1)->shutdown = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_shutdown_get(void * jarg1) { void * jresult ; - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_shutdown_t result; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; result = (switch_module_shutdown_t) ((arg1)->shutdown); jresult = (void *)result; return jresult; @@ -5381,22 +5583,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_shu SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_runtime_set(void * jarg1, void * jarg2) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_runtime_t arg2 = (switch_module_runtime_t) 0 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; arg2 = (switch_module_runtime_t)jarg2; if (arg1) (arg1)->runtime = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_runtime_get(void * jarg1) { void * jresult ; - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_runtime_t result; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; result = (switch_module_runtime_t) ((arg1)->runtime); jresult = (void *)result; return jresult; @@ -5404,22 +5605,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_run SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_flags_set(void * jarg1, unsigned long jarg2) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_flag_t arg2 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; arg2 = (switch_module_flag_t)jarg2; if (arg1) (arg1)->flags = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_loadable_module_function_table_t_flags_get(void * jarg1) { unsigned long jresult ; - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; switch_module_flag_t result; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; result = (switch_module_flag_t) ((arg1)->flags); jresult = (unsigned long)result; return jresult; @@ -5428,20 +5628,19 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_loadable_module_function_tabl SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_loadable_module_function_table_t() { void * jresult ; - switch_loadable_module_function_table_t *result = 0 ; + switch_loadable_module_function_table *result = 0 ; - result = (switch_loadable_module_function_table_t *)new switch_loadable_module_function_table_t(); + result = (switch_loadable_module_function_table *)new switch_loadable_module_function_table(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_loadable_module_function_table_t(void * jarg1) { - switch_loadable_module_function_table_t *arg1 = (switch_loadable_module_function_table_t *) 0 ; + switch_loadable_module_function_table *arg1 = (switch_loadable_module_function_table *) 0 ; - arg1 = (switch_loadable_module_function_table_t *)jarg1; + arg1 = (switch_loadable_module_function_table *)jarg1; delete arg1; - } @@ -5747,8 +5946,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_OK_get() { int jresult ; int result; - result = (int) 0; - + result = (int)(0); jresult = result; return jresult; } @@ -5758,8 +5956,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_ERROR_get() { int jresult ; int result; - result = (int) 1; - + result = (int)(1); jresult = result; return jresult; } @@ -5769,8 +5966,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_INTERNAL_get() { int jresult ; int result; - result = (int) 2; - + result = (int)(2); jresult = result; return jresult; } @@ -5780,8 +5976,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_PERM_get() { int jresult ; int result; - result = (int) 3; - + result = (int)(3); jresult = result; return jresult; } @@ -5791,8 +5986,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_ABORT_get() { int jresult ; int result; - result = (int) 4; - + result = (int)(4); jresult = result; return jresult; } @@ -5802,8 +5996,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_BUSY_get() { int jresult ; int result; - result = (int) 5; - + result = (int)(5); jresult = result; return jresult; } @@ -5813,8 +6006,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_LOCKED_get() { int jresult ; int result; - result = (int) 6; - + result = (int)(6); jresult = result; return jresult; } @@ -5824,8 +6016,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_NOMEM_get() { int jresult ; int result; - result = (int) 7; - + result = (int)(7); jresult = result; return jresult; } @@ -5835,8 +6026,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_READONLY_get() { int jresult ; int result; - result = (int) 8; - + result = (int)(8); jresult = result; return jresult; } @@ -5846,8 +6036,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_INTERRUPT_get() { int jresult ; int result; - result = (int) 9; - + result = (int)(9); jresult = result; return jresult; } @@ -5857,8 +6046,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_IOERR_get() { int jresult ; int result; - result = (int) 10; - + result = (int)(10); jresult = result; return jresult; } @@ -5868,8 +6056,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_CORRUPT_get() { int jresult ; int result; - result = (int) 11; - + result = (int)(11); jresult = result; return jresult; } @@ -5879,8 +6066,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_NOTFOUND_get() { int jresult ; int result; - result = (int) 12; - + result = (int)(12); jresult = result; return jresult; } @@ -5890,8 +6076,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_FULL_get() { int jresult ; int result; - result = (int) 13; - + result = (int)(13); jresult = result; return jresult; } @@ -5901,8 +6086,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_CANTOPEN_get() { int jresult ; int result; - result = (int) 14; - + result = (int)(14); jresult = result; return jresult; } @@ -5912,8 +6096,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_PROTOCOL_get() { int jresult ; int result; - result = (int) 15; - + result = (int)(15); jresult = result; return jresult; } @@ -5923,8 +6106,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_EMPTY_get() { int jresult ; int result; - result = (int) 16; - + result = (int)(16); jresult = result; return jresult; } @@ -5934,8 +6116,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_SCHEMA_get() { int jresult ; int result; - result = (int) 17; - + result = (int)(17); jresult = result; return jresult; } @@ -5945,8 +6126,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_TOOBIG_get() { int jresult ; int result; - result = (int) 18; - + result = (int)(18); jresult = result; return jresult; } @@ -5956,8 +6136,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_CONSTRAINT_get() { int jresult ; int result; - result = (int) 19; - + result = (int)(19); jresult = result; return jresult; } @@ -5967,8 +6146,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_MISMATCH_get() { int jresult ; int result; - result = (int) 20; - + result = (int)(20); jresult = result; return jresult; } @@ -5978,8 +6156,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_MISUSE_get() { int jresult ; int result; - result = (int) 21; - + result = (int)(21); jresult = result; return jresult; } @@ -5989,8 +6166,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_NOLFS_get() { int jresult ; int result; - result = (int) 22; - + result = (int)(22); jresult = result; return jresult; } @@ -6000,8 +6176,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_AUTH_get() { int jresult ; int result; - result = (int) 23; - + result = (int)(23); jresult = result; return jresult; } @@ -6011,8 +6186,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_FORMAT_get() { int jresult ; int result; - result = (int) 24; - + result = (int)(24); jresult = result; return jresult; } @@ -6022,8 +6196,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_RANGE_get() { int jresult ; int result; - result = (int) 25; - + result = (int)(25); jresult = result; return jresult; } @@ -6033,8 +6206,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_NOTADB_get() { int jresult ; int result; - result = (int) 26; - + result = (int)(26); jresult = result; return jresult; } @@ -6044,8 +6216,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_ROW_get() { int jresult ; int result; - result = (int) 100; - + result = (int)(100); jresult = result; return jresult; } @@ -6055,8 +6226,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_DONE_get() { int jresult ; int result; - result = (int) 101; - + result = (int)(101); jresult = result; return jresult; } @@ -6246,8 +6416,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get() { int jresult ; int result; - result = (int) 128; - + result = (int)(128); jresult = result; return jresult; } @@ -6257,8 +6426,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_STREAMS_get() { int jresult ; int result; - result = (int) 128; - + result = (int)(128); jresult = result; return jresult; } @@ -6271,7 +6439,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_mms_set(void * jarg arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->mms = arg2; - } @@ -6294,7 +6461,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_ms_set(void * jarg1 arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->ms = arg2; - } @@ -6317,7 +6483,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_sec_set(void * jarg arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->sec = arg2; - } @@ -6340,7 +6505,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_min_set(void * jarg arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->min = arg2; - } @@ -6363,7 +6527,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_hr_set(void * jarg1 arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->hr = arg2; - } @@ -6386,7 +6549,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_day_set(void * jarg arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->day = arg2; - } @@ -6409,7 +6571,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_time_duration_yr_set(void * jarg1 arg1 = (switch_core_time_duration *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->yr = arg2; - } @@ -6440,7 +6601,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_core_time_duration(void * jarg1 arg1 = (switch_core_time_duration *)jarg1; delete arg1; - } @@ -6451,7 +6611,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_app_log_app_set(void * jarg1, char * j arg1 = (switch_app_log *)jarg1; arg2 = (char *)jarg2; { - if (arg1->app) delete [] arg1->app; + delete [] arg1->app; if (arg2) { arg1->app = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->app, (const char *)arg2); @@ -6481,7 +6641,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_app_log_arg_set(void * jarg1, char * j arg1 = (switch_app_log *)jarg1; arg2 = (char *)jarg2; { - if (arg1->arg) delete [] arg1->arg; + delete [] arg1->arg; if (arg2) { arg1->arg = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->arg, (const char *)arg2); @@ -6517,7 +6677,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_app_log_stamp_set(void * jarg1, void * } arg2 = *argp2; if (arg1) (arg1)->stamp = arg2; - } @@ -6528,7 +6687,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_app_log_stamp_get(void * jarg1) { arg1 = (switch_app_log *)jarg1; result = ((arg1)->stamp); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -6540,7 +6699,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_app_log_next_set(void * jarg1, void * arg1 = (switch_app_log *)jarg1; arg2 = (switch_app_log *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -6571,16 +6729,15 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_app_log(void * jarg1) { arg1 = (switch_app_log *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_func_set(void * jarg1, void * jarg2) { - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; switch_thread_start_t arg2 ; switch_thread_start_t *argp2 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; argp2 = (switch_thread_start_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_thread_start_t", 0); @@ -6588,39 +6745,37 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_func_set(void * jarg1, v } arg2 = *argp2; if (arg1) (arg1)->func = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_func_get(void * jarg1) { void * jresult ; - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; switch_thread_start_t result; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; result = ((arg1)->func); - jresult = new switch_thread_start_t((switch_thread_start_t &)result); + jresult = new switch_thread_start_t((const switch_thread_start_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_obj_set(void * jarg1, void * jarg2) { - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; void *arg2 = (void *) 0 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->obj = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_obj_get(void * jarg1) { void * jresult ; - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; void *result = 0 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; result = (void *) ((arg1)->obj); jresult = (void *)result; return jresult; @@ -6628,22 +6783,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_obj_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_alloc_set(void * jarg1, int jarg2) { - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; int arg2 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->alloc = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_thread_data_t_alloc_get(void * jarg1) { int jresult ; - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; int result; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; result = (int) ((arg1)->alloc); jresult = result; return jresult; @@ -6651,22 +6805,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_thread_data_t_alloc_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_pool_set(void * jarg1, void * jarg2) { - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->pool = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_pool_get(void * jarg1) { void * jresult ; - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; switch_memory_pool_t *result = 0 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; result = (switch_memory_pool_t *) ((arg1)->pool); jresult = (void *)result; return jresult; @@ -6675,29 +6828,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_pool_get(void * jarg1) SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_thread_data_t() { void * jresult ; - switch_thread_data_t *result = 0 ; + switch_thread_data_s *result = 0 ; - result = (switch_thread_data_t *)new switch_thread_data_t(); + result = (switch_thread_data_s *)new switch_thread_data_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_thread_data_t(void * jarg1) { - switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_thread_data_s *arg1 = (switch_thread_data_s *) 0 ; - arg1 = (switch_thread_data_t *)jarg1; + arg1 = (switch_thread_data_s *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_on_set(void * jarg1, void * jarg2) { - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_time_t arg2 ; switch_time_t *argp2 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; argp2 = (switch_time_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); @@ -6705,28 +6857,27 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_on_set(void * jarg1, voi } arg2 = *argp2; if (arg1) (arg1)->on = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_hold_record_t_on_get(void * jarg1) { void * jresult ; - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_time_t result; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; result = ((arg1)->on); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_off_set(void * jarg1, void * jarg2) { - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_time_t arg2 ; switch_time_t *argp2 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; argp2 = (switch_time_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); @@ -6734,30 +6885,29 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_off_set(void * jarg1, vo } arg2 = *argp2; if (arg1) (arg1)->off = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_hold_record_t_off_get(void * jarg1) { void * jresult ; - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_time_t result; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; result = ((arg1)->off); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_uuid_set(void * jarg1, char * jarg2) { - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid) delete [] arg1->uuid; + delete [] arg1->uuid; if (arg2) { arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid, (const char *)arg2); @@ -6770,10 +6920,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_uuid_set(void * jarg1, c SWIGEXPORT char * SWIGSTDCALL CSharp_switch_hold_record_t_uuid_get(void * jarg1) { char * jresult ; - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; char *result = 0 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; result = (char *) ((arg1)->uuid); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -6781,22 +6931,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_hold_record_t_uuid_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_hold_record_t_next_set(void * jarg1, void * jarg2) { - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_hold_record_s *arg2 = (switch_hold_record_s *) 0 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; arg2 = (switch_hold_record_s *)jarg2; if (arg1) (arg1)->next = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_hold_record_t_next_get(void * jarg1) { void * jresult ; - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; switch_hold_record_s *result = 0 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; result = (switch_hold_record_s *) ((arg1)->next); jresult = (void *)result; return jresult; @@ -6805,31 +6954,30 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_hold_record_t_next_get(void * jarg1) SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_hold_record_t() { void * jresult ; - switch_hold_record_t *result = 0 ; + switch_hold_record_s *result = 0 ; - result = (switch_hold_record_t *)new switch_hold_record_t(); + result = (switch_hold_record_s *)new switch_hold_record_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_hold_record_t(void * jarg1) { - switch_hold_record_t *arg1 = (switch_hold_record_t *) 0 ; + switch_hold_record_s *arg1 = (switch_hold_record_s *) 0 ; - arg1 = (switch_hold_record_t *)jarg1; + arg1 = (switch_hold_record_s *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_uuid_set(void * jarg1, char * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid) delete [] arg1->uuid; + delete [] arg1->uuid; if (arg2) { arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid, (const char *)arg2); @@ -6842,10 +6990,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_uuid_set(void * jarg1, c SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_node_t_uuid_get(void * jarg1) { char * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; char *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (char *) ((arg1)->uuid); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -6853,45 +7001,43 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_node_t_uuid_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_xml_cdr_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_xml_t arg2 = (switch_xml_t) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->xml_cdr = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_xml_cdr_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_xml_t result; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_xml_t) ((arg1)->xml_cdr); jresult = (void *)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_event_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t__event_set(void * jarg1, void * jarg2) { + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_event_t *arg2 = (switch_event_t *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_event_t *)jarg2; if (arg1) (arg1)->event = arg2; - } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_event_get(void * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t__event_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_event_t *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_event_t *) ((arg1)->event); jresult = (void *)result; return jresult; @@ -6899,22 +7045,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_event_get(void * jarg1 SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_callstate_set(void * jarg1, int jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_channel_callstate_t arg2 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_channel_callstate_t)jarg2; if (arg1) (arg1)->callstate = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_node_t_callstate_get(void * jarg1) { int jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_channel_callstate_t result; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_channel_callstate_t) ((arg1)->callstate); jresult = result; return jresult; @@ -6922,22 +7067,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_node_t_callstate_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_hold_record_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_hold_record_t *arg2 = (switch_hold_record_t *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_hold_record_t *)jarg2; if (arg1) (arg1)->hold_record = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_hold_record_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_hold_record_t *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_hold_record_t *) ((arg1)->hold_record); jresult = (void *)result; return jresult; @@ -6945,45 +7089,65 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_hold_record_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_hup_profile_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_caller_profile_t *arg2 = (switch_caller_profile_t *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_caller_profile_t *)jarg2; if (arg1) (arg1)->hup_profile = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_hup_profile_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_caller_profile_t *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_caller_profile_t *) ((arg1)->hup_profile); jresult = (void *)result; return jresult; } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_direction_set(void * jarg1, int jarg2) { + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (device_uuid_node_s *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_node_t_direction_get(void * jarg1) { + int jresult ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; + switch_call_direction_t result; + + arg1 = (device_uuid_node_s *)jarg1; + result = (switch_call_direction_t) ((arg1)->direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_parent_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_device_record_s *arg2 = (switch_device_record_s *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (switch_device_record_s *)jarg2; if (arg1) (arg1)->parent = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_parent_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; switch_device_record_s *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (switch_device_record_s *) ((arg1)->parent); jresult = (void *)result; return jresult; @@ -6991,22 +7155,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_parent_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_next_set(void * jarg1, void * jarg2) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; device_uuid_node_s *arg2 = (device_uuid_node_s *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; arg2 = (device_uuid_node_s *)jarg2; if (arg1) (arg1)->next = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_next_get(void * jarg1) { void * jresult ; - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; device_uuid_node_s *result = 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; result = (device_uuid_node_s *) ((arg1)->next); jresult = (void *)result; return jresult; @@ -7015,211 +7178,532 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_next_get(void * jarg1) SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_node_t() { void * jresult ; - switch_device_node_t *result = 0 ; + device_uuid_node_s *result = 0 ; - result = (switch_device_node_t *)new switch_device_node_t(); + result = (device_uuid_node_s *)new device_uuid_node_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_device_node_t(void * jarg1) { - switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ; - arg1 = (switch_device_node_t *)jarg1; + arg1 = (device_uuid_node_s *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->total = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->total); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->total_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->total_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->offhook = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->offhook); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->offhook_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->offhook_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->active = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->active); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->active_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->active_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->held = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->held); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->held_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->held_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->hup = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->hup); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->hup_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->hup_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->ringing = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->ringing); jresult = (unsigned long)result; return jresult; } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_set(void * jarg1, unsigned long jarg2) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t arg2 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->ringing_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->ringing_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->early = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_get(void * jarg1) { unsigned long jresult ; - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; uint32_t result; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; result = (uint32_t) ((arg1)->early); jresult = (unsigned long)result; return jresult; } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->early_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->early_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_s *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ring_wait = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_s *)jarg1; + result = (uint32_t) ((arg1)->ring_wait); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_stats_t() { void * jresult ; - switch_device_stats_t *result = 0 ; + switch_device_stats_s *result = 0 ; - result = (switch_device_stats_t *)new switch_device_stats_t(); + result = (switch_device_stats_s *)new switch_device_stats_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_device_stats_t(void * jarg1) { - switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + switch_device_stats_s *arg1 = (switch_device_stats_s *) 0 ; - arg1 = (switch_device_stats_t *)jarg1; + arg1 = (switch_device_stats_s *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_device_id_set(void * jarg1, char * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->device_id) delete [] arg1->device_id; + delete [] arg1->device_id; if (arg2) { arg1->device_id = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->device_id, (const char *)arg2); @@ -7232,10 +7716,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_device_id_set(void * j SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_record_t_device_id_get(void * jarg1) { char * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; char *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (char *) ((arg1)->device_id); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -7243,13 +7727,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_record_t_device_id_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_set(void * jarg1, char * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid) delete [] arg1->uuid; + delete [] arg1->uuid; if (arg2) { arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid, (const char *)arg2); @@ -7262,10 +7746,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_set(void * jarg1, SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_record_t_uuid_get(void * jarg1) { char * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; char *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (char *) ((arg1)->uuid); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -7273,22 +7757,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_device_record_t_uuid_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_refs_set(void * jarg1, int jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; int arg2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_refs_get(void * jarg1) { int jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; int result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (int) ((arg1)->refs); jresult = result; return jresult; @@ -7296,45 +7779,65 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_refs_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_stats_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_stats_t *arg2 = (switch_device_stats_t *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (switch_device_stats_t *)jarg2; if (arg1) (arg1)->stats = *arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_stats_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_stats_t *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (switch_device_stats_t *)& ((arg1)->stats); jresult = (void *)result; return jresult; } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_stats_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_device_stats_t *arg2 = (switch_device_stats_t *) 0 ; + + arg1 = (switch_device_record_s *)jarg1; + arg2 = (switch_device_stats_t *)jarg2; + if (arg1) (arg1)->last_stats = *arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_stats_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_device_stats_t *result = 0 ; + + arg1 = (switch_device_record_s *)jarg1; + result = (switch_device_stats_t *)& ((arg1)->last_stats); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_state_set(void * jarg1, int jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_state_t arg2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (switch_device_state_t)jarg2; if (arg1) (arg1)->state = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_state_get(void * jarg1) { int jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_state_t result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (switch_device_state_t) ((arg1)->state); jresult = result; return jresult; @@ -7342,22 +7845,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_state_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_state_set(void * jarg1, int jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_state_t arg2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (switch_device_state_t)jarg2; if (arg1) (arg1)->last_state = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_last_state_get(void * jarg1) { int jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_device_state_t result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (switch_device_state_t) ((arg1)->last_state); jresult = result; return jresult; @@ -7365,11 +7867,11 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_record_t_last_state_get(void * j SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_active_start_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t arg2 ; switch_time_t *argp2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; argp2 = (switch_time_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); @@ -7377,28 +7879,27 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_active_start_set(void } arg2 = *argp2; if (arg1) (arg1)->active_start = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_active_start_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = ((arg1)->active_start); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_active_stop_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t arg2 ; switch_time_t *argp2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; argp2 = (switch_time_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); @@ -7406,28 +7907,27 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_active_stop_set(void * } arg2 = *argp2; if (arg1) (arg1)->active_stop = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_active_stop_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = ((arg1)->active_stop); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_call_time_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t arg2 ; switch_time_t *argp2 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; argp2 = (switch_time_t *)jarg2; if (!argp2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); @@ -7435,39 +7935,177 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_call_time_set(voi } arg2 = *argp2; if (arg1) (arg1)->last_call_time = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_call_time_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_time_t result; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = ((arg1)->last_call_time); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_start_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_s *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_start_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_s *)jarg1; + result = ((arg1)->ring_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_s *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_s *)jarg1; + result = ((arg1)->ring_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_start_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_s *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_start_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_s *)jarg1; + result = ((arg1)->hold_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_s *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_s *)jarg1; + result = ((arg1)->hold_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_call_start_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_s *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->call_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_call_start_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_s *)jarg1; + result = ((arg1)->call_start); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_list_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; device_uuid_node_s *arg2 = (device_uuid_node_s *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (device_uuid_node_s *)jarg2; if (arg1) (arg1)->uuid_list = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_uuid_list_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; device_uuid_node_s *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (device_uuid_node_s *) ((arg1)->uuid_list); jresult = (void *)result; return jresult; @@ -7475,22 +8113,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_uuid_list_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_tail_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; device_uuid_node_s *arg2 = (device_uuid_node_s *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (device_uuid_node_s *)jarg2; if (arg1) (arg1)->uuid_tail = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_uuid_tail_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; device_uuid_node_s *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (device_uuid_node_s *) ((arg1)->uuid_tail); jresult = (void *)result; return jresult; @@ -7498,22 +8135,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_uuid_tail_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_mutex_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->mutex = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_mutex_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_mutex_t *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (switch_mutex_t *) ((arg1)->mutex); jresult = (void *)result; return jresult; @@ -7521,44 +8157,64 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_mutex_get(void * jar SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_pool_set(void * jarg1, void * jarg2) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->pool = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_pool_get(void * jarg1) { void * jresult ; - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; switch_memory_pool_t *result = 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; result = (switch_memory_pool_t *) ((arg1)->pool); jresult = (void *)result; return jresult; } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_user_data_set(void * jarg1, void * jarg2) { + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (switch_device_record_s *)jarg1; + arg2 = (void *)jarg2; + if (arg1) (arg1)->user_data = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_user_data_get(void * jarg1) { + void * jresult ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; + void *result = 0 ; + + arg1 = (switch_device_record_s *)jarg1; + result = (void *) ((arg1)->user_data); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_record_t() { void * jresult ; - switch_device_record_t *result = 0 ; + switch_device_record_s *result = 0 ; - result = (switch_device_record_t *)new switch_device_record_t(); + result = (switch_device_record_s *)new switch_device_record_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_device_record_t(void * jarg1) { - switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_record_s *arg1 = (switch_device_record_s *) 0 ; - arg1 = (switch_device_record_t *)jarg1; + arg1 = (switch_device_record_s *)jarg1; delete arg1; - } @@ -7566,8 +8222,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_DTLS_SRTP_FNAME_get() { char * jresult ; char *result = 0 ; - result = (char *) "dtls-srtp"; - + result = (char *)("dtls-srtp"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -7577,8 +8232,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MAX_FPLEN_get() { int jresult ; int result; - result = (int) 64; - + result = (int)(64); jresult = result; return jresult; } @@ -7588,30 +8242,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MAX_FPSTRLEN_get() { int jresult ; int result; - result = (int) 192; - + result = (int)(192); jresult = result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_len_set(void * jarg1, unsigned long jarg2) { - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; uint32_t arg2 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->len = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_dtls_fingerprint_t_len_get(void * jarg1) { unsigned long jresult ; - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; uint32_t result; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; result = (uint32_t) ((arg1)->len); jresult = (unsigned long)result; return jresult; @@ -7619,10 +8271,10 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_dtls_fingerprint_t_len_get(void * ja SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_data_set(void * jarg1, void * jarg2) { - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; uint8_t *arg2 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; arg2 = (uint8_t *)jarg2; { size_t ii; @@ -7634,10 +8286,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_data_set(void * jarg1, voi SWIGEXPORT void * SWIGSTDCALL CSharp_dtls_fingerprint_t_data_get(void * jarg1) { void * jresult ; - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; uint8_t *result = 0 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; result = (uint8_t *)(uint8_t *) ((arg1)->data); jresult = result; return jresult; @@ -7645,13 +8297,13 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_dtls_fingerprint_t_data_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_type_set(void * jarg1, char * jarg2) { - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->type) delete [] arg1->type; + delete [] arg1->type; if (arg2) { arg1->type = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->type, (const char *)arg2); @@ -7664,10 +8316,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_type_set(void * jarg1, cha SWIGEXPORT char * SWIGSTDCALL CSharp_dtls_fingerprint_t_type_get(void * jarg1) { char * jresult ; - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; char *result = 0 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; result = (char *) ((arg1)->type); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -7675,24 +8327,28 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_dtls_fingerprint_t_type_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_dtls_fingerprint_t_str_set(void * jarg1, char * jarg2) { - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; char *arg2 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->str, (const char *)arg2, 192); - else arg1->str[0] = 0; + if(arg2) { + strncpy((char*)arg1->str, (const char *)arg2, 192-1); + arg1->str[192-1] = 0; + } else { + arg1->str[0] = 0; + } } } SWIGEXPORT char * SWIGSTDCALL CSharp_dtls_fingerprint_t_str_get(void * jarg1) { char * jresult ; - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; char *result = 0 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; result = (char *)(char *) ((arg1)->str); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -7701,20 +8357,19 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_dtls_fingerprint_t_str_get(void * jarg1) { SWIGEXPORT void * SWIGSTDCALL CSharp_new_dtls_fingerprint_t() { void * jresult ; - dtls_fingerprint_t *result = 0 ; + dtls_fp_s *result = 0 ; - result = (dtls_fingerprint_t *)new dtls_fingerprint_t(); + result = (dtls_fp_s *)new dtls_fp_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_dtls_fingerprint_t(void * jarg1) { - dtls_fingerprint_t *arg1 = (dtls_fingerprint_t *) 0 ; + dtls_fp_s *arg1 = (dtls_fp_s *) 0 ; - arg1 = (dtls_fingerprint_t *)jarg1; + arg1 = (dtls_fp_s *)jarg1; delete arg1; - } @@ -7722,8 +8377,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MESSAGE_STRING_ARG_MAX_get() { int jresult ; int result; - result = (int) 10; - + result = (int)(10); jresult = result; return jresult; } @@ -7736,7 +8390,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_from_set(void * j arg1 = (switch_core_session_message *)jarg1; arg2 = (char *)jarg2; { - if (arg1->from) delete [] arg1->from; + delete [] arg1->from; if (arg2) { arg1->from = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->from, (const char *)arg2); @@ -7766,7 +8420,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_message_id_set(vo arg1 = (switch_core_session_message *)jarg1; arg2 = (switch_core_session_message_types_t)jarg2; if (arg1) (arg1)->message_id = arg2; - } @@ -7789,7 +8442,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_numeric_arg_set(v arg1 = (switch_core_session_message *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->numeric_arg = arg2; - } @@ -7847,7 +8499,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_string_arg_size_s } arg2 = *argp2; if (arg1) (arg1)->string_arg_size = arg2; - } @@ -7858,7 +8509,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_message_string_arg_size arg1 = (switch_core_session_message *)jarg1; result = ((arg1)->string_arg_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -7870,7 +8521,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_pointer_arg_set(v arg1 = (switch_core_session_message *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->pointer_arg = arg2; - } @@ -7899,7 +8549,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_pointer_arg_size_ } arg2 = *argp2; if (arg1) (arg1)->pointer_arg_size = arg2; - } @@ -7910,7 +8559,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_message_pointer_arg_siz arg1 = (switch_core_session_message *)jarg1; result = ((arg1)->pointer_arg_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -7922,7 +8571,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_numeric_reply_set arg1 = (switch_core_session_message *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->numeric_reply = arg2; - } @@ -7945,7 +8593,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_string_reply_set( arg1 = (switch_core_session_message *)jarg1; arg2 = (char *)jarg2; { - if (arg1->string_reply) delete [] arg1->string_reply; + delete [] arg1->string_reply; if (arg2) { arg1->string_reply = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->string_reply, (const char *)arg2); @@ -7981,7 +8629,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_string_reply_size } arg2 = *argp2; if (arg1) (arg1)->string_reply_size = arg2; - } @@ -7992,7 +8639,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_message_string_reply_si arg1 = (switch_core_session_message *)jarg1; result = ((arg1)->string_reply_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -8004,7 +8651,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_pointer_reply_set arg1 = (switch_core_session_message *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->pointer_reply = arg2; - } @@ -8033,7 +8679,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_pointer_reply_siz } arg2 = *argp2; if (arg1) (arg1)->pointer_reply_size = arg2; - } @@ -8044,7 +8689,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_message_pointer_reply_s arg1 = (switch_core_session_message *)jarg1; result = ((arg1)->pointer_reply_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -8056,7 +8701,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_flags_set(void * arg1 = (switch_core_session_message *)jarg1; arg2 = (switch_core_session_message_flag_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -8137,7 +8781,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message__line_set(void * arg1 = (switch_core_session_message *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->_line = arg2; - } @@ -8192,7 +8835,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_message_delivery_time_set } arg2 = *argp2; if (arg1) (arg1)->delivery_time = arg2; - } @@ -8203,7 +8845,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_message_delivery_time_g arg1 = (switch_core_session_message *)jarg1; result = ((arg1)->delivery_time); - jresult = new time_t((time_t &)result); + jresult = new time_t((const time_t &)result); return jresult; } @@ -8223,7 +8865,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_core_session_message(void * jar arg1 = (switch_core_session_message *)jarg1; delete arg1; - } @@ -8234,7 +8875,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_thread_session_running_set(void * arg1 = (switch_core_thread_session *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->running = arg2; - } @@ -8257,7 +8897,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_thread_session_mutex_set(void * j arg1 = (switch_core_thread_session *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->mutex = arg2; - } @@ -8306,7 +8945,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_thread_session_input_callback_set arg1 = (switch_core_thread_session *)jarg1; arg2 = (switch_input_callback_function_t)jarg2; if (arg1) (arg1)->input_callback = arg2; - } @@ -8329,7 +8967,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_thread_session_pool_set(void * ja arg1 = (switch_core_thread_session *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->pool = arg2; - } @@ -8360,7 +8997,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_core_thread_session(void * jarg arg1 = (switch_core_thread_session *)jarg1; delete arg1; - } @@ -8468,8 +9104,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_add(void * jarg1, char * time_t arg6 ; switch_media_bug_flag_t arg7 ; switch_media_bug_t **arg8 = (switch_media_bug_t **) 0 ; - switch_status_t result; time_t *argp6 ; + switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (char *)jarg2; @@ -8834,19 +9470,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_set_pre_buffer_framecoun } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_port_allocator_new(unsigned short jarg1, unsigned short jarg2, unsigned long jarg3, void * jarg4) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_port_allocator_new(char * jarg1, unsigned short jarg2, unsigned short jarg3, unsigned long jarg4, void * jarg5) { int jresult ; - switch_port_t arg1 ; + char *arg1 = (char *) 0 ; switch_port_t arg2 ; - switch_port_flag_t arg3 ; - switch_core_port_allocator_t **arg4 = (switch_core_port_allocator_t **) 0 ; + switch_port_t arg3 ; + switch_port_flag_t arg4 ; + switch_core_port_allocator_t **arg5 = (switch_core_port_allocator_t **) 0 ; switch_status_t result; - arg1 = (switch_port_t)jarg1; + arg1 = (char *)jarg1; arg2 = (switch_port_t)jarg2; - arg3 = (switch_port_flag_t)jarg3; - arg4 = (switch_core_port_allocator_t **)jarg4; - result = (switch_status_t)switch_core_port_allocator_new(arg1,arg2,arg3,arg4); + arg3 = (switch_port_t)jarg3; + arg4 = (switch_port_flag_t)jarg4; + arg5 = (switch_core_port_allocator_t **)jarg5; + result = (switch_status_t)switch_core_port_allocator_new((char const *)arg1,arg2,arg3,arg4,arg5); jresult = result; return jresult; } @@ -9194,8 +9832,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_perform_permanent_alloc(void * char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; int arg4 ; - void *result = 0 ; switch_size_t *argp1 ; + void *result = 0 ; argp1 = (switch_size_t *)jarg1; if (!argp1) { @@ -9219,8 +9857,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_perform_alloc(void * jarg1, voi char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; int arg5 ; - void *result = 0 ; switch_size_t *argp2 ; + void *result = 0 ; arg1 = (switch_memory_pool_t *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -9245,8 +9883,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_perform_session_alloc(void * ja char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; int arg5 ; - void *result = 0 ; switch_size_t *argp2 ; + void *result = 0 ; arg1 = (switch_core_session_t *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -9471,7 +10109,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_id(void * jarg1) { arg1 = (switch_core_session_t *)jarg1; result = switch_core_session_get_id(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -9481,7 +10119,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_id() { switch_size_t result; result = switch_core_session_id(); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -9491,7 +10129,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_id_dec() { switch_size_t result; result = switch_core_session_id_dec(); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -12175,8 +12813,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_management_exec(char * jarg1, int switch_management_action_t arg2 ; char *arg3 = (char *) 0 ; switch_size_t arg4 ; - switch_status_t result; switch_size_t *argp4 ; + switch_status_t result; arg1 = (char *)jarg1; arg2 = (switch_management_action_t)jarg2; @@ -12288,7 +12926,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_uptime() { switch_time_t result; result = switch_core_uptime(); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -12419,7 +13057,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_micro_time_now() { switch_time_t result; result = switch_micro_time_now(); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -12429,7 +13067,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_mono_micro_time_now() { switch_time_t result; result = switch_mono_micro_time_now(); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -12464,7 +13102,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_time_ref() { switch_time_t result; result = switch_time_ref(); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -12481,7 +13119,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_epoch_time_now(void * jarg1) { arg1 = (time_t *)jarg1; result = switch_epoch_time_now(arg1); - jresult = new time_t((time_t &)result); + jresult = new time_t((const time_t &)result); return jresult; } @@ -12505,8 +13143,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_strftime_tz(char * jarg1, char * jarg2, char *arg3 = (char *) 0 ; size_t arg4 ; switch_time_t arg5 ; - switch_status_t result; switch_time_t *argp5 ; + switch_status_t result; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -12529,8 +13167,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_time_exp_tz_name(char * jarg1, void * j char *arg1 = (char *) 0 ; switch_time_exp_t *arg2 = (switch_time_exp_t *) 0 ; switch_time_t arg3 ; - switch_status_t result; switch_time_t *argp3 ; + switch_status_t result; arg1 = (char *)jarg1; arg2 = (switch_time_exp_t *)jarg2; @@ -12579,9 +13217,9 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_monotonic(int jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_timerfd(int jarg1) { - switch_bool_t arg1 ; + int arg1 ; - arg1 = (switch_bool_t)jarg1; + arg1 = (int)jarg1; switch_time_set_timerfd(arg1); } @@ -12831,8 +13469,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_CACHE_DB_LEN_get() { int jresult ; int result; - result = (int) 256; - + result = (int)(256); jresult = result; return jresult; } @@ -12845,7 +13482,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_native_handle_t_core_db_dbh_s arg1 = (switch_cache_db_native_handle_t *)jarg1; arg2 = (switch_core_db_t *)jarg2; if (arg1) (arg1)->core_db_dbh = arg2; - } @@ -12868,7 +13504,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_native_handle_t_odbc_dbh_set( arg1 = (switch_cache_db_native_handle_t *)jarg1; arg2 = (switch_odbc_handle_t *)jarg2; if (arg1) (arg1)->odbc_dbh = arg2; - } @@ -12891,7 +13526,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_native_handle_t_pgsql_dbh_set arg1 = (switch_cache_db_native_handle_t *)jarg1; arg2 = (switch_pgsql_handle_t *)jarg2; if (arg1) (arg1)->pgsql_dbh = arg2; - } @@ -12922,7 +13556,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_native_handle_t(void * arg1 = (switch_cache_db_native_handle_t *)jarg1; delete arg1; - } @@ -12933,7 +13566,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_core_db_options_t_db_path_set arg1 = (switch_cache_db_core_db_options_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->db_path) delete [] arg1->db_path; + delete [] arg1->db_path; if (arg2) { arg1->db_path = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->db_path, (const char *)arg2); @@ -12971,7 +13604,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_core_db_options_t(void arg1 = (switch_cache_db_core_db_options_t *)jarg1; delete arg1; - } @@ -12982,7 +13614,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_odbc_options_t_dsn_set(void * arg1 = (switch_cache_db_odbc_options_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->dsn) delete [] arg1->dsn; + delete [] arg1->dsn; if (arg2) { arg1->dsn = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->dsn, (const char *)arg2); @@ -13012,7 +13644,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_odbc_options_t_user_set(void arg1 = (switch_cache_db_odbc_options_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->user) delete [] arg1->user; + delete [] arg1->user; if (arg2) { arg1->user = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->user, (const char *)arg2); @@ -13042,7 +13674,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_odbc_options_t_pass_set(void arg1 = (switch_cache_db_odbc_options_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->pass) delete [] arg1->pass; + delete [] arg1->pass; if (arg2) { arg1->pass = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->pass, (const char *)arg2); @@ -13080,7 +13712,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_odbc_options_t(void * arg1 = (switch_cache_db_odbc_options_t *)jarg1; delete arg1; - } @@ -13091,7 +13722,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_pgsql_options_t_dsn_set(void arg1 = (switch_cache_db_pgsql_options_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->dsn) delete [] arg1->dsn; + delete [] arg1->dsn; if (arg2) { arg1->dsn = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->dsn, (const char *)arg2); @@ -13129,7 +13760,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_pgsql_options_t(void * arg1 = (switch_cache_db_pgsql_options_t *)jarg1; delete arg1; - } @@ -13140,7 +13770,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_connection_options_t_core_db_ arg1 = (switch_cache_db_connection_options_t *)jarg1; arg2 = (switch_cache_db_core_db_options_t *)jarg2; if (arg1) (arg1)->core_db_options = *arg2; - } @@ -13163,7 +13792,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_connection_options_t_odbc_opt arg1 = (switch_cache_db_connection_options_t *)jarg1; arg2 = (switch_cache_db_odbc_options_t *)jarg2; if (arg1) (arg1)->odbc_options = *arg2; - } @@ -13186,7 +13814,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_connection_options_t_pgsql_op arg1 = (switch_cache_db_connection_options_t *)jarg1; arg2 = (switch_cache_db_pgsql_options_t *)jarg2; if (arg1) (arg1)->pgsql_options = *arg2; - } @@ -13217,7 +13844,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_connection_options_t(v arg1 = (switch_cache_db_connection_options_t *)jarg1; delete arg1; - } @@ -13964,7 +14590,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fork() { pid_t result; result = switch_fork(); - jresult = new pid_t((pid_t &)result); + jresult = new pid_t((const pid_t &)result); return jresult; } @@ -14059,6 +14685,84 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ice_direction(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_debug_pool(void * jarg1) { + switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ; + + arg1 = (switch_stream_handle_t *)jarg1; + switch_core_session_debug_pool(arg1); +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_major() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_major(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_minor() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_minor(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_micro() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_micro(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_revision() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_revision(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_revision_human() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_revision_human(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_full() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_full(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_version_full_human() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_version_full_human(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -14095,7 +14799,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_endpoint_int arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_endpoint_interface_t *)jarg2; if (arg1) (arg1)->endpoint_interface = arg2; - } @@ -14118,7 +14821,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_timer_interf arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_timer_interface_t *)jarg2; if (arg1) (arg1)->timer_interface = arg2; - } @@ -14141,7 +14843,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_dialplan_int arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_dialplan_interface_t *)jarg2; if (arg1) (arg1)->dialplan_interface = arg2; - } @@ -14164,7 +14865,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_codec_interf arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_codec_interface_t *)jarg2; if (arg1) (arg1)->codec_interface = arg2; - } @@ -14187,7 +14887,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_application_ arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_application_interface_t *)jarg2; if (arg1) (arg1)->application_interface = arg2; - } @@ -14210,7 +14909,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_applica arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_chat_application_interface_t *)jarg2; if (arg1) (arg1)->chat_application_interface = arg2; - } @@ -14233,7 +14931,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interfac arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_api_interface_t *)jarg2; if (arg1) (arg1)->api_interface = arg2; - } @@ -14256,7 +14953,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_json_api_int arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_json_api_interface_t *)jarg2; if (arg1) (arg1)->json_api_interface = arg2; - } @@ -14279,7 +14975,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_file_interfa arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_file_interface_t *)jarg2; if (arg1) (arg1)->file_interface = arg2; - } @@ -14302,7 +14997,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_speech_inter arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_speech_interface_t *)jarg2; if (arg1) (arg1)->speech_interface = arg2; - } @@ -14325,7 +15019,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_directory_in arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_directory_interface_t *)jarg2; if (arg1) (arg1)->directory_interface = arg2; - } @@ -14348,7 +15041,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_interfa arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_chat_interface_t *)jarg2; if (arg1) (arg1)->chat_interface = arg2; - } @@ -14371,7 +15063,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_say_interfac arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_say_interface_t *)jarg2; if (arg1) (arg1)->say_interface = arg2; - } @@ -14394,7 +15085,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_asr_interfac arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_asr_interface_t *)jarg2; if (arg1) (arg1)->asr_interface = arg2; - } @@ -14417,7 +15107,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_management_i arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_management_interface_t *)jarg2; if (arg1) (arg1)->management_interface = arg2; - } @@ -14440,7 +15129,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_limit_interf arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_limit_interface_t *)jarg2; if (arg1) (arg1)->limit_interface = arg2; - } @@ -14463,7 +15151,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_rwlock_set(v arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -14486,7 +15173,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_refs_set(voi arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -14509,7 +15195,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_pool_set(voi arg1 = (switch_loadable_module_interface *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->pool = arg2; - } @@ -14540,7 +15225,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_loadable_module_interface(void arg1 = (switch_loadable_module_interface *)jarg1; delete arg1; - } @@ -15069,8 +15753,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CMD_CHUNK_LEN_get() { int jresult ; int result; - result = (int) 1024; - + result = (int)(1024); jresult = result; return jresult; } @@ -15086,8 +15769,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_console_stream_raw_write(void * jarg1, switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ; uint8_t *arg2 = (uint8_t *) 0 ; switch_size_t arg3 ; - switch_status_t result; switch_size_t *argp3 ; + switch_status_t result; arg1 = (switch_stream_handle_t *)jarg1; arg2 = (uint8_t *)jarg2; @@ -15477,7 +16160,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v4_set(void * jarg1, unsigned long jarg2 arg1 = (ip_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->v4 = arg2; - } @@ -15506,7 +16188,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v6_set(void * jarg1, void * jarg2) { } arg2 = *argp2; if (arg1) (arg1)->v6 = arg2; - } @@ -15517,7 +16198,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_ip_t_v6_get(void * jarg1) { arg1 = (ip_t *)jarg1; result = ((arg1)->v6); - jresult = new in6_addr((in6_addr &)result); + jresult = new in6_addr((const in6_addr &)result); return jresult; } @@ -15537,7 +16218,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_ip_t(void * jarg1) { arg1 = (ip_t *)jarg1; delete arg1; - } @@ -15546,10 +16226,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_testv6_subnet(void * jarg1, void * jarg ip_t arg1 ; ip_t arg2 ; ip_t arg3 ; - switch_bool_t result; ip_t *argp1 ; ip_t *argp2 ; ip_t *argp3 ; + switch_bool_t result; argp1 = (ip_t *)jarg1; if (!argp1) { @@ -15580,8 +16260,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_print_host(void * jarg1, char * jarg switch_sockaddr_t *arg1 = (switch_sockaddr_t *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (switch_sockaddr_t *)jarg1; arg2 = (char *)jarg2; @@ -15601,8 +16281,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_SMAX_get() { int jresult ; int result; - result = (int) 32767; - + result = (int)(32767); jresult = result; return jresult; } @@ -15612,8 +16291,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_SMIN_get() { int jresult ; int result; - result = (int) -32768; - + result = (int)(-32768); jresult = result; return jresult; } @@ -15677,9 +16355,9 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_b64_encode(void * jarg1, void * jarg2, switch_size_t arg2 ; unsigned char *arg3 = (unsigned char *) 0 ; switch_size_t arg4 ; - switch_status_t result; switch_size_t *argp2 ; switch_size_t *argp4 ; + switch_status_t result; arg1 = (unsigned char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -15706,8 +16384,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_b64_decode(char * jarg1, char * jarg char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -15718,7 +16396,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_b64_decode(char * jarg1, char * jarg } arg3 = *argp3; result = switch_b64_decode(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -15728,8 +16406,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_amp_encode(char * jarg1, char * jarg char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -15798,8 +16476,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fd_read_line(int jarg1, char * jarg2 int arg1 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (int)jarg1; arg2 = (char *)jarg2; @@ -15810,7 +16488,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fd_read_line(int jarg1, char * jarg2 } arg3 = *argp3; result = switch_fd_read_line(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -15826,7 +16504,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fd_read_dline(int jarg1, void * jarg arg2 = (char **)jarg2; arg3 = (switch_size_t *)jarg3; result = switch_fd_read_dline(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -15842,7 +16520,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fp_read_dline(void * jarg1, void * j arg2 = (char **)jarg2; arg3 = (switch_size_t *)jarg3; result = switch_fp_read_dline(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -15851,8 +16529,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_frame_alloc(void * jarg1, void * jarg2) int jresult ; switch_frame_t **arg1 = (switch_frame_t **) 0 ; switch_size_t arg2 ; - switch_status_t result; switch_size_t *argp2 ; + switch_status_t result; arg1 = (switch_frame_t **)jarg1; argp2 = (switch_size_t *)jarg2; @@ -15933,6 +16611,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_true(char * jarg1) { } +SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_true_byte(char * jarg1) { + unsigned char jresult ; + char *arg1 = (char *) 0 ; + switch_byte_t result; + + arg1 = (char *)jarg1; + result = (switch_byte_t)switch_true_byte((char const *)arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_false(char * jarg1) { int jresult ; char *arg1 = (char *) 0 ; @@ -16005,9 +16695,9 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_get_addr(char * jarg1, void * jarg2, void * switch_size_t arg2 ; sockaddr *arg3 = (sockaddr *) 0 ; socklen_t arg4 ; - char *result = 0 ; switch_size_t *argp2 ; socklen_t *argp4 ; + char *result = 0 ; arg1 = (char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -16035,9 +16725,9 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_get_addr6(char * jarg1, void * jarg2, void switch_size_t arg2 ; sockaddr_in6 *arg3 = (sockaddr_in6 *) 0 ; socklen_t arg4 ; - char *result = 0 ; switch_size_t *argp2 ; socklen_t *argp4 ; + char *result = 0 ; arg1 = (char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -16105,8 +16795,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_build_uri(char * jarg1, void * jarg2, c char *arg4 = (char *) 0 ; switch_sockaddr_t *arg5 = (switch_sockaddr_t *) 0 ; int arg6 ; - int result; switch_size_t *argp2 ; + int result; arg1 = (char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -16306,7 +16996,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_str_time(char * jarg1) { arg1 = (char *)jarg1; result = switch_str_time((char const *)arg1); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -16378,8 +17068,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strip_commas(char * jarg1, char * ja char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -16400,8 +17090,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strip_nonnumerics(char * jarg1, char char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -16512,8 +17202,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_escape_string(char * jarg1, char * j char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -16815,8 +17505,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_network_list_validate_ip6_token(void * switch_network_list_t *arg1 = (switch_network_list_t *) 0 ; ip_t arg2 ; char **arg3 = (char **) 0 ; - switch_bool_t result; ip_t *argp2 ; + switch_bool_t result; arg1 = (switch_network_list_t *)jarg1; argp2 = (ip_t *)jarg2; @@ -16960,8 +17650,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_uuid_str(char * jarg1, void * jarg2) char * jresult ; char *arg1 = (char *) 0 ; switch_size_t arg2 ; - char *result = 0 ; switch_size_t *argp2 ; + char *result = 0 ; arg1 = (char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -17017,8 +17707,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strerror_r(int jarg1, char * jarg2, int arg1 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - char *result = 0 ; switch_size_t *argp3 ; + char *result = 0 ; arg1 = (int)jarg1; arg2 = (char *)jarg2; @@ -17035,13 +17725,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strerror_r(int jarg1, char * jarg2, SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_var_set(void * jarg1, char * jarg2) { - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->var) delete [] arg1->var; + delete [] arg1->var; if (arg2) { arg1->var = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->var, (const char *)arg2); @@ -17054,10 +17744,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_var_set(void * jarg1, char * j SWIGEXPORT char * SWIGSTDCALL CSharp_profile_node_t_var_get(void * jarg1) { char * jresult ; - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; char *result = 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; result = (char *) ((arg1)->var); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -17065,13 +17755,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_profile_node_t_var_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_val_set(void * jarg1, char * jarg2) { - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->val) delete [] arg1->val; + delete [] arg1->val; if (arg2) { arg1->val = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->val, (const char *)arg2); @@ -17084,10 +17774,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_val_set(void * jarg1, char * j SWIGEXPORT char * SWIGSTDCALL CSharp_profile_node_t_val_get(void * jarg1) { char * jresult ; - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; char *result = 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; result = (char *) ((arg1)->val); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -17095,22 +17785,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_profile_node_t_val_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_next_set(void * jarg1, void * jarg2) { - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; profile_node_s *arg2 = (profile_node_s *) 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; arg2 = (profile_node_s *)jarg2; if (arg1) (arg1)->next = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_profile_node_t_next_get(void * jarg1) { void * jresult ; - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; profile_node_s *result = 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; result = (profile_node_s *) ((arg1)->next); jresult = (void *)result; return jresult; @@ -17119,20 +17808,19 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_profile_node_t_next_get(void * jarg1) { SWIGEXPORT void * SWIGSTDCALL CSharp_new_profile_node_t() { void * jresult ; - profile_node_t *result = 0 ; + profile_node_s *result = 0 ; - result = (profile_node_t *)new profile_node_t(); + result = (profile_node_s *)new profile_node_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_profile_node_t(void * jarg1) { - profile_node_t *arg1 = (profile_node_t *) 0 ; + profile_node_s *arg1 = (profile_node_s *) 0 ; - arg1 = (profile_node_t *)jarg1; + arg1 = (profile_node_s *)jarg1; delete arg1; - } @@ -17375,7 +18063,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_caller_ton_set(void * j arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->caller_ton = arg2; - } @@ -17398,7 +18085,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_caller_numplan_set(void arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->caller_numplan = arg2; - } @@ -17479,7 +18165,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_ani_ton_set(void * jarg arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->ani_ton = arg2; - } @@ -17502,7 +18187,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_ani_numplan_set(void * arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->ani_numplan = arg2; - } @@ -17583,7 +18267,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_rdnis_ton_set(void * ja arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->rdnis_ton = arg2; - } @@ -17606,7 +18289,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_rdnis_numplan_set(void arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->rdnis_numplan = arg2; - } @@ -17629,7 +18311,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_destination_number_set( arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->destination_number) delete [] arg1->destination_number; + delete [] arg1->destination_number; if (arg2) { arg1->destination_number = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->destination_number, (const char *)arg2); @@ -17659,7 +18341,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_destination_number_ton_ arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->destination_number_ton = arg2; - } @@ -17682,7 +18363,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_destination_number_nump arg1 = (switch_caller_profile *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->destination_number_numplan = arg2; - } @@ -17734,7 +18414,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_chan_name_set(void * ja arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->chan_name) delete [] arg1->chan_name; + delete [] arg1->chan_name; if (arg2) { arg1->chan_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->chan_name, (const char *)arg2); @@ -17764,7 +18444,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_uuid_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid) delete [] arg1->uuid; + delete [] arg1->uuid; if (arg2) { arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid, (const char *)arg2); @@ -17852,7 +18532,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_flags_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile_flag_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -17875,7 +18554,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_originator_caller_profi arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->originator_caller_profile = arg2; - } @@ -17898,7 +18576,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_originatee_caller_profi arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->originatee_caller_profile = arg2; - } @@ -17921,7 +18598,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_origination_caller_prof arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->origination_caller_profile = arg2; - } @@ -17944,7 +18620,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_hunt_caller_profile_set arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->hunt_caller_profile = arg2; - } @@ -17967,7 +18642,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_times_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_channel_timetable *)jarg2; if (arg1) (arg1)->times = arg2; - } @@ -17990,7 +18664,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_old_times_set(void * ja arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_channel_timetable *)jarg2; if (arg1) (arg1)->old_times = arg2; - } @@ -18013,7 +18686,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_caller_extension_set(vo arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_extension *)jarg2; if (arg1) (arg1)->caller_extension = arg2; - } @@ -18036,7 +18708,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_pool_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->pool = arg2; - } @@ -18059,7 +18730,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_next_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -18082,7 +18752,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_direction_set(void * ja arg1 = (switch_caller_profile *)jarg1; arg2 = (switch_call_direction_t)jarg2; if (arg1) (arg1)->direction = arg2; - } @@ -18098,6 +18767,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_direction_get(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_set(void * jarg1, int jarg2) { + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_caller_profile *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->logical_direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_get(void * jarg1) { + int jresult ; + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_caller_profile *)jarg1; + result = (switch_call_direction_t) ((arg1)->logical_direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_soft_set(void * jarg1, void * jarg2) { switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; profile_node_t *arg2 = (profile_node_t *) 0 ; @@ -18105,7 +18796,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_soft_set(void * jarg1, arg1 = (switch_caller_profile *)jarg1; arg2 = (profile_node_t *)jarg2; if (arg1) (arg1)->soft = arg2; - } @@ -18128,7 +18818,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_uuid_str_set(void * jar arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid_str) delete [] arg1->uuid_str; + delete [] arg1->uuid_str; if (arg2) { arg1->uuid_str = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid_str, (const char *)arg2); @@ -18158,7 +18848,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_clone_of_set(void * jar arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->clone_of) delete [] arg1->clone_of; + delete [] arg1->clone_of; if (arg2) { arg1->clone_of = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->clone_of, (const char *)arg2); @@ -18188,7 +18878,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_transfer_source_set(voi arg1 = (switch_caller_profile *)jarg1; arg2 = (char *)jarg2; { - if (arg1->transfer_source) delete [] arg1->transfer_source; + delete [] arg1->transfer_source; if (arg2) { arg1->transfer_source = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->transfer_source, (const char *)arg2); @@ -18226,7 +18916,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_caller_profile(void * jarg1) { arg1 = (switch_caller_profile *)jarg1; delete arg1; - } @@ -18237,7 +18926,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_application_application_name_se arg1 = (switch_caller_application *)jarg1; arg2 = (char *)jarg2; { - if (arg1->application_name) delete [] arg1->application_name; + delete [] arg1->application_name; if (arg2) { arg1->application_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->application_name, (const char *)arg2); @@ -18267,7 +18956,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_application_application_data_se arg1 = (switch_caller_application *)jarg1; arg2 = (char *)jarg2; { - if (arg1->application_data) delete [] arg1->application_data; + delete [] arg1->application_data; if (arg2) { arg1->application_data = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->application_data, (const char *)arg2); @@ -18297,7 +18986,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_application_application_functio arg1 = (switch_caller_application *)jarg1; arg2 = (switch_application_function_t)jarg2; if (arg1) (arg1)->application_function = arg2; - } @@ -18320,7 +19008,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_application_next_set(void * jar arg1 = (switch_caller_application *)jarg1; arg2 = (switch_caller_application *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -18351,7 +19038,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_caller_application(void * jarg1 arg1 = (switch_caller_application *)jarg1; delete arg1; - } @@ -18362,7 +19048,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_extension_name_set(vo arg1 = (switch_caller_extension *)jarg1; arg2 = (char *)jarg2; { - if (arg1->extension_name) delete [] arg1->extension_name; + delete [] arg1->extension_name; if (arg2) { arg1->extension_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->extension_name, (const char *)arg2); @@ -18392,7 +19078,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_extension_number_set( arg1 = (switch_caller_extension *)jarg1; arg2 = (char *)jarg2; { - if (arg1->extension_number) delete [] arg1->extension_number; + delete [] arg1->extension_number; if (arg2) { arg1->extension_number = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->extension_number, (const char *)arg2); @@ -18422,7 +19108,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_current_application_s arg1 = (switch_caller_extension *)jarg1; arg2 = (switch_caller_application_t *)jarg2; if (arg1) (arg1)->current_application = arg2; - } @@ -18445,7 +19130,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_last_application_set( arg1 = (switch_caller_extension *)jarg1; arg2 = (switch_caller_application_t *)jarg2; if (arg1) (arg1)->last_application = arg2; - } @@ -18468,7 +19152,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_applications_set(void arg1 = (switch_caller_extension *)jarg1; arg2 = (switch_caller_application_t *)jarg2; if (arg1) (arg1)->applications = arg2; - } @@ -18491,7 +19174,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_children_set(void * j arg1 = (switch_caller_extension *)jarg1; arg2 = (switch_caller_profile *)jarg2; if (arg1) (arg1)->children = arg2; - } @@ -18514,7 +19196,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_extension_next_set(void * jarg1 arg1 = (switch_caller_extension *)jarg1; arg2 = (switch_caller_extension *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -18545,7 +19226,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_caller_extension(void * jarg1) arg1 = (switch_caller_extension *)jarg1; delete arg1; - } @@ -18705,7 +19385,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_codec_set(void * jarg1, void * j arg1 = (switch_frame *)jarg1; arg2 = (switch_codec_t *)jarg2; if (arg1) (arg1)->codec = arg2; - } @@ -18757,7 +19436,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_packet_set(void * jarg1, void * arg1 = (switch_frame *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->packet = arg2; - } @@ -18780,7 +19458,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_packetlen_set(void * jarg1, unsi arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->packetlen = arg2; - } @@ -18803,7 +19480,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_extra_data_set(void * jarg1, voi arg1 = (switch_frame *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->extra_data = arg2; - } @@ -18826,7 +19502,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_data_set(void * jarg1, void * ja arg1 = (switch_frame *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->data = arg2; - } @@ -18849,7 +19524,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_datalen_set(void * jarg1, unsign arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->datalen = arg2; - } @@ -18872,7 +19546,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_buflen_set(void * jarg1, unsigne arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->buflen = arg2; - } @@ -18895,7 +19568,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_samples_set(void * jarg1, unsign arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samples = arg2; - } @@ -18918,7 +19590,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_rate_set(void * jarg1, unsigned arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->rate = arg2; - } @@ -18941,7 +19612,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_payload_set(void * jarg1, unsign arg1 = (switch_frame *)jarg1; arg2 = (switch_payload_t)jarg2; if (arg1) (arg1)->payload = arg2; - } @@ -18970,7 +19640,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_timestamp_set(void * jarg1, void } arg2 = *argp2; if (arg1) (arg1)->timestamp = arg2; - } @@ -18981,7 +19650,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_timestamp_get(void * jarg1) { arg1 = (switch_frame *)jarg1; result = ((arg1)->timestamp); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -18993,7 +19662,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_seq_set(void * jarg1, unsigned s arg1 = (switch_frame *)jarg1; arg2 = (uint16_t)jarg2; if (arg1) (arg1)->seq = arg2; - } @@ -19016,7 +19684,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_ssrc_set(void * jarg1, unsigned arg1 = (switch_frame *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->ssrc = arg2; - } @@ -19039,7 +19706,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_m_set(void * jarg1, int jarg2) { arg1 = (switch_frame *)jarg1; arg2 = (switch_bool_t)jarg2; if (arg1) (arg1)->m = arg2; - } @@ -19062,7 +19728,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_flags_set(void * jarg1, unsigned arg1 = (switch_frame *)jarg1; arg2 = (switch_frame_flag_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -19085,7 +19750,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_user_data_set(void * jarg1, void arg1 = (switch_frame *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->user_data = arg2; - } @@ -19101,6 +19765,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_user_data_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_pmap_set(void * jarg1, void * jarg2) { + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *arg2 = (payload_map_t *) 0 ; + + arg1 = (switch_frame *)jarg1; + arg2 = (payload_map_t *)jarg2; + if (arg1) (arg1)->pmap = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_pmap_get(void * jarg1) { + void * jresult ; + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *result = 0 ; + + arg1 = (switch_frame *)jarg1; + result = (payload_map_t *) ((arg1)->pmap); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_frame() { void * jresult ; switch_frame *result = 0 ; @@ -19116,7 +19802,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_frame(void * jarg1) { arg1 = (switch_frame *)jarg1; delete arg1; - } @@ -19127,7 +19812,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_init_set(void * arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_init = arg2; - } @@ -19150,7 +19834,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_routing_set(voi arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_routing = arg2; - } @@ -19173,7 +19856,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_execute_set(voi arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_execute = arg2; - } @@ -19196,7 +19878,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_hangup_set(void arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_hangup = arg2; - } @@ -19219,7 +19900,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_exchange_media_ arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_exchange_media = arg2; - } @@ -19242,7 +19922,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_soft_execute_se arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_soft_execute = arg2; - } @@ -19265,7 +19944,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_consume_media_s arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_consume_media = arg2; - } @@ -19288,7 +19966,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_hibernate_set(v arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_hibernate = arg2; - } @@ -19311,7 +19988,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_reset_set(void arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_reset = arg2; - } @@ -19334,7 +20010,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_park_set(void * arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_park = arg2; - } @@ -19357,7 +20032,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_reporting_set(v arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_reporting = arg2; - } @@ -19380,7 +20054,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_destroy_set(voi arg1 = (switch_state_handler_table *)jarg1; arg2 = (switch_state_handler_t)jarg2; if (arg1) (arg1)->on_destroy = arg2; - } @@ -19403,7 +20076,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_flags_set(void * j arg1 = (switch_state_handler_table *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -19460,7 +20132,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_state_handler_table(void * jarg arg1 = (switch_state_handler_table *)jarg1; delete arg1; - } @@ -19471,7 +20142,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_write_function_set(void arg1 = (switch_stream_handle *)jarg1; arg2 = (switch_stream_handle_write_function_t)jarg2; if (arg1) (arg1)->write_function = arg2; - } @@ -19494,7 +20164,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_raw_write_function_set(v arg1 = (switch_stream_handle *)jarg1; arg2 = (switch_stream_handle_raw_write_function_t)jarg2; if (arg1) (arg1)->raw_write_function = arg2; - } @@ -19517,7 +20186,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_data_set(void * jarg1, v arg1 = (switch_stream_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->data = arg2; - } @@ -19540,7 +20208,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_end_set(void * jarg1, vo arg1 = (switch_stream_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->end = arg2; - } @@ -19569,7 +20236,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_data_size_set(void * jar } arg2 = *argp2; if (arg1) (arg1)->data_size = arg2; - } @@ -19580,7 +20246,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_stream_handle_data_size_get(void * j arg1 = (switch_stream_handle *)jarg1; result = ((arg1)->data_size); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -19598,7 +20264,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_data_len_set(void * jarg } arg2 = *argp2; if (arg1) (arg1)->data_len = arg2; - } @@ -19609,7 +20274,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_stream_handle_data_len_get(void * ja arg1 = (switch_stream_handle *)jarg1; result = ((arg1)->data_len); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -19627,7 +20292,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_alloc_len_set(void * jar } arg2 = *argp2; if (arg1) (arg1)->alloc_len = arg2; - } @@ -19638,7 +20302,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_stream_handle_alloc_len_get(void * j arg1 = (switch_stream_handle *)jarg1; result = ((arg1)->alloc_len); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -19656,7 +20320,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_alloc_chunk_set(void * j } arg2 = *argp2; if (arg1) (arg1)->alloc_chunk = arg2; - } @@ -19667,7 +20330,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_stream_handle_alloc_chunk_get(void * arg1 = (switch_stream_handle *)jarg1; result = ((arg1)->alloc_chunk); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -19679,7 +20342,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_stream_handle_param_event_set(void * j arg1 = (switch_stream_handle *)jarg1; arg2 = (switch_event_t *)jarg2; if (arg1) (arg1)->param_event = arg2; - } @@ -19710,7 +20372,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_stream_handle(void * jarg1) { arg1 = (switch_stream_handle *)jarg1; delete arg1; - } @@ -19721,7 +20382,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_outgoing_channel_set(void arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_outgoing_channel_t)jarg2; if (arg1) (arg1)->outgoing_channel = arg2; - } @@ -19744,7 +20404,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_read_frame_set(void * jarg arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_read_frame_t)jarg2; if (arg1) (arg1)->read_frame = arg2; - } @@ -19767,7 +20426,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_write_frame_set(void * jar arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_write_frame_t)jarg2; if (arg1) (arg1)->write_frame = arg2; - } @@ -19790,7 +20448,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_kill_channel_set(void * ja arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_kill_channel_t)jarg2; if (arg1) (arg1)->kill_channel = arg2; - } @@ -19813,7 +20470,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_send_dtmf_set(void * jarg1 arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_send_dtmf_t)jarg2; if (arg1) (arg1)->send_dtmf = arg2; - } @@ -19836,7 +20492,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_receive_message_set(void * arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_receive_message_t)jarg2; if (arg1) (arg1)->receive_message = arg2; - } @@ -19859,7 +20514,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_receive_event_set(void * j arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_receive_event_t)jarg2; if (arg1) (arg1)->receive_event = arg2; - } @@ -19882,7 +20536,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_state_change_set(void * ja arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_state_change_t)jarg2; if (arg1) (arg1)->state_change = arg2; - } @@ -19905,7 +20558,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_read_video_frame_set(void arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_read_video_frame_t)jarg2; if (arg1) (arg1)->read_video_frame = arg2; - } @@ -19928,7 +20580,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_write_video_frame_set(void arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_write_video_frame_t)jarg2; if (arg1) (arg1)->write_video_frame = arg2; - } @@ -19951,7 +20602,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_state_run_set(void * jarg1 arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_state_run_t)jarg2; if (arg1) (arg1)->state_run = arg2; - } @@ -19974,7 +20624,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_get_jb_set(void * jarg1, v arg1 = (switch_io_routines *)jarg1; arg2 = (switch_io_get_jb_t)jarg2; if (arg1) (arg1)->get_jb = arg2; - } @@ -20031,7 +20680,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_routines(void * jarg1) { arg1 = (switch_io_routines *)jarg1; delete arg1; - } @@ -20071,7 +20719,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_io_routines_set(voi arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_io_routines_t *)jarg2; if (arg1) (arg1)->io_routines = arg2; - } @@ -20094,7 +20741,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_state_handler_set(v arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_state_handler_table_t *)jarg2; if (arg1) (arg1)->state_handler = arg2; - } @@ -20117,7 +20763,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_private_info_set(vo arg1 = (switch_endpoint_interface *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -20140,7 +20785,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_rwlock_set(void * j arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -20163,7 +20807,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_refs_set(void * jar arg1 = (switch_endpoint_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -20186,7 +20829,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_reflock_set(void * arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -20209,7 +20851,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_parent_set(void * j arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -20232,7 +20873,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_next_set(void * jar arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_endpoint_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -20255,7 +20895,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_recover_callback_se arg1 = (switch_endpoint_interface *)jarg1; arg2 = (switch_core_recover_callback_t)jarg2; if (arg1) (arg1)->recover_callback = arg2; - } @@ -20286,7 +20925,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_endpoint_interface(void * jarg1 arg1 = (switch_endpoint_interface *)jarg1; delete arg1; - } @@ -20297,7 +20935,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interval_set(void * jarg1, int j arg1 = (switch_timer *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->interval = arg2; - } @@ -20320,7 +20957,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_flags_set(void * jarg1, unsigned arg1 = (switch_timer *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -20343,7 +20979,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_samples_set(void * jarg1, unsign arg1 = (switch_timer *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->samples = arg2; - } @@ -20366,7 +21001,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_samplecount_set(void * jarg1, un arg1 = (switch_timer *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samplecount = arg2; - } @@ -20389,7 +21023,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_timer_interface_set(void * jarg1 arg1 = (switch_timer *)jarg1; arg2 = (switch_timer_interface_t *)jarg2; if (arg1) (arg1)->timer_interface = arg2; - } @@ -20412,7 +21045,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_memory_pool_set(void * jarg1, vo arg1 = (switch_timer *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -20435,7 +21067,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_private_info_set(void * jarg1, v arg1 = (switch_timer *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -20464,7 +21095,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_diff_set(void * jarg1, void * ja } arg2 = *argp2; if (arg1) (arg1)->diff = arg2; - } @@ -20475,7 +21105,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_timer_diff_get(void * jarg1) { arg1 = (switch_timer *)jarg1; result = ((arg1)->diff); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -20493,7 +21123,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_tick_set(void * jarg1, void * ja } arg2 = *argp2; if (arg1) (arg1)->tick = arg2; - } @@ -20504,7 +21133,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_timer_tick_get(void * jarg1) { arg1 = (switch_timer *)jarg1; result = ((arg1)->tick); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -20524,7 +21153,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_timer(void * jarg1) { arg1 = (switch_timer *)jarg1; delete arg1; - } @@ -20564,7 +21192,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_init_set(void * arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *))jarg2; if (arg1) (arg1)->timer_init = arg2; - } @@ -20587,7 +21214,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_next_set(void * arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *))jarg2; if (arg1) (arg1)->timer_next = arg2; - } @@ -20610,7 +21236,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_step_set(void * arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *))jarg2; if (arg1) (arg1)->timer_step = arg2; - } @@ -20633,7 +21258,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_sync_set(void * arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *))jarg2; if (arg1) (arg1)->timer_sync = arg2; - } @@ -20656,7 +21280,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_check_set(void * arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *,switch_bool_t))jarg2; if (arg1) (arg1)->timer_check = arg2; - } @@ -20679,7 +21302,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_timer_destroy_set(void arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_status_t (*)(switch_timer_t *))jarg2; if (arg1) (arg1)->timer_destroy = arg2; - } @@ -20702,7 +21324,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_rwlock_set(void * jarg arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -20725,7 +21346,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_refs_set(void * jarg1, arg1 = (switch_timer_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -20748,7 +21368,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_reflock_set(void * jar arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -20771,7 +21390,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_parent_set(void * jarg arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -20794,7 +21412,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_timer_interface_next_set(void * jarg1, arg1 = (switch_timer_interface *)jarg1; arg2 = (switch_timer_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -20825,7 +21442,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_timer_interface(void * jarg1) { arg1 = (switch_timer_interface *)jarg1; delete arg1; - } @@ -20865,7 +21481,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_hunt_function_set(v arg1 = (switch_dialplan_interface *)jarg1; arg2 = (switch_dialplan_hunt_function_t)jarg2; if (arg1) (arg1)->hunt_function = arg2; - } @@ -20888,7 +21503,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_rwlock_set(void * j arg1 = (switch_dialplan_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -20911,7 +21525,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_refs_set(void * jar arg1 = (switch_dialplan_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -20934,7 +21547,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_reflock_set(void * arg1 = (switch_dialplan_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -20957,7 +21569,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_parent_set(void * j arg1 = (switch_dialplan_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -20980,7 +21591,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_dialplan_interface_next_set(void * jar arg1 = (switch_dialplan_interface *)jarg1; arg2 = (switch_dialplan_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -21011,7 +21621,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_dialplan_interface(void * jarg1 arg1 = (switch_dialplan_interface *)jarg1; delete arg1; - } @@ -21051,7 +21660,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_open_set(void * ja arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,char const *))jarg2; if (arg1) (arg1)->file_open = arg2; - } @@ -21074,7 +21682,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_close_set(void * j arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *))jarg2; if (arg1) (arg1)->file_close = arg2; - } @@ -21097,7 +21704,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_truncate_set(void arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,int64_t))jarg2; if (arg1) (arg1)->file_truncate = arg2; - } @@ -21120,7 +21726,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_read_set(void * ja arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *))jarg2; if (arg1) (arg1)->file_read = arg2; - } @@ -21143,7 +21748,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_write_set(void * j arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *))jarg2; if (arg1) (arg1)->file_write = arg2; - } @@ -21166,7 +21770,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_read_video_set(voi arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *))jarg2; if (arg1) (arg1)->file_read_video = arg2; - } @@ -21189,7 +21792,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_write_video_set(vo arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *))jarg2; if (arg1) (arg1)->file_write_video = arg2; - } @@ -21212,7 +21814,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_seek_set(void * ja arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,unsigned int *,int64_t,int))jarg2; if (arg1) (arg1)->file_seek = arg2; - } @@ -21235,7 +21836,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_set_string_set(voi arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,switch_audio_col_t,char const *))jarg2; if (arg1) (arg1)->file_set_string = arg2; - } @@ -21258,7 +21858,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_get_string_set(voi arg1 = (switch_file_interface *)jarg1; arg2 = (switch_status_t (*)(switch_file_handle_t *,switch_audio_col_t,char const **))jarg2; if (arg1) (arg1)->file_get_string = arg2; - } @@ -21281,7 +21880,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_extens_set(void * jarg1 arg1 = (switch_file_interface *)jarg1; arg2 = (char **)jarg2; if (arg1) (arg1)->extens = arg2; - } @@ -21304,7 +21902,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_rwlock_set(void * jarg1 arg1 = (switch_file_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -21327,7 +21924,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_refs_set(void * jarg1, arg1 = (switch_file_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -21350,7 +21946,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_reflock_set(void * jarg arg1 = (switch_file_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -21373,7 +21968,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_parent_set(void * jarg1 arg1 = (switch_file_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -21396,7 +21990,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_next_set(void * jarg1, arg1 = (switch_file_interface *)jarg1; arg2 = (switch_file_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -21427,7 +22020,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_file_interface(void * jarg1) { arg1 = (switch_file_interface *)jarg1; delete arg1; - } @@ -21438,7 +22030,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_file_interface_set(void * arg1 = (switch_file_handle *)jarg1; arg2 = (switch_file_interface_t *)jarg2; if (arg1) (arg1)->file_interface = arg2; - } @@ -21461,7 +22052,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_flags_set(void * jarg1, un arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -21484,7 +22074,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_fd_set(void * jarg1, void arg1 = (switch_file_handle *)jarg1; arg2 = (switch_file_t *)jarg2; if (arg1) (arg1)->fd = arg2; - } @@ -21507,7 +22096,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->samples = arg2; - } @@ -21530,7 +22118,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samplerate_set(void * jarg arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samplerate = arg2; - } @@ -21553,7 +22140,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_native_rate_set(void * jar arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->native_rate = arg2; - } @@ -21576,7 +22162,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_channels_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->channels = arg2; - } @@ -21599,7 +22184,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_format_set(void * jarg1, u arg1 = (switch_file_handle *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->format = arg2; - } @@ -21622,7 +22206,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_sections_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->sections = arg2; - } @@ -21645,7 +22228,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_seekable_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->seekable = arg2; - } @@ -21674,7 +22256,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_sample_count_set(void * ja } arg2 = *argp2; if (arg1) (arg1)->sample_count = arg2; - } @@ -21685,7 +22266,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_sample_count_get(void * arg1 = (switch_file_handle *)jarg1; result = ((arg1)->sample_count); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -21697,7 +22278,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_speed_set(void * jarg1, in arg1 = (switch_file_handle *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->speed = arg2; - } @@ -21720,7 +22300,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_memory_pool_set(void * jar arg1 = (switch_file_handle *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -21743,7 +22322,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_prebuf_set(void * jarg1, u arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->prebuf = arg2; - } @@ -21766,7 +22344,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_interval_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->interval = arg2; - } @@ -21789,7 +22366,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_private_info_set(void * ja arg1 = (switch_file_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -21812,7 +22388,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_handler_set(void * jarg1, arg1 = (switch_file_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->handler) delete [] arg1->handler; + delete [] arg1->handler; if (arg2) { arg1->handler = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->handler, (const char *)arg2); @@ -21842,7 +22418,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pos_set(void * jarg1, long arg1 = (switch_file_handle *)jarg1; arg2 = (int64_t)jarg2; if (arg1) (arg1)->pos = arg2; - } @@ -21865,7 +22440,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_audio_buffer_set(void * ja arg1 = (switch_file_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->audio_buffer = arg2; - } @@ -21888,7 +22462,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_sp_audio_buffer_set(void * arg1 = (switch_file_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->sp_audio_buffer = arg2; - } @@ -21911,7 +22484,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_thresh_set(void * jarg1, u arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->thresh = arg2; - } @@ -21934,7 +22506,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_silence_hits_set(void * ja arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->silence_hits = arg2; - } @@ -21957,7 +22528,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_offset_pos_set(void * jarg arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->offset_pos = arg2; - } @@ -21986,7 +22556,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_in_set(void * jarg } arg2 = *argp2; if (arg1) (arg1)->samples_in = arg2; - } @@ -21997,7 +22566,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_in_get(void * ja arg1 = (switch_file_handle *)jarg1; result = ((arg1)->samples_in); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -22015,7 +22584,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_out_set(void * jar } arg2 = *argp2; if (arg1) (arg1)->samples_out = arg2; - } @@ -22026,7 +22594,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_out_get(void * j arg1 = (switch_file_handle *)jarg1; result = ((arg1)->samples_out); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -22038,7 +22606,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_vol_set(void * jarg1, int arg1 = (switch_file_handle *)jarg1; arg2 = (int32_t)jarg2; if (arg1) (arg1)->vol = arg2; - } @@ -22061,7 +22628,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_resampler_set(void * jarg1 arg1 = (switch_file_handle *)jarg1; arg2 = (switch_audio_resampler_t *)jarg2; if (arg1) (arg1)->resampler = arg2; - } @@ -22084,7 +22650,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_buffer_set(void * jarg1, v arg1 = (switch_file_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->buffer = arg2; - } @@ -22107,7 +22672,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_dbuf_set(void * jarg1, voi arg1 = (switch_file_handle *)jarg1; arg2 = (switch_byte_t *)jarg2; if (arg1) (arg1)->dbuf = arg2; - } @@ -22136,7 +22700,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_dbuflen_set(void * jarg1, } arg2 = *argp2; if (arg1) (arg1)->dbuflen = arg2; - } @@ -22147,7 +22710,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_dbuflen_get(void * jarg1 arg1 = (switch_file_handle *)jarg1; result = ((arg1)->dbuflen); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -22159,7 +22722,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_set(void * jarg arg1 = (switch_file_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->pre_buffer = arg2; - } @@ -22182,7 +22744,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_data_set(void * arg1 = (switch_file_handle *)jarg1; arg2 = (unsigned char *)jarg2; if (arg1) (arg1)->pre_buffer_data = arg2; - } @@ -22211,7 +22772,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_datalen_set(voi } arg2 = *argp2; if (arg1) (arg1)->pre_buffer_datalen = arg2; - } @@ -22222,7 +22782,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_pre_buffer_datalen_get(v arg1 = (switch_file_handle *)jarg1; result = ((arg1)->pre_buffer_datalen); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -22292,7 +22852,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_line_set(void * jarg1, int arg1 = (switch_file_handle *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->line = arg2; - } @@ -22315,7 +22874,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_file_path_set(void * jarg1 arg1 = (switch_file_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->file_path) delete [] arg1->file_path; + delete [] arg1->file_path; if (arg2) { arg1->file_path = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->file_path, (const char *)arg2); @@ -22345,7 +22904,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_spool_path_set(void * jarg arg1 = (switch_file_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->spool_path) delete [] arg1->spool_path; + delete [] arg1->spool_path; if (arg2) { arg1->spool_path = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->spool_path, (const char *)arg2); @@ -22404,7 +22963,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_max_samples_set(void * jar arg1 = (switch_file_handle *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->max_samples = arg2; - } @@ -22420,18 +22978,17 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_file_handle_max_samples_get(void * jarg } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_params_set(void * jarg1, void * jarg2) { +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle__params_set(void * jarg1, void * jarg2) { switch_file_handle *arg1 = (switch_file_handle *) 0 ; switch_event_t *arg2 = (switch_event_t *) 0 ; arg1 = (switch_file_handle *)jarg1; arg2 = (switch_event_t *)jarg2; if (arg1) (arg1)->params = arg2; - } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_params_get(void * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle__params_get(void * jarg1) { void * jresult ; switch_file_handle *arg1 = (switch_file_handle *) 0 ; switch_event_t *result = 0 ; @@ -22450,7 +23007,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_channels_set(void * ja arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->cur_channels = arg2; - } @@ -22473,7 +23029,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_samplerate_set(void * arg1 = (switch_file_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->cur_samplerate = arg2; - } @@ -22504,7 +23059,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_file_handle(void * jarg1) { arg1 = (switch_file_handle *)jarg1; delete arg1; - } @@ -22544,7 +23098,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_open_set(void * jarg arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char const *,int,char const *,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_open = arg2; - } @@ -22567,7 +23120,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_load_grammar_set(voi arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char const *,char const *))jarg2; if (arg1) (arg1)->asr_load_grammar = arg2; - } @@ -22590,7 +23142,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_unload_grammar_set(v arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char const *))jarg2; if (arg1) (arg1)->asr_unload_grammar = arg2; - } @@ -22613,7 +23164,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_close_set(void * jar arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_close = arg2; - } @@ -22636,7 +23186,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_feed_set(void * jarg arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,void *,unsigned int,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_feed = arg2; - } @@ -22659,7 +23208,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_resume_set(void * ja arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *))jarg2; if (arg1) (arg1)->asr_resume = arg2; - } @@ -22682,7 +23230,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_pause_set(void * jar arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *))jarg2; if (arg1) (arg1)->asr_pause = arg2; - } @@ -22705,7 +23252,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_check_results_set(vo arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_check_results = arg2; - } @@ -22728,7 +23274,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_get_results_set(void arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char **,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_get_results = arg2; - } @@ -22751,7 +23296,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_get_result_headers_s arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,switch_event_t **,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_get_result_headers = arg2; - } @@ -22774,7 +23318,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_start_input_timers_s arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *))jarg2; if (arg1) (arg1)->asr_start_input_timers = arg2; - } @@ -22797,7 +23340,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_text_param_set(void arg1 = (switch_asr_interface *)jarg1; arg2 = (void (*)(switch_asr_handle_t *,char *,char const *))jarg2; if (arg1) (arg1)->asr_text_param = arg2; - } @@ -22820,7 +23362,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_numeric_param_set(vo arg1 = (switch_asr_interface *)jarg1; arg2 = (void (*)(switch_asr_handle_t *,char *,int))jarg2; if (arg1) (arg1)->asr_numeric_param = arg2; - } @@ -22843,7 +23384,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_float_param_set(void arg1 = (switch_asr_interface *)jarg1; arg2 = (void (*)(switch_asr_handle_t *,char *,double))jarg2; if (arg1) (arg1)->asr_float_param = arg2; - } @@ -22866,7 +23406,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_rwlock_set(void * jarg1, arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -22889,7 +23428,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_refs_set(void * jarg1, i arg1 = (switch_asr_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -22912,7 +23450,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_reflock_set(void * jarg1 arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -22935,7 +23472,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_parent_set(void * jarg1, arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -22958,7 +23494,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_next_set(void * jarg1, v arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_asr_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -22981,7 +23516,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_enable_grammar_set(v arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char const *))jarg2; if (arg1) (arg1)->asr_enable_grammar = arg2; - } @@ -23004,7 +23538,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_disable_grammar_set( arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,char const *))jarg2; if (arg1) (arg1)->asr_disable_grammar = arg2; - } @@ -23027,7 +23560,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_disable_all_grammars arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *))jarg2; if (arg1) (arg1)->asr_disable_all_grammars = arg2; - } @@ -23050,7 +23582,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_interface_asr_feed_dtmf_set(void * arg1 = (switch_asr_interface *)jarg1; arg2 = (switch_status_t (*)(switch_asr_handle_t *,switch_dtmf_t const *,switch_asr_flag_t *))jarg2; if (arg1) (arg1)->asr_feed_dtmf = arg2; - } @@ -23081,7 +23612,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_asr_interface(void * jarg1) { arg1 = (switch_asr_interface *)jarg1; delete arg1; - } @@ -23092,7 +23622,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_asr_interface_set(void * ja arg1 = (switch_asr_handle *)jarg1; arg2 = (switch_asr_interface_t *)jarg2; if (arg1) (arg1)->asr_interface = arg2; - } @@ -23115,7 +23644,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_flags_set(void * jarg1, uns arg1 = (switch_asr_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -23138,7 +23666,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_name_set(void * jarg1, char arg1 = (switch_asr_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->name) delete [] arg1->name; + delete [] arg1->name; if (arg2) { arg1->name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->name, (const char *)arg2); @@ -23168,7 +23696,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_codec_set(void * jarg1, cha arg1 = (switch_asr_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->codec) delete [] arg1->codec; + delete [] arg1->codec; if (arg2) { arg1->codec = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->codec, (const char *)arg2); @@ -23198,7 +23726,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_rate_set(void * jarg1, unsi arg1 = (switch_asr_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->rate = arg2; - } @@ -23221,7 +23748,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_grammar_set(void * jarg1, c arg1 = (switch_asr_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->grammar) delete [] arg1->grammar; + delete [] arg1->grammar; if (arg2) { arg1->grammar = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->grammar, (const char *)arg2); @@ -23251,7 +23778,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_param_set(void * jarg1, cha arg1 = (switch_asr_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->param) delete [] arg1->param; + delete [] arg1->param; if (arg2) { arg1->param = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->param, (const char *)arg2); @@ -23281,7 +23808,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_memory_pool_set(void * jarg arg1 = (switch_asr_handle *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -23304,7 +23830,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_buffer_set(void * jarg1, vo arg1 = (switch_asr_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->buffer = arg2; - } @@ -23327,7 +23852,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_dbuf_set(void * jarg1, void arg1 = (switch_asr_handle *)jarg1; arg2 = (switch_byte_t *)jarg2; if (arg1) (arg1)->dbuf = arg2; - } @@ -23356,7 +23880,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_dbuflen_set(void * jarg1, v } arg2 = *argp2; if (arg1) (arg1)->dbuflen = arg2; - } @@ -23367,7 +23890,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_asr_handle_dbuflen_get(void * jarg1) arg1 = (switch_asr_handle *)jarg1; result = ((arg1)->dbuflen); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -23379,7 +23902,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_resampler_set(void * jarg1, arg1 = (switch_asr_handle *)jarg1; arg2 = (switch_audio_resampler_t *)jarg2; if (arg1) (arg1)->resampler = arg2; - } @@ -23402,7 +23924,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_samplerate_set(void * jarg1 arg1 = (switch_asr_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samplerate = arg2; - } @@ -23425,7 +23946,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_native_rate_set(void * jarg arg1 = (switch_asr_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->native_rate = arg2; - } @@ -23448,7 +23968,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_asr_handle_private_info_set(void * jar arg1 = (switch_asr_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -23479,7 +23998,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_asr_handle(void * jarg1) { arg1 = (switch_asr_handle *)jarg1; delete arg1; - } @@ -23519,7 +24037,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_open_set(void arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_status_t (*)(switch_speech_handle_t *,char const *,int,switch_speech_flag_t *))jarg2; if (arg1) (arg1)->speech_open = arg2; - } @@ -23542,7 +24059,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_close_set(void arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_status_t (*)(switch_speech_handle_t *,switch_speech_flag_t *))jarg2; if (arg1) (arg1)->speech_close = arg2; - } @@ -23565,7 +24081,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_feed_tts_set(v arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_status_t (*)(switch_speech_handle_t *,char *,switch_speech_flag_t *))jarg2; if (arg1) (arg1)->speech_feed_tts = arg2; - } @@ -23588,7 +24103,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_read_tts_set(v arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_status_t (*)(switch_speech_handle_t *,void *,switch_size_t *,switch_speech_flag_t *))jarg2; if (arg1) (arg1)->speech_read_tts = arg2; - } @@ -23611,7 +24125,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_flush_tts_set( arg1 = (switch_speech_interface *)jarg1; arg2 = (void (*)(switch_speech_handle_t *))jarg2; if (arg1) (arg1)->speech_flush_tts = arg2; - } @@ -23634,7 +24147,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_text_param_tts arg1 = (switch_speech_interface *)jarg1; arg2 = (void (*)(switch_speech_handle_t *,char *,char const *))jarg2; if (arg1) (arg1)->speech_text_param_tts = arg2; - } @@ -23657,7 +24169,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_numeric_param_ arg1 = (switch_speech_interface *)jarg1; arg2 = (void (*)(switch_speech_handle_t *,char *,int))jarg2; if (arg1) (arg1)->speech_numeric_param_tts = arg2; - } @@ -23680,7 +24191,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_speech_float_param_tt arg1 = (switch_speech_interface *)jarg1; arg2 = (void (*)(switch_speech_handle_t *,char *,double))jarg2; if (arg1) (arg1)->speech_float_param_tts = arg2; - } @@ -23703,7 +24213,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_rwlock_set(void * jar arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -23726,7 +24235,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_refs_set(void * jarg1 arg1 = (switch_speech_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -23749,7 +24257,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_reflock_set(void * ja arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -23772,7 +24279,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_parent_set(void * jar arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -23795,7 +24301,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_interface_next_set(void * jarg1 arg1 = (switch_speech_interface *)jarg1; arg2 = (switch_speech_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -23826,7 +24331,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_speech_interface(void * jarg1) arg1 = (switch_speech_interface *)jarg1; delete arg1; - } @@ -23837,7 +24341,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_speech_interface_set(voi arg1 = (switch_speech_handle *)jarg1; arg2 = (switch_speech_interface_t *)jarg2; if (arg1) (arg1)->speech_interface = arg2; - } @@ -23860,7 +24363,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_flags_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -23883,7 +24385,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_name_set(void * jarg1, c arg1 = (switch_speech_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->name) delete [] arg1->name; + delete [] arg1->name; if (arg2) { arg1->name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->name, (const char *)arg2); @@ -23913,7 +24415,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_rate_set(void * jarg1, u arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->rate = arg2; - } @@ -23936,7 +24437,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_speed_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->speed = arg2; - } @@ -23959,7 +24459,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_samples_set(void * jarg1 arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samples = arg2; - } @@ -23982,8 +24481,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_voice_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->voice, (const char *)arg2, 80); - else arg1->voice[0] = 0; + if(arg2) { + strncpy((char*)arg1->voice, (const char *)arg2, 80-1); + arg1->voice[80-1] = 0; + } else { + arg1->voice[0] = 0; + } } } @@ -24007,7 +24510,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_engine_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->engine) delete [] arg1->engine; + delete [] arg1->engine; if (arg2) { arg1->engine = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->engine, (const char *)arg2); @@ -24037,7 +24540,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_param_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (char *)jarg2; { - if (arg1->param) delete [] arg1->param; + delete [] arg1->param; if (arg2) { arg1->param = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->param, (const char *)arg2); @@ -24067,7 +24570,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_memory_pool_set(void * j arg1 = (switch_speech_handle *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -24090,7 +24592,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_resampler_set(void * jar arg1 = (switch_speech_handle *)jarg1; arg2 = (switch_audio_resampler_t *)jarg2; if (arg1) (arg1)->resampler = arg2; - } @@ -24113,7 +24614,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_buffer_set(void * jarg1, arg1 = (switch_speech_handle *)jarg1; arg2 = (switch_buffer_t *)jarg2; if (arg1) (arg1)->buffer = arg2; - } @@ -24136,7 +24636,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_dbuf_set(void * jarg1, v arg1 = (switch_speech_handle *)jarg1; arg2 = (switch_byte_t *)jarg2; if (arg1) (arg1)->dbuf = arg2; - } @@ -24165,7 +24664,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_dbuflen_set(void * jarg1 } arg2 = *argp2; if (arg1) (arg1)->dbuflen = arg2; - } @@ -24176,7 +24674,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_speech_handle_dbuflen_get(void * jar arg1 = (switch_speech_handle *)jarg1; result = ((arg1)->dbuflen); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -24188,7 +24686,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_samplerate_set(void * ja arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samplerate = arg2; - } @@ -24211,7 +24708,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_native_rate_set(void * j arg1 = (switch_speech_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->native_rate = arg2; - } @@ -24234,7 +24730,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_speech_handle_private_info_set(void * arg1 = (switch_speech_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -24265,7 +24760,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_speech_handle(void * jarg1) { arg1 = (switch_speech_handle *)jarg1; delete arg1; - } @@ -24305,7 +24799,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_say_function_set(void * arg1 = (switch_say_interface *)jarg1; arg2 = (switch_say_callback_t)jarg2; if (arg1) (arg1)->say_function = arg2; - } @@ -24328,7 +24821,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_say_string_function_set( arg1 = (switch_say_interface *)jarg1; arg2 = (switch_say_string_callback_t)jarg2; if (arg1) (arg1)->say_string_function = arg2; - } @@ -24351,7 +24843,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_rwlock_set(void * jarg1, arg1 = (switch_say_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -24374,7 +24865,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_refs_set(void * jarg1, i arg1 = (switch_say_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -24397,7 +24887,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_reflock_set(void * jarg1 arg1 = (switch_say_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -24420,7 +24909,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_parent_set(void * jarg1, arg1 = (switch_say_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -24443,7 +24931,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_say_interface_next_set(void * jarg1, v arg1 = (switch_say_interface *)jarg1; arg2 = (switch_say_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -24474,7 +24961,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_say_interface(void * jarg1) { arg1 = (switch_say_interface *)jarg1; delete arg1; - } @@ -24514,7 +25000,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_chat_send_set(void * ja arg1 = (switch_chat_interface *)jarg1; arg2 = (switch_status_t (*)(switch_event_t *))jarg2; if (arg1) (arg1)->chat_send = arg2; - } @@ -24537,7 +25022,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_rwlock_set(void * jarg1 arg1 = (switch_chat_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -24560,7 +25044,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_refs_set(void * jarg1, arg1 = (switch_chat_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -24583,7 +25066,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_reflock_set(void * jarg arg1 = (switch_chat_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -24606,7 +25088,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_parent_set(void * jarg1 arg1 = (switch_chat_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -24629,7 +25110,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_next_set(void * jarg1, arg1 = (switch_chat_interface *)jarg1; arg2 = (switch_chat_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -24660,7 +25140,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_chat_interface(void * jarg1) { arg1 = (switch_chat_interface *)jarg1; delete arg1; - } @@ -24700,7 +25179,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_management_functi arg1 = (switch_management_interface *)jarg1; arg2 = (switch_status_t (*)(char *,switch_management_action_t,char *,switch_size_t))jarg2; if (arg1) (arg1)->management_function = arg2; - } @@ -24723,7 +25201,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_rwlock_set(void * arg1 = (switch_management_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -24746,7 +25223,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_refs_set(void * j arg1 = (switch_management_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -24769,7 +25245,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_reflock_set(void arg1 = (switch_management_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -24792,7 +25267,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_parent_set(void * arg1 = (switch_management_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -24815,7 +25289,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_management_interface_next_set(void * j arg1 = (switch_management_interface *)jarg1; arg2 = (switch_management_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -24846,7 +25319,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_management_interface(void * jar arg1 = (switch_management_interface *)jarg1; delete arg1; - } @@ -24886,7 +25358,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_incr_set(void * jarg1, arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_status_t (*)(switch_core_session_t *,char const *,char const *,int const,int const))jarg2; if (arg1) (arg1)->incr = arg2; - } @@ -24909,7 +25380,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_release_set(void * jar arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_status_t (*)(switch_core_session_t *,char const *,char const *))jarg2; if (arg1) (arg1)->release = arg2; - } @@ -24932,7 +25402,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_usage_set(void * jarg1 arg1 = (switch_limit_interface *)jarg1; arg2 = (int (*)(char const *,char const *,uint32_t *))jarg2; if (arg1) (arg1)->usage = arg2; - } @@ -24955,7 +25424,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_reset_set(void * jarg1 arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_status_t (*)(void))jarg2; if (arg1) (arg1)->reset = arg2; - } @@ -24978,7 +25446,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_status_set(void * jarg arg1 = (switch_limit_interface *)jarg1; arg2 = (char *(*)(void))jarg2; if (arg1) (arg1)->status = arg2; - } @@ -25001,7 +25468,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_interval_reset_set(voi arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_status_t (*)(char const *,char const *))jarg2; if (arg1) (arg1)->interval_reset = arg2; - } @@ -25024,7 +25490,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_rwlock_set(void * jarg arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -25047,7 +25512,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_refs_set(void * jarg1, arg1 = (switch_limit_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -25070,7 +25534,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_reflock_set(void * jar arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -25093,7 +25556,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_parent_set(void * jarg arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -25116,7 +25578,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_limit_interface_next_set(void * jarg1, arg1 = (switch_limit_interface *)jarg1; arg2 = (switch_limit_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -25147,7 +25608,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_limit_interface(void * jarg1) { arg1 = (switch_limit_interface *)jarg1; delete arg1; - } @@ -25187,7 +25647,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_directory_open_set arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_status_t (*)(switch_directory_handle_t *,char *,char *,char *))jarg2; if (arg1) (arg1)->directory_open = arg2; - } @@ -25210,7 +25669,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_directory_close_se arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_status_t (*)(switch_directory_handle_t *))jarg2; if (arg1) (arg1)->directory_close = arg2; - } @@ -25233,7 +25691,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_directory_query_se arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_status_t (*)(switch_directory_handle_t *,char *,char *))jarg2; if (arg1) (arg1)->directory_query = arg2; - } @@ -25256,7 +25713,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_directory_next_set arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_status_t (*)(switch_directory_handle_t *))jarg2; if (arg1) (arg1)->directory_next = arg2; - } @@ -25279,7 +25735,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_directory_next_pai arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_status_t (*)(switch_directory_handle_t *,char **,char **))jarg2; if (arg1) (arg1)->directory_next_pair = arg2; - } @@ -25302,7 +25757,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_rwlock_set(void * arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -25325,7 +25779,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_refs_set(void * ja arg1 = (switch_directory_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -25348,7 +25801,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_reflock_set(void * arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -25371,7 +25823,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_parent_set(void * arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -25394,7 +25845,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_interface_next_set(void * ja arg1 = (switch_directory_interface *)jarg1; arg2 = (switch_directory_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -25425,7 +25875,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_directory_interface(void * jarg arg1 = (switch_directory_interface *)jarg1; delete arg1; - } @@ -25436,7 +25885,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_handle_directory_interface_s arg1 = (switch_directory_handle *)jarg1; arg2 = (switch_directory_interface_t *)jarg2; if (arg1) (arg1)->directory_interface = arg2; - } @@ -25459,7 +25907,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_handle_flags_set(void * jarg arg1 = (switch_directory_handle *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -25482,7 +25929,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_handle_memory_pool_set(void arg1 = (switch_directory_handle *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -25505,7 +25951,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_directory_handle_private_info_set(void arg1 = (switch_directory_handle *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -25536,7 +25981,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_directory_handle(void * jarg1) arg1 = (switch_directory_handle *)jarg1; delete arg1; - } @@ -25547,7 +25991,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_settings_unused_set(void * jarg1 arg1 = (switch_codec_settings *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->unused = arg2; - } @@ -25578,7 +26021,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_codec_settings(void * jarg1) { arg1 = (switch_codec_settings *)jarg1; delete arg1; - } @@ -25589,7 +26031,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_actual_samples_per_second_s arg1 = (switch_codec_fmtp *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->actual_samples_per_second = arg2; - } @@ -25612,7 +26053,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_bits_per_second_set(void * arg1 = (switch_codec_fmtp *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->bits_per_second = arg2; - } @@ -25635,7 +26075,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_microseconds_per_packet_set arg1 = (switch_codec_fmtp *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->microseconds_per_packet = arg2; - } @@ -25658,7 +26097,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_private_info_set(void * jar arg1 = (switch_codec_fmtp *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -25689,7 +26127,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_codec_fmtp(void * jarg1) { arg1 = (switch_codec_fmtp *)jarg1; delete arg1; - } @@ -25700,7 +26137,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_codec_interface_set(void * jarg1 arg1 = (switch_codec *)jarg1; arg2 = (switch_codec_interface_t *)jarg2; if (arg1) (arg1)->codec_interface = arg2; - } @@ -25723,7 +26159,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_set(void * jarg1, arg1 = (switch_codec *)jarg1; arg2 = (switch_codec_implementation_t *)jarg2; if (arg1) (arg1)->implementation = (switch_codec_implementation_t const *)arg2; - } @@ -25746,7 +26181,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_in_set(void * jarg1, char * arg1 = (switch_codec *)jarg1; arg2 = (char *)jarg2; { - if (arg1->fmtp_in) delete [] arg1->fmtp_in; + delete [] arg1->fmtp_in; if (arg2) { arg1->fmtp_in = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->fmtp_in, (const char *)arg2); @@ -25776,7 +26211,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_fmtp_out_set(void * jarg1, char arg1 = (switch_codec *)jarg1; arg2 = (char *)jarg2; { - if (arg1->fmtp_out) delete [] arg1->fmtp_out; + delete [] arg1->fmtp_out; if (arg2) { arg1->fmtp_out = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->fmtp_out, (const char *)arg2); @@ -25806,7 +26241,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_flags_set(void * jarg1, unsigned arg1 = (switch_codec *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -25829,7 +26263,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_memory_pool_set(void * jarg1, vo arg1 = (switch_codec *)jarg1; arg2 = (switch_memory_pool_t *)jarg2; if (arg1) (arg1)->memory_pool = arg2; - } @@ -25852,7 +26285,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_private_info_set(void * jarg1, v arg1 = (switch_codec *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->private_info = arg2; - } @@ -25875,7 +26307,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_agreed_pt_set(void * jarg1, unsi arg1 = (switch_codec *)jarg1; arg2 = (switch_payload_t)jarg2; if (arg1) (arg1)->agreed_pt = arg2; - } @@ -25898,7 +26329,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_mutex_set(void * jarg1, void * j arg1 = (switch_codec *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->mutex = arg2; - } @@ -25921,7 +26351,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_next_set(void * jarg1, void * ja arg1 = (switch_codec *)jarg1; arg2 = (switch_codec *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -25944,7 +26373,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_session_set(void * jarg1, void * arg1 = (switch_codec *)jarg1; arg2 = (switch_core_session_t *)jarg2; if (arg1) (arg1)->session = arg2; - } @@ -25967,7 +26395,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_cur_frame_set(void * jarg1, void arg1 = (switch_codec *)jarg1; arg2 = (switch_frame_t *)jarg2; if (arg1) (arg1)->cur_frame = arg2; - } @@ -25998,7 +26425,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_codec(void * jarg1) { arg1 = (switch_codec *)jarg1; delete arg1; - } @@ -26009,7 +26435,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_codec_type_set(vo arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_codec_type_t)jarg2; if (arg1) (arg1)->codec_type = arg2; - } @@ -26032,7 +26457,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_ianacode_set(void arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_payload_t)jarg2; if (arg1) (arg1)->ianacode = arg2; - } @@ -26055,7 +26479,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_iananame_set(void arg1 = (switch_codec_implementation *)jarg1; arg2 = (char *)jarg2; { - if (arg1->iananame) delete [] arg1->iananame; + delete [] arg1->iananame; if (arg2) { arg1->iananame = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->iananame, (const char *)arg2); @@ -26085,7 +26509,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_fmtp_set(void * j arg1 = (switch_codec_implementation *)jarg1; arg2 = (char *)jarg2; { - if (arg1->fmtp) delete [] arg1->fmtp; + delete [] arg1->fmtp; if (arg2) { arg1->fmtp = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->fmtp, (const char *)arg2); @@ -26115,7 +26539,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_samples_per_secon arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samples_per_second = arg2; - } @@ -26138,7 +26561,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_actual_samples_pe arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->actual_samples_per_second = arg2; - } @@ -26161,7 +26583,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_bits_per_second_s arg1 = (switch_codec_implementation *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->bits_per_second = arg2; - } @@ -26184,7 +26605,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_microseconds_per_ arg1 = (switch_codec_implementation *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->microseconds_per_packet = arg2; - } @@ -26207,7 +26627,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_samples_per_packe arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->samples_per_packet = arg2; - } @@ -26230,7 +26649,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_decoded_bytes_per arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->decoded_bytes_per_packet = arg2; - } @@ -26253,7 +26671,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_encoded_bytes_per arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->encoded_bytes_per_packet = arg2; - } @@ -26276,7 +26693,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_number_of_channel arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->number_of_channels = arg2; - } @@ -26299,7 +26715,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_codec_frames_per_ arg1 = (switch_codec_implementation *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->codec_frames_per_packet = arg2; - } @@ -26322,7 +26737,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_init_set(void * j arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_core_codec_init_func_t)jarg2; if (arg1) (arg1)->init = arg2; - } @@ -26345,7 +26759,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_encode_set(void * arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_core_codec_encode_func_t)jarg2; if (arg1) (arg1)->encode = arg2; - } @@ -26368,7 +26781,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_decode_set(void * arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_core_codec_decode_func_t)jarg2; if (arg1) (arg1)->decode = arg2; - } @@ -26391,7 +26803,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_destroy_set(void arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_core_codec_destroy_func_t)jarg2; if (arg1) (arg1)->destroy = arg2; - } @@ -26414,7 +26825,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_codec_id_set(void arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->codec_id = arg2; - } @@ -26437,7 +26847,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_impl_id_set(void arg1 = (switch_codec_implementation *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->impl_id = arg2; - } @@ -26460,7 +26869,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_implementation_next_set(void * j arg1 = (switch_codec_implementation *)jarg1; arg2 = (switch_codec_implementation *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -26491,7 +26899,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_codec_implementation(void * jar arg1 = (switch_codec_implementation *)jarg1; delete arg1; - } @@ -26531,7 +26938,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_implementations_set(vo arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_codec_implementation_t *)jarg2; if (arg1) (arg1)->implementations = arg2; - } @@ -26554,7 +26960,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_parse_fmtp_set(void * arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_core_codec_fmtp_parse_func_t)jarg2; if (arg1) (arg1)->parse_fmtp = arg2; - } @@ -26577,7 +26982,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_codec_id_set(void * ja arg1 = (switch_codec_interface *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->codec_id = arg2; - } @@ -26600,7 +27004,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_rwlock_set(void * jarg arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -26623,7 +27026,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_refs_set(void * jarg1, arg1 = (switch_codec_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -26646,7 +27048,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_reflock_set(void * jar arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -26669,7 +27070,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_parent_set(void * jarg arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -26692,7 +27092,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_interface_next_set(void * jarg1, arg1 = (switch_codec_interface *)jarg1; arg2 = (switch_codec_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -26723,7 +27122,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_codec_interface(void * jarg1) { arg1 = (switch_codec_interface *)jarg1; delete arg1; - } @@ -26763,7 +27161,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_application_func arg1 = (switch_application_interface *)jarg1; arg2 = (switch_application_function_t)jarg2; if (arg1) (arg1)->application_function = arg2; - } @@ -26873,7 +27270,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_flags_set(void * arg1 = (switch_application_interface *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -26896,7 +27292,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_rwlock_set(void arg1 = (switch_application_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -26919,7 +27314,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_refs_set(void * arg1 = (switch_application_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -26942,7 +27336,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_reflock_set(void arg1 = (switch_application_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -26965,7 +27358,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_parent_set(void arg1 = (switch_application_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -26988,7 +27380,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_application_interface_next_set(void * arg1 = (switch_application_interface *)jarg1; arg2 = (switch_application_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -27019,7 +27410,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_application_interface(void * ja arg1 = (switch_application_interface *)jarg1; delete arg1; - } @@ -27059,7 +27449,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_chat_applic arg1 = (switch_chat_application_interface *)jarg1; arg2 = (switch_chat_application_function_t)jarg2; if (arg1) (arg1)->chat_application_function = arg2; - } @@ -27169,7 +27558,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_flags_set(v arg1 = (switch_chat_application_interface *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -27192,7 +27580,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_rwlock_set( arg1 = (switch_chat_application_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -27215,7 +27602,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_refs_set(vo arg1 = (switch_chat_application_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -27238,7 +27624,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_reflock_set arg1 = (switch_chat_application_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -27261,7 +27646,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_parent_set( arg1 = (switch_chat_application_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -27284,7 +27668,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_next_set(vo arg1 = (switch_chat_application_interface *)jarg1; arg2 = (switch_chat_application_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -27315,7 +27698,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_chat_application_interface(void arg1 = (switch_chat_application_interface *)jarg1; delete arg1; - } @@ -27384,7 +27766,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_function_set(void * jarg arg1 = (switch_api_interface *)jarg1; arg2 = (switch_api_function_t)jarg2; if (arg1) (arg1)->function = arg2; - } @@ -27436,7 +27817,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_rwlock_set(void * jarg1, arg1 = (switch_api_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -27459,7 +27839,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_refs_set(void * jarg1, i arg1 = (switch_api_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -27482,7 +27861,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_reflock_set(void * jarg1 arg1 = (switch_api_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -27505,7 +27883,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_parent_set(void * jarg1, arg1 = (switch_api_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -27528,7 +27905,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_next_set(void * jarg1, v arg1 = (switch_api_interface *)jarg1; arg2 = (switch_api_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -27559,7 +27935,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_api_interface(void * jarg1) { arg1 = (switch_api_interface *)jarg1; delete arg1; - } @@ -27628,7 +28003,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_function_set(void * arg1 = (switch_json_api_interface *)jarg1; arg2 = (switch_json_api_function_t)jarg2; if (arg1) (arg1)->function = arg2; - } @@ -27680,7 +28054,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_rwlock_set(void * j arg1 = (switch_json_api_interface *)jarg1; arg2 = (switch_thread_rwlock_t *)jarg2; if (arg1) (arg1)->rwlock = arg2; - } @@ -27703,7 +28076,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_refs_set(void * jar arg1 = (switch_json_api_interface *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -27726,7 +28098,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_reflock_set(void * arg1 = (switch_json_api_interface *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->reflock = arg2; - } @@ -27749,7 +28120,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_parent_set(void * j arg1 = (switch_json_api_interface *)jarg1; arg2 = (switch_loadable_module_interface_t *)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -27772,7 +28142,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_next_set(void * jar arg1 = (switch_json_api_interface *)jarg1; arg2 = (switch_json_api_interface *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -27803,7 +28172,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_json_api_interface(void * jarg1 arg1 = (switch_json_api_interface *)jarg1; delete arg1; - } @@ -27814,7 +28182,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_session_set(void * jarg1, vo arg1 = (switch_slin_data *)jarg1; arg2 = (switch_core_session_t *)jarg2; if (arg1) (arg1)->session = arg2; - } @@ -27837,7 +28204,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_write_frame_set(void * jarg1 arg1 = (switch_slin_data *)jarg1; arg2 = (switch_frame_t *)jarg2; if (arg1) (arg1)->write_frame = *arg2; - } @@ -27860,7 +28226,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_codec_set(void * jarg1, void arg1 = (switch_slin_data *)jarg1; arg2 = (switch_codec_t *)jarg2; if (arg1) (arg1)->codec = *arg2; - } @@ -27883,8 +28248,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_frame_data_set(void * jarg1, arg1 = (switch_slin_data *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->frame_data, (const char *)arg2, 4096); - else arg1->frame_data[0] = 0; + if(arg2) { + strncpy((char*)arg1->frame_data, (const char *)arg2, 4096-1); + arg1->frame_data[4096-1] = 0; + } else { + arg1->frame_data[0] = 0; + } } } @@ -27916,7 +28285,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_slin_data(void * jarg1) { arg1 = (switch_slin_data *)jarg1; delete arg1; - } @@ -27933,7 +28301,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_profile_created_set( } arg2 = *argp2; if (arg1) (arg1)->profile_created = arg2; - } @@ -27944,7 +28311,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_profile_created_ge arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->profile_created); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -27962,7 +28329,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_created_set(void * j } arg2 = *argp2; if (arg1) (arg1)->created = arg2; - } @@ -27973,7 +28339,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_created_get(void * arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->created); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -27991,7 +28357,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_answered_set(void * } arg2 = *argp2; if (arg1) (arg1)->answered = arg2; - } @@ -28002,7 +28367,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_answered_get(void arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->answered); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28020,7 +28385,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_progress_set(void * } arg2 = *argp2; if (arg1) (arg1)->progress = arg2; - } @@ -28031,7 +28395,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_progress_get(void arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->progress); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28049,7 +28413,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_progress_media_set(v } arg2 = *argp2; if (arg1) (arg1)->progress_media = arg2; - } @@ -28060,7 +28423,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_progress_media_get arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->progress_media); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28078,7 +28441,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_hungup_set(void * ja } arg2 = *argp2; if (arg1) (arg1)->hungup = arg2; - } @@ -28089,7 +28451,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_hungup_get(void * arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->hungup); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28107,7 +28469,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_transferred_set(void } arg2 = *argp2; if (arg1) (arg1)->transferred = arg2; - } @@ -28118,7 +28479,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_transferred_get(vo arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->transferred); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28136,7 +28497,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_resurrected_set(void } arg2 = *argp2; if (arg1) (arg1)->resurrected = arg2; - } @@ -28147,7 +28507,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_resurrected_get(vo arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->resurrected); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28165,7 +28525,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_bridged_set(void * j } arg2 = *argp2; if (arg1) (arg1)->bridged = arg2; - } @@ -28176,7 +28535,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_bridged_get(void * arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->bridged); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28194,7 +28553,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_last_hold_set(void * } arg2 = *argp2; if (arg1) (arg1)->last_hold = arg2; - } @@ -28205,7 +28563,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_last_hold_get(void arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->last_hold); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28223,7 +28581,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_hold_accum_set(void } arg2 = *argp2; if (arg1) (arg1)->hold_accum = arg2; - } @@ -28234,7 +28591,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_timetable_hold_accum_get(voi arg1 = (switch_channel_timetable *)jarg1; result = ((arg1)->hold_accum); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -28246,7 +28603,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_timetable_next_set(void * jarg arg1 = (switch_channel_timetable *)jarg1; arg2 = (switch_channel_timetable *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -28277,7 +28633,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_channel_timetable(void * jarg1) arg1 = (switch_channel_timetable *)jarg1; delete arg1; - } @@ -29493,7 +29848,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_has_dtmf(void * jarg1) { arg1 = (switch_channel_t *)jarg1; result = switch_channel_has_dtmf(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -29589,8 +29944,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_dequeue_dtmf_string(void * j switch_channel_t *arg1 = (switch_channel_t *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_channel_t *)jarg1; arg2 = (char *)jarg2; @@ -29601,7 +29956,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_dequeue_dtmf_string(void * j } arg3 = *argp3; result = switch_channel_dequeue_dtmf_string(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -29824,6 +30179,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_direction(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_logical_direction(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_call_direction_t)switch_channel_logical_direction(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_set_direction(void * jarg1, int jarg2) { switch_channel_t *arg1 = (switch_channel_t *) 0 ; switch_call_direction_t arg2 ; @@ -29972,6 +30339,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_api_on(void * jarg1, char * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_process_device_hangup(void * jarg1) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + + arg1 = (switch_channel_t *)jarg1; + switch_channel_process_device_hangup(arg1); +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_queued_extension(void * jarg1) { void * jresult ; switch_channel_t *arg1 = (switch_channel_t *) 0 ; @@ -30154,8 +30529,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ; switch_buffer_t **arg2 = (switch_buffer_t **) 0 ; switch_size_t arg3 ; - switch_status_t result; switch_size_t *argp3 ; + switch_status_t result; arg1 = (switch_memory_pool_t *)jarg1; arg2 = (switch_buffer_t **)jarg2; @@ -30177,10 +30552,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create_dynamic(void * jarg1, voi switch_size_t arg2 ; switch_size_t arg3 ; switch_size_t arg4 ; - switch_status_t result; switch_size_t *argp2 ; switch_size_t *argp3 ; switch_size_t *argp4 ; + switch_status_t result; arg1 = (switch_buffer_t **)jarg1; argp2 = (switch_size_t *)jarg2; @@ -30252,7 +30627,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_len(void * jarg1) { arg1 = (switch_buffer_t *)jarg1; result = switch_buffer_len(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30264,7 +30639,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_freespace(void * jarg1) { arg1 = (switch_buffer_t *)jarg1; result = switch_buffer_freespace(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30276,7 +30651,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_inuse(void * jarg1) { arg1 = (switch_buffer_t *)jarg1; result = switch_buffer_inuse(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30286,8 +30661,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_read(void * jarg1, void * jar switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30298,7 +30673,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_read(void * jarg1, void * jar } arg3 = *argp3; result = switch_buffer_read(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30308,8 +30683,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_peek(void * jarg1, void * jar switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30320,7 +30695,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_peek(void * jarg1, void * jar } arg3 = *argp3; result = switch_buffer_peek(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30334,7 +30709,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_peek_zerocopy(void * jarg1, v arg1 = (switch_buffer_t *)jarg1; arg2 = (void **)jarg2; result = switch_buffer_peek_zerocopy(arg1,(void const **)arg2); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30344,8 +30719,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_read_loop(void * jarg1, void switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30356,7 +30731,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_read_loop(void * jarg1, void } arg3 = *argp3; result = switch_buffer_read_loop(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30376,8 +30751,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_write(void * jarg1, void * ja switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30388,7 +30763,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_write(void * jarg1, void * ja } arg3 = *argp3; result = switch_buffer_write(arg1,(void const *)arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30397,8 +30772,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_toss(void * jarg1, void * jar void * jresult ; switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; switch_size_t arg2 ; - switch_size_t result; switch_size_t *argp2 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -30408,7 +30783,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_toss(void * jarg1, void * jar } arg2 = *argp2; result = switch_buffer_toss(arg1,arg2); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30426,8 +30801,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_slide_write(void * jarg1, voi switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30438,7 +30813,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_slide_write(void * jarg1, voi } arg3 = *argp3; result = switch_buffer_slide_write(arg1,(void const *)arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30456,8 +30831,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_zwrite(void * jarg1, void * j switch_buffer_t *arg1 = (switch_buffer_t *) 0 ; void *arg2 = (void *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (switch_buffer_t *)jarg1; arg2 = (void *)jarg2; @@ -30468,7 +30843,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_buffer_zwrite(void * jarg1, void * j } arg3 = *argp3; result = switch_buffer_zwrite(arg1,(void const *)arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -30480,7 +30855,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_name_set(void * jarg1, ch arg1 = (switch_event_header *)jarg1; arg2 = (char *)jarg2; { - if (arg1->name) delete [] arg1->name; + delete [] arg1->name; if (arg2) { arg1->name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->name, (const char *)arg2); @@ -30510,7 +30885,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_value_set(void * jarg1, c arg1 = (switch_event_header *)jarg1; arg2 = (char *)jarg2; { - if (arg1->value) delete [] arg1->value; + delete [] arg1->value; if (arg2) { arg1->value = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->value, (const char *)arg2); @@ -30540,7 +30915,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_array_set(void * jarg1, v arg1 = (switch_event_header *)jarg1; arg2 = (char **)jarg2; if (arg1) (arg1)->array = arg2; - } @@ -30563,7 +30937,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_idx_set(void * jarg1, int arg1 = (switch_event_header *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->idx = arg2; - } @@ -30586,7 +30959,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_hash_set(void * jarg1, un arg1 = (switch_event_header *)jarg1; arg2 = (unsigned long)jarg2; if (arg1) (arg1)->hash = arg2; - } @@ -30609,7 +30981,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_header_next_set(void * jarg1, vo arg1 = (switch_event_header *)jarg1; arg2 = (switch_event_header *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -30640,7 +31011,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_event_header(void * jarg1) { arg1 = (switch_event_header *)jarg1; delete arg1; - } @@ -30651,7 +31021,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_event_id_set(void * jarg1, int j arg1 = (switch_event *)jarg1; arg2 = (switch_event_types_t)jarg2; if (arg1) (arg1)->event_id = arg2; - } @@ -30674,7 +31043,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_priority_set(void * jarg1, int j arg1 = (switch_event *)jarg1; arg2 = (switch_priority_t)jarg2; if (arg1) (arg1)->priority = arg2; - } @@ -30697,7 +31065,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_owner_set(void * jarg1, char * j arg1 = (switch_event *)jarg1; arg2 = (char *)jarg2; { - if (arg1->owner) delete [] arg1->owner; + delete [] arg1->owner; if (arg2) { arg1->owner = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->owner, (const char *)arg2); @@ -30727,7 +31095,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_subclass_name_set(void * jarg1, arg1 = (switch_event *)jarg1; arg2 = (char *)jarg2; { - if (arg1->subclass_name) delete [] arg1->subclass_name; + delete [] arg1->subclass_name; if (arg2) { arg1->subclass_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->subclass_name, (const char *)arg2); @@ -30757,7 +31125,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_headers_set(void * jarg1, void * arg1 = (switch_event *)jarg1; arg2 = (switch_event_header_t *)jarg2; if (arg1) (arg1)->headers = arg2; - } @@ -30780,7 +31147,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_last_header_set(void * jarg1, vo arg1 = (switch_event *)jarg1; arg2 = (switch_event_header_t *)jarg2; if (arg1) (arg1)->last_header = arg2; - } @@ -30803,7 +31169,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_body_set(void * jarg1, char * ja arg1 = (switch_event *)jarg1; arg2 = (char *)jarg2; { - if (arg1->body) delete [] arg1->body; + delete [] arg1->body; if (arg2) { arg1->body = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->body, (const char *)arg2); @@ -30833,7 +31199,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_bind_user_data_set(void * jarg1, arg1 = (switch_event *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->bind_user_data = arg2; - } @@ -30856,7 +31221,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_event_user_data_set(void * jarg1 arg1 = (switch_event *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->event_user_data = arg2; - } @@ -30879,7 +31243,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_key_set(void * jarg1, unsigned l arg1 = (switch_event *)jarg1; arg2 = (unsigned long)jarg2; if (arg1) (arg1)->key = arg2; - } @@ -30902,7 +31265,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_next_set(void * jarg1, void * ja arg1 = (switch_event *)jarg1; arg2 = (switch_event *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -30925,7 +31287,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_flags_set(void * jarg1, int jarg arg1 = (switch_event *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -30956,27 +31317,25 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_event(void * jarg1) { arg1 = (switch_event *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_event_id_set(void * jarg1, int jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int arg2 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->event_id = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_event_id_get(void * jarg1) { int jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int result; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (int) ((arg1)->event_id); jresult = result; return jresult; @@ -30984,22 +31343,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_event_id_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_priority_set(void * jarg1, int jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int arg2 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->priority = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_priority_get(void * jarg1) { int jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int result; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (int) ((arg1)->priority); jresult = result; return jresult; @@ -31007,22 +31365,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_priority_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_flags_set(void * jarg1, int jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int arg2 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->flags = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_flags_get(void * jarg1) { int jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; int result; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (int) ((arg1)->flags); jresult = result; return jresult; @@ -31030,13 +31387,13 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_serial_event_t_flags_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_owner_set(void * jarg1, char * jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->owner) delete [] arg1->owner; + delete [] arg1->owner; if (arg2) { arg1->owner = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->owner, (const char *)arg2); @@ -31049,10 +31406,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_owner_set(void * jarg1, SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_owner_get(void * jarg1) { char * jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *result = 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (char *) ((arg1)->owner); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -31060,13 +31417,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_owner_get(void * jarg SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_subclass_name_set(void * jarg1, char * jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->subclass_name) delete [] arg1->subclass_name; + delete [] arg1->subclass_name; if (arg2) { arg1->subclass_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->subclass_name, (const char *)arg2); @@ -31079,10 +31436,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_subclass_name_set(void SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_subclass_name_get(void * jarg1) { char * jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *result = 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (char *) ((arg1)->subclass_name); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -31090,13 +31447,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_subclass_name_get(voi SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_body_set(void * jarg1, char * jarg2) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->body) delete [] arg1->body; + delete [] arg1->body; if (arg2) { arg1->body = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->body, (const char *)arg2); @@ -31109,10 +31466,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_t_body_set(void * jarg1, SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_body_get(void * jarg1) { char * jresult ; - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; char *result = 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; result = (char *) ((arg1)->body); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -31121,31 +31478,30 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_t_body_get(void * jarg1 SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_serial_event_t() { void * jresult ; - switch_serial_event_t *result = 0 ; + switch_serial_event_s *result = 0 ; - result = (switch_serial_event_t *)new switch_serial_event_t(); + result = (switch_serial_event_s *)new switch_serial_event_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_serial_event_t(void * jarg1) { - switch_serial_event_t *arg1 = (switch_serial_event_t *) 0 ; + switch_serial_event_s *arg1 = (switch_serial_event_s *) 0 ; - arg1 = (switch_serial_event_t *)jarg1; + arg1 = (switch_serial_event_s *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_header_t_name_set(void * jarg1, char * jarg2) { - switch_serial_event_header_t *arg1 = (switch_serial_event_header_t *) 0 ; + switch_serial_event_header_s *arg1 = (switch_serial_event_header_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_serial_event_header_t *)jarg1; + arg1 = (switch_serial_event_header_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->name) delete [] arg1->name; + delete [] arg1->name; if (arg2) { arg1->name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->name, (const char *)arg2); @@ -31158,10 +31514,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_header_t_name_set(void * SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_header_t_name_get(void * jarg1) { char * jresult ; - switch_serial_event_header_t *arg1 = (switch_serial_event_header_t *) 0 ; + switch_serial_event_header_s *arg1 = (switch_serial_event_header_s *) 0 ; char *result = 0 ; - arg1 = (switch_serial_event_header_t *)jarg1; + arg1 = (switch_serial_event_header_s *)jarg1; result = (char *) ((arg1)->name); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -31169,13 +31525,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_header_t_name_get(void SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_header_t_value_set(void * jarg1, char * jarg2) { - switch_serial_event_header_t *arg1 = (switch_serial_event_header_t *) 0 ; + switch_serial_event_header_s *arg1 = (switch_serial_event_header_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (switch_serial_event_header_t *)jarg1; + arg1 = (switch_serial_event_header_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->value) delete [] arg1->value; + delete [] arg1->value; if (arg2) { arg1->value = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->value, (const char *)arg2); @@ -31188,10 +31544,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_serial_event_header_t_value_set(void * SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_header_t_value_get(void * jarg1) { char * jresult ; - switch_serial_event_header_t *arg1 = (switch_serial_event_header_t *) 0 ; + switch_serial_event_header_s *arg1 = (switch_serial_event_header_s *) 0 ; char *result = 0 ; - arg1 = (switch_serial_event_header_t *)jarg1; + arg1 = (switch_serial_event_header_s *)jarg1; result = (char *) ((arg1)->value); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -31200,20 +31556,19 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_serial_event_header_t_value_get(void SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_serial_event_header_t() { void * jresult ; - switch_serial_event_header_t *result = 0 ; + switch_serial_event_header_s *result = 0 ; - result = (switch_serial_event_header_t *)new switch_serial_event_header_t(); + result = (switch_serial_event_header_s *)new switch_serial_event_header_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_serial_event_header_t(void * jarg1) { - switch_serial_event_header_t *arg1 = (switch_serial_event_header_t *) 0 ; + switch_serial_event_header_s *arg1 = (switch_serial_event_header_s *) 0 ; - arg1 = (switch_serial_event_header_t *)jarg1; + arg1 = (switch_serial_event_header_s *)jarg1; delete arg1; - } @@ -31603,8 +31958,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_binary_deserialize(void * jarg1, void **arg2 = (void **) 0 ; switch_size_t arg3 ; switch_bool_t arg4 ; - switch_status_t result; switch_size_t *argp3 ; + switch_status_t result; arg1 = (switch_event_t **)jarg1; arg2 = (void **)jarg2; @@ -31957,8 +32312,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_NO_EVENT_CHANNEL_ID_get() { int jresult ; int result; - result = (int) 0; - + result = (int)(0); jresult = result; return jresult; } @@ -31968,8 +32322,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EVENT_CHANNEL_GLOBAL_get() { char * jresult ; char *result = 0 ; - result = (char *) "__global__"; - + result = (char *)("__global__"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -32169,12 +32522,77 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_parse_json(void * jarg1, un } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_add_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_add_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_clear_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_clear_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_channel_permission_verify(char * jarg1, char * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (switch_bool_t)switch_event_channel_permission_verify((char const *)arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_modify(char * jarg1, char * jarg2, int jarg3) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t arg3 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_bool_t)jarg3; + switch_event_channel_permission_modify((char const *)arg1,(char const *)arg2,arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_clear(char * jarg1) { + char *arg1 = (char *) 0 ; + + arg1 = (char *)jarg1; + switch_event_channel_permission_clear((char const *)arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RESAMPLE_QUALITY_get() { int jresult ; int result; - result = (int) 2; - + result = (int)(2); jresult = result; return jresult; } @@ -32187,7 +32605,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_resampler_set(void * arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->resampler = arg2; - } @@ -32210,7 +32627,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_from_rate_set(void * arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->from_rate = arg2; - } @@ -32233,7 +32649,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_to_rate_set(void * j arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->to_rate = arg2; - } @@ -32256,7 +32671,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_factor_set(void * ja arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (double)jarg2; if (arg1) (arg1)->factor = arg2; - } @@ -32279,7 +32693,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_rfactor_set(void * j arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (double)jarg2; if (arg1) (arg1)->rfactor = arg2; - } @@ -32302,7 +32715,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_to_set(void * jarg1, arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (int16_t *)jarg2; if (arg1) (arg1)->to = arg2; - } @@ -32325,7 +32737,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_to_len_set(void * ja arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->to_len = arg2; - } @@ -32348,7 +32759,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_audio_resampler_t_to_size_set(void * j arg1 = (switch_audio_resampler_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->to_size = arg2; - } @@ -32379,7 +32789,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_audio_resampler_t(void * jarg1) arg1 = (switch_audio_resampler_t *)jarg1; delete arg1; - } @@ -32440,8 +32849,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_float_to_short(void * jarg1, void * float *arg1 = (float *) 0 ; short *arg2 = (short *) 0 ; switch_size_t arg3 ; - switch_size_t result; switch_size_t *argp3 ; + switch_size_t result; arg1 = (float *)jarg1; arg2 = (short *)jarg2; @@ -32452,7 +32861,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_float_to_short(void * jarg1, void * } arg3 = *argp3; result = switch_float_to_short(arg1,arg2,arg3); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -32612,7 +33021,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_session_set(void * ja arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_core_session_t *)jarg2; if (arg1) (arg1)->session = arg2; - } @@ -32635,7 +33043,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_read_codec_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_codec_t *)jarg2; if (arg1) (arg1)->read_codec = *arg2; - } @@ -32658,7 +33065,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_write_frame_set(void arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_frame_t *)jarg2; if (arg1) (arg1)->write_frame = *arg2; - } @@ -32707,7 +33113,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_socket_set(void * jar arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_socket_t *)jarg2; if (arg1) (arg1)->socket = arg2; - } @@ -32730,7 +33135,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_local_ip_set(void * j arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (char *)jarg2; { - if (arg1->local_ip) delete [] arg1->local_ip; + delete [] arg1->local_ip; if (arg2) { arg1->local_ip = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->local_ip, (const char *)arg2); @@ -32760,7 +33165,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_local_port_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_port_t)jarg2; if (arg1) (arg1)->local_port = arg2; - } @@ -32783,7 +33187,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_remote_ip_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (char *)jarg2; { - if (arg1->remote_ip) delete [] arg1->remote_ip; + delete [] arg1->remote_ip; if (arg2) { arg1->remote_ip = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->remote_ip, (const char *)arg2); @@ -32813,7 +33217,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_remote_port_set(void arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_port_t)jarg2; if (arg1) (arg1)->remote_port = arg2; - } @@ -32836,7 +33239,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_local_addr_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_sockaddr_t *)jarg2; if (arg1) (arg1)->local_addr = arg2; - } @@ -32859,7 +33261,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_remote_addr_set(void arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_sockaddr_t *)jarg2; if (arg1) (arg1)->remote_addr = arg2; - } @@ -32882,7 +33283,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_flag_mutex_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (switch_mutex_t *)jarg2; if (arg1) (arg1)->flag_mutex = arg2; - } @@ -32905,7 +33305,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_flags_set(void * jarg arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (int32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -32928,7 +33327,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_type_set(void * jarg1 arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->type = arg2; - } @@ -32951,7 +33349,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_transport_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->transport = arg2; - } @@ -32974,7 +33371,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_unicast_conninfo_stream_id_set(void * arg1 = (switch_unicast_conninfo *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->stream_id = arg2; - } @@ -33005,7 +33401,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_unicast_conninfo(void * jarg1) arg1 = (switch_unicast_conninfo *)jarg1; delete arg1; - } @@ -33244,9 +33639,9 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_collect_digits_count(void * jarg1, uint32_t arg7 ; uint32_t arg8 ; uint32_t arg9 ; - switch_status_t result; switch_size_t *argp3 ; switch_size_t *argp4 ; + switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (char *)jarg2; @@ -33730,8 +34125,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_tone_detect_session(void * jarg1, c char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; switch_tone_detect_callback_t arg9 = (switch_tone_detect_callback_t) 0 ; - switch_status_t result; time_t *argp5 ; + switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (char *)jarg2; @@ -34056,8 +34451,8 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_ivr_schedule_transfer(void * char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; char *arg5 = (char *) 0 ; - uint32_t result; time_t *argp1 ; + uint32_t result; argp1 = (time_t *)jarg1; if (!argp1) { @@ -34081,8 +34476,8 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_ivr_schedule_hangup(void * ja char *arg2 = (char *) 0 ; switch_call_cause_t arg3 ; switch_bool_t arg4 ; - uint32_t result; time_t *argp1 ; + uint32_t result; argp1 = (time_t *)jarg1; if (!argp1) { @@ -34219,8 +34614,8 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_ivr_schedule_broadcast(void * char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; switch_media_flag_t arg4 ; - uint32_t result; time_t *argp1 ; + uint32_t result; argp1 = (time_t *)jarg1; if (!argp1) { @@ -34618,8 +35013,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_find_bridged_uuid(char * jarg1, cha char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - switch_status_t result; switch_size_t *argp3 ; + switch_status_t result; arg1 = (char *)jarg1; arg2 = (char *)jarg2; @@ -34681,8 +35076,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_read(void * jarg1, unsigned long ja uint32_t arg8 ; char *arg9 = (char *) 0 ; uint32_t arg10 ; - switch_status_t result; switch_size_t *argp7 ; + switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (uint32_t)jarg2; @@ -35253,8 +35648,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_insert_file(void * jarg1, char * ja char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; switch_size_t arg4 ; - switch_status_t result; switch_size_t *argp4 ; + switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (char *)jarg2; @@ -35349,8 +35744,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; - result = (int) 16384; - + result = (int)(16384); jresult = result; return jresult; } @@ -35360,8 +35754,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTCP_MAX_BUF_LEN_get() { int jresult ; int result; - result = (int) 16384; - + result = (int)(16384); jresult = result; return jresult; } @@ -35371,8 +35764,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_WORDS_get() { int jresult ; int result; - result = (int) 4094; - + result = (int)(4094); jresult = result; return jresult; } @@ -35382,8 +35774,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_CRYPTO_LEN_get() { int jresult ; int result; - result = (int) 64; - + result = (int)(64); jresult = result; return jresult; } @@ -35393,8 +35784,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_KEY_LEN_get() { int jresult ; int result; - result = (int) 30; - + result = (int)(30); jresult = result; return jresult; } @@ -35404,8 +35794,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_RTP_CRYPTO_KEY_32_get() { char * jresult ; char *result = 0 ; - result = (char *) "AES_CM_128_HMAC_SHA1_32"; - + result = (char *)("AES_CM_128_HMAC_SHA1_32"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -35415,8 +35804,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_RTP_CRYPTO_KEY_80_get() { char * jresult ; char *result = 0 ; - result = (char *) "AES_CM_128_HMAC_SHA1_80"; - + result = (char *)("AES_CM_128_HMAC_SHA1_80"); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; } @@ -35429,7 +35817,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_crypto_key_index_set(void * jarg1, arg1 = (switch_rtp_crypto_key *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->index = arg2; - } @@ -35452,7 +35839,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_crypto_key_type_set(void * jarg1, arg1 = (switch_rtp_crypto_key *)jarg1; arg2 = (switch_rtp_crypto_key_type_t)jarg2; if (arg1) (arg1)->type = arg2; - } @@ -35507,7 +35893,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_crypto_key_keylen_set(void * jarg1 } arg2 = *argp2; if (arg1) (arg1)->keylen = arg2; - } @@ -35518,7 +35903,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_crypto_key_keylen_get(void * jar arg1 = (switch_rtp_crypto_key *)jarg1; result = ((arg1)->keylen); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -35530,7 +35915,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_crypto_key_next_set(void * jarg1, arg1 = (switch_rtp_crypto_key *)jarg1; arg2 = (switch_rtp_crypto_key *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -35561,18 +35945,17 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_crypto_key(void * jarg1) { arg1 = (switch_rtp_crypto_key *)jarg1; delete arg1; - } SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_foundation_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->foundation) delete [] arg1->foundation; + delete [] arg1->foundation; if (arg2) { arg1->foundation = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->foundation, (const char *)arg2); @@ -35585,10 +35968,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_foundation_set(void * jarg1, char * j SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_foundation_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->foundation); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35596,22 +35979,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_foundation_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_component_id_set(void * jarg1, int jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; int arg2 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->component_id = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_icand_t_component_id_get(void * jarg1) { int jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; int result; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (int) ((arg1)->component_id); jresult = result; return jresult; @@ -35619,13 +36001,13 @@ SWIGEXPORT int SWIGSTDCALL CSharp_icand_t_component_id_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_transport_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->transport) delete [] arg1->transport; + delete [] arg1->transport; if (arg2) { arg1->transport = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->transport, (const char *)arg2); @@ -35638,10 +36020,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_transport_set(void * jarg1, char * ja SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_transport_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->transport); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35649,22 +36031,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_transport_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_priority_set(void * jarg1, unsigned long jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; uint32_t arg2 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->priority = arg2; - } SWIGEXPORT unsigned long SWIGSTDCALL CSharp_icand_t_priority_get(void * jarg1) { unsigned long jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; uint32_t result; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (uint32_t) ((arg1)->priority); jresult = (unsigned long)result; return jresult; @@ -35672,13 +36053,13 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_icand_t_priority_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_con_addr_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->con_addr) delete [] arg1->con_addr; + delete [] arg1->con_addr; if (arg2) { arg1->con_addr = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->con_addr, (const char *)arg2); @@ -35691,10 +36072,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_con_addr_set(void * jarg1, char * jar SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_con_addr_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->con_addr); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35702,22 +36083,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_con_addr_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_con_port_set(void * jarg1, unsigned short jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; switch_port_t arg2 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (switch_port_t)jarg2; if (arg1) (arg1)->con_port = arg2; - } SWIGEXPORT unsigned short SWIGSTDCALL CSharp_icand_t_con_port_get(void * jarg1) { unsigned short jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; switch_port_t result; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (switch_port_t) ((arg1)->con_port); jresult = result; return jresult; @@ -35725,13 +36105,13 @@ SWIGEXPORT unsigned short SWIGSTDCALL CSharp_icand_t_con_port_get(void * jarg1) SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_cand_type_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->cand_type) delete [] arg1->cand_type; + delete [] arg1->cand_type; if (arg2) { arg1->cand_type = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->cand_type, (const char *)arg2); @@ -35744,10 +36124,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_cand_type_set(void * jarg1, char * ja SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_cand_type_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->cand_type); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35755,13 +36135,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_cand_type_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_raddr_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->raddr) delete [] arg1->raddr; + delete [] arg1->raddr; if (arg2) { arg1->raddr = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->raddr, (const char *)arg2); @@ -35774,10 +36154,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_raddr_set(void * jarg1, char * jarg2) SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_raddr_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->raddr); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35785,22 +36165,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_raddr_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_rport_set(void * jarg1, unsigned short jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; switch_port_t arg2 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (switch_port_t)jarg2; if (arg1) (arg1)->rport = arg2; - } SWIGEXPORT unsigned short SWIGSTDCALL CSharp_icand_t_rport_get(void * jarg1) { unsigned short jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; switch_port_t result; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (switch_port_t) ((arg1)->rport); jresult = result; return jresult; @@ -35808,13 +36187,13 @@ SWIGEXPORT unsigned short SWIGSTDCALL CSharp_icand_t_rport_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_generation_set(void * jarg1, char * jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->generation) delete [] arg1->generation; + delete [] arg1->generation; if (arg2) { arg1->generation = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->generation, (const char *)arg2); @@ -35827,10 +36206,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_generation_set(void * jarg1, char * j SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_generation_get(void * jarg1) { char * jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; char *result = 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (char *) ((arg1)->generation); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -35838,22 +36217,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_icand_t_generation_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_icand_t_ready_set(void * jarg1, unsigned char jarg2) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; uint8_t arg2 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; arg2 = (uint8_t)jarg2; if (arg1) (arg1)->ready = arg2; - } SWIGEXPORT unsigned char SWIGSTDCALL CSharp_icand_t_ready_get(void * jarg1) { unsigned char jresult ; - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; uint8_t result; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; result = (uint8_t) ((arg1)->ready); jresult = result; return jresult; @@ -35862,20 +36240,19 @@ SWIGEXPORT unsigned char SWIGSTDCALL CSharp_icand_t_ready_get(void * jarg1) { SWIGEXPORT void * SWIGSTDCALL CSharp_new_icand_t() { void * jresult ; - icand_t *result = 0 ; + icand_s *result = 0 ; - result = (icand_t *)new icand_t(); + result = (icand_s *)new icand_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_icand_t(void * jarg1) { - icand_t *arg1 = (icand_t *) 0 ; + icand_s *arg1 = (icand_s *) 0 ; - arg1 = (icand_t *)jarg1; + arg1 = (icand_s *)jarg1; delete arg1; - } @@ -35883,24 +36260,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MAX_CAND_get() { int jresult ; int result; - result = (int) 25; - + result = (int)(50); jresult = result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_cands_set(void * jarg1, void * jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; icand_t (*arg2)[2] ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (icand_t (*)[2])jarg2; { icand_t (*inp)[2] = (icand_t (*)[2])(arg2); icand_t (*dest)[2] = (icand_t (*)[2])(arg1->cands); size_t ii = 0; - for (; ii < 25; ++ii) { + for (; ii < 50; ++ii) { icand_t *ip = inp[ii]; icand_t *dp = dest[ii]; size_t jj = 0; @@ -35912,10 +36288,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_cands_set(void * jarg1, void * jarg2) { SWIGEXPORT void * SWIGSTDCALL CSharp_ice_t_cands_get(void * jarg1) { void * jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; icand_t (*result)[2] = 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (icand_t (*)[2])(icand_t (*)[2]) ((arg1)->cands); jresult = result; return jresult; @@ -35923,22 +36299,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_ice_t_cands_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_cand_idx_set(void * jarg1, int jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; int arg2 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->cand_idx = arg2; - } SWIGEXPORT int SWIGSTDCALL CSharp_ice_t_cand_idx_get(void * jarg1) { int jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; int result; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (int) ((arg1)->cand_idx); jresult = result; return jresult; @@ -35946,10 +36321,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_ice_t_cand_idx_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_chosen_set(void * jarg1, void * jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; int *arg2 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (int *)jarg2; { size_t ii; @@ -35961,10 +36336,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_chosen_set(void * jarg1, void * jarg2) SWIGEXPORT void * SWIGSTDCALL CSharp_ice_t_chosen_get(void * jarg1) { void * jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; int *result = 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (int *)(int *) ((arg1)->chosen); jresult = result; return jresult; @@ -35972,13 +36347,13 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_ice_t_chosen_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_ufrag_set(void * jarg1, char * jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->ufrag) delete [] arg1->ufrag; + delete [] arg1->ufrag; if (arg2) { arg1->ufrag = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->ufrag, (const char *)arg2); @@ -35991,10 +36366,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_ufrag_set(void * jarg1, char * jarg2) { SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_ufrag_get(void * jarg1) { char * jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *result = 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (char *) ((arg1)->ufrag); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -36002,13 +36377,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_ufrag_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_pwd_set(void * jarg1, char * jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->pwd) delete [] arg1->pwd; + delete [] arg1->pwd; if (arg2) { arg1->pwd = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->pwd, (const char *)arg2); @@ -36021,10 +36396,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_pwd_set(void * jarg1, char * jarg2) { SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_pwd_get(void * jarg1) { char * jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *result = 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (char *) ((arg1)->pwd); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -36032,13 +36407,13 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_pwd_get(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_options_set(void * jarg1, char * jarg2) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; arg2 = (char *)jarg2; { - if (arg1->options) delete [] arg1->options; + delete [] arg1->options; if (arg2) { arg1->options = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->options, (const char *)arg2); @@ -36051,10 +36426,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_ice_t_options_set(void * jarg1, char * jarg2) SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_options_get(void * jarg1) { char * jresult ; - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; char *result = 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; result = (char *) ((arg1)->options); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -36063,20 +36438,19 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_ice_t_options_get(void * jarg1) { SWIGEXPORT void * SWIGSTDCALL CSharp_new_ice_t() { void * jresult ; - ice_t *result = 0 ; + ice_s *result = 0 ; - result = (ice_t *)new ice_t(); + result = (ice_s *)new ice_s(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_ice_t(void * jarg1) { - ice_t *arg1 = (ice_t *) 0 ; + ice_s *arg1 = (ice_s *) 0 ; - arg1 = (ice_t *)jarg1; + arg1 = (ice_s *)jarg1; delete arg1; - } @@ -36088,8 +36462,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_add_crypto_key(void * jarg1, int ja switch_rtp_crypto_key_type_t arg4 ; unsigned char *arg5 = (unsigned char *) 0 ; switch_size_t arg6 ; - switch_status_t result; switch_size_t *argp6 ; + switch_status_t result; arg1 = (switch_rtp_t *)jarg1; arg2 = (switch_rtp_crypto_direction_t)jarg2; @@ -36443,8 +36817,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_ice(void * jarg1, char * j ice_proto_t arg6 ; switch_core_media_ice_type_t arg7 ; ice_t *arg8 = (ice_t *) 0 ; - switch_status_t result; switch_core_media_ice_type_t *argp7 ; + switch_status_t result; arg1 = (switch_rtp_t *)jarg1; arg2 = (char *)jarg2; @@ -36732,7 +37106,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_has_dtmf(void * jarg1) { arg1 = (switch_rtp_t *)jarg1; result = switch_rtp_has_dtmf(arg1); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -36746,7 +37120,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_dequeue_dtmf(void * jarg1, void arg1 = (switch_rtp_t *)jarg1; arg2 = (switch_dtmf_t *)jarg2; result = switch_rtp_dequeue_dtmf(arg1,arg2); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -36923,16 +37297,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { - switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; - switch_payload_t arg2 ; - - arg1 = (switch_rtp_t *)jarg1; - arg2 = (switch_payload_t)jarg2; - switch_rtp_set_recv_pt(arg1,arg2); -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; @@ -36955,6 +37319,20 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_get_private(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_set_payload_map(void * jarg1, void * jarg2) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + payload_map_t **arg2 = (payload_map_t **) 0 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (payload_map_t **)jarg2; + result = (switch_status_t)switch_rtp_set_payload_map(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_intentional_bugs(void * jarg1, int jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_rtp_bug_flag_t arg2 ; @@ -37058,7 +37436,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_data_set(void * jarg1, char arg1 = (switch_log_node_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->data) delete [] arg1->data; + delete [] arg1->data; if (arg2) { arg1->data = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->data, (const char *)arg2); @@ -37088,8 +37466,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_file_set(void * jarg1, char arg1 = (switch_log_node_t *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->file, (const char *)arg2, 80); - else arg1->file[0] = 0; + if(arg2) { + strncpy((char*)arg1->file, (const char *)arg2, 80-1); + arg1->file[80-1] = 0; + } else { + arg1->file[0] = 0; + } } } @@ -37113,7 +37495,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_line_set(void * jarg1, unsi arg1 = (switch_log_node_t *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->line = arg2; - } @@ -37136,8 +37517,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_func_set(void * jarg1, char arg1 = (switch_log_node_t *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->func, (const char *)arg2, 80); - else arg1->func[0] = 0; + if(arg2) { + strncpy((char*)arg1->func, (const char *)arg2, 80-1); + arg1->func[80-1] = 0; + } else { + arg1->func[0] = 0; + } } } @@ -37161,7 +37546,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_level_set(void * jarg1, int arg1 = (switch_log_node_t *)jarg1; arg2 = (switch_log_level_t)jarg2; if (arg1) (arg1)->level = arg2; - } @@ -37190,7 +37574,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_timestamp_set(void * jarg1, } arg2 = *argp2; if (arg1) (arg1)->timestamp = arg2; - } @@ -37201,7 +37584,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_log_node_t_timestamp_get(void * jarg arg1 = (switch_log_node_t *)jarg1; result = ((arg1)->timestamp); - jresult = new switch_time_t((switch_time_t &)result); + jresult = new switch_time_t((const switch_time_t &)result); return jresult; } @@ -37213,7 +37596,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_content_set(void * jarg1, c arg1 = (switch_log_node_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->content) delete [] arg1->content; + delete [] arg1->content; if (arg2) { arg1->content = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->content, (const char *)arg2); @@ -37243,7 +37626,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_userdata_set(void * jarg1, arg1 = (switch_log_node_t *)jarg1; arg2 = (char *)jarg2; { - if (arg1->userdata) delete [] arg1->userdata; + delete [] arg1->userdata; if (arg2) { arg1->userdata = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->userdata, (const char *)arg2); @@ -37273,7 +37656,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_channel_set(void * jarg1, i arg1 = (switch_log_node_t *)jarg1; arg2 = (switch_text_channel_t)jarg2; if (arg1) (arg1)->channel = arg2; - } @@ -37296,7 +37678,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_slevel_set(void * jarg1, in arg1 = (switch_log_node_t *)jarg1; arg2 = (switch_log_level_t)jarg2; if (arg1) (arg1)->slevel = arg2; - } @@ -37327,7 +37708,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_log_node_t(void * jarg1) { arg1 = (switch_log_node_t *)jarg1; delete arg1; - } @@ -37443,8 +37823,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_XML_BUFSIZE_get() { int jresult ; int result; - result = (int) 1024; - + result = (int)(1024); jresult = result; return jresult; } @@ -37457,7 +37836,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_name_set(void * jarg1, char * jarg arg1 = (switch_xml *)jarg1; arg2 = (char *)jarg2; { - if (arg1->name) delete [] arg1->name; + delete [] arg1->name; if (arg2) { arg1->name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->name, (const char *)arg2); @@ -37487,7 +37866,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_attr_set(void * jarg1, void * jarg arg1 = (switch_xml *)jarg1; arg2 = (char **)jarg2; if (arg1) (arg1)->attr = arg2; - } @@ -37510,7 +37888,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_txt_set(void * jarg1, char * jarg2 arg1 = (switch_xml *)jarg1; arg2 = (char *)jarg2; { - if (arg1->txt) delete [] arg1->txt; + delete [] arg1->txt; if (arg2) { arg1->txt = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->txt, (const char *)arg2); @@ -37540,7 +37918,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_free_path_set(void * jarg1, char * arg1 = (switch_xml *)jarg1; arg2 = (char *)jarg2; { - if (arg1->free_path) delete [] arg1->free_path; + delete [] arg1->free_path; if (arg2) { arg1->free_path = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->free_path, (const char *)arg2); @@ -37576,7 +37954,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_off_set(void * jarg1, void * jarg2 } arg2 = *argp2; if (arg1) (arg1)->off = arg2; - } @@ -37587,7 +37964,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_xml_off_get(void * jarg1) { arg1 = (switch_xml *)jarg1; result = ((arg1)->off); - jresult = new switch_size_t((switch_size_t &)result); + jresult = new switch_size_t((const switch_size_t &)result); return jresult; } @@ -37599,7 +37976,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_next_set(void * jarg1, void * jarg arg1 = (switch_xml *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -37622,7 +37998,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_sibling_set(void * jarg1, void * j arg1 = (switch_xml *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->sibling = arg2; - } @@ -37645,7 +38020,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_ordered_set(void * jarg1, void * j arg1 = (switch_xml *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->ordered = arg2; - } @@ -37668,7 +38042,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_child_set(void * jarg1, void * jar arg1 = (switch_xml *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->child = arg2; - } @@ -37691,7 +38064,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_parent_set(void * jarg1, void * ja arg1 = (switch_xml *)jarg1; arg2 = (switch_xml_t)jarg2; if (arg1) (arg1)->parent = arg2; - } @@ -37714,7 +38086,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_flags_set(void * jarg1, unsigned l arg1 = (switch_xml *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -37737,7 +38108,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_is_switch_xml_root_t_set(void * ja arg1 = (switch_xml *)jarg1; arg2 = (switch_bool_t)jarg2; if (arg1) (arg1)->is_switch_xml_root_t = arg2; - } @@ -37760,7 +38130,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_xml_refs_set(void * jarg1, unsigned lo arg1 = (switch_xml *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->refs = arg2; - } @@ -37791,7 +38160,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_xml(void * jarg1) { arg1 = (switch_xml *)jarg1; delete arg1; - } @@ -37813,8 +38181,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_xml_parse_str(char * jarg1, void * j void * jresult ; char *arg1 = (char *) 0 ; switch_size_t arg2 ; - switch_xml_t result; switch_size_t *argp2 ; + switch_xml_t result; arg1 = (char *)jarg1; argp2 = (switch_size_t *)jarg2; @@ -38014,9 +38382,9 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_xml_toxml_buf(void * jarg1, char * j switch_size_t arg3 ; switch_size_t arg4 ; switch_bool_t arg5 ; - char *result = 0 ; switch_size_t *argp3 ; switch_size_t *argp4 ; + char *result = 0 ; arg1 = (switch_xml_t)jarg1; arg2 = (char *)jarg2; @@ -38086,8 +38454,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_xml_add_child(void * jarg1, char * j switch_xml_t arg1 = (switch_xml_t) 0 ; char *arg2 = (char *) 0 ; switch_size_t arg3 ; - switch_xml_t result; switch_size_t *argp3 ; + switch_xml_t result; arg1 = (switch_xml_t)jarg1; arg2 = (char *)jarg2; @@ -38164,8 +38532,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_xml_insert(void * jarg1, void * jarg switch_xml_t arg1 = (switch_xml_t) 0 ; switch_xml_t arg2 = (switch_xml_t) 0 ; switch_size_t arg3 ; - switch_xml_t result; switch_size_t *argp3 ; + switch_xml_t result; arg1 = (switch_xml_t)jarg1; arg2 = (switch_xml_t)jarg2; @@ -38602,7 +38970,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_outgoing_channel_outgoin arg1 = (switch_io_event_hook_outgoing_channel *)jarg1; arg2 = (switch_outgoing_channel_hook_t)jarg2; if (arg1) (arg1)->outgoing_channel = arg2; - } @@ -38625,7 +38992,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_outgoing_channel_next_se arg1 = (switch_io_event_hook_outgoing_channel *)jarg1; arg2 = (switch_io_event_hook_outgoing_channel *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38656,7 +39022,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_outgoing_channel( arg1 = (switch_io_event_hook_outgoing_channel *)jarg1; delete arg1; - } @@ -38667,7 +39032,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_receive_message_receive_ arg1 = (switch_io_event_hook_receive_message *)jarg1; arg2 = (switch_receive_message_hook_t)jarg2; if (arg1) (arg1)->receive_message = arg2; - } @@ -38690,7 +39054,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_receive_message_next_set arg1 = (switch_io_event_hook_receive_message *)jarg1; arg2 = (switch_io_event_hook_receive_message *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38721,7 +39084,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_receive_message(v arg1 = (switch_io_event_hook_receive_message *)jarg1; delete arg1; - } @@ -38732,7 +39094,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_receive_event_receive_ev arg1 = (switch_io_event_hook_receive_event *)jarg1; arg2 = (switch_receive_event_hook_t)jarg2; if (arg1) (arg1)->receive_event = arg2; - } @@ -38755,7 +39116,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_receive_event_next_set(v arg1 = (switch_io_event_hook_receive_event *)jarg1; arg2 = (switch_io_event_hook_receive_event *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38786,7 +39146,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_receive_event(voi arg1 = (switch_io_event_hook_receive_event *)jarg1; delete arg1; - } @@ -38797,7 +39156,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_read_frame_read_frame_se arg1 = (switch_io_event_hook_read_frame *)jarg1; arg2 = (switch_read_frame_hook_t)jarg2; if (arg1) (arg1)->read_frame = arg2; - } @@ -38820,7 +39178,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_read_frame_next_set(void arg1 = (switch_io_event_hook_read_frame *)jarg1; arg2 = (switch_io_event_hook_read_frame *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38851,7 +39208,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_read_frame(void * arg1 = (switch_io_event_hook_read_frame *)jarg1; delete arg1; - } @@ -38862,7 +39218,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_video_read_frame_video_r arg1 = (switch_io_event_hook_video_read_frame *)jarg1; arg2 = (switch_read_frame_hook_t)jarg2; if (arg1) (arg1)->video_read_frame = arg2; - } @@ -38885,7 +39240,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_video_read_frame_next_se arg1 = (switch_io_event_hook_video_read_frame *)jarg1; arg2 = (switch_io_event_hook_video_read_frame *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38916,7 +39270,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_video_read_frame( arg1 = (switch_io_event_hook_video_read_frame *)jarg1; delete arg1; - } @@ -38927,7 +39280,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_write_frame_write_frame_ arg1 = (switch_io_event_hook_write_frame *)jarg1; arg2 = (switch_write_frame_hook_t)jarg2; if (arg1) (arg1)->write_frame = arg2; - } @@ -38950,7 +39302,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_write_frame_next_set(voi arg1 = (switch_io_event_hook_write_frame *)jarg1; arg2 = (switch_io_event_hook_write_frame *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -38981,7 +39332,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_write_frame(void arg1 = (switch_io_event_hook_write_frame *)jarg1; delete arg1; - } @@ -38992,7 +39342,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_video_write_frame_video_ arg1 = (switch_io_event_hook_video_write_frame *)jarg1; arg2 = (switch_video_write_frame_hook_t)jarg2; if (arg1) (arg1)->video_write_frame = arg2; - } @@ -39015,7 +39364,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_video_write_frame_next_s arg1 = (switch_io_event_hook_video_write_frame *)jarg1; arg2 = (switch_io_event_hook_video_write_frame *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39046,7 +39394,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_video_write_frame arg1 = (switch_io_event_hook_video_write_frame *)jarg1; delete arg1; - } @@ -39057,7 +39404,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_kill_channel_kill_channe arg1 = (switch_io_event_hook_kill_channel *)jarg1; arg2 = (switch_kill_channel_hook_t)jarg2; if (arg1) (arg1)->kill_channel = arg2; - } @@ -39080,7 +39426,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_kill_channel_next_set(vo arg1 = (switch_io_event_hook_kill_channel *)jarg1; arg2 = (switch_io_event_hook_kill_channel *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39111,7 +39456,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_kill_channel(void arg1 = (switch_io_event_hook_kill_channel *)jarg1; delete arg1; - } @@ -39122,7 +39466,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_send_dtmf_send_dtmf_set( arg1 = (switch_io_event_hook_send_dtmf *)jarg1; arg2 = (switch_send_dtmf_hook_t)jarg2; if (arg1) (arg1)->send_dtmf = arg2; - } @@ -39145,7 +39488,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_send_dtmf_next_set(void arg1 = (switch_io_event_hook_send_dtmf *)jarg1; arg2 = (switch_io_event_hook_send_dtmf *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39176,7 +39518,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_send_dtmf(void * arg1 = (switch_io_event_hook_send_dtmf *)jarg1; delete arg1; - } @@ -39187,7 +39528,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_recv_dtmf_recv_dtmf_set( arg1 = (switch_io_event_hook_recv_dtmf *)jarg1; arg2 = (switch_recv_dtmf_hook_t)jarg2; if (arg1) (arg1)->recv_dtmf = arg2; - } @@ -39210,7 +39550,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_recv_dtmf_next_set(void arg1 = (switch_io_event_hook_recv_dtmf *)jarg1; arg2 = (switch_io_event_hook_recv_dtmf *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39241,7 +39580,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_recv_dtmf(void * arg1 = (switch_io_event_hook_recv_dtmf *)jarg1; delete arg1; - } @@ -39252,7 +39590,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_change_state_chang arg1 = (switch_io_event_hook_state_change *)jarg1; arg2 = (switch_state_change_hook_t)jarg2; if (arg1) (arg1)->state_change = arg2; - } @@ -39275,7 +39612,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_change_next_set(vo arg1 = (switch_io_event_hook_state_change *)jarg1; arg2 = (switch_io_event_hook_state_change *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39306,7 +39642,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_change(void arg1 = (switch_io_event_hook_state_change *)jarg1; delete arg1; - } @@ -39317,7 +39652,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_run_state_run_set( arg1 = (switch_io_event_hook_state_run *)jarg1; arg2 = (switch_state_run_hook_t)jarg2; if (arg1) (arg1)->state_run = arg2; - } @@ -39340,7 +39674,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_run_next_set(void arg1 = (switch_io_event_hook_state_run *)jarg1; arg2 = (switch_io_event_hook_state_run *)jarg2; if (arg1) (arg1)->next = arg2; - } @@ -39371,7 +39704,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_run(void * arg1 = (switch_io_event_hook_state_run *)jarg1; delete arg1; - } @@ -39382,7 +39714,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_outgoing_channel_set(vo arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_outgoing_channel_t *)jarg2; if (arg1) (arg1)->outgoing_channel = arg2; - } @@ -39405,7 +39736,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_receive_message_set(voi arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_receive_message_t *)jarg2; if (arg1) (arg1)->receive_message = arg2; - } @@ -39428,7 +39758,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_receive_event_set(void arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_receive_event_t *)jarg2; if (arg1) (arg1)->receive_event = arg2; - } @@ -39451,7 +39780,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_read_frame_set(void * j arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_read_frame_t *)jarg2; if (arg1) (arg1)->read_frame = arg2; - } @@ -39474,7 +39802,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_video_read_frame_set(vo arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_video_read_frame_t *)jarg2; if (arg1) (arg1)->video_read_frame = arg2; - } @@ -39497,7 +39824,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_write_frame_set(void * arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_write_frame_t *)jarg2; if (arg1) (arg1)->write_frame = arg2; - } @@ -39520,7 +39846,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_video_write_frame_set(v arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_video_write_frame_t *)jarg2; if (arg1) (arg1)->video_write_frame = arg2; - } @@ -39543,7 +39868,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_kill_channel_set(void * arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_kill_channel_t *)jarg2; if (arg1) (arg1)->kill_channel = arg2; - } @@ -39566,7 +39890,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_send_dtmf_set(void * ja arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_send_dtmf_t *)jarg2; if (arg1) (arg1)->send_dtmf = arg2; - } @@ -39589,7 +39912,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_recv_dtmf_set(void * ja arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_recv_dtmf_t *)jarg2; if (arg1) (arg1)->recv_dtmf = arg2; - } @@ -39612,7 +39934,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_state_change_set(void * arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_state_change_t *)jarg2; if (arg1) (arg1)->state_change = arg2; - } @@ -39635,7 +39956,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_state_run_set(void * ja arg1 = (switch_io_event_hooks *)jarg1; arg2 = (switch_io_event_hook_state_run_t *)jarg2; if (arg1) (arg1)->state_run = arg2; - } @@ -39666,7 +39986,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hooks(void * jarg1) { arg1 = (switch_io_event_hooks *)jarg1; delete arg1; - } @@ -40013,7 +40332,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_created_set(void * jarg arg1 = (switch_scheduler_task *)jarg1; arg2 = (int64_t)jarg2; if (arg1) (arg1)->created = arg2; - } @@ -40036,7 +40354,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_runtime_set(void * jarg arg1 = (switch_scheduler_task *)jarg1; arg2 = (int64_t)jarg2; if (arg1) (arg1)->runtime = arg2; - } @@ -40059,7 +40376,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_cmd_id_set(void * jarg1 arg1 = (switch_scheduler_task *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->cmd_id = arg2; - } @@ -40082,7 +40398,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_repeat_set(void * jarg1 arg1 = (switch_scheduler_task *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->repeat = arg2; - } @@ -40105,7 +40420,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_group_set(void * jarg1, arg1 = (switch_scheduler_task *)jarg1; arg2 = (char *)jarg2; { - if (arg1->group) delete [] arg1->group; + delete [] arg1->group; if (arg2) { arg1->group = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->group, (const char *)arg2); @@ -40135,7 +40450,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_cmd_arg_set(void * jarg arg1 = (switch_scheduler_task *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->cmd_arg = arg2; - } @@ -40158,7 +40472,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_task_id_set(void * jarg arg1 = (switch_scheduler_task *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->task_id = arg2; - } @@ -40174,6 +40487,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_task_id_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_hash_set(void * jarg1, unsigned long jarg2) { + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + unsigned long arg2 ; + + arg1 = (switch_scheduler_task *)jarg1; + arg2 = (unsigned long)jarg2; + if (arg1) (arg1)->hash = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_hash_get(void * jarg1) { + unsigned long jresult ; + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + unsigned long result; + + arg1 = (switch_scheduler_task *)jarg1; + result = (unsigned long) ((arg1)->hash); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_scheduler_task() { void * jresult ; switch_scheduler_task *result = 0 ; @@ -40189,7 +40524,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_scheduler_task(void * jarg1) { arg1 = (switch_scheduler_task *)jarg1; delete arg1; - } @@ -40202,8 +40536,8 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_add_task(void * jar uint32_t arg5 ; void *arg6 = (void *) 0 ; switch_scheduler_flag_t arg7 ; - uint32_t result; time_t *argp1 ; + uint32_t result; argp1 = (time_t *)jarg1; if (!argp1) { @@ -40264,7 +40598,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_file_set(void * jarg1, void * j arg1 = (switch_config *)jarg1; arg2 = (FILE *)jarg2; if (arg1) (arg1)->file = arg2; - } @@ -40287,8 +40620,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_path_set(void * jarg1, char * j arg1 = (switch_config *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->path, (const char *)arg2, 512); - else arg1->path[0] = 0; + if(arg2) { + strncpy((char*)arg1->path, (const char *)arg2, 512-1); + arg1->path[512-1] = 0; + } else { + arg1->path[0] = 0; + } } } @@ -40312,8 +40649,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_category_set(void * jarg1, char arg1 = (switch_config *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->category, (const char *)arg2, 256); - else arg1->category[0] = 0; + if(arg2) { + strncpy((char*)arg1->category, (const char *)arg2, 256-1); + arg1->category[256-1] = 0; + } else { + arg1->category[0] = 0; + } } } @@ -40337,8 +40678,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_section_set(void * jarg1, char arg1 = (switch_config *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->section, (const char *)arg2, 256); - else arg1->section[0] = 0; + if(arg2) { + strncpy((char*)arg1->section, (const char *)arg2, 256-1); + arg1->section[256-1] = 0; + } else { + arg1->section[0] = 0; + } } } @@ -40362,8 +40707,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_buf_set(void * jarg1, char * ja arg1 = (switch_config *)jarg1; arg2 = (char *)jarg2; { - if (arg2) strncpy((char *)arg1->buf, (const char *)arg2, 1024); - else arg1->buf[0] = 0; + if(arg2) { + strncpy((char*)arg1->buf, (const char *)arg2, 1024-1); + arg1->buf[1024-1] = 0; + } else { + arg1->buf[0] = 0; + } } } @@ -40387,7 +40736,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_lineno_set(void * jarg1, int ja arg1 = (switch_config *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->lineno = arg2; - } @@ -40410,7 +40758,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_catno_set(void * jarg1, int jar arg1 = (switch_config *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->catno = arg2; - } @@ -40433,7 +40780,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_sectno_set(void * jarg1, int ja arg1 = (switch_config *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->sectno = arg2; - } @@ -40456,7 +40802,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_config_lockto_set(void * jarg1, int ja arg1 = (switch_config *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->lockto = arg2; - } @@ -40487,7 +40832,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_config(void * jarg1) { arg1 = (switch_config *)jarg1; delete arg1; - } @@ -40653,7 +40997,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_IvrMenu(void * jarg1) { arg1 = (IVRMenu *)jarg1; delete arg1; - } @@ -40700,7 +41043,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_Api(void * jarg1) { arg1 = (API *)jarg1; delete arg1; - } @@ -40747,22 +41089,21 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_Api_getTime(void * jarg1) { SWIGEXPORT void SWIGSTDCALL CSharp_input_callback_state_t_function_set(void * jarg1, void * jarg2) { - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *arg2 = (void *) 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->function = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_function_get(void * jarg1) { void * jresult ; - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *result = 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; result = (void *) ((arg1)->function); jresult = (void *)result; return jresult; @@ -40770,22 +41111,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_function_get(void * SWIGEXPORT void SWIGSTDCALL CSharp_input_callback_state_t_threadState_set(void * jarg1, void * jarg2) { - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *arg2 = (void *) 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->threadState = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_threadState_get(void * jarg1) { void * jresult ; - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *result = 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; result = (void *) ((arg1)->threadState); jresult = (void *)result; return jresult; @@ -40793,22 +41133,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_threadState_get(void SWIGEXPORT void SWIGSTDCALL CSharp_input_callback_state_t_extra_set(void * jarg1, void * jarg2) { - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *arg2 = (void *) 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; arg2 = (void *)jarg2; if (arg1) (arg1)->extra = arg2; - } SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_extra_get(void * jarg1) { void * jresult ; - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; void *result = 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; result = (void *) ((arg1)->extra); jresult = (void *)result; return jresult; @@ -40816,13 +41155,13 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_input_callback_state_t_extra_get(void * jar SWIGEXPORT void SWIGSTDCALL CSharp_input_callback_state_t_funcargs_set(void * jarg1, char * jarg2) { - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; char *arg2 = (char *) 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; arg2 = (char *)jarg2; { - if (arg1->funcargs) delete [] arg1->funcargs; + delete [] arg1->funcargs; if (arg2) { arg1->funcargs = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->funcargs, (const char *)arg2); @@ -40835,10 +41174,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_input_callback_state_t_funcargs_set(void * ja SWIGEXPORT char * SWIGSTDCALL CSharp_input_callback_state_t_funcargs_get(void * jarg1) { char * jresult ; - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; char *result = 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; result = (char *) ((arg1)->funcargs); jresult = SWIG_csharp_string_callback((const char *)result); return jresult; @@ -40847,20 +41186,19 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_input_callback_state_t_funcargs_get(void * SWIGEXPORT void * SWIGSTDCALL CSharp_new_input_callback_state_t() { void * jresult ; - input_callback_state_t *result = 0 ; + input_callback_state *result = 0 ; - result = (input_callback_state_t *)new input_callback_state_t(); + result = (input_callback_state *)new input_callback_state(); jresult = (void *)result; return jresult; } SWIGEXPORT void SWIGSTDCALL CSharp_delete_input_callback_state_t(void * jarg1) { - input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; + input_callback_state *arg1 = (input_callback_state *) 0 ; - arg1 = (input_callback_state_t *)jarg1; + arg1 = (input_callback_state *)jarg1; delete arg1; - } @@ -40871,7 +41209,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_DTMF_digit_set(void * jarg1, char jarg2) { arg1 = (DTMF *)jarg1; arg2 = (char)jarg2; if (arg1) (arg1)->digit = arg2; - } @@ -40894,7 +41231,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_DTMF_duration_set(void * jarg1, unsigned long arg1 = (DTMF *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->duration = arg2; - } @@ -40929,7 +41265,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_DTMF(void * jarg1) { arg1 = (DTMF *)jarg1; delete arg1; - } @@ -40960,7 +41295,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_Stream(void * jarg1) { arg1 = (Stream *)jarg1; delete arg1; - } @@ -40993,7 +41327,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Event_InternalEvent_set(void * jarg1, void * arg1 = (Event *)jarg1; arg2 = (switch_event_t *)jarg2; if (arg1) (arg1)->event = arg2; - } @@ -41016,7 +41349,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Event_serialized_string_set(void * jarg1, cha arg1 = (Event *)jarg1; arg2 = (char *)jarg2; { - if (arg1->serialized_string) delete [] arg1->serialized_string; + delete [] arg1->serialized_string; if (arg2) { arg1->serialized_string = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->serialized_string, (const char *)arg2); @@ -41046,7 +41379,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Event_mine_set(void * jarg1, int jarg2) { arg1 = (Event *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->mine = arg2; - } @@ -41095,7 +41427,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_Event(void * jarg1) { arg1 = (Event *)jarg1; delete arg1; - } @@ -41258,7 +41589,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_events_set(void * jarg1, void * arg1 = (EventConsumer *)jarg1; arg2 = (switch_queue_t *)jarg2; if (arg1) (arg1)->events = arg2; - } @@ -41281,7 +41611,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_e_event_id_set(void * jarg1, in arg1 = (EventConsumer *)jarg1; arg2 = (switch_event_types_t)jarg2; if (arg1) (arg1)->e_event_id = arg2; - } @@ -41304,7 +41633,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_e_callback_set(void * jarg1, ch arg1 = (EventConsumer *)jarg1; arg2 = (char *)jarg2; { - if (arg1->e_callback) delete [] arg1->e_callback; + delete [] arg1->e_callback; if (arg2) { arg1->e_callback = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->e_callback, (const char *)arg2); @@ -41334,7 +41663,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_e_subclass_name_set(void * jarg arg1 = (EventConsumer *)jarg1; arg2 = (char *)jarg2; { - if (arg1->e_subclass_name) delete [] arg1->e_subclass_name; + delete [] arg1->e_subclass_name; if (arg2) { arg1->e_subclass_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->e_subclass_name, (const char *)arg2); @@ -41364,7 +41693,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_e_cb_arg_set(void * jarg1, char arg1 = (EventConsumer *)jarg1; arg2 = (char *)jarg2; { - if (arg1->e_cb_arg) delete [] arg1->e_cb_arg; + delete [] arg1->e_cb_arg; if (arg2) { arg1->e_cb_arg = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->e_cb_arg, (const char *)arg2); @@ -41420,7 +41749,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_node_index_set(void * jarg1, un arg1 = (EventConsumer *)jarg1; arg2 = (uint32_t)jarg2; if (arg1) (arg1)->node_index = arg2; - } @@ -41457,7 +41785,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_EventConsumer(void * jarg1) { arg1 = (EventConsumer *)jarg1; delete arg1; - } @@ -41506,7 +41833,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_CoreSession(void * jarg1) { arg1 = (CoreSession *)jarg1; delete arg1; - } @@ -41517,7 +41843,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_InternalSession_set(void * jarg1, arg1 = (CoreSession *)jarg1; arg2 = (switch_core_session_t *)jarg2; if (arg1) (arg1)->session = arg2; - } @@ -41540,7 +41865,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_channel_set(void * jarg1, void * arg1 = (CoreSession *)jarg1; arg2 = (switch_channel_t *)jarg2; if (arg1) (arg1)->channel = arg2; - } @@ -41563,7 +41887,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_flags_set(void * jarg1, unsigned arg1 = (CoreSession *)jarg1; arg2 = (unsigned int)jarg2; if (arg1) (arg1)->flags = arg2; - } @@ -41586,7 +41909,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_allocated_set(void * jarg1, int j arg1 = (CoreSession *)jarg1; arg2 = (int)jarg2; if (arg1) (arg1)->allocated = arg2; - } @@ -41609,7 +41931,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_cb_state_set(void * jarg1, void * arg1 = (CoreSession *)jarg1; arg2 = (input_callback_state *)jarg2; if (arg1) (arg1)->cb_state = *arg2; - } @@ -41632,7 +41953,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_HookState_set(void * jarg1, int j arg1 = (CoreSession *)jarg1; arg2 = (switch_channel_state_t)jarg2; if (arg1) (arg1)->hook_state = arg2; - } @@ -41655,7 +41975,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_cause_set(void * jarg1, int jarg2 arg1 = (CoreSession *)jarg1; arg2 = (switch_call_cause_t)jarg2; if (arg1) (arg1)->cause = arg2; - } @@ -41678,7 +41997,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_uuid_set(void * jarg1, char * jar arg1 = (CoreSession *)jarg1; arg2 = (char *)jarg2; { - if (arg1->uuid) delete [] arg1->uuid; + delete [] arg1->uuid; if (arg2) { arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->uuid, (const char *)arg2); @@ -41708,7 +42027,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_tts_name_set(void * jarg1, char * arg1 = (CoreSession *)jarg1; arg2 = (char *)jarg2; { - if (arg1->tts_name) delete [] arg1->tts_name; + delete [] arg1->tts_name; if (arg2) { arg1->tts_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->tts_name, (const char *)arg2); @@ -41738,7 +42057,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_voice_name_set(void * jarg1, char arg1 = (CoreSession *)jarg1; arg2 = (char *)jarg2; { - if (arg1->voice_name) delete [] arg1->voice_name; + delete [] arg1->voice_name; if (arg2) { arg1->voice_name = (char *) (new char[strlen((const char *)arg2)+1]); strcpy((char *)arg1->voice_name, (const char *)arg2); @@ -42373,10 +42692,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_CoreSession_get_cb_args(void * jarg1) { switch_input_args_t *result = 0 ; arg1 = (CoreSession *)jarg1; - { - switch_input_args_t const &_result_ref = ((CoreSession const *)arg1)->get_cb_args(); - result = (switch_input_args_t *) &_result_ref; - } + result = (switch_input_args_t *) &((CoreSession const *)arg1)->get_cb_args(); jresult = (void *)result; return jresult; } @@ -42424,7 +42740,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_msleep(unsigned int jarg1) { unsigned int arg1 ; arg1 = (unsigned int)jarg1; - msleep(arg1); + switch_msleep(arg1); } @@ -42433,12 +42749,12 @@ SWIGEXPORT void SWIGSTDCALL CSharp_bridge(void * jarg1, void * jarg2) { CoreSession *arg2 = 0 ; arg1 = (CoreSession *)jarg1; - if(!arg1) { + if (!arg1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "CoreSession & type is null", 0); return ; } arg2 = (CoreSession *)jarg2; - if(!arg2) { + if (!arg2) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "CoreSession & type is null", 0); return ; } @@ -42517,12 +42833,11 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_ManagedSession(void * jarg1) { arg1 = (ManagedSession *)jarg1; delete arg1; - } -SWIGEXPORT CoreSession * SWIGSTDCALL CSharp_ManagedSessionUpcast(ManagedSession *objectRef) { - return (CoreSession *)objectRef; +SWIGEXPORT CoreSession * SWIGSTDCALL CSharp_ManagedSession_SWIGUpcast(ManagedSession *jarg1) { + return (CoreSession *)jarg1; } #ifdef __cplusplus diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/BanTracker.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/BanTracker.cs new file mode 100644 index 0000000000..dd5c950e0d --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/BanTracker.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FreeSWITCH; +using FreeSWITCH.Native; + +namespace winFailToBan +{ + public static class BanTracker + { + public static int MaxFails = 3; + public static int FailMinutes = 1; + public static int BanMinutes = 1; + public static String BanApi = @"system netsh adv fire add rule name={0} dir=in action=block remoteip={1}"; + public static String UnBanApi = @"system netsh adv fire delete rule name={0}"; + + // Tracker object + public static Dictionary> MainTracker = + new Dictionary>(); + + // Active Ban list Key=IP val=baninfo + public static Dictionary ActiveBans = + new Dictionary(); + + + public static void Startup() + { + LoadSettings(); + } + + private static void LoadSettings() + { + using (var a = new Api(null)) + { + var setting = a.ExecuteString("global_getvar ban_maxfails"); + if (!String.IsNullOrEmpty(setting)) + MaxFails = int.Parse(setting); + + setting = a.ExecuteString("global_getvar ban_failminutes"); + if (!String.IsNullOrEmpty(setting)) + FailMinutes = int.Parse(setting); + + setting = a.ExecuteString("global_getvar ban_banminutes"); + if (!String.IsNullOrEmpty(setting)) + BanMinutes = int.Parse(setting); + } + } + + private static void CleanOld(List l) + { + var expiretime = DateTime.Now.Subtract(new TimeSpan(0, FailMinutes, 0)); + var expired = l.Where(x => x < expiretime).ToList(); + expired.ForEach(x => l.Remove(x)); + } + + public static void CleanUp() + { + var templist = new List(); + foreach (var kvp in MainTracker) + { + CleanOld(kvp.Value); + if (kvp.Value.Count == 0) + templist.Add(kvp.Key); + } + + templist.ForEach(i => + { + MainTracker.Remove(i); + Log.WriteLine(LogLevel.Critical, "FTB: Removed tracker entry for {0}", i); + }); // remove all the dictinoary entries that are old + + templist.Clear(); + + // now unban the expired bans + templist.AddRange(from kvp in ActiveBans where kvp.Value.Expires < DateTime.Now select kvp.Key); + templist.ForEach(Unban); + } + + public static void TrackFailure(String ipAddress) + { + LoadSettings(); // just in case they've changed... + if (ActiveBans.ContainsKey(ipAddress)) + return; // don't process again, some delay may happen between the ban, and it taking effect by external system + + if (!MainTracker.ContainsKey(ipAddress)) + MainTracker.Add(ipAddress, new List()); + var l = MainTracker[ipAddress]; + CleanOld(l); // clean out the old ones + l.Add(DateTime.Now); // add the failure to the list + Log.WriteLine(LogLevel.Critical, "Fail to ban logging attempt from {0} count is {1}", ipAddress, l.Count); + if (l.Count > MaxFails) + { + // do the ban here + l.Clear(); + MainTracker.Remove(ipAddress); + Ban(ipAddress); + } + } + + public static void Ban(String ipAddress) + { + Log.WriteLine(LogLevel.Critical, "FTP Banning IP Address {0}", ipAddress); + if (ActiveBans.ContainsKey(ipAddress)) + return; // it's already banned so f-it + + var bi = new BanInfo(); + ActiveBans.Add(ipAddress, bi); + // Execute the ban API callback here + var acmd = String.Format(BanApi, bi.FirewallRuleName, ipAddress); + Log.WriteLine(LogLevel.Critical, "FTB: api command: {0}", acmd); + using (var a = new Api(null)) + a.ExecuteString(acmd); + } + + public static void Unban(String ipAddress) + { + Log.WriteLine(LogLevel.Critical, "FTB: Unbanning ip address {0}", ipAddress); + if (!ActiveBans.ContainsKey(ipAddress)) + return; // nothing to do, it's not banned + + var bi = ActiveBans[ipAddress]; // get the ban info + // Execute the unban API + var acmd = String.Format(UnBanApi, bi.FirewallRuleName); + Log.WriteLine(LogLevel.Critical, "FTB: api command: {0}", acmd); + using (var a = new Api(null)) + a.ExecuteString(acmd); + + ActiveBans.Remove(ipAddress); + } + } + + public class BanInfo + { + public String FirewallRuleName { get; set; } + public DateTime Expires { get; set; } + + public BanInfo() + { + FirewallRuleName = "ftb-" + Guid.NewGuid().ToString("N"); + Expires = DateTime.Now.AddMinutes(BanTracker.BanMinutes); + } + } +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/EventLoop.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/EventLoop.cs new file mode 100644 index 0000000000..7f96f4a534 --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/EventLoop.cs @@ -0,0 +1,87 @@ +using System; +using System.Threading; +using FreeSWITCH.Native; +using winFailToBan.Internal; +using FreeSWITCH; + +namespace winFailToBan +{ + public static class EventLoop + { + public static Boolean Running = true; + private static Thread _eventThread; + + public static void StartEvents() + { + if (_eventThread != null) + return; + _eventThread = new Thread(EventMainLoop); + Running = true; + _eventThread.Start(); + } + + public static void StopEvents() + { + Running = false; + } + + public static void EventMainLoop() + { + EventConsumer ec = null; + try + { + + ec = new EventConsumer("CUSTOM", "sofia::register_attempt", 100); + ec.bind("SHUTDOWN", String.Empty); + ec.bind("HEARTBEAT", String.Empty); + while (Running) + { + var evt = ec.pop(0, 0); + if (evt == null) + continue; + + var en = evt.InternalEvent.GetValueOfHeader("Event-Name"); + if (en == "CUSTOM") + en = evt.InternalEvent.GetValueOfHeader("Event-SubClass"); + switch (en) + { + case @"sofia::register_attempt": + { + var iev = evt.InternalEvent; + var ar = iev.GetValueOfHeader("auth-result"); // get the value of the result to see if it's the case we want + var ip = iev.GetValueOfHeader("network-ip"); // and the ip address the register came from + + if (ar == "FORBIDDEN") + { + BanTracker.TrackFailure(ip); + } + } + break; + + case "SHUTDOWN": + Log.WriteLine(LogLevel.Critical,"FTB: Processing Shutdown event"); + Running = false; + break; + + case "HEARTBEAT": + BanTracker.CleanUp(); + break; + + default: + break; + } + } + } + catch (Exception exx) + { + Log.WriteLine(LogLevel.Critical, "FailToBan -- Exception in event loop {0}", exx.Message); + } + finally + { + if(ec != null) + ec.Dispose(); + _eventThread = null; + } + } + } +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/Fail2Ban.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Fail2Ban.cs new file mode 100644 index 0000000000..789fec152e --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Fail2Ban.cs @@ -0,0 +1,45 @@ +using FreeSWITCH; + +namespace winFailToBan +{ + public class Fail2Ban : IApiPlugin , ILoadNotificationPlugin + { + public void Execute(ApiContext context) + { + var cmds = context.Arguments.Split(" ".ToCharArray()); + var cmd = cmds[0].ToLower(); + switch (cmd) + { + case "shutdown": + Shutdown(); + break; + + default: + context.Stream.Write("\n\nInvalid Command\n\n"); + break; + } + } + + public void ExecuteBackground(ApiBackgroundContext context) + { + return; + } + + public static void Startup() + { + BanTracker.Startup(); + EventLoop.StartEvents(); + } + + public static void Shutdown() + { + EventLoop.StopEvents(); + } + + public bool Load() + { + Startup(); + return true; + } + } +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHandler.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHandler.cs new file mode 100644 index 0000000000..65da2972ea --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHandler.cs @@ -0,0 +1,83 @@ +using System; +using FreeSWITCH; +using FreeSWITCH.Native; + +namespace winFailToBan.Internal +{ + + public class ConfigurationEventArgs : EventArgs + { + public SwitchXmlSearchBinding.XmlBindingArgs FsArgs { get; private set; } + public fsConfigDocument Result { get; set; } + public Boolean DontProcess { get; set; } + + public ConfigurationEventArgs(SwitchXmlSearchBinding.XmlBindingArgs args) + { + DontProcess = false; + FsArgs = args; + Result = null; + } + } + + // Bind XML search function turned into CLR events for ease use + public class ConfigHandler : IDisposable + { + public event EventHandler DirectoryRequest; + public event EventHandler DialPlanRequest; + + private IDisposable _binder; // object to bind to + + public void Dispose() + { + if(_binder != null) + _binder.Dispose(); + _binder = null; + } + + public String XmlCallback(SwitchXmlSearchBinding.XmlBindingArgs args) + { + String rv = null; // return value + switch (args.Section.ToLower()) + { + case "directory": + var dargs = new ConfigurationEventArgs(args); + if (DirectoryRequest != null) + { + var temp = DirectoryRequest; + temp(this, dargs); + if (dargs.DontProcess) + return null; + if (dargs.Result != null) + rv = dargs.Result.ToXMLString(); + } + break; + + case "dialplan": + var dialargs = new ConfigurationEventArgs(args); + if(DialPlanRequest != null) + { + var temp = DialPlanRequest; + temp(this, dialargs); + if (dialargs.Result != null) + rv = dialargs.Result.ToXMLString(); + } + break; + } + + return rv ?? new fsNotFoundDocument().ToXMLString(); + } + + ~ConfigHandler() + { + Dispose(); + } + + public ConfigHandler() + { + _binder = SwitchXmlSearchBinding.Bind(XmlCallback, + switch_xml_section_enum_t.SWITCH_XML_SECTION_DIRECTORY | + switch_xml_section_enum_t.SWITCH_XML_SECTION_DIALPLAN); + + } + } +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHelper.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHelper.cs new file mode 100644 index 0000000000..bc0e039497 --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Internal/ConfigHelper.cs @@ -0,0 +1,327 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using FreeSWITCH.Native; +using Stream = System.IO.Stream; + +namespace winFailToBan.Internal +{ + public abstract class fsConfigDocument + { + public XElement xmldoc; + public XElement main; + + protected fsConfigDocument(String SectionName) + { + main = new XElement("wtf", + new XElement("document", + new XAttribute("type", "freeswitch/xml"), + new XElement("section", + new XAttribute("name", SectionName), + new XAttribute("description", "Auto generated") + ))); + xmldoc = main.Descendants("document").Single(); + } + + public Int64 Length() + { + return xmldoc.ToString().Length + 2; + } + + public String ToXMLString() + { + return xmldoc.ToString(); + } + + public Int64 WriteXML(Stream outStream) + { + var wr = new StreamWriter(outStream); + wr.WriteLine(xmldoc.ToString()); + wr.Flush(); + return xmldoc.ToString().Length + 2; + } + + public void WriteXML(TextWriter outText) + { + outText.Write(xmldoc.ToString()); + } + + + protected void SectionChild(XElement Node) + { + // ReSharper disable PossibleNullReferenceException + if (xmldoc != null) xmldoc.Element("section").Add(Node); + // ReSharper restore PossibleNullReferenceException + } + } + + public class fsNotFoundDocument : fsConfigDocument + { + public fsNotFoundDocument() + : base("result") + { + SectionChild(new XElement("result", + new XAttribute("status", "not found"))); + } + } + + public class fsDomainGatewayDirectoryDocument : fsConfigDocument + { + public fsDomainGatewayDirectoryDocument(Dictionary>> domainGatewayList) + : base("directory") + { + if (xmldoc == null) + return; + foreach (var v in + (from d in domainGatewayList + select new XElement("domain", + new XAttribute("name", d.Key), + new XElement("user", + new XAttribute("id", "gatewaydummyser"), + new XElement("gateways", + from g in d.Value + select new XElement("gateway", + new XAttribute("name", g.Key), + from p in g.Value + select new XElement("param", + new XAttribute( + "name", p.Key), + new XAttribute( + "value", p.Value)))))))) + xmldoc.Element("section").Add(v); + } + } + + public class fsDirectoryDocument : fsConfigDocument + { + public fsDirectoryDocument(String Domain, String User, String Password) + : base("directory") + { + SectionChild(new XElement("domain", + new XAttribute("name", Domain), + new XElement("user", + new XAttribute("id", User), + new XElement("params", + new XElement("param", + new XAttribute("name", "password"), + new XAttribute("value", Password) + ) + ) + ) + )); + } + public fsDirectoryDocument(String Domain, String User, String Password, Dictionary Params) + : this(Domain, User, Password) + { + if (Params == null) + return; + // ReSharper disable PossibleNullReferenceException + xmldoc.Element("section").Element("domain").Element("user").Element("params").Add( + // ReSharper restore PossibleNullReferenceException + from par in Params + select new XElement("param", + new XAttribute("name", par.Key), + new XAttribute("value", par.Value))); + } + + public fsDirectoryDocument(String Domain, String User, String Password, Dictionary Params, Dictionary Variables) + : this(Domain, User, Password, Params) + { + if (Variables == null) + return; + // ReSharper disable PossibleNullReferenceException + xmldoc.Element("section").Element("domain").Element("user").Add( + // ReSharper restore PossibleNullReferenceException + new XElement("variables", from v in Variables + select new XElement("variable", + new XAttribute("name", v.Key), + new XAttribute("value", v.Value)))); + } + } + + public class fsDialPlanDocument : fsConfigDocument + { + + private static XElement MakeActionNode(String ActionString) + { + var p = ActionString.Split(",".ToCharArray(), 2); + var rv = new XElement("action", + new XAttribute("application", p[0])); + if (p.Length > 1) + rv.Add(new XAttribute("data", p[1])); + return rv; + } + + public fsDialPlanDocument(String Context, IEnumerable Actions) + : base("dialplan") + { + SectionChild(new XElement("context", + new XAttribute("name", Context), + new XElement("extension", + new XAttribute("name", "extension"), + new XElement("condition", + from act in Actions + select MakeActionNode(act))))); + } + } + + public static class ConfigExtensions + { + public static switch_event_header GetHeader(this switch_event e, String HeaderName) + { + for (var x = e.headers; x != null; x = x.next) + { + if (HeaderName.ToLower() == x.name.ToLower()) + return x; + } + return null; + } + + public static String GetValueOfHeader(this switch_event e, String headerName, String defaultValue = "") + { + var head = e.GetHeader(headerName); + return (head == null ? defaultValue : head.value); + } + + public static Boolean GetBooleanHeader(this switch_event e, String headerName) + { + var hv = e.GetValueOfHeader(headerName); + hv = (String.IsNullOrEmpty(hv) ? "false" : hv); + Boolean rv = false; + Boolean.TryParse(hv, out rv); + return rv; + } + + public static Guid GetUUID(this Event e) + { + var idfld = e.GetHeader("Unique-ID"); + return String.IsNullOrEmpty(idfld) ? Guid.Empty : new Guid(idfld); + } + + public static void ForEach(this switch_event e, Action action) + { + for (var x = e.headers; x != null; x = x.next) + { + action(x.name, x.value); + } + } + + public static Guid GetGuid(this switch_event e) + { + return e.GetHeader("Unique-ID") == null ? Guid.Empty : Guid.Parse(e.GetHeader("Unique-ID").value); + } + + public static void Dump(this switch_event e) + { + e.ForEach((n, v) => Console.WriteLine("{0}={1}", n, v)); + } + + public static Dictionary ExtractVars(this switch_event e) + { + var r = new Dictionary(); + for (var x = e.headers; x != null; x = x.next) + { + if (x.name.StartsWith("variable_")) + { + r.Add(x.name.ToLower().Replace("variable_", String.Empty), + x.value); + } + } + return r; + } + + public static String ModDigits(this String Orig, int qdel, String Prefix) + { + var rv = Orig; + rv = qdel > Orig.Length ? String.Empty : rv.Substring(qdel); + if (!String.IsNullOrEmpty(Prefix)) + rv = Prefix + rv; + return rv; + } + + //public static String RoutingReplace(this String Orig, String Orignal, String Modified) + //{ + // var rv = Orig; + // rv = rv.Replace("%d", Modified); + // rv = rv.Replace("%o", Orignal); + // return rv; + //} + + public static void MergeFrom( + this Dictionary dict, + Dictionary src + ) + { + foreach (var entry in src) + { + if (!dict.ContainsKey(entry.Key)) + dict.Add(entry.Key, entry.Value); + } + } + + public static void RemoveKeysIn( + this Dictionary dict, + IEnumerable keys + ) + { + foreach (var k in keys) + if (dict.ContainsKey(k)) + dict.Remove(k); + } + + public static void AddVariableTextList(this Dictionary d, String varslist) + { + if (d == null || String.IsNullOrEmpty(varslist)) + return; + foreach (var vardef in varslist.Split(",".ToCharArray())) + { + var args = vardef.Split("=".ToCharArray(), 2); + if (!d.ContainsKey(args[0])) + { + d.Add(args[0], args[1]); + } + else + { + d[args[0]] = args[1]; + } + } + } + + public static String ToParamString(this Dictionary d) + { + var firstPart = new List(); + foreach (var e in d) + { + firstPart.Add(String.Format("{0}={1}", e.Key, e.Value)); + } + var rv = String.Join(",", firstPart.ToArray()); + return rv; + } + + public static String ToChannelVars(this Dictionary d, Boolean bLocal) + { + if (d == null || d.Count == 0) + return String.Empty; + String fmt; + if (bLocal) + fmt = "[{0}]"; + else + fmt = "{{{0}}}"; + return String.Format(fmt, d.ToParamString()); + } + + public static void AddActions(this List l, params String[] strings) + { + String seperator = "^"; + foreach (var s in strings) + { + if (String.IsNullOrEmpty(s)) + continue; + l.AddRange(s.Split(seperator.ToCharArray())); + } + } + } + +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/Properties/AssemblyInfo.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6036cbd3aa --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("winFailToBan")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("winFailToBan")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a171cab9-d773-4070-9993-26a581c6f243")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/packages.config b/src/mod/languages/mod_managed/managed/examples/winFailToBan/packages.config new file mode 100644 index 0000000000..8412e6360d --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/skel.cs b/src/mod/languages/mod_managed/managed/examples/winFailToBan/skel.cs new file mode 100644 index 0000000000..ca622b75cf --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/skel.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FreeSWITCH; +using winFailToBan.Internal; + +namespace winFailToBan +{ + public class SampleApp : IAppPlugin + { + // example class for a dialplan APP just implment the run method + public void Run(AppContext context) + { + var s = context.Session; + var args = context.Arguments; + // Do something with them here + } + } + + // Example class to implment an API command + public class SampleApi : IApiPlugin + { + public void Execute(ApiContext context) + { + throw new NotImplementedException(); + } + + public void ExecuteBackground(ApiBackgroundContext context) + { + throw new NotImplementedException(); + } + } + + // This examle class can be used to handle XML config lookups for dialplan and directory + + public class SampleConfigHandler : ILoadNotificationPlugin + { + private static ConfigHandler MyConfigHandler; + + static void HandleDirectoryLookups(Object sender, ConfigurationEventArgs e) + { + e.Result = null; // not found example just return after this + // return; // uncomment to just return not-fouond + + // return a directory object that will work + var evt = e.FsArgs.Parameters; // Get the raw event that generated the userDir lookup + var eventName = evt.GetHeader("Event-Name").value; // Find the event name + + // If your module handles voicemail authorization then implment the following + // to update the voicemail password, when they change their voicemail password using TUI + if (eventName == "CUSTOM") + { + var subClass = evt.GetValueOfHeader("Event-Subclass"); + if (subClass == "vm::maintenance") + { + var vmaction = evt.GetValueOfHeader("VM-Actoun"); + var username = evt.GetValueOfHeader("VM-User"); + var newPassword = evt.GetValueOfHeader("VM-User-Password"); + if (vmaction == "change-password" && !string.IsNullOrEmpty(username) && + !String.IsNullOrEmpty(newPassword)) + { + // implment your code to update the users vm password in your database + return; // No more processing we don't actually do an auth just a notification + } + } + } + + // to make sure we don't have some future events messing us up... + if (eventName != "REQUEST_PARAMS" && eventName != "GENERAL") + return; + + // implment the following if you want to handle gateway lookup from directory when a profile loads + if (evt.GetValueOfHeader("purpose") == "gateways") + { + var profileName = evt.GetValueOfHeader("profile"); + // implment your gateway lookup + //e.Result = new fsDomainGatewayDirectoryDocument(myGwStructure); + return; + } + + var action = evt.GetValueOfHeader("action", "none"); // get the action + + // If you want to handle ESL Logins implment the following + if (action == "event_socket_auth") + { + // preform your stuff here + // e.result = ... + return; + } + + // Normal lookup processing + if (evt.GetHeader("user") == null || evt.GetHeader("domain") == null) + return; // does't have required fields + var method = evt.GetValueOfHeader("sip_auth_method", "unknown"); + var user = evt.GetValueOfHeader("user"); + var domain = evt.GetValueOfHeader("domain"); + + // Some variables to return the params and variables section of the user record + var variables = new Dictionary(); + var uparams = new Dictionary(); + + + // if you're implmenting reverse-auth of devices + if (action == "reverse-auth-lookup") + { + // lookup stuff in your db + uparams.Add("reverse-auth-user", "device uername"); + uparams.Add("reverse-auth-pass", "device password"); + } + + // if you handle voicemail passwords ... + if (true /*check for voicemail box */) + { + uparams.Add("vm-password", "theirvmpassword"); + // the following is optional + uparams.Add("MWI-Account", "registrationstring"); + } + // add more parameters here + uparams.Add("anyotherparameters", "value"); + + // add variables here for example + variables.Add("user_context", "theuserscontext"); + + e.Result = new fsDirectoryDocument( + domain, + user, + "theirpassword", + uparams, + variables); + + return; + } + + // Example dialplan handler + static void HandleDialPlanRequest(object sender, ConfigurationEventArgs e) + { + var evt = e.FsArgs.Parameters; // get the native event that caused this dialplan lookup + + // extract the minimum variables you will need + var context = evt.GetValueOfHeader("Hunt-Context"); // the context + var destination = evt.GetValueOfHeader("Hunt-Destination-Number"); // the dialed number or "DID" + var ani = evt.GetValueOfHeader("Hunt-ANI"); // The ANI/CallerID number + + // A place to return the dialplan actions you want + var actions = new List(); // format is "app,data" + + // add the actions for your code they shouldn't be static this is just an example + actions.Add("set,continue_on_fail=true"); + actions.Add("brige,sofia/mygateway/" + destination); + actions.Add("transfer,fialedDest XML failedcontext"); + e.Result = new fsDialPlanDocument(context, actions); + return; // Isn't this easy? + } + + public bool Load() + { + // Start any threads doing event consumer loops + MyConfigHandler = new ConfigHandler(); // init a config handler + MyConfigHandler.DirectoryRequest += HandleDirectoryLookups; + MyConfigHandler.DialPlanRequest += HandleDialPlanRequest; + return true; + } + } + +} diff --git a/src/mod/languages/mod_managed/managed/examples/winFailToBan/winFailToBan.csproj b/src/mod/languages/mod_managed/managed/examples/winFailToBan/winFailToBan.csproj new file mode 100644 index 0000000000..664b2212eb --- /dev/null +++ b/src/mod/languages/mod_managed/managed/examples/winFailToBan/winFailToBan.csproj @@ -0,0 +1,68 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {5BA0D5BD-330D-4EE2-B959-CAFEA04E50E0} + Library + Properties + winFailToBan + winFailToBan + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + {834e2b2f-5483-4b80-8fe3-fe48ff76e5c0} + FreeSWITCH.Managed.2012 + + + + + \ No newline at end of file diff --git a/src/mod/languages/mod_managed/managed/swig.2010.cs b/src/mod/languages/mod_managed/managed/swig.2010.cs index 3aff242242..bfe88dc482 100644 --- a/src/mod/languages/mod_managed/managed/swig.2010.cs +++ b/src/mod/languages/mod_managed/managed/swig.2010.cs @@ -41,7 +41,7 @@ public class Api : IDisposable { } } - public Api() : this(freeswitchPINVOKE.new_Api(), true) { + public Api(CoreSession s) : this(freeswitchPINVOKE.new_Api(CoreSession.getCPtr(s)), true) { } public string Execute(string command, string data) { @@ -1386,8 +1386,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_port_allocator_new(ushort start, ushort end, uint flags, SWIGTYPE_p_p_switch_core_port_allocator new_allocator) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_port_allocator_new(start, end, flags, SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(new_allocator)); + public static switch_status_t switch_core_port_allocator_new(string ip, ushort start, ushort end, uint flags, SWIGTYPE_p_p_switch_core_port_allocator new_allocator) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_port_allocator_new(ip, start, end, flags, SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(new_allocator)); return ret; } @@ -1773,6 +1773,11 @@ public class freeswitch { return ret; } + public static string switch_core_get_domain(switch_bool_t dup) { + string ret = freeswitchPINVOKE.switch_core_get_domain((int)dup); + return ret; + } + public static void switch_core_set_variable(string varname, string value) { freeswitchPINVOKE.switch_core_set_variable(varname, value); } @@ -1881,6 +1886,10 @@ public class freeswitch { return ret; } + public static void switch_core_session_video_reset(SWIGTYPE_p_switch_core_session session) { + freeswitchPINVOKE.switch_core_session_video_reset(SWIGTYPE_p_switch_core_session.getCPtr(session)); + } + public static switch_status_t switch_core_session_execute_application_get_flags(SWIGTYPE_p_switch_core_session session, string app, string arg, SWIGTYPE_p_int flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_execute_application_get_flags(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg, SWIGTYPE_p_int.getCPtr(flags)); return ret; @@ -1906,14 +1915,14 @@ public class freeswitch { return ret; } - public static SWIGTYPE_p_void switch_core_session_get_private(SWIGTYPE_p_switch_core_session session) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_private(SWIGTYPE_p_switch_core_session.getCPtr(session)); + public static SWIGTYPE_p_void switch_core_session_get_private_class(SWIGTYPE_p_switch_core_session session, switch_pvt_class_t index) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_private_class(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)index); SWIGTYPE_p_void ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_void(cPtr, false); return ret; } - public static switch_status_t switch_core_session_set_private(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_void private_info) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_private(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_void.getCPtr(private_info)); + public static switch_status_t switch_core_session_set_private_class(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_void private_info, switch_pvt_class_t index) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_private_class(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_void.getCPtr(private_info), (int)index); return ret; } @@ -2353,7 +2362,7 @@ public class freeswitch { freeswitchPINVOKE.switch_core_db_test_reactive(SWIGTYPE_p_sqlite3.getCPtr(db), test_sql, drop_sql, reactive_sql); } - public static switch_status_t switch_core_perform_file_open(string file, string func, int line, switch_file_handle fh, string file_path, byte channels, uint rate, uint flags, SWIGTYPE_p_apr_pool_t pool) { + public static switch_status_t switch_core_perform_file_open(string file, string func, int line, switch_file_handle fh, string file_path, uint channels, uint rate, uint flags, SWIGTYPE_p_apr_pool_t pool) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_perform_file_open(file, func, line, switch_file_handle.getCPtr(fh), file_path, channels, rate, flags, SWIGTYPE_p_apr_pool_t.getCPtr(pool)); return ret; } @@ -2754,8 +2763,8 @@ public class freeswitch { freeswitchPINVOKE.switch_time_set_monotonic((int)enable); } - public static void switch_time_set_timerfd(switch_bool_t enable) { - freeswitchPINVOKE.switch_time_set_timerfd((int)enable); + public static void switch_time_set_timerfd(int enable) { + freeswitchPINVOKE.switch_time_set_timerfd(enable); } public static void switch_time_set_nanosleep(switch_bool_t enable) { @@ -3146,6 +3155,50 @@ public class freeswitch { return ret; } + public static switch_call_direction_t switch_ice_direction(SWIGTYPE_p_switch_core_session session) { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_ice_direction(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + + public static void switch_core_session_debug_pool(switch_stream_handle stream) { + freeswitchPINVOKE.switch_core_session_debug_pool(switch_stream_handle.getCPtr(stream)); + } + + public static string switch_version_major() { + string ret = freeswitchPINVOKE.switch_version_major(); + return ret; + } + + public static string switch_version_minor() { + string ret = freeswitchPINVOKE.switch_version_minor(); + return ret; + } + + public static string switch_version_micro() { + string ret = freeswitchPINVOKE.switch_version_micro(); + return ret; + } + + public static string switch_version_revision() { + string ret = freeswitchPINVOKE.switch_version_revision(); + return ret; + } + + public static string switch_version_revision_human() { + string ret = freeswitchPINVOKE.switch_version_revision_human(); + return ret; + } + + public static string switch_version_full() { + string ret = freeswitchPINVOKE.switch_version_full(); + return ret; + } + + public static string switch_version_full_human() { + string ret = freeswitchPINVOKE.switch_version_full_human(); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3222,6 +3275,12 @@ public class freeswitch { return ret; } + public static switch_json_api_interface switch_loadable_module_get_json_api_interface(string name) { + IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_json_api_interface(name); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + public static switch_file_interface switch_loadable_module_get_file_interface(string name) { IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_file_interface(name); switch_file_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_file_interface(cPtr, false); @@ -3285,6 +3344,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_json_api_execute(SWIGTYPE_p_cJSON json, SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_cJSON retval) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_json_api_execute(SWIGTYPE_p_cJSON.getCPtr(json), SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_cJSON.getCPtr(retval)); + return ret; + } + public static switch_status_t switch_loadable_module_load_module(string dir, string fname, switch_bool_t runtime, ref string err) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_load_module(dir, fname, (int)runtime, ref err); return ret; @@ -3319,6 +3383,21 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_f_p_switch_core_session__int switch_core_get_secondary_recover_callback(string key) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_get_secondary_recover_callback(key); + SWIGTYPE_p_f_p_switch_core_session__int ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session__int(cPtr, false); + return ret; + } + + public static switch_status_t switch_core_register_secondary_recover_callback(string key, SWIGTYPE_p_f_p_switch_core_session__int cb) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_register_secondary_recover_callback(key, SWIGTYPE_p_f_p_switch_core_session__int.getCPtr(cb)); + return ret; + } + + public static void switch_core_unregister_secondary_recover_callback(string key) { + freeswitchPINVOKE.switch_core_unregister_secondary_recover_callback(key); + } + public static void switch_console_loop() { freeswitchPINVOKE.switch_console_loop(); } @@ -3359,6 +3438,10 @@ public class freeswitch { return ret; } + public static void switch_console_push_match_unique(SWIGTYPE_p_p_switch_console_callback_match matches, string new_val) { + freeswitchPINVOKE.switch_console_push_match_unique(SWIGTYPE_p_p_switch_console_callback_match.getCPtr(matches), new_val); + } + public static void switch_console_push_match(SWIGTYPE_p_p_switch_console_callback_match matches, string new_val) { freeswitchPINVOKE.switch_console_push_match(SWIGTYPE_p_p_switch_console_callback_match.getCPtr(matches), new_val); } @@ -3590,6 +3673,11 @@ public class freeswitch { return ret; } + public static byte switch_true_byte(string expr) { + byte ret = freeswitchPINVOKE.switch_true_byte(expr); + return ret; + } + public static int switch_false(string expr) { int ret = freeswitchPINVOKE.switch_false(expr); return ret; @@ -3605,6 +3693,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_find_interface_ip(string buf, int len, SWIGTYPE_p_int mask, string ifname, int family) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_find_interface_ip(buf, len, SWIGTYPE_p_int.getCPtr(mask), ifname, family); + return ret; + } + public static string get_addr(string buf, SWIGTYPE_p_switch_size_t len, SWIGTYPE_p_sockaddr sa, SWIGTYPE_p_socklen_t salen) { string ret = freeswitchPINVOKE.get_addr(buf, SWIGTYPE_p_switch_size_t.getCPtr(len), SWIGTYPE_p_sockaddr.getCPtr(sa), SWIGTYPE_p_socklen_t.getCPtr(salen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4546,6 +4639,15 @@ public class freeswitch { return ret; } + public static switch_call_direction_t switch_channel_logical_direction(SWIGTYPE_p_switch_channel channel) { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_channel_logical_direction(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + + public static void switch_channel_set_direction(SWIGTYPE_p_switch_channel channel, switch_call_direction_t direction) { + freeswitchPINVOKE.switch_channel_set_direction(SWIGTYPE_p_switch_channel.getCPtr(channel), (int)direction); + } + public static SWIGTYPE_p_switch_core_session switch_channel_get_session(SWIGTYPE_p_switch_channel channel) { IntPtr cPtr = freeswitchPINVOKE.switch_channel_get_session(SWIGTYPE_p_switch_channel.getCPtr(channel)); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); @@ -4911,8 +5013,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event eventp, SWIGTYPE_p_p_void data, SWIGTYPE_p_switch_size_t len, switch_bool_t destroy) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event.getCPtr(eventp), SWIGTYPE_p_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len), (int)destroy); + public static switch_status_t switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event eventp, SWIGTYPE_p_p_void data, SWIGTYPE_p_switch_size_t len, switch_bool_t duplicate) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event.getCPtr(eventp), SWIGTYPE_p_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len), (int)duplicate); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -4932,6 +5034,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_event_serialize_json_obj(switch_event arg0, SWIGTYPE_p_p_cJSON json) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_serialize_json_obj(switch_event.getCPtr(arg0), SWIGTYPE_p_p_cJSON.getCPtr(json)); + return ret; + } + public static switch_status_t switch_event_create_json(SWIGTYPE_p_p_switch_event arg0, string json) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_create_json(SWIGTYPE_p_p_switch_event.getCPtr(arg0), json); return ret; @@ -4990,10 +5097,124 @@ public class freeswitch { freeswitchPINVOKE.switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1), prefix); } + public static void switch_json_add_presence_data_cols(switch_event arg0, SWIGTYPE_p_cJSON json, string prefix) { + freeswitchPINVOKE.switch_json_add_presence_data_cols(switch_event.getCPtr(arg0), SWIGTYPE_p_cJSON.getCPtr(json), prefix); + } + public static void switch_event_launch_dispatch_threads(uint max) { freeswitchPINVOKE.switch_event_launch_dispatch_threads(max); } + public static uint switch_event_channel_broadcast(string event_channel, SWIGTYPE_p_p_cJSON json, string key, uint id) { + uint ret = freeswitchPINVOKE.switch_event_channel_broadcast(event_channel, SWIGTYPE_p_p_cJSON.getCPtr(json), key, id); + return ret; + } + + public static uint switch_event_channel_unbind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func) { + uint ret = freeswitchPINVOKE.switch_event_channel_unbind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func)); + return ret; + } + + public static switch_status_t switch_event_channel_bind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func, SWIGTYPE_p_unsigned_long id) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_channel_bind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func), SWIGTYPE_p_unsigned_long.getCPtr(id)); + return ret; + } + + public static switch_status_t switch_live_array_clear(SWIGTYPE_p_switch_live_array_s la) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_clear(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + return ret; + } + + public static switch_status_t switch_live_array_bootstrap(SWIGTYPE_p_switch_live_array_s la, string sessid, uint channel_id) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_bootstrap(SWIGTYPE_p_switch_live_array_s.getCPtr(la), sessid, channel_id); + return ret; + } + + public static switch_status_t switch_live_array_destroy(SWIGTYPE_p_p_switch_live_array_s live_arrayP) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_destroy(SWIGTYPE_p_p_switch_live_array_s.getCPtr(live_arrayP)); + return ret; + } + + public static switch_status_t switch_live_array_create(string event_channel, string name, uint channel_id, SWIGTYPE_p_p_switch_live_array_s live_arrayP) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_create(event_channel, name, channel_id, SWIGTYPE_p_p_switch_live_array_s.getCPtr(live_arrayP)); + return ret; + } + + public static SWIGTYPE_p_cJSON switch_live_array_get(SWIGTYPE_p_switch_live_array_s la, string name) { + IntPtr cPtr = freeswitchPINVOKE.switch_live_array_get(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name); + SWIGTYPE_p_cJSON ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_cJSON(cPtr, false); + return ret; + } + + public static SWIGTYPE_p_cJSON switch_live_array_get_idx(SWIGTYPE_p_switch_live_array_s la, int idx) { + IntPtr cPtr = freeswitchPINVOKE.switch_live_array_get_idx(SWIGTYPE_p_switch_live_array_s.getCPtr(la), idx); + SWIGTYPE_p_cJSON ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_cJSON(cPtr, false); + return ret; + } + + public static switch_status_t switch_live_array_del(SWIGTYPE_p_switch_live_array_s la, string name) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_del(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name); + return ret; + } + + public static switch_status_t switch_live_array_add(SWIGTYPE_p_switch_live_array_s la, string name, int index, SWIGTYPE_p_p_cJSON obj, switch_bool_t destroy) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_add(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name, index, SWIGTYPE_p_p_cJSON.getCPtr(obj), (int)destroy); + return ret; + } + + public static switch_status_t switch_live_array_visible(SWIGTYPE_p_switch_live_array_s la, switch_bool_t visible, switch_bool_t force) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_visible(SWIGTYPE_p_switch_live_array_s.getCPtr(la), (int)visible, (int)force); + return ret; + } + + public static switch_bool_t switch_live_array_isnew(SWIGTYPE_p_switch_live_array_s la) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_isnew(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + return ret; + } + + public static void switch_live_array_lock(SWIGTYPE_p_switch_live_array_s la) { + freeswitchPINVOKE.switch_live_array_lock(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + } + + public static void switch_live_array_unlock(SWIGTYPE_p_switch_live_array_s la) { + freeswitchPINVOKE.switch_live_array_unlock(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + } + + public static void switch_live_array_set_user_data(SWIGTYPE_p_switch_live_array_s la, SWIGTYPE_p_void user_data) { + freeswitchPINVOKE.switch_live_array_set_user_data(SWIGTYPE_p_switch_live_array_s.getCPtr(la), SWIGTYPE_p_void.getCPtr(user_data)); + } + + public static void switch_live_array_set_command_handler(SWIGTYPE_p_switch_live_array_s la, SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void command_handler) { + freeswitchPINVOKE.switch_live_array_set_command_handler(SWIGTYPE_p_switch_live_array_s.getCPtr(la), SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void.getCPtr(command_handler)); + } + + public static void switch_live_array_parse_json(SWIGTYPE_p_cJSON json, uint channel_id) { + freeswitchPINVOKE.switch_live_array_parse_json(SWIGTYPE_p_cJSON.getCPtr(json), channel_id); + } + + public static switch_bool_t switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_event_channel_permission_verify(string cookie, string event_channel) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_event_channel_permission_verify(cookie, event_channel); + return ret; + } + + public static void switch_event_channel_permission_modify(string cookie, string event_channel, switch_bool_t set) { + freeswitchPINVOKE.switch_event_channel_permission_modify(cookie, event_channel, (int)set); + } + + public static void switch_event_channel_permission_clear(string cookie) { + freeswitchPINVOKE.switch_event_channel_permission_clear(cookie); + } + public static switch_status_t switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t new_resampler, uint from_rate, uint to_rate, uint to_size, int quality, uint channels, string file, string func, int line) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t.getCPtr(new_resampler), from_rate, to_rate, to_size, quality, channels, file, func, line); return ret; @@ -6062,10 +6283,6 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } - public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { - freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); - } - public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -6076,6 +6293,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp rtp_session, SWIGTYPE_p_p_payload_map_t pmap) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), SWIGTYPE_p_p_payload_map_t.getCPtr(pmap)); + return ret; + } + public static void switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_bug_flag_t bugs) { freeswitchPINVOKE.switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)bugs); } @@ -6100,6 +6322,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_rtp_del_dtls(SWIGTYPE_p_switch_rtp rtp_session, dtls_type_t type) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_del_dtls(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)type); + return ret; + } + public static int switch_rtp_has_dtls() { int ret = freeswitchPINVOKE.switch_rtp_has_dtls(); return ret; @@ -6814,6 +7041,11 @@ public class freeswitch { public static readonly int SWITCH_DEFAULT_FILE_BUFFER_LEN = freeswitchPINVOKE.SWITCH_DEFAULT_FILE_BUFFER_LEN_get(); public static readonly int SWITCH_DTMF_LOG_LEN = freeswitchPINVOKE.SWITCH_DTMF_LOG_LEN_get(); public static readonly int SWITCH_MAX_TRANS = freeswitchPINVOKE.SWITCH_MAX_TRANS_get(); + public static readonly int SWITCH_CORE_SESSION_MAX_PRIVATES = freeswitchPINVOKE.SWITCH_CORE_SESSION_MAX_PRIVATES_get(); + public static readonly double JITTER_VARIANCE_THRESHOLD = freeswitchPINVOKE.JITTER_VARIANCE_THRESHOLD_get(); + public static readonly double IPDV_THRESHOLD = freeswitchPINVOKE.IPDV_THRESHOLD_get(); + public static readonly int LOST_BURST_ANALYZE = freeswitchPINVOKE.LOST_BURST_ANALYZE_get(); + public static readonly int LOST_BURST_CAPTURE = freeswitchPINVOKE.LOST_BURST_CAPTURE_get(); public static readonly int SWITCH_MAX_STACKS = freeswitchPINVOKE.SWITCH_MAX_STACKS_get(); public static readonly int SWITCH_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_THREAD_STACKSIZE_get(); public static readonly int SWITCH_SYSTEM_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_SYSTEM_THREAD_STACKSIZE_get(); @@ -6870,6 +7102,8 @@ public class freeswitch { public static readonly int SWITCH_CMD_CHUNK_LEN = freeswitchPINVOKE.SWITCH_CMD_CHUNK_LEN_get(); public static readonly int SWITCH_SMAX = freeswitchPINVOKE.SWITCH_SMAX_get(); public static readonly int SWITCH_SMIN = freeswitchPINVOKE.SWITCH_SMIN_get(); + public static readonly int NO_EVENT_CHANNEL_ID = freeswitchPINVOKE.NO_EVENT_CHANNEL_ID_get(); + public static readonly string SWITCH_EVENT_CHANNEL_GLOBAL = freeswitchPINVOKE.SWITCH_EVENT_CHANNEL_GLOBAL_get(); public static readonly int SWITCH_RESAMPLE_QUALITY = freeswitchPINVOKE.SWITCH_RESAMPLE_QUALITY_get(); public static readonly int SWITCH_RTP_MAX_BUF_LEN = freeswitchPINVOKE.SWITCH_RTP_MAX_BUF_LEN_get(); public static readonly int SWITCH_RTCP_MAX_BUF_LEN = freeswitchPINVOKE.SWITCH_RTCP_MAX_BUF_LEN_get(); @@ -7561,6 +7795,21 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_MAX_TRANS_get")] public static extern int SWITCH_MAX_TRANS_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get")] + public static extern int SWITCH_CORE_SESSION_MAX_PRIVATES_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_JITTER_VARIANCE_THRESHOLD_get")] + public static extern double JITTER_VARIANCE_THRESHOLD_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_IPDV_THRESHOLD_get")] + public static extern double IPDV_THRESHOLD_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_LOST_BURST_ANALYZE_get")] + public static extern int LOST_BURST_ANALYZE_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_LOST_BURST_CAPTURE_get")] + public static extern int LOST_BURST_CAPTURE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_digit_set")] public static extern void switch_dtmf_t_digit_set(HandleRef jarg1, char jarg2); @@ -7897,6 +8146,120 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_largest_jb_size_get")] public static extern IntPtr switch_rtp_numbers_t_largest_jb_size_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_proc_time_set")] + public static extern void switch_rtp_numbers_t_last_proc_time_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_proc_time_get")] + public static extern long switch_rtp_numbers_t_last_proc_time_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_n_set")] + public static extern void switch_rtp_numbers_t_jitter_n_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_n_get")] + public static extern long switch_rtp_numbers_t_jitter_n_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_add_set")] + public static extern void switch_rtp_numbers_t_jitter_add_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_add_get")] + public static extern long switch_rtp_numbers_t_jitter_add_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_addsq_set")] + public static extern void switch_rtp_numbers_t_jitter_addsq_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_addsq_get")] + public static extern long switch_rtp_numbers_t_jitter_addsq_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_variance_set")] + public static extern void switch_rtp_numbers_t_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_variance_get")] + public static extern double switch_rtp_numbers_t_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_min_variance_set")] + public static extern void switch_rtp_numbers_t_min_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_min_variance_get")] + public static extern double switch_rtp_numbers_t_min_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_max_variance_set")] + public static extern void switch_rtp_numbers_t_max_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_max_variance_get")] + public static extern double switch_rtp_numbers_t_max_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_std_deviation_set")] + public static extern void switch_rtp_numbers_t_std_deviation_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_std_deviation_get")] + public static extern double switch_rtp_numbers_t_std_deviation_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_lossrate_set")] + public static extern void switch_rtp_numbers_t_lossrate_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_lossrate_get")] + public static extern double switch_rtp_numbers_t_lossrate_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_burstrate_set")] + public static extern void switch_rtp_numbers_t_burstrate_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_burstrate_get")] + public static extern double switch_rtp_numbers_t_burstrate_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mean_interval_set")] + public static extern void switch_rtp_numbers_t_mean_interval_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mean_interval_get")] + public static extern double switch_rtp_numbers_t_mean_interval_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_loss_set")] + public static extern void switch_rtp_numbers_t_loss_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_loss_get")] + public static extern IntPtr switch_rtp_numbers_t_loss_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_loss_set")] + public static extern void switch_rtp_numbers_t_last_loss_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_loss_get")] + public static extern int switch_rtp_numbers_t_last_loss_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_recved_set")] + public static extern void switch_rtp_numbers_t_recved_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_recved_get")] + public static extern int switch_rtp_numbers_t_recved_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_processed_seq_set")] + public static extern void switch_rtp_numbers_t_last_processed_seq_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_processed_seq_get")] + public static extern int switch_rtp_numbers_t_last_processed_seq_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_flaws_set")] + public static extern void switch_rtp_numbers_t_flaws_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_flaws_get")] + public static extern IntPtr switch_rtp_numbers_t_flaws_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_flaw_set")] + public static extern void switch_rtp_numbers_t_last_flaw_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_flaw_get")] + public static extern IntPtr switch_rtp_numbers_t_last_flaw_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_R_set")] + public static extern void switch_rtp_numbers_t_R_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_R_get")] + public static extern double switch_rtp_numbers_t_R_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mos_set")] + public static extern void switch_rtp_numbers_t_mos_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mos_get")] + public static extern double switch_rtp_numbers_t_mos_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtp_numbers_t")] public static extern IntPtr new_switch_rtp_numbers_t(); @@ -8683,6 +9046,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_alloc_get")] public static extern int switch_thread_data_t_alloc_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_pool_set")] + public static extern void switch_thread_data_t_pool_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_pool_get")] + public static extern IntPtr switch_thread_data_t_pool_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_thread_data_t")] public static extern IntPtr new_switch_thread_data_t(); @@ -8755,6 +9124,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_hup_profile_get")] public static extern IntPtr switch_device_node_t_hup_profile_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_set")] + public static extern void switch_device_node_t_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_get")] + public static extern int switch_device_node_t_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_parent_set")] public static extern void switch_device_node_t_parent_set(HandleRef jarg1, HandleRef jarg2); @@ -8779,42 +9154,132 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_get")] public static extern uint switch_device_stats_t_total_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_set")] + public static extern void switch_device_stats_t_total_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_get")] + public static extern uint switch_device_stats_t_total_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_set")] + public static extern void switch_device_stats_t_total_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_get")] + public static extern uint switch_device_stats_t_total_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_set")] public static extern void switch_device_stats_t_offhook_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_get")] public static extern uint switch_device_stats_t_offhook_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_set")] + public static extern void switch_device_stats_t_offhook_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_get")] + public static extern uint switch_device_stats_t_offhook_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_set")] + public static extern void switch_device_stats_t_offhook_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_get")] + public static extern uint switch_device_stats_t_offhook_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_set")] public static extern void switch_device_stats_t_active_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_get")] public static extern uint switch_device_stats_t_active_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_set")] + public static extern void switch_device_stats_t_active_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_get")] + public static extern uint switch_device_stats_t_active_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_set")] + public static extern void switch_device_stats_t_active_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_get")] + public static extern uint switch_device_stats_t_active_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_set")] public static extern void switch_device_stats_t_held_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_get")] public static extern uint switch_device_stats_t_held_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_set")] + public static extern void switch_device_stats_t_held_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_get")] + public static extern uint switch_device_stats_t_held_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_set")] + public static extern void switch_device_stats_t_held_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_get")] + public static extern uint switch_device_stats_t_held_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_set")] public static extern void switch_device_stats_t_hup_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_get")] public static extern uint switch_device_stats_t_hup_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_set")] + public static extern void switch_device_stats_t_hup_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_get")] + public static extern uint switch_device_stats_t_hup_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_set")] + public static extern void switch_device_stats_t_hup_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_get")] + public static extern uint switch_device_stats_t_hup_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_set")] public static extern void switch_device_stats_t_ringing_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_get")] public static extern uint switch_device_stats_t_ringing_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_set")] + public static extern void switch_device_stats_t_ringing_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_get")] + public static extern uint switch_device_stats_t_ringing_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_set")] + public static extern void switch_device_stats_t_ringing_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_get")] + public static extern uint switch_device_stats_t_ringing_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_set")] public static extern void switch_device_stats_t_early_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_get")] public static extern uint switch_device_stats_t_early_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_set")] + public static extern void switch_device_stats_t_early_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_get")] + public static extern uint switch_device_stats_t_early_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_set")] + public static extern void switch_device_stats_t_early_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_get")] + public static extern uint switch_device_stats_t_early_out_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_set")] + public static extern void switch_device_stats_t_ring_wait_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_get")] + public static extern uint switch_device_stats_t_ring_wait_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_stats_t")] public static extern IntPtr new_switch_device_stats_t(); @@ -8845,6 +9310,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_stats_get")] public static extern IntPtr switch_device_record_t_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_set")] + public static extern void switch_device_record_t_last_stats_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_get")] + public static extern IntPtr switch_device_record_t_last_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_state_set")] public static extern void switch_device_record_t_state_set(HandleRef jarg1, int jarg2); @@ -8875,6 +9346,36 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_call_time_get")] public static extern IntPtr switch_device_record_t_last_call_time_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_set")] + public static extern void switch_device_record_t_ring_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_get")] + public static extern IntPtr switch_device_record_t_ring_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_set")] + public static extern void switch_device_record_t_ring_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_get")] + public static extern IntPtr switch_device_record_t_ring_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_set")] + public static extern void switch_device_record_t_hold_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_get")] + public static extern IntPtr switch_device_record_t_hold_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_set")] + public static extern void switch_device_record_t_hold_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_get")] + public static extern IntPtr switch_device_record_t_hold_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_set")] + public static extern void switch_device_record_t_call_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_get")] + public static extern IntPtr switch_device_record_t_call_start_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_uuid_list_set")] public static extern void switch_device_record_t_uuid_list_set(HandleRef jarg1, HandleRef jarg2); @@ -8899,6 +9400,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_pool_get")] public static extern IntPtr switch_device_record_t_pool_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_set")] + public static extern void switch_device_record_t_user_data_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_get")] + public static extern IntPtr switch_device_record_t_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_record_t")] public static extern IntPtr new_switch_device_record_t(); @@ -9209,7 +9716,7 @@ class freeswitchPINVOKE { public static extern int switch_core_media_bug_set_pre_buffer_framecount(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_new")] - public static extern int switch_core_port_allocator_new(ushort jarg1, ushort jarg2, uint jarg3, HandleRef jarg4); + public static extern int switch_core_port_allocator_new(string jarg1, ushort jarg2, ushort jarg3, uint jarg4, HandleRef jarg5); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_request_port")] public static extern int switch_core_port_allocator_request_port(HandleRef jarg1, HandleRef jarg2); @@ -9439,6 +9946,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_switchname")] public static extern string switch_core_get_switchname(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_domain")] + public static extern string switch_core_get_domain(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_set_variable")] public static extern void switch_core_set_variable(string jarg1, string jarg2); @@ -9505,6 +10015,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_exec")] public static extern int switch_core_session_exec(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_video_reset")] + public static extern void switch_core_session_video_reset(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_get_flags")] public static extern int switch_core_session_execute_application_get_flags(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); @@ -9520,11 +10033,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_receive_event")] public static extern int switch_core_session_receive_event(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_private")] - public static extern IntPtr switch_core_session_get_private(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_private_class")] + public static extern IntPtr switch_core_session_get_private_class(HandleRef jarg1, int jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_private")] - public static extern int switch_core_session_set_private(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_private_class")] + public static extern int switch_core_session_set_private_class(HandleRef jarg1, HandleRef jarg2, int jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_add_stream")] public static extern int switch_core_session_add_stream(HandleRef jarg1, HandleRef jarg2); @@ -9788,7 +10301,7 @@ class freeswitchPINVOKE { public static extern void switch_core_db_test_reactive(HandleRef jarg1, string jarg2, string jarg3, string jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_perform_file_open")] - public static extern int switch_core_perform_file_open(string jarg1, string jarg2, int jarg3, HandleRef jarg4, string jarg5, byte jarg6, uint jarg7, uint jarg8, HandleRef jarg9); + public static extern int switch_core_perform_file_open(string jarg1, string jarg2, int jarg3, HandleRef jarg4, string jarg5, uint jarg6, uint jarg7, uint jarg8, HandleRef jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_read")] public static extern int switch_core_file_read(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); @@ -10381,6 +10894,33 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_stream_system_fork")] public static extern int switch_stream_system_fork(string jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ice_direction")] + public static extern int switch_ice_direction(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_debug_pool")] + public static extern void switch_core_session_debug_pool(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_major")] + public static extern string switch_version_major(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_minor")] + public static extern string switch_version_minor(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_micro")] + public static extern string switch_version_micro(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_revision")] + public static extern string switch_version_revision(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_revision_human")] + public static extern string switch_version_revision_human(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_full")] + public static extern string switch_version_full(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_full_human")] + public static extern string switch_version_full_human(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -10429,6 +10969,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_api_interface_get")] public static extern IntPtr switch_loadable_module_interface_api_interface_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_json_api_interface_set")] + public static extern void switch_loadable_module_interface_json_api_interface_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_json_api_interface_get")] + public static extern IntPtr switch_loadable_module_interface_json_api_interface_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_file_interface_set")] public static extern void switch_loadable_module_interface_file_interface_set(HandleRef jarg1, HandleRef jarg2); @@ -10543,6 +11089,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_api_interface")] public static extern IntPtr switch_loadable_module_get_api_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_json_api_interface")] + public static extern IntPtr switch_loadable_module_get_json_api_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_file_interface")] public static extern IntPtr switch_loadable_module_get_file_interface(string jarg1); @@ -10576,6 +11125,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_api_execute")] public static extern int switch_api_execute(string jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_execute")] + public static extern int switch_json_api_execute(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_load_module")] public static extern int switch_loadable_module_load_module(string jarg1, string jarg2, int jarg3, ref string jarg4); @@ -10597,6 +11149,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_codec_ready")] public static extern int switch_core_codec_ready(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_secondary_recover_callback")] + public static extern IntPtr switch_core_get_secondary_recover_callback(string jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_register_secondary_recover_callback")] + public static extern int switch_core_register_secondary_recover_callback(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_unregister_secondary_recover_callback")] + public static extern void switch_core_unregister_secondary_recover_callback(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CMD_CHUNK_LEN_get")] public static extern int SWITCH_CMD_CHUNK_LEN_get(); @@ -10624,6 +11185,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_console_run_complete_func")] public static extern int switch_console_run_complete_func(string jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_console_push_match_unique")] + public static extern void switch_console_push_match_unique(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_console_push_match")] public static extern void switch_console_push_match(HandleRef jarg1, string jarg2); @@ -10786,6 +11350,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_true")] public static extern int switch_true(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_true_byte")] + public static extern byte switch_true_byte(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_false")] public static extern int switch_false(string jarg1); @@ -10795,6 +11362,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_find_local_ip")] public static extern int switch_find_local_ip(string jarg1, int jarg2, HandleRef jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_find_interface_ip")] + public static extern int switch_find_interface_ip(string jarg1, int jarg2, HandleRef jarg3, string jarg4, int jarg5); + [DllImport("mod_managed", EntryPoint="CSharp_get_addr")] public static extern string get_addr(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); @@ -11242,6 +11812,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_direction_get")] public static extern int switch_caller_profile_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_set")] + public static extern void switch_caller_profile_logical_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_get")] + public static extern int switch_caller_profile_logical_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_soft_set")] public static extern void switch_caller_profile_soft_set(HandleRef jarg1, HandleRef jarg2); @@ -11479,6 +12055,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_user_data_get")] public static extern IntPtr switch_frame_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_set")] + public static extern void switch_frame_pmap_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_get")] + public static extern IntPtr switch_frame_pmap_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_frame")] public static extern IntPtr new_switch_frame(); @@ -12116,10 +12698,10 @@ class freeswitchPINVOKE { public static extern uint switch_file_handle_native_rate_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_channels_set")] - public static extern void switch_file_handle_channels_set(HandleRef jarg1, byte jarg2); + public static extern void switch_file_handle_channels_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_channels_get")] - public static extern byte switch_file_handle_channels_get(HandleRef jarg1); + public static extern uint switch_file_handle_channels_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_format_set")] public static extern void switch_file_handle_format_set(HandleRef jarg1, uint jarg2); @@ -12325,6 +12907,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_get")] public static extern IntPtr switch_file_handle__params_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_channels_set")] + public static extern void switch_file_handle_cur_channels_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_channels_get")] + public static extern uint switch_file_handle_cur_channels_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_samplerate_set")] + public static extern void switch_file_handle_cur_samplerate_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_samplerate_get")] + public static extern uint switch_file_handle_cur_samplerate_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_file_handle")] public static extern IntPtr new_switch_file_handle(); @@ -13615,6 +14209,66 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_api_interface")] public static extern void delete_switch_api_interface(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_interface_name_set")] + public static extern void switch_json_api_interface_interface_name_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_interface_name_get")] + public static extern string switch_json_api_interface_interface_name_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_desc_set")] + public static extern void switch_json_api_interface_desc_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_desc_get")] + public static extern string switch_json_api_interface_desc_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_function_set")] + public static extern void switch_json_api_interface_function_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_function_get")] + public static extern IntPtr switch_json_api_interface_function_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_syntax_set")] + public static extern void switch_json_api_interface_syntax_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_syntax_get")] + public static extern string switch_json_api_interface_syntax_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_rwlock_set")] + public static extern void switch_json_api_interface_rwlock_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_rwlock_get")] + public static extern IntPtr switch_json_api_interface_rwlock_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_refs_set")] + public static extern void switch_json_api_interface_refs_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_refs_get")] + public static extern int switch_json_api_interface_refs_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_reflock_set")] + public static extern void switch_json_api_interface_reflock_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_reflock_get")] + public static extern IntPtr switch_json_api_interface_reflock_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_parent_set")] + public static extern void switch_json_api_interface_parent_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_parent_get")] + public static extern IntPtr switch_json_api_interface_parent_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_next_set")] + public static extern void switch_json_api_interface_next_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_next_get")] + public static extern IntPtr switch_json_api_interface_next_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_json_api_interface")] + public static extern IntPtr new_switch_json_api_interface(); + + [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_json_api_interface")] + public static extern void delete_switch_json_api_interface(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_slin_data_session_set")] public static extern void switch_slin_data_session_set(HandleRef jarg1, HandleRef jarg2); @@ -14071,6 +14725,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_direction")] public static extern int switch_channel_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_logical_direction")] + public static extern int switch_channel_logical_direction(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_set_direction")] + public static extern void switch_channel_set_direction(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_session")] public static extern IntPtr switch_channel_get_session(HandleRef jarg1); @@ -14485,6 +15145,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_serialize_json")] public static extern int switch_event_serialize_json(HandleRef jarg1, ref string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_serialize_json_obj")] + public static extern int switch_event_serialize_json_obj(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_create_json")] public static extern int switch_event_create_json(HandleRef jarg1, string jarg2); @@ -14521,9 +15184,87 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_add_presence_data_cols")] public static extern void switch_event_add_presence_data_cols(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_add_presence_data_cols")] + public static extern void switch_json_add_presence_data_cols(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_launch_dispatch_threads")] public static extern void switch_event_launch_dispatch_threads(uint jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_broadcast")] + public static extern uint switch_event_channel_broadcast(string jarg1, HandleRef jarg2, string jarg3, uint jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_unbind")] + public static extern uint switch_event_channel_unbind(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_bind")] + public static extern int switch_event_channel_bind(string jarg1, HandleRef jarg2, HandleRef jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_NO_EVENT_CHANNEL_ID_get")] + public static extern int NO_EVENT_CHANNEL_ID_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_EVENT_CHANNEL_GLOBAL_get")] + public static extern string SWITCH_EVENT_CHANNEL_GLOBAL_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_clear")] + public static extern int switch_live_array_clear(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_bootstrap")] + public static extern int switch_live_array_bootstrap(HandleRef jarg1, string jarg2, uint jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_destroy")] + public static extern int switch_live_array_destroy(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_create")] + public static extern int switch_live_array_create(string jarg1, string jarg2, uint jarg3, HandleRef jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_get")] + public static extern IntPtr switch_live_array_get(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_get_idx")] + public static extern IntPtr switch_live_array_get_idx(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_del")] + public static extern int switch_live_array_del(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_add")] + public static extern int switch_live_array_add(HandleRef jarg1, string jarg2, int jarg3, HandleRef jarg4, int jarg5); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_visible")] + public static extern int switch_live_array_visible(HandleRef jarg1, int jarg2, int jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_isnew")] + public static extern int switch_live_array_isnew(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_lock")] + public static extern void switch_live_array_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_unlock")] + public static extern void switch_live_array_unlock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_set_user_data")] + public static extern void switch_live_array_set_user_data(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_set_command_handler")] + public static extern void switch_live_array_set_command_handler(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_parse_json")] + public static extern void switch_live_array_parse_json(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_add_alias")] + public static extern int switch_live_array_add_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_clear_alias")] + public static extern int switch_live_array_clear_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_verify")] + public static extern int switch_event_channel_permission_verify(string jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_modify")] + public static extern void switch_event_channel_permission_modify(string jarg1, string jarg2, int jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_clear")] + public static extern void switch_event_channel_permission_clear(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RESAMPLE_QUALITY_get")] public static extern int SWITCH_RESAMPLE_QUALITY_get(); @@ -15511,15 +16252,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] - public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_private")] public static extern IntPtr switch_rtp_get_private(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_payload_map")] + public static extern int switch_rtp_set_payload_map(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_intentional_bugs")] public static extern void switch_rtp_intentional_bugs(HandleRef jarg1, int jarg2); @@ -15535,6 +16276,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_add_dtls")] public static extern int switch_rtp_add_dtls(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_del_dtls")] + public static extern int switch_rtp_del_dtls(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_has_dtls")] public static extern int switch_rtp_has_dtls(); @@ -16264,6 +17008,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_cmd_id_get")] public static extern uint switch_scheduler_task_cmd_id_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_repeat_set")] + public static extern void switch_scheduler_task_repeat_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_repeat_get")] + public static extern uint switch_scheduler_task_repeat_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_group_set")] public static extern void switch_scheduler_task_group_set(HandleRef jarg1, string jarg2); @@ -16282,6 +17032,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_task_id_get")] public static extern uint switch_scheduler_task_task_id_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_hash_set")] + public static extern void switch_scheduler_task_hash_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_hash_get")] + public static extern uint switch_scheduler_task_hash_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_scheduler_task")] public static extern IntPtr new_switch_scheduler_task(); @@ -16403,7 +17159,7 @@ class freeswitchPINVOKE { public static extern void IvrMenu_Execute(HandleRef jarg1, HandleRef jarg2, string jarg3); [DllImport("mod_managed", EntryPoint="CSharp_new_Api")] - public static extern IntPtr new_Api(); + public static extern IntPtr new_Api(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_delete_Api")] public static extern void delete_Api(HandleRef jarg1); @@ -17624,6 +18380,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_cJSON { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_cJSON(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_cJSON() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_cJSON obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_FILE { private HandleRef swigCPtr; @@ -17744,6 +18530,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_p_switch_console_callback_match__switch_status_t { private HandleRef swigCPtr; @@ -17954,6 +18770,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_q_const__switch_log_node_t_enum_switch_log_level_t__switch_status_t { private HandleRef swigCPtr; @@ -19634,6 +20480,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t { private HandleRef swigCPtr; @@ -20444,6 +21320,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_pid_t { private HandleRef swigCPtr; @@ -20564,6 +21470,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_p_char { private HandleRef swigCPtr; @@ -21344,6 +22280,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_switch_live_array_s { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_switch_live_array_s(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_switch_live_array_s() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_live_array_s obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_switch_log_node_t { private HandleRef swigCPtr; @@ -22394,6 +23360,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_switch_live_array_s { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_switch_live_array_s(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_switch_live_array_s() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_switch_live_array_s obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_switch_media_bug { private HandleRef swigCPtr; @@ -25573,6 +26569,16 @@ public class switch_caller_profile : IDisposable { } } + public switch_call_direction_t logical_direction { + set { + freeswitchPINVOKE.switch_caller_profile_logical_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_caller_profile_logical_direction_get(swigCPtr); + return ret; + } + } + public profile_node_t soft { set { freeswitchPINVOKE.switch_caller_profile_soft_set(swigCPtr, profile_node_t.getCPtr(value)); @@ -25773,6 +26779,7 @@ public enum switch_channel_callstate_t { CCS_EARLY, CCS_ACTIVE, CCS_HELD, + CCS_RING_WAIT, CCS_HANGUP, CCS_UNHOLD } @@ -25892,6 +26899,7 @@ public enum switch_channel_flag_t { CF_CONFIRM_BLIND_TRANSFER, CF_NO_PRESENCE, CF_CONFERENCE, + CF_CONFERENCE_ADV, CF_RECOVERING, CF_RECOVERING_BRIDGE, CF_TRACKED, @@ -25923,6 +26931,10 @@ public enum switch_channel_flag_t { CF_VIDEO_PASSIVE, CF_NOVIDEO, CF_VIDEO_ECHO, + CF_SLA_INTERCEPT, + CF_VIDEO_BREAK, + CF_MEDIA_PAUSE, + CF_BYPASS_MEDIA_AFTER_HOLD, CF_FLAG_MAX } @@ -27868,6 +28880,10 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INDICATE_MEDIA_RENEG, + SWITCH_MESSAGE_REFER_EVENT, + SWITCH_MESSAGE_ANSWER_EVENT, + SWITCH_MESSAGE_PROGRESS_EVENT, + SWITCH_MESSAGE_RING_EVENT, SWITCH_MESSAGE_INVALID } @@ -28201,6 +29217,16 @@ public class switch_device_node_t : IDisposable { } } + public switch_call_direction_t direction { + set { + freeswitchPINVOKE.switch_device_node_t_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_device_node_t_direction_get(swigCPtr); + return ret; + } + } + public switch_device_record_t parent { set { freeswitchPINVOKE.switch_device_node_t_parent_set(swigCPtr, switch_device_record_t.getCPtr(value)); @@ -28313,6 +29339,17 @@ public class switch_device_record_t : IDisposable { } } + public switch_device_stats_t last_stats { + set { + freeswitchPINVOKE.switch_device_record_t_last_stats_set(swigCPtr, switch_device_stats_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_last_stats_get(swigCPtr); + switch_device_stats_t ret = (cPtr == IntPtr.Zero) ? null : new switch_device_stats_t(cPtr, false); + return ret; + } + } + public switch_device_state_t state { set { freeswitchPINVOKE.switch_device_record_t_state_set(swigCPtr, (int)value); @@ -28369,6 +29406,66 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_switch_time_t ring_start { + set { + freeswitchPINVOKE.switch_device_record_t_ring_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t ring_stop { + set { + freeswitchPINVOKE.switch_device_record_t_ring_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_start { + set { + freeswitchPINVOKE.switch_device_record_t_hold_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_stop { + set { + freeswitchPINVOKE.switch_device_record_t_hold_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t call_start { + set { + freeswitchPINVOKE.switch_device_record_t_call_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_call_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public switch_device_node_t uuid_list { set { freeswitchPINVOKE.switch_device_record_t_uuid_list_set(swigCPtr, switch_device_node_t.getCPtr(value)); @@ -28413,6 +29510,17 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_void user_data { + set { + freeswitchPINVOKE.switch_device_record_t_user_data_set(swigCPtr, SWIGTYPE_p_void.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_user_data_get(swigCPtr); + SWIGTYPE_p_void ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_void(cPtr, false); + return ret; + } + } + public switch_device_record_t() : this(freeswitchPINVOKE.new_switch_device_record_t(), true) { } @@ -28492,6 +29600,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint total_in { + set { + freeswitchPINVOKE.switch_device_stats_t_total_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_in_get(swigCPtr); + return ret; + } + } + + public uint total_out { + set { + freeswitchPINVOKE.switch_device_stats_t_total_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_out_get(swigCPtr); + return ret; + } + } + public uint offhook { set { freeswitchPINVOKE.switch_device_stats_t_offhook_set(swigCPtr, value); @@ -28502,6 +29630,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint offhook_in { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_in_get(swigCPtr); + return ret; + } + } + + public uint offhook_out { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_out_get(swigCPtr); + return ret; + } + } + public uint active { set { freeswitchPINVOKE.switch_device_stats_t_active_set(swigCPtr, value); @@ -28512,6 +29660,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint active_in { + set { + freeswitchPINVOKE.switch_device_stats_t_active_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_in_get(swigCPtr); + return ret; + } + } + + public uint active_out { + set { + freeswitchPINVOKE.switch_device_stats_t_active_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_out_get(swigCPtr); + return ret; + } + } + public uint held { set { freeswitchPINVOKE.switch_device_stats_t_held_set(swigCPtr, value); @@ -28522,6 +29690,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint held_in { + set { + freeswitchPINVOKE.switch_device_stats_t_held_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_in_get(swigCPtr); + return ret; + } + } + + public uint held_out { + set { + freeswitchPINVOKE.switch_device_stats_t_held_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_out_get(swigCPtr); + return ret; + } + } + public uint hup { set { freeswitchPINVOKE.switch_device_stats_t_hup_set(swigCPtr, value); @@ -28532,6 +29720,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint hup_in { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_in_get(swigCPtr); + return ret; + } + } + + public uint hup_out { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_out_get(swigCPtr); + return ret; + } + } + public uint ringing { set { freeswitchPINVOKE.switch_device_stats_t_ringing_set(swigCPtr, value); @@ -28542,6 +29750,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint ringing_in { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_in_get(swigCPtr); + return ret; + } + } + + public uint ringing_out { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_out_get(swigCPtr); + return ret; + } + } + public uint early { set { freeswitchPINVOKE.switch_device_stats_t_early_set(swigCPtr, value); @@ -28552,6 +29780,36 @@ public class switch_device_stats_t : IDisposable { } } + public uint early_in { + set { + freeswitchPINVOKE.switch_device_stats_t_early_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_in_get(swigCPtr); + return ret; + } + } + + public uint early_out { + set { + freeswitchPINVOKE.switch_device_stats_t_early_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_out_get(swigCPtr); + return ret; + } + } + + public uint ring_wait { + set { + freeswitchPINVOKE.switch_device_stats_t_ring_wait_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ring_wait_get(swigCPtr); + return ret; + } + } + public switch_device_stats_t() : this(freeswitchPINVOKE.new_switch_device_stats_t(), true) { } @@ -29842,6 +31100,8 @@ public enum switch_event_types_t { SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_RELOADXML, SWITCH_EVENT_NOTIFY, + SWITCH_EVENT_PHONE_FEATURE, + SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE, SWITCH_EVENT_SEND_MESSAGE, SWITCH_EVENT_RECV_MESSAGE, SWITCH_EVENT_REQUEST_PARAMS, @@ -29962,7 +31222,8 @@ namespace FreeSWITCH.Native { SWITCH_FILE_BUFFER_DONE = (1 << 14), SWITCH_FILE_WRITE_APPEND = (1 << 15), SWITCH_FILE_WRITE_OVER = (1 << 16), - SWITCH_FILE_NOMUX = (1 << 17) + SWITCH_FILE_NOMUX = (1 << 17), + SWITCH_FILE_BREAK_ON_CHANGE = (1 << 18) } } @@ -30071,12 +31332,12 @@ public class switch_file_handle : IDisposable { } } - public byte channels { + public uint channels { set { freeswitchPINVOKE.switch_file_handle_channels_set(swigCPtr, value); } get { - byte ret = freeswitchPINVOKE.switch_file_handle_channels_get(swigCPtr); + uint ret = freeswitchPINVOKE.switch_file_handle_channels_get(swigCPtr); return ret; } } @@ -30441,6 +31702,26 @@ public class switch_file_handle : IDisposable { } } + public uint cur_channels { + set { + freeswitchPINVOKE.switch_file_handle_cur_channels_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_file_handle_cur_channels_get(swigCPtr); + return ret; + } + } + + public uint cur_samplerate { + set { + freeswitchPINVOKE.switch_file_handle_cur_samplerate_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_file_handle_cur_samplerate_get(swigCPtr); + return ret; + } + } + public switch_file_handle() : this(freeswitchPINVOKE.new_switch_file_handle(), true) { } @@ -30899,6 +32180,17 @@ public class switch_frame : IDisposable { } } + public SWIGTYPE_p_payload_map_t pmap { + set { + freeswitchPINVOKE.switch_frame_pmap_set(swigCPtr, SWIGTYPE_p_payload_map_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_frame_pmap_get(swigCPtr); + SWIGTYPE_p_payload_map_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_payload_map_t(cPtr, false); + return ret; + } + } + public switch_frame() : this(freeswitchPINVOKE.new_switch_frame(), true) { } @@ -32618,6 +33910,150 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class switch_json_api_interface : IDisposable { + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal switch_json_api_interface(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr(switch_json_api_interface obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } + + ~switch_json_api_interface() { + Dispose(); + } + + public virtual void Dispose() { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_json_api_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + + public string interface_name { + set { + freeswitchPINVOKE.switch_json_api_interface_interface_name_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_interface_name_get(swigCPtr); + return ret; + } + } + + public string desc { + set { + freeswitchPINVOKE.switch_json_api_interface_desc_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_desc_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t function { + set { + freeswitchPINVOKE.switch_json_api_interface_function_set(swigCPtr, SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_function_get(swigCPtr); + SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t(cPtr, false); + return ret; + } + } + + public string syntax { + set { + freeswitchPINVOKE.switch_json_api_interface_syntax_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_syntax_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_thread_rwlock_t rwlock { + set { + freeswitchPINVOKE.switch_json_api_interface_rwlock_set(swigCPtr, SWIGTYPE_p_switch_thread_rwlock_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_rwlock_get(swigCPtr); + SWIGTYPE_p_switch_thread_rwlock_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_thread_rwlock_t(cPtr, false); + return ret; + } + } + + public int refs { + set { + freeswitchPINVOKE.switch_json_api_interface_refs_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_json_api_interface_refs_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_mutex_t reflock { + set { + freeswitchPINVOKE.switch_json_api_interface_reflock_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_reflock_get(swigCPtr); + SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); + return ret; + } + } + + public switch_loadable_module_interface parent { + set { + freeswitchPINVOKE.switch_json_api_interface_parent_set(swigCPtr, switch_loadable_module_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_parent_get(swigCPtr); + switch_loadable_module_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_loadable_module_interface(cPtr, false); + return ret; + } + } + + public switch_json_api_interface next { + set { + freeswitchPINVOKE.switch_json_api_interface_next_set(swigCPtr, switch_json_api_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_next_get(swigCPtr); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + } + + public switch_json_api_interface() : this(freeswitchPINVOKE.new_switch_json_api_interface(), true) { + } + +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class switch_limit_interface : IDisposable { private HandleRef swigCPtr; protected bool swigCMemOwn; @@ -33016,6 +34452,17 @@ public class switch_loadable_module_interface : IDisposable { } } + public switch_json_api_interface json_api_interface { + set { + freeswitchPINVOKE.switch_loadable_module_interface_json_api_interface_set(swigCPtr, switch_json_api_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_interface_json_api_interface_get(swigCPtr); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + } + public switch_file_interface file_interface { set { freeswitchPINVOKE.switch_loadable_module_interface_file_interface_set(swigCPtr, switch_file_interface.getCPtr(value)); @@ -33581,7 +35028,8 @@ public enum switch_module_interface_name_t { SWITCH_ASR_INTERFACE, SWITCH_MANAGEMENT_INTERFACE, SWITCH_LIMIT_INTERFACE, - SWITCH_CHAT_APPLICATION_INTERFACE + SWITCH_CHAT_APPLICATION_INTERFACE, + SWITCH_JSON_API_INTERFACE } } @@ -33599,9 +35047,11 @@ namespace FreeSWITCH.Native { SOF_NONE = 0, SOF_NOBLOCK = (1 << 0), SOF_FORKED_DIAL = (1 << 1), - SOF_NO_EFFECTIVE_CID_NUM = (1 << 2), - SOF_NO_EFFECTIVE_CID_NAME = (1 << 3), - SOF_NO_LIMITS = (1 << 4) + SOF_NO_EFFECTIVE_ANI = (1 << 2), + SOF_NO_EFFECTIVE_ANIII = (1 << 3), + SOF_NO_EFFECTIVE_CID_NUM = (1 << 4), + SOF_NO_EFFECTIVE_CID_NAME = (1 << 5), + SOF_NO_LIMITS = (1 << 6) } } @@ -33618,7 +35068,9 @@ namespace FreeSWITCH.Native { [System.Flags] public enum switch_port_flag_enum_t { SPF_NONE = 0, SPF_ODD = (1 << 0), - SPF_EVEN = (1 << 1) + SPF_EVEN = (1 << 1), + SPF_ROBUST_TCP = (1 << 2), + SPF_ROBUST_UDP = (1 << 3) } } @@ -33649,6 +35101,22 @@ public enum switch_priority_t { namespace FreeSWITCH.Native { +public enum switch_pvt_class_t { + SWITCH_PVT_PRIMARY = 0, + SWITCH_PVT_SECONDARY +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + public enum switch_ring_ready_t { SWITCH_RING_READY_NONE, SWITCH_RING_READY_RINGING, @@ -33856,7 +35324,8 @@ public enum switch_rtp_bug_flag_t { RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7), RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), RTP_BUG_CHANGE_SSRC_ON_MARKER = (1 << 9), - RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10) + RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10), + RTP_BUG_ACCEPT_ANY_PAYLOAD = (1 << 11) } } @@ -34013,6 +35482,7 @@ namespace FreeSWITCH.Native { public enum switch_rtp_flag_t { SWITCH_RTP_FLAG_NOBLOCK = 0, + SWITCH_RTP_FLAG_DTMF_ON, SWITCH_RTP_FLAG_IO, SWITCH_RTP_FLAG_USE_TIMER, SWITCH_RTP_FLAG_RTCP_PASSTHRU, @@ -34044,6 +35514,11 @@ public enum switch_rtp_flag_t { SWITCH_RTP_FLAG_VIDEO, SWITCH_RTP_FLAG_ENABLE_RTCP, SWITCH_RTP_FLAG_RTCP_MUX, + SWITCH_RTP_FLAG_KILL_JB, + SWITCH_RTP_FLAG_VIDEO_BREAK, + SWITCH_RTP_FLAG_PAUSE, + SWITCH_RTP_FLAG_FIR, + SWITCH_RTP_FLAG_PLI, SWITCH_RTP_FLAG_INVALID } @@ -34448,6 +35923,201 @@ public class switch_rtp_numbers_t : IDisposable { } } + public long last_proc_time { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_proc_time_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_proc_time_get(swigCPtr); + return ret; + } + } + + public long jitter_n { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_n_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_n_get(swigCPtr); + return ret; + } + } + + public long jitter_add { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_add_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_add_get(swigCPtr); + return ret; + } + } + + public long jitter_addsq { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_addsq_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_addsq_get(swigCPtr); + return ret; + } + } + + public double variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_variance_get(swigCPtr); + return ret; + } + } + + public double min_variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_min_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_min_variance_get(swigCPtr); + return ret; + } + } + + public double max_variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_max_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_max_variance_get(swigCPtr); + return ret; + } + } + + public double std_deviation { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_std_deviation_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_std_deviation_get(swigCPtr); + return ret; + } + } + + public double lossrate { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_lossrate_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_lossrate_get(swigCPtr); + return ret; + } + } + + public double burstrate { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_burstrate_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_burstrate_get(swigCPtr); + return ret; + } + } + + public double mean_interval { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_mean_interval_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_mean_interval_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_int loss { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_loss_set(swigCPtr, SWIGTYPE_p_int.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_rtp_numbers_t_loss_get(swigCPtr); + SWIGTYPE_p_int ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_int(cPtr, false); + return ret; + } + } + + public int last_loss { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_loss_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_loss_get(swigCPtr); + return ret; + } + } + + public int recved { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_recved_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_recved_get(swigCPtr); + return ret; + } + } + + public int last_processed_seq { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_processed_seq_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_processed_seq_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t flaws { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_flaws_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_rtp_numbers_t_flaws_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t last_flaw { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_flaw_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_rtp_numbers_t_last_flaw_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public double R { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_R_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_R_get(swigCPtr); + return ret; + } + } + + public double mos { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_mos_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_mos_get(swigCPtr); + return ret; + } + } + public switch_rtp_numbers_t() : this(freeswitchPINVOKE.new_switch_rtp_numbers_t(), true) { } @@ -34648,7 +36318,8 @@ namespace FreeSWITCH.Native { public enum switch_say_gender_t { SSG_MASCULINE, SSG_FEMININE, - SSG_NEUTER + SSG_NEUTER, + SSG_UTRUM } } @@ -34930,6 +36601,16 @@ public class switch_scheduler_task : IDisposable { } } + public uint repeat { + set { + freeswitchPINVOKE.switch_scheduler_task_repeat_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_scheduler_task_repeat_get(swigCPtr); + return ret; + } + } + public string group { set { freeswitchPINVOKE.switch_scheduler_task_group_set(swigCPtr, value); @@ -34961,6 +36642,16 @@ public class switch_scheduler_task : IDisposable { } } + public uint hash { + set { + freeswitchPINVOKE.switch_scheduler_task_hash_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_scheduler_task_hash_get(swigCPtr); + return ret; + } + } + public switch_scheduler_task() : this(freeswitchPINVOKE.new_switch_scheduler_task(), true) { } @@ -36056,7 +37747,9 @@ public enum switch_status_t { SWITCH_STATUS_FOUND, SWITCH_STATUS_CONTINUE, SWITCH_STATUS_TERM, - SWITCH_STATUS_NOT_INITALIZED + SWITCH_STATUS_NOT_INITALIZED, + SWITCH_STATUS_XBREAK = 35, + SWITCH_STATUS_WINBREAK = 730035 } } @@ -36505,6 +38198,17 @@ public class switch_thread_data_t : IDisposable { } } + public SWIGTYPE_p_apr_pool_t pool { + set { + freeswitchPINVOKE.switch_thread_data_t_pool_set(swigCPtr, SWIGTYPE_p_apr_pool_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_thread_data_t_pool_get(swigCPtr); + SWIGTYPE_p_apr_pool_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_apr_pool_t(cPtr, false); + return ret; + } + } + public switch_thread_data_t() : this(freeswitchPINVOKE.new_switch_thread_data_t(), true) { } @@ -37377,7 +39081,7 @@ namespace FreeSWITCH.Native { SWITCH_XML_SECTION_CONFIG = (1 << 0), SWITCH_XML_SECTION_DIRECTORY = (1 << 1), SWITCH_XML_SECTION_DIALPLAN = (1 << 2), - SWITCH_XML_SECTION_PHRASES = (1 << 3), + SWITCH_XML_SECTION_LANGUAGES = (1 << 3), SWITCH_XML_SECTION_CHATPLAN = (1 << 4), SWITCH_XML_SECTION_MAX = (1 << 4) } diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 50ac5a3245..ef496f5e37 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30,11 +30,13 @@ public class Api : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_Api(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_Api(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -62,7 +64,7 @@ public class Api : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -92,11 +94,13 @@ public class audio_buffer_header_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_audio_buffer_header_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_audio_buffer_header_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -129,7 +133,7 @@ public class audio_buffer_header_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -145,7 +149,7 @@ public enum cache_db_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -175,11 +179,13 @@ public class CoreSession : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_CoreSession(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_CoreSession(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -508,7 +514,7 @@ public class CoreSession : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -524,7 +530,7 @@ public enum dm_match_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -554,11 +560,13 @@ public class dtls_fingerprint_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_dtls_fingerprint_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_dtls_fingerprint_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -612,7 +620,7 @@ public class dtls_fingerprint_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -631,7 +639,7 @@ public enum dtls_state_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -649,7 +657,7 @@ public enum dtls_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -679,11 +687,13 @@ public class DTMF : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_DTMF(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_DTMF(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -716,7 +726,7 @@ public class DTMF : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -732,7 +742,7 @@ public enum dtmf_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -762,11 +772,13 @@ public class EventConsumer : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_EventConsumer(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_EventConsumer(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -866,7 +878,7 @@ public class EventConsumer : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -896,11 +908,13 @@ public partial class Event : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_Event(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_Event(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -1002,7 +1016,7 @@ public partial class Event : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -1372,8 +1386,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_port_allocator_new(ushort start, ushort end, uint flags, SWIGTYPE_p_p_switch_core_port_allocator new_allocator) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_port_allocator_new(start, end, flags, SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(new_allocator)); + public static switch_status_t switch_core_port_allocator_new(string ip, ushort start, ushort end, uint flags, SWIGTYPE_p_p_switch_core_port_allocator new_allocator) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_port_allocator_new(ip, start, end, flags, SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(new_allocator)); return ret; } @@ -2749,8 +2763,8 @@ public class freeswitch { freeswitchPINVOKE.switch_time_set_monotonic((int)enable); } - public static void switch_time_set_timerfd(switch_bool_t enable) { - freeswitchPINVOKE.switch_time_set_timerfd((int)enable); + public static void switch_time_set_timerfd(int enable) { + freeswitchPINVOKE.switch_time_set_timerfd(enable); } public static void switch_time_set_nanosleep(switch_bool_t enable) { @@ -3146,6 +3160,45 @@ public class freeswitch { return ret; } + public static void switch_core_session_debug_pool(switch_stream_handle stream) { + freeswitchPINVOKE.switch_core_session_debug_pool(switch_stream_handle.getCPtr(stream)); + } + + public static string switch_version_major() { + string ret = freeswitchPINVOKE.switch_version_major(); + return ret; + } + + public static string switch_version_minor() { + string ret = freeswitchPINVOKE.switch_version_minor(); + return ret; + } + + public static string switch_version_micro() { + string ret = freeswitchPINVOKE.switch_version_micro(); + return ret; + } + + public static string switch_version_revision() { + string ret = freeswitchPINVOKE.switch_version_revision(); + return ret; + } + + public static string switch_version_revision_human() { + string ret = freeswitchPINVOKE.switch_version_revision_human(); + return ret; + } + + public static string switch_version_full() { + string ret = freeswitchPINVOKE.switch_version_full(); + return ret; + } + + public static string switch_version_full_human() { + string ret = freeswitchPINVOKE.switch_version_full_human(); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3620,6 +3673,11 @@ public class freeswitch { return ret; } + public static byte switch_true_byte(string expr) { + byte ret = freeswitchPINVOKE.switch_true_byte(expr); + return ret; + } + public static int switch_false(string expr) { int ret = freeswitchPINVOKE.switch_false(expr); return ret; @@ -4581,6 +4639,11 @@ public class freeswitch { return ret; } + public static switch_call_direction_t switch_channel_logical_direction(SWIGTYPE_p_switch_channel channel) { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_channel_logical_direction(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + public static void switch_channel_set_direction(SWIGTYPE_p_switch_channel channel, switch_call_direction_t direction) { freeswitchPINVOKE.switch_channel_set_direction(SWIGTYPE_p_switch_channel.getCPtr(channel), (int)direction); } @@ -4639,6 +4702,10 @@ public class freeswitch { return ret; } + public static void switch_channel_process_device_hangup(SWIGTYPE_p_switch_channel channel) { + freeswitchPINVOKE.switch_channel_process_device_hangup(SWIGTYPE_p_switch_channel.getCPtr(channel)); + } + public static switch_caller_extension switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel channel) { IntPtr cPtr = freeswitchPINVOKE.switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel.getCPtr(channel)); switch_caller_extension ret = (cPtr == IntPtr.Zero) ? null : new switch_caller_extension(cPtr, false); @@ -5129,6 +5196,29 @@ public class freeswitch { freeswitchPINVOKE.switch_live_array_parse_json(SWIGTYPE_p_cJSON.getCPtr(json), channel_id); } + public static switch_bool_t switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_event_channel_permission_verify(string cookie, string event_channel) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_event_channel_permission_verify(cookie, event_channel); + return ret; + } + + public static void switch_event_channel_permission_modify(string cookie, string event_channel, switch_bool_t set) { + freeswitchPINVOKE.switch_event_channel_permission_modify(cookie, event_channel, (int)set); + } + + public static void switch_event_channel_permission_clear(string cookie) { + freeswitchPINVOKE.switch_event_channel_permission_clear(cookie); + } + public static switch_status_t switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t new_resampler, uint from_rate, uint to_rate, uint to_size, int quality, uint channels, string file, string func, int line) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t.getCPtr(new_resampler), from_rate, to_rate, to_size, quality, channels, file, func, line); return ret; @@ -5628,8 +5718,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_ivr_menu_bind_function(SWIGTYPE_p_switch_ivr_menu menu, SWIGTYPE_p_switch_ivr_menu_action_function_t function, string arg, string bind) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_menu_bind_function(SWIGTYPE_p_switch_ivr_menu.getCPtr(menu), SWIGTYPE_p_switch_ivr_menu_action_function_t.getCPtr(function), arg, bind); + public static switch_status_t switch_ivr_menu_bind_function(SWIGTYPE_p_switch_ivr_menu menu, SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t function, string arg, string bind) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_menu_bind_function(SWIGTYPE_p_switch_ivr_menu.getCPtr(menu), SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t.getCPtr(function), arg, bind); return ret; } @@ -5653,8 +5743,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_ivr_menu_stack_xml_add_custom(SWIGTYPE_p_switch_ivr_menu_xml_ctx xml_menu_ctx, string name, SWIGTYPE_p_switch_ivr_menu_action_function_t function) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_menu_stack_xml_add_custom(SWIGTYPE_p_switch_ivr_menu_xml_ctx.getCPtr(xml_menu_ctx), name, SWIGTYPE_p_switch_ivr_menu_action_function_t.getCPtr(function)); + public static switch_status_t switch_ivr_menu_stack_xml_add_custom(SWIGTYPE_p_switch_ivr_menu_xml_ctx xml_menu_ctx, string name, SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t function) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_menu_stack_xml_add_custom(SWIGTYPE_p_switch_ivr_menu_xml_ctx.getCPtr(xml_menu_ctx), name, SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t.getCPtr(function)); return ret; } @@ -6197,10 +6287,6 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } - public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { - freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); - } - public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -6211,6 +6297,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp rtp_session, SWIGTYPE_p_p_payload_map_t pmap) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), SWIGTYPE_p_p_payload_map_t.getCPtr(pmap)); + return ret; + } + public static void switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_bug_flag_t bugs) { freeswitchPINVOKE.switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)bugs); } @@ -6955,6 +7046,10 @@ public class freeswitch { public static readonly int SWITCH_DTMF_LOG_LEN = freeswitchPINVOKE.SWITCH_DTMF_LOG_LEN_get(); public static readonly int SWITCH_MAX_TRANS = freeswitchPINVOKE.SWITCH_MAX_TRANS_get(); public static readonly int SWITCH_CORE_SESSION_MAX_PRIVATES = freeswitchPINVOKE.SWITCH_CORE_SESSION_MAX_PRIVATES_get(); + public static readonly double JITTER_VARIANCE_THRESHOLD = freeswitchPINVOKE.JITTER_VARIANCE_THRESHOLD_get(); + public static readonly double IPDV_THRESHOLD = freeswitchPINVOKE.IPDV_THRESHOLD_get(); + public static readonly int LOST_BURST_ANALYZE = freeswitchPINVOKE.LOST_BURST_ANALYZE_get(); + public static readonly int LOST_BURST_CAPTURE = freeswitchPINVOKE.LOST_BURST_CAPTURE_get(); public static readonly int SWITCH_MAX_STACKS = freeswitchPINVOKE.SWITCH_MAX_STACKS_get(); public static readonly int SWITCH_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_THREAD_STACKSIZE_get(); public static readonly int SWITCH_SYSTEM_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_SYSTEM_THREAD_STACKSIZE_get(); @@ -7028,7 +7123,7 @@ public class freeswitch { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -7193,6 +7288,10 @@ class freeswitchPINVOKE { } + static freeswitchPINVOKE() { + } + + protected class SWIGStringHelper { @@ -7703,6 +7802,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get")] public static extern int SWITCH_CORE_SESSION_MAX_PRIVATES_get(); + [DllImport("mod_managed", EntryPoint="CSharp_JITTER_VARIANCE_THRESHOLD_get")] + public static extern double JITTER_VARIANCE_THRESHOLD_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_IPDV_THRESHOLD_get")] + public static extern double IPDV_THRESHOLD_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_LOST_BURST_ANALYZE_get")] + public static extern int LOST_BURST_ANALYZE_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_LOST_BURST_CAPTURE_get")] + public static extern int LOST_BURST_CAPTURE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_digit_set")] public static extern void switch_dtmf_t_digit_set(HandleRef jarg1, char jarg2); @@ -8039,6 +8150,120 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_largest_jb_size_get")] public static extern IntPtr switch_rtp_numbers_t_largest_jb_size_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_proc_time_set")] + public static extern void switch_rtp_numbers_t_last_proc_time_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_proc_time_get")] + public static extern long switch_rtp_numbers_t_last_proc_time_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_n_set")] + public static extern void switch_rtp_numbers_t_jitter_n_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_n_get")] + public static extern long switch_rtp_numbers_t_jitter_n_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_add_set")] + public static extern void switch_rtp_numbers_t_jitter_add_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_add_get")] + public static extern long switch_rtp_numbers_t_jitter_add_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_addsq_set")] + public static extern void switch_rtp_numbers_t_jitter_addsq_set(HandleRef jarg1, long jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_jitter_addsq_get")] + public static extern long switch_rtp_numbers_t_jitter_addsq_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_variance_set")] + public static extern void switch_rtp_numbers_t_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_variance_get")] + public static extern double switch_rtp_numbers_t_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_min_variance_set")] + public static extern void switch_rtp_numbers_t_min_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_min_variance_get")] + public static extern double switch_rtp_numbers_t_min_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_max_variance_set")] + public static extern void switch_rtp_numbers_t_max_variance_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_max_variance_get")] + public static extern double switch_rtp_numbers_t_max_variance_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_std_deviation_set")] + public static extern void switch_rtp_numbers_t_std_deviation_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_std_deviation_get")] + public static extern double switch_rtp_numbers_t_std_deviation_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_lossrate_set")] + public static extern void switch_rtp_numbers_t_lossrate_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_lossrate_get")] + public static extern double switch_rtp_numbers_t_lossrate_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_burstrate_set")] + public static extern void switch_rtp_numbers_t_burstrate_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_burstrate_get")] + public static extern double switch_rtp_numbers_t_burstrate_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mean_interval_set")] + public static extern void switch_rtp_numbers_t_mean_interval_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mean_interval_get")] + public static extern double switch_rtp_numbers_t_mean_interval_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_loss_set")] + public static extern void switch_rtp_numbers_t_loss_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_loss_get")] + public static extern IntPtr switch_rtp_numbers_t_loss_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_loss_set")] + public static extern void switch_rtp_numbers_t_last_loss_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_loss_get")] + public static extern int switch_rtp_numbers_t_last_loss_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_recved_set")] + public static extern void switch_rtp_numbers_t_recved_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_recved_get")] + public static extern int switch_rtp_numbers_t_recved_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_processed_seq_set")] + public static extern void switch_rtp_numbers_t_last_processed_seq_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_processed_seq_get")] + public static extern int switch_rtp_numbers_t_last_processed_seq_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_flaws_set")] + public static extern void switch_rtp_numbers_t_flaws_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_flaws_get")] + public static extern IntPtr switch_rtp_numbers_t_flaws_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_flaw_set")] + public static extern void switch_rtp_numbers_t_last_flaw_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_last_flaw_get")] + public static extern IntPtr switch_rtp_numbers_t_last_flaw_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_R_set")] + public static extern void switch_rtp_numbers_t_R_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_R_get")] + public static extern double switch_rtp_numbers_t_R_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mos_set")] + public static extern void switch_rtp_numbers_t_mos_set(HandleRef jarg1, double jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_mos_get")] + public static extern double switch_rtp_numbers_t_mos_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtp_numbers_t")] public static extern IntPtr new_switch_rtp_numbers_t(); @@ -8879,11 +9104,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_xml_cdr_get")] public static extern IntPtr switch_device_node_t_xml_cdr_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_event_set")] - public static extern void switch_device_node_t_event_set(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t__event_set")] + public static extern void switch_device_node_t__event_set(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_event_get")] - public static extern IntPtr switch_device_node_t_event_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t__event_get")] + public static extern IntPtr switch_device_node_t__event_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_callstate_set")] public static extern void switch_device_node_t_callstate_set(HandleRef jarg1, int jarg2); @@ -8903,6 +9128,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_hup_profile_get")] public static extern IntPtr switch_device_node_t_hup_profile_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_set")] + public static extern void switch_device_node_t_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_get")] + public static extern int switch_device_node_t_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_parent_set")] public static extern void switch_device_node_t_parent_set(HandleRef jarg1, HandleRef jarg2); @@ -8927,42 +9158,132 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_get")] public static extern uint switch_device_stats_t_total_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_set")] + public static extern void switch_device_stats_t_total_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_get")] + public static extern uint switch_device_stats_t_total_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_set")] + public static extern void switch_device_stats_t_total_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_get")] + public static extern uint switch_device_stats_t_total_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_set")] public static extern void switch_device_stats_t_offhook_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_get")] public static extern uint switch_device_stats_t_offhook_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_set")] + public static extern void switch_device_stats_t_offhook_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_get")] + public static extern uint switch_device_stats_t_offhook_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_set")] + public static extern void switch_device_stats_t_offhook_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_get")] + public static extern uint switch_device_stats_t_offhook_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_set")] public static extern void switch_device_stats_t_active_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_get")] public static extern uint switch_device_stats_t_active_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_set")] + public static extern void switch_device_stats_t_active_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_get")] + public static extern uint switch_device_stats_t_active_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_set")] + public static extern void switch_device_stats_t_active_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_get")] + public static extern uint switch_device_stats_t_active_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_set")] public static extern void switch_device_stats_t_held_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_get")] public static extern uint switch_device_stats_t_held_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_set")] + public static extern void switch_device_stats_t_held_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_get")] + public static extern uint switch_device_stats_t_held_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_set")] + public static extern void switch_device_stats_t_held_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_get")] + public static extern uint switch_device_stats_t_held_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_set")] public static extern void switch_device_stats_t_hup_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_get")] public static extern uint switch_device_stats_t_hup_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_set")] + public static extern void switch_device_stats_t_hup_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_get")] + public static extern uint switch_device_stats_t_hup_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_set")] + public static extern void switch_device_stats_t_hup_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_get")] + public static extern uint switch_device_stats_t_hup_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_set")] public static extern void switch_device_stats_t_ringing_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_get")] public static extern uint switch_device_stats_t_ringing_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_set")] + public static extern void switch_device_stats_t_ringing_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_get")] + public static extern uint switch_device_stats_t_ringing_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_set")] + public static extern void switch_device_stats_t_ringing_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_get")] + public static extern uint switch_device_stats_t_ringing_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_set")] public static extern void switch_device_stats_t_early_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_get")] public static extern uint switch_device_stats_t_early_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_set")] + public static extern void switch_device_stats_t_early_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_get")] + public static extern uint switch_device_stats_t_early_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_set")] + public static extern void switch_device_stats_t_early_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_get")] + public static extern uint switch_device_stats_t_early_out_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_set")] + public static extern void switch_device_stats_t_ring_wait_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_get")] + public static extern uint switch_device_stats_t_ring_wait_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_stats_t")] public static extern IntPtr new_switch_device_stats_t(); @@ -8993,6 +9314,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_stats_get")] public static extern IntPtr switch_device_record_t_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_set")] + public static extern void switch_device_record_t_last_stats_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_get")] + public static extern IntPtr switch_device_record_t_last_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_state_set")] public static extern void switch_device_record_t_state_set(HandleRef jarg1, int jarg2); @@ -9023,6 +9350,36 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_call_time_get")] public static extern IntPtr switch_device_record_t_last_call_time_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_set")] + public static extern void switch_device_record_t_ring_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_get")] + public static extern IntPtr switch_device_record_t_ring_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_set")] + public static extern void switch_device_record_t_ring_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_get")] + public static extern IntPtr switch_device_record_t_ring_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_set")] + public static extern void switch_device_record_t_hold_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_get")] + public static extern IntPtr switch_device_record_t_hold_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_set")] + public static extern void switch_device_record_t_hold_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_get")] + public static extern IntPtr switch_device_record_t_hold_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_set")] + public static extern void switch_device_record_t_call_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_get")] + public static extern IntPtr switch_device_record_t_call_start_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_uuid_list_set")] public static extern void switch_device_record_t_uuid_list_set(HandleRef jarg1, HandleRef jarg2); @@ -9047,6 +9404,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_pool_get")] public static extern IntPtr switch_device_record_t_pool_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_set")] + public static extern void switch_device_record_t_user_data_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_get")] + public static extern IntPtr switch_device_record_t_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_record_t")] public static extern IntPtr new_switch_device_record_t(); @@ -9357,7 +9720,7 @@ class freeswitchPINVOKE { public static extern int switch_core_media_bug_set_pre_buffer_framecount(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_new")] - public static extern int switch_core_port_allocator_new(ushort jarg1, ushort jarg2, uint jarg3, HandleRef jarg4); + public static extern int switch_core_port_allocator_new(string jarg1, ushort jarg2, ushort jarg3, uint jarg4, HandleRef jarg5); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_request_port")] public static extern int switch_core_port_allocator_request_port(HandleRef jarg1, HandleRef jarg2); @@ -10538,6 +10901,30 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ice_direction")] public static extern int switch_ice_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_debug_pool")] + public static extern void switch_core_session_debug_pool(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_major")] + public static extern string switch_version_major(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_minor")] + public static extern string switch_version_minor(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_micro")] + public static extern string switch_version_micro(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_revision")] + public static extern string switch_version_revision(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_revision_human")] + public static extern string switch_version_revision_human(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_full")] + public static extern string switch_version_full(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_version_full_human")] + public static extern string switch_version_full_human(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -10967,6 +11354,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_true")] public static extern int switch_true(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_true_byte")] + public static extern byte switch_true_byte(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_false")] public static extern int switch_false(string jarg1); @@ -11426,6 +11816,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_direction_get")] public static extern int switch_caller_profile_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_set")] + public static extern void switch_caller_profile_logical_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_get")] + public static extern int switch_caller_profile_logical_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_soft_set")] public static extern void switch_caller_profile_soft_set(HandleRef jarg1, HandleRef jarg2); @@ -11663,6 +12059,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_user_data_get")] public static extern IntPtr switch_frame_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_set")] + public static extern void switch_frame_pmap_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_get")] + public static extern IntPtr switch_frame_pmap_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_frame")] public static extern IntPtr new_switch_frame(); @@ -12503,11 +12905,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_max_samples_get")] public static extern int switch_file_handle_max_samples_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_params_set")] - public static extern void switch_file_handle_params_set(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_set")] + public static extern void switch_file_handle__params_set(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_params_get")] - public static extern IntPtr switch_file_handle_params_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_get")] + public static extern IntPtr switch_file_handle__params_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_channels_set")] public static extern void switch_file_handle_cur_channels_set(HandleRef jarg1, uint jarg2); @@ -14327,6 +14729,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_direction")] public static extern int switch_channel_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_logical_direction")] + public static extern int switch_channel_logical_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_set_direction")] public static extern void switch_channel_set_direction(HandleRef jarg1, int jarg2); @@ -14363,6 +14768,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_api_on")] public static extern int switch_channel_api_on(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_process_device_hangup")] + public static extern void switch_channel_process_device_hangup(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_queued_extension")] public static extern IntPtr switch_channel_get_queued_extension(HandleRef jarg1); @@ -14849,6 +15257,21 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_parse_json")] public static extern void switch_live_array_parse_json(HandleRef jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_add_alias")] + public static extern int switch_live_array_add_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_clear_alias")] + public static extern int switch_live_array_clear_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_verify")] + public static extern int switch_event_channel_permission_verify(string jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_modify")] + public static extern void switch_event_channel_permission_modify(string jarg1, string jarg2, int jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_clear")] + public static extern void switch_event_channel_permission_clear(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RESAMPLE_QUALITY_get")] public static extern int SWITCH_RESAMPLE_QUALITY_get(); @@ -15836,15 +16259,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] - public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_private")] public static extern IntPtr switch_rtp_get_private(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_payload_map")] + public static extern int switch_rtp_set_payload_map(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_intentional_bugs")] public static extern void switch_rtp_intentional_bugs(HandleRef jarg1, int jarg2); @@ -16616,6 +17039,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_task_id_get")] public static extern uint switch_scheduler_task_task_id_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_hash_set")] + public static extern void switch_scheduler_task_hash_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_hash_get")] + public static extern uint switch_scheduler_task_hash_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_scheduler_task")] public static extern IntPtr new_switch_scheduler_task(); @@ -17162,14 +17591,14 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_ManagedSession")] public static extern void delete_ManagedSession(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_ManagedSessionUpcast")] - public static extern IntPtr ManagedSessionUpcast(IntPtr objectRef); + [DllImport("mod_managed", EntryPoint="CSharp_ManagedSession_SWIGUpcast")] + public static extern IntPtr ManagedSession_SWIGUpcast(IntPtr jarg1); } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17199,11 +17628,13 @@ public class icand_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_icand_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_icand_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17326,7 +17757,7 @@ public class icand_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17342,7 +17773,7 @@ public enum ice_proto_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17372,11 +17803,13 @@ public class ice_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_ice_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_ice_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17451,7 +17884,7 @@ public class ice_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17481,11 +17914,13 @@ public class input_callback_state_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_input_callback_state_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_input_callback_state_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17541,7 +17976,7 @@ public class input_callback_state_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17571,11 +18006,13 @@ public class ip_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_ip_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_ip_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17610,7 +18047,7 @@ public class ip_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17640,11 +18077,13 @@ public class IvrMenu : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_IvrMenu(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_IvrMenu(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17665,7 +18104,7 @@ public class IvrMenu : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17679,7 +18118,7 @@ using System.Runtime.InteropServices; public partial class ManagedSession : CoreSession { private HandleRef swigCPtr; - internal ManagedSession(IntPtr cPtr, bool cMemoryOwn) : base(freeswitchPINVOKE.ManagedSessionUpcast(cPtr), cMemoryOwn) { + internal ManagedSession(IntPtr cPtr, bool cMemoryOwn) : base(freeswitchPINVOKE.ManagedSession_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new HandleRef(this, cPtr); } @@ -17693,11 +18132,13 @@ public partial class ManagedSession : CoreSession { public override void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_ManagedSession(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_ManagedSession(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); base.Dispose(); } @@ -17717,7 +18158,7 @@ public partial class ManagedSession : CoreSession { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17747,11 +18188,13 @@ public class profile_node_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_profile_node_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_profile_node_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17795,7 +18238,7 @@ public class profile_node_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17812,7 +18255,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17842,11 +18285,13 @@ public partial class Stream : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_Stream(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_Stream(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -17871,7 +18316,7 @@ public partial class Stream : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17901,7 +18346,7 @@ public class SWIGTYPE_p_a_2__icand_s { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17931,7 +18376,7 @@ public class SWIGTYPE_p_apr_pool_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17961,7 +18406,7 @@ public class SWIGTYPE_p_cJSON { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -17991,7 +18436,7 @@ public class SWIGTYPE_p_FILE { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18021,7 +18466,7 @@ public class SWIGTYPE_p_float { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18051,7 +18496,7 @@ public class SWIGTYPE_p_f_p_char_enum_switch_management_action_t_p_char_switch_s } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18081,7 +18526,7 @@ public class SWIGTYPE_p_f_p_p_switch_loadable_module_interface_p_apr_pool_t__swi } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18111,7 +18556,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18141,7 +18586,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_p_switch_console_cal } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18171,7 +18616,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_co } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18201,7 +18646,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_unsigned_long__int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18231,7 +18676,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_void__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18261,7 +18706,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18291,7 +18736,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_switch_codec_fmtp__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18321,7 +18766,7 @@ public class SWIGTYPE_p_f_p_q_const__char_p_switch_core_session_p_switch_stream_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18351,7 +18796,7 @@ public class SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__swit } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18381,7 +18826,7 @@ public class SWIGTYPE_p_f_p_q_const__switch_log_node_t_enum_switch_log_level_t__ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18411,7 +18856,7 @@ public class SWIGTYPE_p_f_p_q_const__void_p_q_const__void_p_void__switch_bool_t } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18441,7 +18886,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_char_double__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18471,7 +18916,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_char_int__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18501,7 +18946,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_char_p_q_const__char__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18531,7 +18976,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_p_char_p_unsigned_long__switch_s } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18561,7 +19006,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_p_switch_event_p_unsigned_long__ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18591,7 +19036,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_q_const__char_int_p_q_const__cha } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18621,7 +19066,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_q_const__char_p_q_const__char__s } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18651,7 +19096,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_q_const__char__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18681,7 +19126,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_q_const__switch_dtmf_t_p_unsigne } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18711,7 +19156,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_unsigned_long__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18741,7 +19186,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle_p_void_unsigned_int_p_unsigned_lon } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18771,7 +19216,7 @@ public class SWIGTYPE_p_f_p_switch_asr_handle__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18801,7 +19246,7 @@ public class SWIGTYPE_p_f_p_switch_codec_p_switch_codec_p_void_unsigned_long_uns } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18831,7 +19276,7 @@ public class SWIGTYPE_p_f_p_switch_codec__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18861,7 +19306,7 @@ public class SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_s } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18891,7 +19336,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_enum_switch_channel_callstate_t_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18921,7 +19366,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_enum_switch_media_type_t__p_stfu } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18951,7 +19396,7 @@ public class SWIGTYPE_p_f_p_switch_core_session__int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -18981,7 +19426,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19011,7 +19456,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_char_p_switch_say_args_t_p_p_c } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19041,7 +19486,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_char_p_switch_say_args_t_p_swi } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19071,7 +19516,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_p_switch_frame_unsigned_long_i } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19101,7 +19546,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__char_p_q_const__char_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19131,7 +19576,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__char_p_q_const__char_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19161,7 +19606,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__char_p_q_const__char_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19191,7 +19636,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__char__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19221,7 +19666,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__switch_dtmf_t_enum_sw } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19251,7 +19696,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_q_const__switch_dtmf_t__switch } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19281,7 +19726,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_core_session_message__s } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19311,7 +19756,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_p } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19341,7 +19786,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_p } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19371,7 +19816,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_event__switch_status_t } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19401,7 +19846,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_frame_p_void__switch_st } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19431,7 +19876,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_switch_frame_unsigned_long_int } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19461,7 +19906,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_void_enum_switch_input_type_t_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19491,7 +19936,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_p_void__p_void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19521,7 +19966,7 @@ public class SWIGTYPE_p_f_p_switch_core_session__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19551,7 +19996,7 @@ public class SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19581,7 +20026,7 @@ public class SWIGTYPE_p_f_p_switch_directory_handle_p_char_p_char_p_char__switch } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19611,7 +20056,7 @@ public class SWIGTYPE_p_f_p_switch_directory_handle_p_char_p_char__switch_status } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19641,7 +20086,7 @@ public class SWIGTYPE_p_f_p_switch_directory_handle_p_p_char_p_p_char__switch_st } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19671,7 +20116,7 @@ public class SWIGTYPE_p_f_p_switch_directory_handle__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19701,7 +20146,7 @@ public class SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19731,7 +20176,7 @@ public class SWIGTYPE_p_f_p_switch_event__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19761,7 +20206,7 @@ public class SWIGTYPE_p_f_p_switch_event__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19791,7 +20236,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_enum_switch_audio_col_t_p_p_q_con } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19821,7 +20266,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_enum_switch_audio_col_t_p_q_const } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19851,7 +20296,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_long_long__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19881,7 +20326,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_p_q_const__char__switch_status_t } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19911,7 +20356,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_p_unsigned_int_long_long_int__swi } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19941,7 +20386,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_st } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -19971,7 +20416,7 @@ public class SWIGTYPE_p_f_p_switch_file_handle__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20001,7 +20446,37 @@ public class SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + +public class SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_ivr_menu_p_char_p_char_size_t_p_void__switch_ivr_action_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20031,7 +20506,7 @@ public class SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20061,7 +20536,7 @@ public class SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__swit } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20091,7 +20566,7 @@ public class SWIGTYPE_p_f_p_switch_media_bug_p_void__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20121,7 +20596,7 @@ public class SWIGTYPE_p_f_p_switch_rtp_p_switch_socket_t_p_void_switch_size_t_p_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20151,7 +20626,7 @@ public class SWIGTYPE_p_f_p_switch_scheduler_task__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20181,7 +20656,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_char_double__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20211,7 +20686,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_char_int__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20241,7 +20716,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_char_p_q_const__char__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20271,7 +20746,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_char_p_unsigned_long__switch_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20301,7 +20776,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_q_const__char_int_p_unsigned_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20331,7 +20806,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_unsigned_long__switch_status_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20361,7 +20836,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle_p_void_p_switch_size_t_p_unsign } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20391,7 +20866,7 @@ public class SWIGTYPE_p_f_p_switch_speech_handle__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20421,7 +20896,7 @@ public class SWIGTYPE_p_f_p_switch_stream_handle_p_q_const__char_v_______switch_ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20451,7 +20926,7 @@ public class SWIGTYPE_p_f_p_switch_stream_handle_p_unsigned_char_switch_size_t__ } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20481,7 +20956,7 @@ public class SWIGTYPE_p_f_p_switch_thread_t_p_void__p_void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20511,7 +20986,7 @@ public class SWIGTYPE_p_f_p_switch_timer_enum_switch_bool_t__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20541,7 +21016,7 @@ public class SWIGTYPE_p_f_p_switch_timer__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20571,7 +21046,7 @@ public class SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20601,7 +21076,7 @@ public class SWIGTYPE_p_f_p_void_p_q_const__char__int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20631,7 +21106,7 @@ public class SWIGTYPE_p_f_p_void_p_switch_event__int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20661,7 +21136,7 @@ public class SWIGTYPE_p_f_p_void__void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20691,7 +21166,7 @@ public class SWIGTYPE_p_f_uint8_t_p_p_q_const__char_p_void__p_switch_xml { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20721,7 +21196,7 @@ public class SWIGTYPE_p_f_void__p_char { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20751,7 +21226,7 @@ public class SWIGTYPE_p_f_void__switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20781,7 +21256,7 @@ public class SWIGTYPE_p_HashElem { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20811,7 +21286,7 @@ public class SWIGTYPE_p_in6_addr { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20841,7 +21316,7 @@ public class SWIGTYPE_p_int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20871,7 +21346,37 @@ public class SWIGTYPE_p_p_apr_pool_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + +public class SWIGTYPE_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20901,7 +21406,7 @@ public class SWIGTYPE_p_p_char { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20931,7 +21436,7 @@ public class SWIGTYPE_p_p_cJSON { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20961,7 +21466,37 @@ public class SWIGTYPE_p_pid_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + +public class SWIGTYPE_p_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -20991,7 +21526,7 @@ public class SWIGTYPE_p_p_p_char { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21021,7 +21556,7 @@ public class SWIGTYPE_p_p_real_pcre { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21051,7 +21586,7 @@ public class SWIGTYPE_p_p_sqlite3 { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21081,7 +21616,7 @@ public class SWIGTYPE_p_p_sqlite3_stmt { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21111,7 +21646,7 @@ public class SWIGTYPE_p_p_switch_audio_resampler_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21141,7 +21676,7 @@ public class SWIGTYPE_p_p_switch_buffer { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21171,7 +21706,7 @@ public class SWIGTYPE_p_p_switch_cache_db_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21201,7 +21736,7 @@ public class SWIGTYPE_p_p_switch_caller_extension { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21231,7 +21766,7 @@ public class SWIGTYPE_p_p_switch_channel { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21261,7 +21796,7 @@ public class SWIGTYPE_p_p_switch_codec_implementation { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21291,7 +21826,7 @@ public class SWIGTYPE_p_p_switch_console_callback_match { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21321,7 +21856,7 @@ public class SWIGTYPE_p_p_switch_core_port_allocator { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21351,7 +21886,7 @@ public class SWIGTYPE_p_p_switch_core_session { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21381,7 +21916,7 @@ public class SWIGTYPE_p_p_switch_core_session_message { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21411,7 +21946,7 @@ public class SWIGTYPE_p_p_switch_device_record_s { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21441,7 +21976,7 @@ public class SWIGTYPE_p_p_switch_event { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21471,7 +22006,7 @@ public class SWIGTYPE_p_p_switch_event_node { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21501,7 +22036,7 @@ public class SWIGTYPE_p_p_switch_file_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21531,7 +22066,7 @@ public class SWIGTYPE_p_p_switch_frame { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21561,7 +22096,7 @@ public class SWIGTYPE_p_p_switch_hash { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21591,7 +22126,7 @@ public class SWIGTYPE_p_p_switch_ivr_digit_stream { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21621,7 +22156,7 @@ public class SWIGTYPE_p_p_switch_ivr_digit_stream_parser { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21651,7 +22186,7 @@ public class SWIGTYPE_p_p_switch_ivr_dmachine { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21681,7 +22216,7 @@ public class SWIGTYPE_p_p_switch_ivr_dmachine_match { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21711,7 +22246,7 @@ public class SWIGTYPE_p_p_switch_ivr_menu { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21741,7 +22276,7 @@ public class SWIGTYPE_p_p_switch_ivr_menu_xml_ctx { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21771,7 +22306,7 @@ public class SWIGTYPE_p_p_switch_live_array_s { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21801,7 +22336,7 @@ public class SWIGTYPE_p_p_switch_log_node_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21831,7 +22366,7 @@ public class SWIGTYPE_p_p_switch_media_bug { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21861,7 +22396,7 @@ public class SWIGTYPE_p_p_switch_network_list { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21891,7 +22426,7 @@ public class SWIGTYPE_p_p_switch_rtp { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21921,7 +22456,7 @@ public class SWIGTYPE_p_p_switch_say_file_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21951,7 +22486,7 @@ public class SWIGTYPE_p_p_switch_sql_queue_manager { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -21981,7 +22516,7 @@ public class SWIGTYPE_p_p_switch_thread_data_s { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22011,7 +22546,7 @@ public class SWIGTYPE_p_p_switch_xml_binding { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22041,7 +22576,7 @@ public class SWIGTYPE_p_p_switch_xml { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22071,7 +22606,7 @@ public class SWIGTYPE_p_p_void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22101,7 +22636,7 @@ public class SWIGTYPE_p_real_pcre { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22131,7 +22666,7 @@ public class SWIGTYPE_p_short { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22161,7 +22696,7 @@ public class SWIGTYPE_p_sockaddr { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22191,7 +22726,7 @@ public class SWIGTYPE_p_sockaddr_in6 { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22221,7 +22756,7 @@ public class SWIGTYPE_p_socklen_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22251,7 +22786,7 @@ public class SWIGTYPE_p_sqlite3 { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22281,7 +22816,7 @@ public class SWIGTYPE_p_sqlite3_stmt { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22311,7 +22846,7 @@ public class SWIGTYPE_p_stfu_instance_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22341,7 +22876,7 @@ public class SWIGTYPE_p_switch_buffer { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22371,7 +22906,7 @@ public class SWIGTYPE_p_switch_cache_db_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22401,7 +22936,7 @@ public class SWIGTYPE_p_switch_call_cause_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22431,7 +22966,7 @@ public class SWIGTYPE_p_switch_channel { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22461,7 +22996,7 @@ public class SWIGTYPE_p_switch_core_media_ice_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22491,7 +23026,7 @@ public class SWIGTYPE_p_switch_core_port_allocator { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22521,7 +23056,7 @@ public class SWIGTYPE_p_switch_core_session { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22551,7 +23086,7 @@ public class SWIGTYPE_p_switch_event_types_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22581,7 +23116,7 @@ public class SWIGTYPE_p_switch_file_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22611,7 +23146,7 @@ public class SWIGTYPE_p_switch_hash { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22641,7 +23176,7 @@ public class SWIGTYPE_p_switch_interval_time_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22671,7 +23206,7 @@ public class SWIGTYPE_p_switch_ivr_action_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22701,7 +23236,7 @@ public class SWIGTYPE_p_switch_ivr_digit_stream { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22731,7 +23266,7 @@ public class SWIGTYPE_p_switch_ivr_digit_stream_parser { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22761,37 +23296,7 @@ public class SWIGTYPE_p_switch_ivr_dmachine { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -namespace FreeSWITCH.Native { - -using System; -using System.Runtime.InteropServices; - -public class SWIGTYPE_p_switch_ivr_menu_action_function_t { - private HandleRef swigCPtr; - - internal SWIGTYPE_p_switch_ivr_menu_action_function_t(IntPtr cPtr, bool futureUse) { - swigCPtr = new HandleRef(this, cPtr); - } - - protected SWIGTYPE_p_switch_ivr_menu_action_function_t() { - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - - internal static HandleRef getCPtr(SWIGTYPE_p_switch_ivr_menu_action_function_t obj) { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } -} - -} -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22821,7 +23326,7 @@ public class SWIGTYPE_p_switch_ivr_menu { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22851,7 +23356,7 @@ public class SWIGTYPE_p_switch_ivr_menu_xml_ctx { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22881,7 +23386,7 @@ public class SWIGTYPE_p_switch_live_array_s { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22911,7 +23416,7 @@ public class SWIGTYPE_p_switch_media_bug { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22941,7 +23446,7 @@ public class SWIGTYPE_p_switch_mutex_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -22971,7 +23476,7 @@ public class SWIGTYPE_p_switch_network_list { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23001,7 +23506,7 @@ public class SWIGTYPE_p_switch_odbc_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23031,7 +23536,7 @@ public class SWIGTYPE_p_switch_pgsql_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23061,7 +23566,7 @@ public class SWIGTYPE_p_switch_pollfd_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23091,7 +23596,7 @@ public class SWIGTYPE_p_switch_queue_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23121,7 +23626,7 @@ public class SWIGTYPE_p_switch_rtcp_frame { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23151,7 +23656,7 @@ public class SWIGTYPE_p_switch_rtp { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23181,7 +23686,7 @@ public class SWIGTYPE_p_switch_rtp_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23211,7 +23716,7 @@ public class SWIGTYPE_p_switch_say_file_handle { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23241,7 +23746,7 @@ public class SWIGTYPE_p_switch_size_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23271,7 +23776,7 @@ public class SWIGTYPE_p_switch_sockaddr_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23301,7 +23806,7 @@ public class SWIGTYPE_p_switch_socket_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23331,7 +23836,7 @@ public class SWIGTYPE_p_switch_sql_queue_manager { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23361,7 +23866,7 @@ public class SWIGTYPE_p_switch_ssize_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23391,7 +23896,7 @@ public class SWIGTYPE_p_switch_thread_rwlock_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23421,7 +23926,7 @@ public class SWIGTYPE_p_switch_thread_start_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23451,7 +23956,7 @@ public class SWIGTYPE_p_switch_time_exp_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23481,7 +23986,7 @@ public class SWIGTYPE_p_switch_time_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23511,7 +24016,7 @@ public class SWIGTYPE_p_switch_xml_binding { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23541,7 +24046,7 @@ public class SWIGTYPE_p_time_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23571,7 +24076,7 @@ public class SWIGTYPE_p_unsigned_char { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23601,7 +24106,7 @@ public class SWIGTYPE_p_unsigned_int { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23631,7 +24136,7 @@ public class SWIGTYPE_p_unsigned_long { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23661,7 +24166,7 @@ public class SWIGTYPE_p_unsigned_short { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23691,7 +24196,7 @@ public class SWIGTYPE_p_void { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23714,7 +24219,7 @@ public enum switch_abc_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23744,11 +24249,13 @@ public class switch_api_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_api_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_api_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -23856,7 +24363,7 @@ public class switch_api_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23876,7 +24383,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -23906,11 +24413,13 @@ public class switch_application_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_application_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_application_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -24038,7 +24547,7 @@ public class switch_application_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24068,11 +24577,13 @@ public class switch_app_log : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_app_log(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_app_log(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -24128,7 +24639,7 @@ public class switch_app_log : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24148,7 +24659,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24178,11 +24689,13 @@ public class switch_asr_handle : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_asr_handle(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_asr_handle(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -24353,7 +24866,7 @@ public class switch_asr_handle : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24383,11 +24896,13 @@ public class switch_asr_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_asr_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_asr_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -24662,7 +25177,7 @@ public class switch_asr_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24682,7 +25197,7 @@ public enum switch_audio_col_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24712,11 +25227,13 @@ public class switch_audio_resampler_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_audio_resampler_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_audio_resampler_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -24811,7 +25328,7 @@ public class switch_audio_resampler_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24833,7 +25350,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24849,7 +25366,7 @@ public enum switch_bitpack_mode_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -24879,11 +25396,13 @@ public class switch_bitpack_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_bitpack_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_bitpack_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25028,7 +25547,7 @@ public class switch_bitpack_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25044,7 +25563,7 @@ public enum switch_bool_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25074,11 +25593,13 @@ public class switch_cache_db_connection_options_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_connection_options_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_cache_db_connection_options_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25124,7 +25645,7 @@ public class switch_cache_db_connection_options_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25154,11 +25675,13 @@ public class switch_cache_db_core_db_options_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_core_db_options_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_cache_db_core_db_options_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25181,7 +25704,7 @@ public class switch_cache_db_core_db_options_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25198,7 +25721,7 @@ public enum switch_cache_db_handle_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25228,11 +25751,13 @@ public class switch_cache_db_native_handle_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_native_handle_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_cache_db_native_handle_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25278,7 +25803,7 @@ public class switch_cache_db_native_handle_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25308,11 +25833,13 @@ public class switch_cache_db_odbc_options_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_odbc_options_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_cache_db_odbc_options_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25355,7 +25882,7 @@ public class switch_cache_db_odbc_options_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25385,11 +25912,13 @@ public class switch_cache_db_pgsql_options_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_pgsql_options_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_cache_db_pgsql_options_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25412,7 +25941,7 @@ public class switch_cache_db_pgsql_options_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25495,7 +26024,7 @@ public enum switch_call_cause_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25511,7 +26040,7 @@ public enum switch_call_direction_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25541,11 +26070,13 @@ public class switch_caller_application : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_caller_application(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_caller_application(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25600,7 +26131,7 @@ public class switch_caller_application : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25630,11 +26161,13 @@ public class switch_caller_extension : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_caller_extension(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_caller_extension(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -25722,7 +26255,7 @@ public class switch_caller_extension : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -25752,11 +26285,13 @@ public class switch_caller_profile : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_caller_profile(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_caller_profile(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -26140,6 +26675,16 @@ public class switch_caller_profile : IDisposable { } } + public switch_call_direction_t logical_direction { + set { + freeswitchPINVOKE.switch_caller_profile_logical_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_caller_profile_logical_direction_get(swigCPtr); + return ret; + } + } + public profile_node_t soft { set { freeswitchPINVOKE.switch_caller_profile_soft_set(swigCPtr, profile_node_t.getCPtr(value)); @@ -26189,7 +26734,7 @@ public class switch_caller_profile : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26207,7 +26752,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26226,7 +26771,7 @@ public enum switch_channel_app_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26241,6 +26786,7 @@ public enum switch_channel_callstate_t { CCS_EARLY, CCS_ACTIVE, CCS_HELD, + CCS_RING_WAIT, CCS_HANGUP, CCS_UNHOLD } @@ -26248,7 +26794,7 @@ public enum switch_channel_callstate_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26269,7 +26815,7 @@ public enum switch_channel_cap_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26360,6 +26906,7 @@ public enum switch_channel_flag_t { CF_CONFIRM_BLIND_TRANSFER, CF_NO_PRESENCE, CF_CONFERENCE, + CF_CONFERENCE_ADV, CF_RECOVERING, CF_RECOVERING_BRIDGE, CF_TRACKED, @@ -26393,13 +26940,15 @@ public enum switch_channel_flag_t { CF_VIDEO_ECHO, CF_SLA_INTERCEPT, CF_VIDEO_BREAK, + CF_MEDIA_PAUSE, + CF_BYPASS_MEDIA_AFTER_HOLD, CF_FLAG_MAX } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26427,7 +26976,7 @@ public enum switch_channel_state_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26457,11 +27006,13 @@ public class switch_channel_timetable : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_channel_timetable(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_channel_timetable(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -26617,7 +27168,7 @@ public class switch_channel_timetable : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26632,7 +27183,7 @@ public enum switch_chat_application_flag_enum_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26662,11 +27213,13 @@ public class switch_chat_application_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_chat_application_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_chat_application_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -26794,7 +27347,7 @@ public class switch_chat_application_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26824,11 +27377,13 @@ public class switch_chat_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_chat_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_chat_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -26916,7 +27471,7 @@ public class switch_chat_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -26946,11 +27501,13 @@ public class switch_codec : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_codec(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_codec(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27091,7 +27648,7 @@ public class switch_codec : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27114,7 +27671,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27144,11 +27701,13 @@ public class switch_codec_fmtp : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_codec_fmtp(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_codec_fmtp(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27202,7 +27761,7 @@ public class switch_codec_fmtp : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27232,11 +27791,13 @@ public class switch_codec_implementation : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_codec_implementation(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_codec_implementation(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27454,7 +28015,7 @@ public class switch_codec_implementation : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27484,11 +28045,13 @@ public class switch_codec_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_codec_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_codec_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27597,7 +28160,7 @@ public class switch_codec_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27627,11 +28190,13 @@ public class switch_codec_settings : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_codec_settings(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_codec_settings(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27654,7 +28219,7 @@ public class switch_codec_settings : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27672,7 +28237,7 @@ public enum switch_codec_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27702,11 +28267,13 @@ public class switch_config : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_config(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_config(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27810,7 +28377,7 @@ public class switch_config : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27840,11 +28407,13 @@ public class switch_console_callback_match : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_console_callback_match(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_console_callback_match(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27899,7 +28468,7 @@ public class switch_console_callback_match : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -27929,11 +28498,13 @@ public class switch_console_callback_match_node : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_console_callback_match_node(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_console_callback_match_node(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -27967,7 +28538,7 @@ public class switch_console_callback_match_node : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28007,7 +28578,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28037,11 +28608,13 @@ public class switch_core_session_message : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_core_session_message(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_core_session_message(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28247,7 +28820,7 @@ public class switch_core_session_message : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28264,7 +28837,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28314,6 +28887,7 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INDICATE_MEDIA_RENEG, + SWITCH_MESSAGE_REFER_EVENT, SWITCH_MESSAGE_ANSWER_EVENT, SWITCH_MESSAGE_PROGRESS_EVENT, SWITCH_MESSAGE_RING_EVENT, @@ -28323,7 +28897,7 @@ public enum switch_core_session_message_types_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28353,11 +28927,13 @@ public class switch_core_thread_session : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_core_thread_session(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_core_thread_session(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28424,7 +29000,7 @@ public class switch_core_thread_session : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28454,11 +29030,13 @@ public class switch_core_time_duration : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_core_time_duration(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_core_time_duration(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28541,7 +29119,7 @@ public class switch_core_time_duration : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28571,11 +29149,13 @@ public class switch_device_node_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_device_node_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_device_node_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28601,12 +29181,12 @@ public class switch_device_node_t : IDisposable { } } - public switch_event event { + public switch_event _event { set { - freeswitchPINVOKE.switch_device_node_t_event_set(swigCPtr, switch_event.getCPtr(value)); + freeswitchPINVOKE.switch_device_node_t__event_set(swigCPtr, switch_event.getCPtr(value)); } get { - IntPtr cPtr = freeswitchPINVOKE.switch_device_node_t_event_get(swigCPtr); + IntPtr cPtr = freeswitchPINVOKE.switch_device_node_t__event_get(swigCPtr); switch_event ret = (cPtr == IntPtr.Zero) ? null : new switch_event(cPtr, false); return ret; } @@ -28644,6 +29224,16 @@ public class switch_device_node_t : IDisposable { } } + public switch_call_direction_t direction { + set { + freeswitchPINVOKE.switch_device_node_t_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_device_node_t_direction_get(swigCPtr); + return ret; + } + } + public switch_device_record_t parent { set { freeswitchPINVOKE.switch_device_node_t_parent_set(swigCPtr, switch_device_record_t.getCPtr(value)); @@ -28674,7 +29264,7 @@ public class switch_device_node_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28704,11 +29294,13 @@ public class switch_device_record_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_device_record_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_device_record_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28754,6 +29346,17 @@ public class switch_device_record_t : IDisposable { } } + public switch_device_stats_t last_stats { + set { + freeswitchPINVOKE.switch_device_record_t_last_stats_set(swigCPtr, switch_device_stats_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_last_stats_get(swigCPtr); + switch_device_stats_t ret = (cPtr == IntPtr.Zero) ? null : new switch_device_stats_t(cPtr, false); + return ret; + } + } + public switch_device_state_t state { set { freeswitchPINVOKE.switch_device_record_t_state_set(swigCPtr, (int)value); @@ -28810,6 +29413,66 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_switch_time_t ring_start { + set { + freeswitchPINVOKE.switch_device_record_t_ring_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t ring_stop { + set { + freeswitchPINVOKE.switch_device_record_t_ring_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_start { + set { + freeswitchPINVOKE.switch_device_record_t_hold_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_stop { + set { + freeswitchPINVOKE.switch_device_record_t_hold_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t call_start { + set { + freeswitchPINVOKE.switch_device_record_t_call_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_call_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public switch_device_node_t uuid_list { set { freeswitchPINVOKE.switch_device_record_t_uuid_list_set(swigCPtr, switch_device_node_t.getCPtr(value)); @@ -28854,6 +29517,17 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_void user_data { + set { + freeswitchPINVOKE.switch_device_record_t_user_data_set(swigCPtr, SWIGTYPE_p_void.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_user_data_get(swigCPtr); + SWIGTYPE_p_void ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_void(cPtr, false); + return ret; + } + } + public switch_device_record_t() : this(freeswitchPINVOKE.new_switch_device_record_t(), true) { } @@ -28862,7 +29536,7 @@ public class switch_device_record_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28882,7 +29556,7 @@ public enum switch_device_state_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -28912,11 +29586,13 @@ public class switch_device_stats_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_device_stats_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_device_stats_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -28931,6 +29607,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint total_in { + set { + freeswitchPINVOKE.switch_device_stats_t_total_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_in_get(swigCPtr); + return ret; + } + } + + public uint total_out { + set { + freeswitchPINVOKE.switch_device_stats_t_total_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_out_get(swigCPtr); + return ret; + } + } + public uint offhook { set { freeswitchPINVOKE.switch_device_stats_t_offhook_set(swigCPtr, value); @@ -28941,6 +29637,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint offhook_in { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_in_get(swigCPtr); + return ret; + } + } + + public uint offhook_out { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_out_get(swigCPtr); + return ret; + } + } + public uint active { set { freeswitchPINVOKE.switch_device_stats_t_active_set(swigCPtr, value); @@ -28951,6 +29667,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint active_in { + set { + freeswitchPINVOKE.switch_device_stats_t_active_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_in_get(swigCPtr); + return ret; + } + } + + public uint active_out { + set { + freeswitchPINVOKE.switch_device_stats_t_active_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_out_get(swigCPtr); + return ret; + } + } + public uint held { set { freeswitchPINVOKE.switch_device_stats_t_held_set(swigCPtr, value); @@ -28961,6 +29697,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint held_in { + set { + freeswitchPINVOKE.switch_device_stats_t_held_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_in_get(swigCPtr); + return ret; + } + } + + public uint held_out { + set { + freeswitchPINVOKE.switch_device_stats_t_held_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_out_get(swigCPtr); + return ret; + } + } + public uint hup { set { freeswitchPINVOKE.switch_device_stats_t_hup_set(swigCPtr, value); @@ -28971,6 +29727,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint hup_in { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_in_get(swigCPtr); + return ret; + } + } + + public uint hup_out { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_out_get(swigCPtr); + return ret; + } + } + public uint ringing { set { freeswitchPINVOKE.switch_device_stats_t_ringing_set(swigCPtr, value); @@ -28981,6 +29757,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint ringing_in { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_in_get(swigCPtr); + return ret; + } + } + + public uint ringing_out { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_out_get(swigCPtr); + return ret; + } + } + public uint early { set { freeswitchPINVOKE.switch_device_stats_t_early_set(swigCPtr, value); @@ -28991,6 +29787,36 @@ public class switch_device_stats_t : IDisposable { } } + public uint early_in { + set { + freeswitchPINVOKE.switch_device_stats_t_early_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_in_get(swigCPtr); + return ret; + } + } + + public uint early_out { + set { + freeswitchPINVOKE.switch_device_stats_t_early_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_out_get(swigCPtr); + return ret; + } + } + + public uint ring_wait { + set { + freeswitchPINVOKE.switch_device_stats_t_ring_wait_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ring_wait_get(swigCPtr); + return ret; + } + } + public switch_device_stats_t() : this(freeswitchPINVOKE.new_switch_device_stats_t(), true) { } @@ -28999,7 +29825,7 @@ public class switch_device_stats_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29029,11 +29855,13 @@ public class switch_dialplan_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_dialplan_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_dialplan_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29121,7 +29949,7 @@ public class switch_dialplan_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29138,7 +29966,7 @@ public enum switch_digit_action_target_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29168,11 +29996,13 @@ public class switch_directories : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_directories(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_directories(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29335,7 +30165,7 @@ public class switch_directories : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29350,7 +30180,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29380,11 +30210,13 @@ public class switch_directory_handle : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_directory_handle(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_directory_handle(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29440,7 +30272,7 @@ public class switch_directory_handle : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29470,11 +30302,13 @@ public class switch_directory_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_directory_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_directory_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29606,7 +30440,7 @@ public class switch_directory_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29622,7 +30456,7 @@ public enum switch_dtmf_direction_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29641,7 +30475,7 @@ public enum switch_dtmf_source_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29671,11 +30505,13 @@ public class switch_dtmf_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_dtmf_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_dtmf_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29728,7 +30564,7 @@ public class switch_dtmf_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29747,7 +30583,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29777,11 +30613,13 @@ public class switch_endpoint_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_endpoint_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_endpoint_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -29902,7 +30740,7 @@ public class switch_endpoint_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -29932,11 +30770,13 @@ public class switch_event : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_event(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_event(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -30074,7 +30914,7 @@ public class switch_event : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30091,7 +30931,7 @@ public enum switch_event_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30121,11 +30961,13 @@ public class switch_event_header : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_event_header(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_event_header(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -30198,7 +31040,7 @@ public class switch_event_header : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30302,7 +31144,7 @@ public enum switch_event_types_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30335,7 +31177,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30365,11 +31207,13 @@ public class switch_file_handle : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_file_handle(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_file_handle(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -30795,12 +31639,12 @@ public class switch_file_handle : IDisposable { } } - public switch_event params { + public switch_event _params { set { - freeswitchPINVOKE.switch_file_handle_params_set(swigCPtr, switch_event.getCPtr(value)); + freeswitchPINVOKE.switch_file_handle__params_set(swigCPtr, switch_event.getCPtr(value)); } get { - IntPtr cPtr = freeswitchPINVOKE.switch_file_handle_params_get(swigCPtr); + IntPtr cPtr = freeswitchPINVOKE.switch_file_handle__params_get(swigCPtr); switch_event ret = (cPtr == IntPtr.Zero) ? null : new switch_event(cPtr, false); return ret; } @@ -30834,7 +31678,7 @@ public class switch_file_handle : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -30864,11 +31708,13 @@ public class switch_file_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_file_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_file_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31064,7 +31910,7 @@ public class switch_file_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31094,11 +31940,13 @@ public class switch_filenames : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_filenames(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_filenames(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31121,7 +31969,7 @@ public class switch_filenames : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31151,11 +31999,13 @@ public class switch_frame : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_frame(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_frame(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31337,6 +32187,17 @@ public class switch_frame : IDisposable { } } + public SWIGTYPE_p_payload_map_t pmap { + set { + freeswitchPINVOKE.switch_frame_pmap_set(swigCPtr, SWIGTYPE_p_payload_map_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_frame_pmap_get(swigCPtr); + SWIGTYPE_p_payload_map_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_payload_map_t(cPtr, false); + return ret; + } + } + public switch_frame() : this(freeswitchPINVOKE.new_switch_frame(), true) { } @@ -31345,7 +32206,7 @@ public class switch_frame : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31371,7 +32232,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31401,11 +32262,13 @@ public class switch_hold_record_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_hold_record_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_hold_record_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31463,7 +32326,7 @@ public class switch_hold_record_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31480,7 +32343,7 @@ public enum switch_hup_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31510,11 +32373,13 @@ public class switch_input_args_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_input_args_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_input_args_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31602,7 +32467,7 @@ public class switch_input_args_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31618,7 +32483,7 @@ public enum switch_input_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31648,11 +32513,13 @@ public class switch_io_event_hook_kill_channel : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_kill_channel(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_kill_channel(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31687,7 +32554,7 @@ public class switch_io_event_hook_kill_channel : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31717,11 +32584,13 @@ public class switch_io_event_hook_outgoing_channel : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_outgoing_channel(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_outgoing_channel(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31756,7 +32625,7 @@ public class switch_io_event_hook_outgoing_channel : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31786,11 +32655,13 @@ public class switch_io_event_hook_read_frame : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_read_frame(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_read_frame(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31825,7 +32696,7 @@ public class switch_io_event_hook_read_frame : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31855,11 +32726,13 @@ public class switch_io_event_hook_receive_event : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_receive_event(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_receive_event(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31894,7 +32767,7 @@ public class switch_io_event_hook_receive_event : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31924,11 +32797,13 @@ public class switch_io_event_hook_receive_message : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_receive_message(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_receive_message(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -31963,7 +32838,7 @@ public class switch_io_event_hook_receive_message : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -31993,11 +32868,13 @@ public class switch_io_event_hook_recv_dtmf : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_recv_dtmf(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_recv_dtmf(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32032,7 +32909,7 @@ public class switch_io_event_hook_recv_dtmf : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32062,11 +32939,13 @@ public class switch_io_event_hooks : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hooks(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hooks(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32211,7 +33090,7 @@ public class switch_io_event_hooks : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32241,11 +33120,13 @@ public class switch_io_event_hook_send_dtmf : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_send_dtmf(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_send_dtmf(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32280,7 +33161,7 @@ public class switch_io_event_hook_send_dtmf : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32310,11 +33191,13 @@ public class switch_io_event_hook_state_change : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_state_change(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_state_change(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32349,7 +33232,7 @@ public class switch_io_event_hook_state_change : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32379,11 +33262,13 @@ public class switch_io_event_hook_state_run : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_state_run(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_state_run(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32418,7 +33303,7 @@ public class switch_io_event_hook_state_run : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32448,11 +33333,13 @@ public class switch_io_event_hook_video_read_frame : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_video_read_frame(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_video_read_frame(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32487,7 +33374,7 @@ public class switch_io_event_hook_video_read_frame : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32517,11 +33404,13 @@ public class switch_io_event_hook_video_write_frame : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_video_write_frame(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_video_write_frame(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32556,7 +33445,7 @@ public class switch_io_event_hook_video_write_frame : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32586,11 +33475,13 @@ public class switch_io_event_hook_write_frame : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_write_frame(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_event_hook_write_frame(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32625,7 +33516,7 @@ public class switch_io_event_hook_write_frame : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32642,7 +33533,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32667,7 +33558,7 @@ public enum switch_io_routine_name_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32697,11 +33588,13 @@ public class switch_io_routines : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_routines(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_io_routines(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32857,7 +33750,7 @@ public class switch_io_routines : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32878,7 +33771,7 @@ public enum switch_ivr_action_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32908,11 +33801,13 @@ public class switch_ivr_dmachine_match : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_ivr_dmachine_match(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_ivr_dmachine_match(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -32977,7 +33872,7 @@ public class switch_ivr_dmachine_match : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -32994,7 +33889,7 @@ public enum switch_ivr_menu_flags { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33011,7 +33906,7 @@ public enum switch_ivr_option_enum_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33041,11 +33936,13 @@ public class switch_json_api_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_json_api_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_json_api_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -33153,7 +34050,7 @@ public class switch_json_api_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33183,11 +34080,13 @@ public class switch_limit_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_limit_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_limit_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -33330,7 +34229,7 @@ public class switch_limit_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33360,11 +34259,13 @@ public class switch_loadable_module_function_table_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_loadable_module_function_table_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_loadable_module_function_table_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -33430,7 +34331,7 @@ public class switch_loadable_module_function_table_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33460,11 +34361,13 @@ public class switch_loadable_module_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_loadable_module_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_loadable_module_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -33695,7 +34598,7 @@ public class switch_loadable_module_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33729,7 +34632,7 @@ public enum switch_log_level_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33759,11 +34662,13 @@ public class switch_log_node_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_log_node_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_log_node_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -33878,7 +34783,7 @@ public class switch_log_node_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33895,7 +34800,7 @@ public enum switch_management_action_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -33925,11 +34830,13 @@ public class switch_management_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_management_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_management_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34017,7 +34924,7 @@ public class switch_management_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34049,7 +34956,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34073,7 +34980,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34089,7 +34996,7 @@ public enum switch_media_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34105,7 +35012,7 @@ public enum switch_module_flag_enum_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34135,7 +35042,7 @@ public enum switch_module_interface_name_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34147,15 +35054,17 @@ namespace FreeSWITCH.Native { SOF_NONE = 0, SOF_NOBLOCK = (1 << 0), SOF_FORKED_DIAL = (1 << 1), - SOF_NO_EFFECTIVE_CID_NUM = (1 << 2), - SOF_NO_EFFECTIVE_CID_NAME = (1 << 3), - SOF_NO_LIMITS = (1 << 4) + SOF_NO_EFFECTIVE_ANI = (1 << 2), + SOF_NO_EFFECTIVE_ANIII = (1 << 3), + SOF_NO_EFFECTIVE_CID_NUM = (1 << 4), + SOF_NO_EFFECTIVE_CID_NAME = (1 << 5), + SOF_NO_LIMITS = (1 << 6) } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34166,13 +35075,15 @@ namespace FreeSWITCH.Native { [System.Flags] public enum switch_port_flag_enum_t { SPF_NONE = 0, SPF_ODD = (1 << 0), - SPF_EVEN = (1 << 1) + SPF_EVEN = (1 << 1), + SPF_ROBUST_TCP = (1 << 2), + SPF_ROBUST_UDP = (1 << 3) } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34189,7 +35100,7 @@ public enum switch_priority_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34205,7 +35116,7 @@ public enum switch_pvt_class_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34222,7 +35133,7 @@ public enum switch_ring_ready_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34252,11 +35163,13 @@ public class switch_rtcp_hdr_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtcp_hdr_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtcp_hdr_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34319,7 +35232,7 @@ public class switch_rtcp_hdr_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34349,11 +35262,13 @@ public class switch_rtcp_numbers_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtcp_numbers_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtcp_numbers_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34396,7 +35311,7 @@ public class switch_rtcp_numbers_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34423,7 +35338,7 @@ public enum switch_rtp_bug_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34442,7 +35357,7 @@ public enum switch_rtp_crypto_direction_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34472,11 +35387,13 @@ public class switch_rtp_crypto_key : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtp_crypto_key(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtp_crypto_key(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34543,7 +35460,7 @@ public class switch_rtp_crypto_key : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34562,7 +35479,7 @@ public enum switch_rtp_crypto_key_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34572,6 +35489,7 @@ namespace FreeSWITCH.Native { public enum switch_rtp_flag_t { SWITCH_RTP_FLAG_NOBLOCK = 0, + SWITCH_RTP_FLAG_DTMF_ON, SWITCH_RTP_FLAG_IO, SWITCH_RTP_FLAG_USE_TIMER, SWITCH_RTP_FLAG_RTCP_PASSTHRU, @@ -34605,13 +35523,16 @@ public enum switch_rtp_flag_t { SWITCH_RTP_FLAG_RTCP_MUX, SWITCH_RTP_FLAG_KILL_JB, SWITCH_RTP_FLAG_VIDEO_BREAK, + SWITCH_RTP_FLAG_PAUSE, + SWITCH_RTP_FLAG_FIR, + SWITCH_RTP_FLAG_PLI, SWITCH_RTP_FLAG_INVALID } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34628,7 +35549,7 @@ public enum switch_rtp_flush_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34658,11 +35579,13 @@ public class switch_rtp_hdr_ext_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtp_hdr_ext_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtp_hdr_ext_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34695,7 +35618,7 @@ public class switch_rtp_hdr_ext_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34725,11 +35648,13 @@ public class switch_rtp_hdr_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtp_hdr_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtp_hdr_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -34832,7 +35757,7 @@ public class switch_rtp_hdr_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -34862,11 +35787,13 @@ public class switch_rtp_numbers_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtp_numbers_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtp_numbers_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35003,6 +35930,201 @@ public class switch_rtp_numbers_t : IDisposable { } } + public long last_proc_time { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_proc_time_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_proc_time_get(swigCPtr); + return ret; + } + } + + public long jitter_n { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_n_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_n_get(swigCPtr); + return ret; + } + } + + public long jitter_add { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_add_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_add_get(swigCPtr); + return ret; + } + } + + public long jitter_addsq { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_jitter_addsq_set(swigCPtr, value); + } + get { + long ret = freeswitchPINVOKE.switch_rtp_numbers_t_jitter_addsq_get(swigCPtr); + return ret; + } + } + + public double variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_variance_get(swigCPtr); + return ret; + } + } + + public double min_variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_min_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_min_variance_get(swigCPtr); + return ret; + } + } + + public double max_variance { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_max_variance_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_max_variance_get(swigCPtr); + return ret; + } + } + + public double std_deviation { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_std_deviation_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_std_deviation_get(swigCPtr); + return ret; + } + } + + public double lossrate { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_lossrate_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_lossrate_get(swigCPtr); + return ret; + } + } + + public double burstrate { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_burstrate_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_burstrate_get(swigCPtr); + return ret; + } + } + + public double mean_interval { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_mean_interval_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_mean_interval_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_int loss { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_loss_set(swigCPtr, SWIGTYPE_p_int.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_rtp_numbers_t_loss_get(swigCPtr); + SWIGTYPE_p_int ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_int(cPtr, false); + return ret; + } + } + + public int last_loss { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_loss_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_loss_get(swigCPtr); + return ret; + } + } + + public int recved { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_recved_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_recved_get(swigCPtr); + return ret; + } + } + + public int last_processed_seq { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_processed_seq_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_rtp_numbers_t_last_processed_seq_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t flaws { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_flaws_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_rtp_numbers_t_flaws_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t last_flaw { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_last_flaw_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_rtp_numbers_t_last_flaw_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public double R { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_R_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_R_get(swigCPtr); + return ret; + } + } + + public double mos { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_mos_set(swigCPtr, value); + } + get { + double ret = freeswitchPINVOKE.switch_rtp_numbers_t_mos_get(swigCPtr); + return ret; + } + } + public switch_rtp_numbers_t() : this(freeswitchPINVOKE.new_switch_rtp_numbers_t(), true) { } @@ -35011,7 +36133,7 @@ public class switch_rtp_numbers_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35041,11 +36163,13 @@ public class switch_rtp_stats_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_rtp_stats_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_rtp_stats_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35101,7 +36225,7 @@ public class switch_rtp_stats_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35131,11 +36255,13 @@ public class switch_say_args_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_say_args_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_say_args_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35188,7 +36314,7 @@ public class switch_say_args_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35199,13 +36325,14 @@ namespace FreeSWITCH.Native { public enum switch_say_gender_t { SSG_MASCULINE, SSG_FEMININE, - SSG_NEUTER + SSG_NEUTER, + SSG_UTRUM } } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35235,11 +36362,13 @@ public class switch_say_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_say_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_say_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35338,7 +36467,7 @@ public class switch_say_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35357,7 +36486,7 @@ public enum switch_say_method_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35390,7 +36519,7 @@ public enum switch_say_type_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35408,7 +36537,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35438,11 +36567,13 @@ public class switch_scheduler_task : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_scheduler_task(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_scheduler_task(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35518,6 +36649,16 @@ public class switch_scheduler_task : IDisposable { } } + public uint hash { + set { + freeswitchPINVOKE.switch_scheduler_task_hash_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_scheduler_task_hash_get(swigCPtr); + return ret; + } + } + public switch_scheduler_task() : this(freeswitchPINVOKE.new_switch_scheduler_task(), true) { } @@ -35526,7 +36667,7 @@ public class switch_scheduler_task : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35556,11 +36697,13 @@ public class switch_serial_event_header_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_serial_event_header_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_serial_event_header_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35593,7 +36736,7 @@ public class switch_serial_event_header_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35623,11 +36766,13 @@ public class switch_serial_event_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_serial_event_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_serial_event_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35700,7 +36845,7 @@ public class switch_serial_event_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35756,7 +36901,7 @@ public enum switch_session_ctl_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35774,7 +36919,7 @@ public enum switch_signal_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35804,11 +36949,13 @@ public class switch_slin_data : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_slin_data(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_slin_data(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -35864,7 +37011,7 @@ public class switch_slin_data : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35886,7 +37033,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -35916,11 +37063,13 @@ public class switch_speech_handle : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_speech_handle(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_speech_handle(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -36111,7 +37260,7 @@ public class switch_speech_handle : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36141,11 +37290,13 @@ public class switch_speech_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_speech_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_speech_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -36310,7 +37461,7 @@ public class switch_speech_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36329,7 +37480,7 @@ public enum switch_stack_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36344,7 +37495,7 @@ public enum switch_state_handler_flag_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36370,7 +37521,7 @@ public enum switch_state_handler_name_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36400,11 +37551,13 @@ public class switch_state_handler_table : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_state_handler_table(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_state_handler_table(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -36570,7 +37723,7 @@ public class switch_state_handler_table : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36609,7 +37762,7 @@ public enum switch_status_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36639,11 +37792,13 @@ public class switch_stream_handle : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_stream_handle(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_stream_handle(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -36759,7 +37914,7 @@ public class switch_stream_handle : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36789,11 +37944,13 @@ public class switch_t38_options_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_t38_options_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_t38_options_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -36956,7 +38113,7 @@ public class switch_t38_options_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -36974,7 +38131,7 @@ public enum switch_text_channel_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37004,11 +38161,13 @@ public class switch_thread_data_t : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_thread_data_t(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_thread_data_t(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -37065,7 +38224,7 @@ public class switch_thread_data_t : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37083,7 +38242,7 @@ public enum switch_thread_priority_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37113,11 +38272,13 @@ public class switch_timer : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_timer(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_timer(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -37227,7 +38388,7 @@ public class switch_timer : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37242,7 +38403,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37262,7 +38423,7 @@ public enum switch_timer_func_name_t { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37292,11 +38453,13 @@ public class switch_timer_interface : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_timer_interface(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_timer_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -37439,7 +38602,7 @@ public class switch_timer_interface : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37469,11 +38632,13 @@ public class switch_unicast_conninfo : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_unicast_conninfo(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_unicast_conninfo(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -37654,7 +38819,7 @@ public class switch_unicast_conninfo : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37672,7 +38837,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37689,7 +38854,7 @@ public enum switch_uri_flags { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37707,7 +38872,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37737,11 +38902,13 @@ public class switch_xml : IDisposable { public virtual void Dispose() { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_xml(swigCPtr); + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_xml(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } @@ -37890,7 +39057,7 @@ public class switch_xml : IDisposable { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -37908,7 +39075,7 @@ namespace FreeSWITCH.Native { } /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 2.0.7 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/mod/languages/mod_managed/mod_managed.2012.vcxproj b/src/mod/languages/mod_managed/mod_managed.2012.vcxproj index 2eb9aedb7d..9d35cafdab 100644 --- a/src/mod/languages/mod_managed/mod_managed.2012.vcxproj +++ b/src/mod/languages/mod_managed/mod_managed.2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -164,6 +164,7 @@ false true + /ignore:4248 %(AdditionalOptions) @@ -186,6 +187,7 @@ true false MachineX64 + /ignore:4248 %(AdditionalOptions) @@ -203,6 +205,7 @@ true true true + /ignore:4248 %(AdditionalOptions) @@ -224,6 +227,7 @@ true true MachineX64 + /ignore:4248 %(AdditionalOptions) @@ -244,6 +248,7 @@ false + /ignore:4248 %(AdditionalOptions) @@ -268,6 +273,7 @@ false MachineX64 + /ignore:4248 %(AdditionalOptions) @@ -287,6 +293,7 @@ true true true + /ignore:4248 %(AdditionalOptions) @@ -310,6 +317,7 @@ true true MachineX64 + /ignore:4248 %(AdditionalOptions) diff --git a/src/mod/languages/mod_perl/mod_perl.c b/src/mod/languages/mod_perl/mod_perl.c index 3ee3e52a7e..dfd47dfeb8 100644 --- a/src/mod/languages/mod_perl/mod_perl.c +++ b/src/mod/languages/mod_perl/mod_perl.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index 0757fcd85c..a7c2a690bd 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -8195,7 +8195,7 @@ XS(_wrap_msleep) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "msleep" "', argument " "1"" of type '" "unsigned int""'"); } arg1 = static_cast< unsigned int >(val1); - msleep(arg1); + switch_msleep(arg1); XSRETURN(argvi); diff --git a/src/mod/languages/mod_python/hack.diff b/src/mod/languages/mod_python/hack.diff index 593e01aa27..9e50d93ba1 100644 --- a/src/mod/languages/mod_python/hack.diff +++ b/src/mod/languages/mod_python/hack.diff @@ -1,28 +1,16 @@ -Index: mod_python_wrap.cpp -=================================================================== ---- mod_python_wrap.cpp (revision 16581) -+++ mod_python_wrap.cpp (working copy) -@@ -5555,7 +5555,9 @@ - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "EventConsumer_pop" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); -+ Py_BEGIN_ALLOW_THREADS; - result = (Event *)(arg1)->pop(arg2); -+ Py_END_ALLOW_THREADS; - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN | 0 ); - return resultobj; - fail: -@@ -5577,7 +5579,9 @@ - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EventConsumer_pop" "', argument " "1"" of type '" "EventConsumer *""'"); +--- mod_python_wrap_patched.cpp 2013-12-23 23:19:43.308488527 +0500 ++++ mod_python_wrap.cpp 2013-12-23 23:19:37.572488834 +0500 +@@ -5585,7 +5585,9 @@ + } + arg3 = static_cast< int >(val3); } - arg1 = reinterpret_cast< EventConsumer * >(argp1); + Py_BEGIN_ALLOW_THREADS; - result = (Event *)(arg1)->pop(); + result = (Event *)(arg1)->pop(arg2,arg3); + Py_END_ALLOW_THREADS; resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN | 0 ); return resultobj; fail: -@@ -9560,20 +9564,20 @@ +@@ -8515,20 +8517,20 @@ } @@ -46,7 +34,7 @@ Index: mod_python_wrap.cpp PyObject *resultobj = 0; char *arg1 = (char *) 0 ; CoreSession *arg2 = (CoreSession *) 0 ; -@@ -9598,7 +9602,7 @@ +@@ -8553,7 +8555,7 @@ } arg2 = reinterpret_cast< CoreSession * >(argp2); result = (PYTHON::Session *)new PYTHON::Session(arg1,arg2); @@ -55,7 +43,7 @@ Index: mod_python_wrap.cpp if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: -@@ -9607,7 +9611,7 @@ +@@ -8562,7 +8564,7 @@ } @@ -64,7 +52,7 @@ Index: mod_python_wrap.cpp PyObject *resultobj = 0; char *arg1 = (char *) 0 ; PYTHON::Session *result = 0 ; -@@ -9623,7 +9627,7 @@ +@@ -8578,7 +8580,7 @@ } arg1 = reinterpret_cast< char * >(buf1); result = (PYTHON::Session *)new PYTHON::Session(arg1); @@ -73,7 +61,7 @@ Index: mod_python_wrap.cpp if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: -@@ -9632,7 +9636,7 @@ +@@ -8587,7 +8589,7 @@ } @@ -82,7 +70,7 @@ Index: mod_python_wrap.cpp PyObject *resultobj = 0; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; PYTHON::Session *result = 0 ; -@@ -9647,7 +9651,7 @@ +@@ -8602,7 +8604,7 @@ } arg1 = reinterpret_cast< switch_core_session_t * >(argp1); result = (PYTHON::Session *)new PYTHON::Session(arg1); diff --git a/src/mod/languages/mod_python/mod_python.c b/src/mod/languages/mod_python/mod_python.c index d4d74d2c95..af53ab2107 100644 --- a/src/mod/languages/mod_python/mod_python.c +++ b/src/mod/languages/mod_python/mod_python.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index b7379edb7d..8db6cc0c8f 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -5596,7 +5596,9 @@ SWIGINTERN PyObject *_wrap_EventConsumer_pop(PyObject *SWIGUNUSEDPARM(self), PyO } arg3 = static_cast< int >(val3); } + Py_BEGIN_ALLOW_THREADS; result = (Event *)(arg1)->pop(arg2,arg3); + Py_END_ALLOW_THREADS; resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN | 0 ); return resultobj; fail: @@ -8398,7 +8400,7 @@ SWIGINTERN PyObject *_wrap_msleep(PyObject *SWIGUNUSEDPARM(self), PyObject *args SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "msleep" "', argument " "1"" of type '" "unsigned int""'"); } arg1 = static_cast< unsigned int >(val1); - msleep(arg1); + switch_msleep(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 2cb9947e56..47baa2df79 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * @@ -1491,7 +1491,7 @@ static JSBool session_recordfile(JSContext * cx, JSObject * obj, uintN argc, jsv check_hangup_hook(jss, &ret); *rval = cb_state.ret; - return ret; + return (JSBool)ret; } static JSBool session_collect_input(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -1550,7 +1550,7 @@ static JSBool session_collect_input(JSContext * cx, JSObject * obj, uintN argc, check_hangup_hook(jss, &ret); *rval = cb_state.ret; - return ret; + return (JSBool)ret; } /* session.sayphrase(phrase_name, phrase_data, language, dtmf_callback, dtmf_callback_args)*/ @@ -1626,7 +1626,7 @@ static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsva check_hangup_hook(jss, &ret); *rval = cb_state.ret; - return ret; + return (JSBool)ret; } static jsval check_hangup_hook(struct js_session *jss, jsval * rp) @@ -1770,7 +1770,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv switch_snprintf(posbuf, sizeof(posbuf), "%u", fh.offset_pos); switch_channel_set_variable(channel, "last_file_position", posbuf); - return ret; + return (JSBool)ret; } @@ -1834,7 +1834,7 @@ static JSBool session_sleep(JSContext * cx, JSObject * obj, uintN argc, jsval * check_hangup_hook(jss, &ret); *rval = cb_state.ret; - return ret; + return (JSBool)ret; } static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -2028,7 +2028,7 @@ static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval * check_hangup_hook(jss, &ret); *rval = cb_state.ret; - return ret; + return (JSBool)ret; } static JSBool session_get_digits(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -2228,7 +2228,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, JS_ResumeRequest(cx, saveDepth); check_hangup_hook(jss, &ret); - return ret; + return (JSBool)ret; } static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -2274,7 +2274,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc } JS_ResumeRequest(cx, saveDepth); check_hangup_hook(jss, &ret); - return ret; + return (JSBool)ret; } static JSBool session_detach(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -2311,7 +2311,7 @@ static JSBool session_detach(JSContext * cx, JSObject * obj, uintN argc, jsval * *rval = JS_FALSE; } - return ret; + return (JSBool)ret; } static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) @@ -2354,7 +2354,7 @@ static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval } *rval = BOOLEAN_TO_JSVAL(retval); - return ret; + return (JSBool)ret; } static JSBool session_get_event(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h index 78e543dedb..406fe34441 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c index e028187e72..caa72fb5c2 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c index b9a8431eb9..a704a32c26 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c index 8cb93cec5d..64ec16aaff 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c index 7688eb6593..54140c5084 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c index 8192e72d9f..1a7640d667 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2014, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/languages/mod_v8/Makefile.am b/src/mod/languages/mod_v8/Makefile.am new file mode 100644 index 0000000000..7355a47251 --- /dev/null +++ b/src/mod/languages/mod_v8/Makefile.am @@ -0,0 +1,158 @@ +include $(top_srcdir)/build/modmake.rulesam + +AUTOMAKE_OPTIONS = foreign + +# V8 version to use +V8=v8-3.24.14 + +V8_DIR=$(switch_srcdir)/libs/$(V8) +V8_BUILDDIR=$(switch_builddir)/libs/$(V8) + +if ISMAC +V8_LIBDIR=$(V8_DIR)/out/native +V8_LIBEXT=dylib +# Build with snapshot doesn't work for OSX right now +V8_BUILDPARAMS=snapshot=off i18nsupport=off +V8_SNAPSHOT=nosnapshot +else +V8_LIBDIR=$(V8_DIR)/out/native/lib.target +V8_LIBEXT=so +# Some gcc versions report warnings incorrectly +V8_BUILDPARAMS=strictaliasing=off werror=no i18nsupport=off +V8_SNAPSHOT=snapshot +endif + +if ENABLE_STATIC_V8 +# Build the static lib version of V8 +if ISMAC +V8_STATIC_DIR=$(V8_DIR)/out/native +V8_ICU_STATIC_DIR=$(V8_DIR)/out/native +V8_CXXFLAGS = +else +V8_STATIC_DIR=$(V8_DIR)/out/native/obj.target/tools/gyp +V8_ICU_STATIC_DIR=$(V8_DIR)/out/native/obj.target/third_party/icu +V8_CXXFLAGS = -fPIC +endif +V8LIB=$(V8_STATIC_DIR)/libv8_base*.a +else +# Build the dynamic lib version of V8 +V8_BUILDPARAMS += library=shared +V8LIB=$(V8_LIBDIR)/libv8.$(V8_LIBEXT) +endif + +# Try to find the target platform for our configured CXX compiler +# Parse the result one extra time to handle different i386 platforms (i386, i486 etc) +CXX_TARGET_PLATFORM := $(shell $(CXX) -v 2>&1 | grep Target | cut '-d:' -f2 | cut '-d-' -f1 | tr -d ' ') +CXX_TARGET_PLATFORM_I386 := $(shell echo "$(CXX_TARGET_PLATFORM)" | sed 's/^\(.\{1\}\)\(.\{1\}\)/\13/') + +CURL_DIR=$(switch_srcdir)/libs/curl +CURL_BUILDDIR=$(switch_builddir)/libs/curl +CURLLA=${switch_builddir}/libs/curl/lib/libcurl.la + +MODNAME=mod_v8 + +AM_CFLAGS += -I. -I./include -I$(V8_DIR)/include +AM_CPPFLAGS += -I. -I./include -I$(V8_DIR)/include +AM_LDFLAGS += -avoid-version -module -no-undefined -shared + +if ENABLE_STATIC_V8 +AM_LIBADD = $(switch_builddir)/libfreeswitch.la +V8_LDFLAGS = $(V8_STATIC_DIR)/libv8_{base*,$(V8_SNAPSHOT)*}.a $(SOLINK) #$(V8_ICU_STATIC_DIR)/libicu{i18n,uc,data}.a $(SOLINK) +else +AM_LIBADD = $(switch_builddir)/libfreeswitch.la -lv8 #-licuuc -licui18n +AM_LDFLAGS += -L$(V8_LIBDIR) +endif + +BUILT_SOURCES = $(V8LIB) $(LIBCURL_DEPS) + +if HAVE_ODBC +AM_CFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS) +AM_CPPFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS) +AM_LDFLAGS += -DHAVE_ODBC -lodbc +endif + +mod_LTLIBRARIES = mod_v8.la + +mod_v8_la_SOURCES = \ + mod_v8.cpp \ + src/jsmain.cpp \ + src/jsbase.cpp \ + src/fscoredb.cpp \ + src/fscurl.cpp \ + src/fsdtmf.cpp \ + src/fsevent.cpp \ + src/fsfileio.cpp \ + src/fsglobal.cpp \ + src/fsodbc.cpp \ + src/fspcre.cpp \ + src/fsrequest.cpp \ + src/fssession.cpp \ + src/fssocket.cpp \ + src/fsteletone.cpp \ + src/fsxml.cpp \ + src/fsfile.cpp \ + src/fseventhandler.cpp + +mod_v8_la_CFLAGS = $(AM_CFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src +mod_v8_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src +mod_v8_la_LIBADD = $(AM_LIBADD) +mod_v8_la_LDFLAGS = $(AM_LDFLAGS) $(LIBCURL) $(V8_LDFLAGS) + +#mod_LTLIBRARIES += mod_v8_skel.la +#mod_v8_skel_la_SOURCES = mod_v8_skel.cpp +#mod_v8_skel_la_CFLAGS = $(AM_CFLAGS) -DJSMOD_IMPORT +#mod_v8_skel_la_CPPFLAGS = $(AM_CPPFLAGS) -DJSMOD_IMPORT +#mod_v8_skel_la_LIBADD = $(AM_LIBADD) +#mod_v8_skel_la_LDFLAGS = $(AM_LDFLAGS) + +$(SOURCES): $(BUILT_SOURCES) + +$(V8_DIR): + $(GETLIB) $(V8).tar.bz2 +if ISFREEBSD + /bin/cp -f gyp $(V8_DIR)/build/gyp +endif + +$(V8LIB): $(V8_DIR) + if test "$(CXX_TARGET_PLATFORM)" = "x86_64"; then \ + defines="v8_target_arch=x64 target_arch=x64"; \ + else \ + if test "$(CXX_TARGET_PLATFORM)" = "arm"; then \ + defines="v8_target_arch=arm target_arch=arm"; \ + else \ + if test "$(CXX_TARGET_PLATFORM_I386)" = "i386"; then \ + defines="v8_target_arch=ia32 target_arch=ia32"; \ + fi; \ + fi; \ + fi; \ + cd $(V8_BUILDDIR) && CFLAGS="$(V8_CXXFLAGS)" CXXFLAGS="$(V8_CXXFLAGS)" \ + LINK=@CXX@ CXX=@CXX@ GYPFLAGS="--no-parallel" GYP_DEFINES="$$defines" \ + PYTHONPATH="$(V8_BUILDDIR)/build/gyp/pylib:$(PYTHONPATH)" $(MAKE) $(V8_BUILDPARAMS) native + +$(CURLLA): + @cd $(CURL_BUILDDIR) && $(MAKE) + $(TOUCH_TARGET) + +if ENABLE_STATIC_V8 +install-exec-local: $(V8LIB) +else +# This is a temporary solution to force Mac OSX build to load the libraries at the right place +if ISMAC +install-exec-local: $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) + install_name_tool -change /usr/local/lib/libv8.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) .libs/mod_v8.so +# install_name_tool -change /usr/local/lib/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) .libs/mod_v8.so +# install_name_tool -change /usr/local/lib/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) .libs/mod_v8.so + install_name_tool -change /usr/local/lib/libv8.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) +# install_name_tool -change /usr/local/lib/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) +# install_name_tool -change /usr/local/lib/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) +# install_name_tool -change /usr/local/lib/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) +# install_name_tool -change /usr/local/lib/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) +# install_name_tool -change /usr/local/lib/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) +else +install-exec-local: $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) +endif +$(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT): $(V8LIB) + rm -f $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libv8.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) +# rm -f $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) +# rm -f $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) +endif diff --git a/src/mod/languages/mod_v8/conf/autoload_configs/v8.conf.xml b/src/mod/languages/mod_v8/conf/autoload_configs/v8.conf.xml new file mode 100644 index 0000000000..01c9e2bd99 --- /dev/null +++ b/src/mod/languages/mod_v8/conf/autoload_configs/v8.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/mod/languages/mod_v8/gyp b/src/mod/languages/mod_v8/gyp new file mode 100755 index 0000000000..3d82e147f8 --- /dev/null +++ b/src/mod/languages/mod_v8/gyp @@ -0,0 +1,18 @@ +#!/usr/bin/env python2 + +# Copyright (c) 2009 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import sys + +# TODO(mark): sys.path manipulation is some temporary testing stuff. +try: + import gyp +except ImportError, e: + import os.path + sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) + import gyp + +if __name__ == '__main__': + sys.exit(gyp.main(sys.argv[1:])) diff --git a/src/mod/languages/mod_v8/include/fscoredb.hpp b/src/mod/languages/mod_v8/include/fscoredb.hpp new file mode 100644 index 0000000000..5ac0a052b5 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fscoredb.hpp @@ -0,0 +1,89 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fscoredb.hpp -- JavaScript CoreDB class header + * + */ + +#ifndef FS_COREDB_H +#define FS_COREDB_H + +#include "mod_v8.h" + +/* Macros for easier V8 callback definitions */ +#define JS_COREDB_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSCoreDB) +#define JS_COREDB_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSCoreDB) +#define JS_COREDB_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSCoreDB) +#define JS_COREDB_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSCoreDB) +#define JS_COREDB_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSCoreDB) +#define JS_COREDB_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSCoreDB) + +class FSCoreDB : public JSBase +{ +private: + switch_memory_pool_t *_pool; + switch_core_db_t *_db; + switch_core_db_stmt_t *_stmt; + const char *_dbname; + v8::Persistent _callback; + + void Init(); + void DoClose(); + void StepEx(const v8::FunctionCallbackInfo& info, int stepSuccessCode); + static int Callback(void *pArg, int argc, char **argv, char **columnNames); +public: + FSCoreDB(JSMain *owner) : JSBase(owner) { Init(); } + FSCoreDB(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSCoreDB(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_COREDB_FUNCTION_DEF(Exec); + JS_COREDB_FUNCTION_DEF(Close); + JS_COREDB_FUNCTION_DEF(Next); + JS_COREDB_FUNCTION_DEF(Step); + JS_COREDB_FUNCTION_DEF(Fetch); + JS_COREDB_FUNCTION_DEF(Prepare); + JS_COREDB_FUNCTION_DEF(BindText); + JS_COREDB_FUNCTION_DEF(BindInt); + JS_COREDB_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_COREDB_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fscurl.hpp b/src/mod/languages/mod_v8/include/fscurl.hpp new file mode 100644 index 0000000000..0a01d264d4 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fscurl.hpp @@ -0,0 +1,79 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fscurl.hpp -- JavaScript CURL class header + * + */ + +#ifndef FS_CURL_H +#define FS_CURL_H + +#include "mod_v8.h" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_CURL_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSCURL) +#define JS_CURL_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSCURL) +#define JS_CURL_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSCURL) +#define JS_CURL_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSCURL) +#define JS_CURL_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSCURL) +#define JS_CURL_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSCURL) + +class FSCURL : public JSBase +{ +private: + switch_CURL *_curl_handle; + v8::Persistent _function; + v8::Persistent _user_data; + v8::Persistent _ret; + + void Init(void); + static size_t FileCallback(void *ptr, size_t size, size_t nmemb, void *data); +public: + FSCURL(JSMain *owner) : JSBase(owner) { Init(); } + FSCURL(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSCURL(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_CURL_FUNCTION_DEF(Run); +}; + +#endif /* FS_CURL_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsdtmf.hpp b/src/mod/languages/mod_v8/include/fsdtmf.hpp new file mode 100644 index 0000000000..c931390cea --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsdtmf.hpp @@ -0,0 +1,74 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsdtmf.hpp -- JavaScript DTMF class header + * + */ + +#ifndef FS_DTMF_H +#define FS_DTMF_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_DTMF_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSDTMF) +#define JS_DTMF_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSDTMF) +#define JS_DTMF_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSDTMF) +#define JS_DTMF_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSDTMF) +#define JS_DTMF_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSDTMF) +#define JS_DTMF_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSDTMF) + +class FSDTMF : public JSBase +{ +private: + switch_dtmf_t *_dtmf; +public: + FSDTMF(JSMain *owner) : JSBase(owner) { _dtmf = NULL; } + FSDTMF(const v8::FunctionCallbackInfo& info) : JSBase(info) { _dtmf = NULL; } + virtual ~FSDTMF(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + static v8::Handle New(switch_dtmf_t *dtmf, const char *name, JSMain *js); + JS_DTMF_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_DTMF_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsevent.hpp b/src/mod/languages/mod_v8/include/fsevent.hpp new file mode 100644 index 0000000000..53336aede2 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsevent.hpp @@ -0,0 +1,95 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsevent.hpp -- JavaScript Event class header + * + */ + +#ifndef FS_EVENT_H +#define FS_EVENT_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_EVENT_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSEvent) +#define JS_EVENT_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSEvent) +#define JS_EVENT_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSEvent) +#define JS_EVENT_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSEvent) +#define JS_EVENT_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSEvent) +#define JS_EVENT_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSEvent) + +#define JS_EVENT_GET_PROPERTY_IMPL_STATIC(method_name) JS_GET_PROPERTY_IMPL_STATIC(method_name, FSEvent) +#define JS_EVENT_SET_PROPERTY_IMPL_STATIC(method_name) JS_SET_PROPERTY_IMPL_STATIC(method_name, FSEvent) +#define JS_EVENT_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSEvent) + +class FSEvent : public JSBase +{ +private: + switch_event_t *_event; + int _freed; + + void Init(); + bool IsArray(const char *var); +public: + FSEvent(JSMain *owner) : JSBase(owner) { Init(); } + FSEvent(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSEvent(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + void SetEvent(switch_event_t *event, int freed = 0); + switch_event_t **GetEvent(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + static v8::Handle New(switch_event_t *event, const char *name, JSMain *js); + JS_EVENT_FUNCTION_DEF(AddHeader); + JS_EVENT_FUNCTION_DEF(GetHeader); + JS_EVENT_FUNCTION_DEF(IsArrayHeader); + JS_EVENT_FUNCTION_DEF(AddBody); + JS_EVENT_FUNCTION_DEF(GetBody); + JS_EVENT_FUNCTION_DEF(GetType); + JS_EVENT_FUNCTION_DEF(Serialize); + JS_EVENT_FUNCTION_DEF(ChatExecute); + JS_FUNCTION_DEF_STATIC(Fire); // This will also destroy the C++ object + JS_FUNCTION_DEF_STATIC(Destroy); // This will also destroy the C++ object + JS_EVENT_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_EVENT_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fseventhandler.hpp b/src/mod/languages/mod_v8/include/fseventhandler.hpp new file mode 100644 index 0000000000..cfc9c37bd2 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fseventhandler.hpp @@ -0,0 +1,94 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fseventhandler.hpp -- JavaScript EventHandler class header + * + */ + +#ifndef FS_EVENTHANDLER_H +#define FS_EVENTHANDLER_H + +#include "mod_v8.h" + +/* Macros for easier V8 callback definitions */ +#define JS_EVENTHANDLER_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSEventHandler) +#define JS_EVENTHANDLER_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSEventHandler) +#define JS_EVENTHANDLER_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSEventHandler) +#define JS_EVENTHANDLER_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSEventHandler) +#define JS_EVENTHANDLER_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSEventHandler) +#define JS_EVENTHANDLER_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSEventHandler) +#define JS_EVENTHANDLER_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSEventHandler) +#define JS_EVENTHANDLER_GET_PROPERTY_IMPL_STATIC(method_name) JS_GET_PROPERTY_IMPL_STATIC(method_name, FSEventHandler) + +class FSEventHandler : public JSBase +{ +private: + switch_mutex_t *_mutex; + switch_memory_pool_t *_pool; + switch_hash_t *_event_hash; + switch_queue_t *_event_queue; + uint8_t _event_list[SWITCH_EVENT_ALL + 1]; + switch_event_t *_filters; + + void Init(); + void DoSubscribe(const v8::FunctionCallbackInfo& info); +public: + FSEventHandler(JSMain *owner) : JSBase(owner) { Init(); } + FSEventHandler(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSEventHandler(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Public method to queue an event to this instance */ + void QueueEvent(switch_event_t *event); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_EVENTHANDLER_FUNCTION_DEF(Subscribe); + JS_EVENTHANDLER_FUNCTION_DEF(UnSubscribe); + JS_EVENTHANDLER_FUNCTION_DEF(AddFilter); + JS_EVENTHANDLER_FUNCTION_DEF(DeleteFilter); + JS_EVENTHANDLER_FUNCTION_DEF(GetEvent); + JS_EVENTHANDLER_FUNCTION_DEF(SendEvent); + JS_EVENTHANDLER_FUNCTION_DEF(ExecuteApi); + JS_EVENTHANDLER_FUNCTION_DEF(ExecuteBgApi); + JS_FUNCTION_DEF_STATIC(Destroy); + JS_GET_PROPERTY_DEF_STATIC(GetReadyProperty); +}; + +#endif /* FS_EVENTHANDLER_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsfile.hpp b/src/mod/languages/mod_v8/include/fsfile.hpp new file mode 100644 index 0000000000..7f98e13b5e --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsfile.hpp @@ -0,0 +1,111 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsfile.hpp -- JavaScript File class header + * + */ + +#ifndef FS_FILE_H +#define FS_FILE_H + +#include "mod_v8.h" + +/* Macros for easier V8 callback definitions */ +#define JS_FILE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSFile) +#define JS_FILE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSFile) +#define JS_FILE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSFile) +#define JS_FILE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSFile) +#define JS_FILE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSFile) +#define JS_FILE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSFile) + +class FSFile : public JSBase +{ +private: + void Init(); +public: + FSFile(JSMain *owner) : JSBase(owner) { } + FSFile(const v8::FunctionCallbackInfo& info) : JSBase(info) { } + virtual ~FSFile(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_FILE_FUNCTION_DEF(Close); + JS_FILE_FUNCTION_DEF(CopyTo); + JS_FILE_FUNCTION_DEF(Flush); + JS_FILE_FUNCTION_DEF(List); + JS_FILE_FUNCTION_DEF(MkDir); + JS_FILE_FUNCTION_DEF(Open); + JS_FILE_FUNCTION_DEF(Read); + JS_FILE_FUNCTION_DEF(ReadAll); + JS_FILE_FUNCTION_DEF(ReadLn); + JS_FILE_FUNCTION_DEF(Remove); + JS_FILE_FUNCTION_DEF(RenameTo); + JS_FILE_FUNCTION_DEF(Seek); + JS_FILE_FUNCTION_DEF(ToString); + JS_FILE_FUNCTION_DEF(ToURL); + JS_FILE_FUNCTION_DEF(Write); + JS_FILE_FUNCTION_DEF(WriteAll); + JS_FILE_FUNCTION_DEF(WriteLn); + + JS_FILE_GET_PROPERTY_DEF(GetPropCanAppend); + JS_FILE_GET_PROPERTY_DEF(GetPropCanRead); + JS_FILE_GET_PROPERTY_DEF(GetPropCanReplace); + JS_FILE_GET_PROPERTY_DEF(GetPropCanWrite); + JS_FILE_GET_PROPERTY_DEF(GetPropCreationTime); + JS_FILE_GET_PROPERTY_DEF(GetPropExists); + JS_FILE_GET_PROPERTY_DEF(GetPropHasAutoFlush); + JS_FILE_GET_PROPERTY_DEF(GetPropHasRandomAccess); + JS_FILE_GET_PROPERTY_DEF(GetPropIsDirectory); + JS_FILE_GET_PROPERTY_DEF(GetPropIsFile); + JS_FILE_GET_PROPERTY_DEF(GetPropIsNative); + JS_FILE_GET_PROPERTY_DEF(GetPropIsOpen); + JS_FILE_GET_PROPERTY_DEF(GetPropLastModified); + JS_FILE_GET_PROPERTY_DEF(GetPropLength); + JS_FILE_GET_PROPERTY_DEF(GetPropMode); + JS_FILE_GET_PROPERTY_DEF(GetPropName); + JS_FILE_GET_PROPERTY_DEF(GetPropParent); + JS_FILE_GET_PROPERTY_DEF(GetPropPath); + JS_FILE_GET_PROPERTY_DEF(GetPropPosition); + JS_FILE_SET_PROPERTY_DEF(SetPropPosition); + JS_FILE_GET_PROPERTY_DEF(GetPropSize); + JS_FILE_GET_PROPERTY_DEF(GetPropType); +}; + +#endif /* FS_FILE_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsfileio.hpp b/src/mod/languages/mod_v8/include/fsfileio.hpp new file mode 100644 index 0000000000..05a4d220db --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsfileio.hpp @@ -0,0 +1,84 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsfileio.hpp -- JavaScript FileIO class header + * + */ + +#ifndef FS_FILEIO_H +#define FS_FILEIO_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_FILEIO_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSFileIO) +#define JS_FILEIO_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSFileIO) +#define JS_FILEIO_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSFileIO) +#define JS_FILEIO_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSFileIO) +#define JS_FILEIO_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSFileIO) +#define JS_FILEIO_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSFileIO) + +class FSFileIO : public JSBase +{ +private: + char *_path; + unsigned int _flags; + switch_file_t *_fd; + switch_memory_pool_t *_pool; + char *_buf; + switch_size_t _buflen; + int32_t _bufsize; + + void Init(); +public: + FSFileIO(JSMain *owner) : JSBase(owner) { Init(); } + FSFileIO(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSFileIO(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_FILEIO_FUNCTION_DEF(Read); + JS_FILEIO_FUNCTION_DEF(Write); + JS_FILEIO_FUNCTION_DEF(GetData); + JS_FILEIO_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_FILEIO_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsglobal.hpp b/src/mod/languages/mod_v8/include/fsglobal.hpp new file mode 100644 index 0000000000..7095a12dd2 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsglobal.hpp @@ -0,0 +1,79 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsglobal.hpp -- JavaScript Global functions + * + */ + +#ifndef FS_GLOBAL_H +#define FS_GLOBAL_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_GLOBAL_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSGlobal) + +/* All globally available functions (not related to objects) */ +class FSGlobal +{ +private: + static size_t HashCallback(void *ptr, size_t size, size_t nmemb, void *data); + static size_t FileCallback(void *ptr, size_t size, size_t nmemb, void *data); + static size_t FetchUrlCallback(void *ptr, size_t size, size_t nmemb, void *data); +public: + static const js_function_t *GetFunctionDefinitions(); + + /* Methods available from JavaScript */ + JS_FUNCTION_DEF_STATIC(Log); + JS_FUNCTION_DEF_STATIC(GlobalGet); + JS_FUNCTION_DEF_STATIC(GlobalSet); + JS_FUNCTION_DEF_STATIC(Exit); + JS_FUNCTION_DEF_STATIC(Include); + JS_FUNCTION_DEF_STATIC(Bridge); + JS_FUNCTION_DEF_STATIC(Email); + JS_FUNCTION_DEF_STATIC(ApiExecute); + JS_FUNCTION_DEF_STATIC(Use); + JS_FUNCTION_DEF_STATIC(Sleep); + JS_FUNCTION_DEF_STATIC(FileDelete); + JS_FUNCTION_DEF_STATIC(System); + JS_FUNCTION_DEF_STATIC(FetchURL); + JS_FUNCTION_DEF_STATIC(FetchURLHash); + JS_FUNCTION_DEF_STATIC(FetchURLFile); +}; + +#endif /* FS_GLOBAL_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsodbc.hpp b/src/mod/languages/mod_v8/include/fsodbc.hpp new file mode 100644 index 0000000000..c3e6b4e153 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsodbc.hpp @@ -0,0 +1,114 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsodbc.hpp -- JavaScript ODBC class header + * + */ + +#ifndef FS_ODBC_H +#define FS_ODBC_H + +#include "mod_v8.h" + +#if defined(WIN32) && !defined(HAVE_ODBC) +#define HAVE_ODBC +#endif + +#ifdef HAVE_ODBC + +#include +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4201) +#include +#pragma warning(pop) +#else +#include +#endif +#include + +/* Macros for easier V8 callback definitions */ +#define JS_ODBC_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSODBC) +#define JS_ODBC_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSODBC) +#define JS_ODBC_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSODBC) +#define JS_ODBC_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSODBC) +#define JS_ODBC_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSODBC) +#define JS_ODBC_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSODBC) + +#define JS_ODBC_GET_PROPERTY_IMPL_STATIC(method_name) JS_GET_PROPERTY_IMPL_STATIC(method_name, FSODBC) +#define JS_ODBC_SET_PROPERTY_IMPL_STATIC(method_name) JS_SET_PROPERTY_IMPL_STATIC(method_name, FSODBC) +#define JS_ODBC_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSODBC) + +class FSODBC : public JSBase +{ +private: + switch_odbc_handle_t *_handle; + SQLHSTMT _stmt; + SQLCHAR *_colbuf; + int32_t _cblen; + std::string _dsn; + + void Init(); +public: + FSODBC(JSMain *owner) : JSBase(owner) { Init(); } + FSODBC(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSODBC(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + static FSODBC *New(char *dsn, char *username, char *password, const v8::FunctionCallbackInfo& info); + switch_odbc_status_t Connect(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_ODBC_FUNCTION_DEF(Connect); + JS_ODBC_FUNCTION_DEF(Disconnect); + JS_ODBC_FUNCTION_DEF(Exec); + JS_ODBC_FUNCTION_DEF(Execute); + JS_ODBC_FUNCTION_DEF(NumRows); + JS_ODBC_FUNCTION_DEF(NumCols); + JS_ODBC_FUNCTION_DEF(NextRow); + JS_ODBC_FUNCTION_DEF(GetData); + JS_FUNCTION_DEF_STATIC(Close); // This will also destroy the C++ object + JS_ODBC_GET_PROPERTY_DEF(GetProperty); + +}; + +#endif /* HAVE_ODBC */ + +#endif /* FS_ODBC_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fspcre.hpp b/src/mod/languages/mod_v8/include/fspcre.hpp new file mode 100644 index 0000000000..da1a3bbe2d --- /dev/null +++ b/src/mod/languages/mod_v8/include/fspcre.hpp @@ -0,0 +1,81 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fspcre.hpp -- JavaScript PCRE class header + * + */ + +#ifndef FS_PCRE_H +#define FS_PCRE_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_PCRE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSPCRE) +#define JS_PCRE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSPCRE) +#define JS_PCRE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSPCRE) +#define JS_PCRE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSPCRE) +#define JS_PCRE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSPCRE) +#define JS_PCRE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSPCRE) + +class FSPCRE : public JSBase +{ +private: + switch_regex_t *_re; + char *_str; + int _proceed; + int _ovector[30]; + int _freed; + + void Init(); +public: + FSPCRE(JSMain *owner) : JSBase(owner) { Init(); } + FSPCRE(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSPCRE(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_PCRE_FUNCTION_DEF(Compile); + JS_PCRE_FUNCTION_DEF(Substitute); + JS_PCRE_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_PCRE_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsrequest.hpp b/src/mod/languages/mod_v8/include/fsrequest.hpp new file mode 100644 index 0000000000..c96bb8824b --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsrequest.hpp @@ -0,0 +1,81 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsrequest.hpp -- JavaScript Request class header + * + */ + +#ifndef FS_REQUEST_H +#define FS_REQUEST_H + +#include "javascript.hpp" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_REQUEST_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSRequest) +#define JS_REQUEST_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSRequest) +#define JS_REQUEST_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSRequest) +#define JS_REQUEST_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSRequest) +#define JS_REQUEST_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSRequest) +#define JS_REQUEST_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSRequest) + +class FSRequest : public JSBase +{ +private: + const char *_cmd; + switch_stream_handle_t *_stream; + + void Init(); +public: + FSRequest(JSMain *owner) : JSBase(owner) { Init(); } + FSRequest(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSRequest(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + void Init(const char *cmd, switch_stream_handle_t *stream); + + /* Methods available from JavaScript */ + JS_REQUEST_FUNCTION_DEF(Write); + JS_REQUEST_FUNCTION_DEF(GetHeader); + JS_REQUEST_FUNCTION_DEF(AddHeader); + JS_REQUEST_FUNCTION_DEF(DumpEnv); + JS_REQUEST_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_REQUEST_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fssession.hpp b/src/mod/languages/mod_v8/include/fssession.hpp new file mode 100644 index 0000000000..aa918534b5 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fssession.hpp @@ -0,0 +1,165 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fssession.hpp -- JavaScript Session class header + * + */ + +#ifndef FS_SESSION_H +#define FS_SESSION_H + +#include "javascript.hpp" +#include + +typedef struct { + switch_speech_handle_t sh; + switch_codec_t codec; + int speaking; +} js_session_speech_t; + +typedef enum { + S_HUP = (1 << 0), +} session_flag_t; + +/* Macros for easier V8 callback definitions */ +#define JS_SESSION_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSSession) +#define JS_SESSION_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSSession) +#define JS_SESSION_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSSession) +#define JS_SESSION_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSSession) +#define JS_SESSION_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSSession) +#define JS_SESSION_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSSession) + +class FSSession : public JSBase +{ +private: + switch_core_session_t *_session; // The FS session + unsigned int flags; // Flags related to this session + switch_call_cause_t _cause; // Hangup cause + v8::Persistent _on_hangup;// Hangup hook + int _stack_depth; + switch_channel_state_t _hook_state; + char *_destination_number; + char *_dialplan; + char *_caller_id_name; + char *_caller_id_number; + char *_network_addr; + char *_ani; + char *_aniii; + char *_rdnis; + char *_context; + char *_username; + int _check_state; + js_session_speech_t *_speech; + + void Init(void); + switch_status_t InitSpeechEngine(const char *engine, const char *voice); + void DestroySpeechEngine(); + static switch_status_t CommonCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen); + static switch_status_t StreamInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen); + static switch_status_t RecordInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen); + static bool CheckHangupHook(FSSession *obj, bool *ret); + static switch_status_t HangupHook(switch_core_session_t *session); +public: + FSSession(JSMain *owner) : JSBase(owner) { Init(); } + FSSession(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSSession(void); + virtual std::string GetJSClassName(); + + static const js_class_definition_t *GetClassDefinition(); + + switch_core_session_t *GetSession(); + void Init(switch_core_session_t *session, unsigned int flags); + static switch_status_t CollectInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_SESSION_FUNCTION_DEF(Originate); + JS_SESSION_FUNCTION_DEF(SetCallerdata); + JS_SESSION_FUNCTION_DEF(SetHangupHook); + JS_SESSION_FUNCTION_DEF(SetAutoHangup); + JS_SESSION_FUNCTION_DEF(SayPhrase); + JS_SESSION_FUNCTION_DEF(StreamFile); + JS_SESSION_FUNCTION_DEF(CollectInput); + JS_SESSION_FUNCTION_DEF(RecordFile); + JS_SESSION_FUNCTION_DEF(FlushEvents); + JS_SESSION_FUNCTION_DEF(FlushDigits); + JS_SESSION_FUNCTION_DEF(Speak); + JS_SESSION_FUNCTION_DEF(SetVariable); + JS_SESSION_FUNCTION_DEF(GetVariable); + JS_SESSION_FUNCTION_DEF(GetDigits); + JS_SESSION_FUNCTION_DEF(Answer); + JS_SESSION_FUNCTION_DEF(PreAnswer); + JS_SESSION_FUNCTION_DEF(GenerateXmlCdr); + JS_SESSION_FUNCTION_DEF(Ready); + JS_SESSION_FUNCTION_DEF(Answered); + JS_SESSION_FUNCTION_DEF(MediaReady); + JS_SESSION_FUNCTION_DEF(RingReady); + JS_SESSION_FUNCTION_DEF(WaitForAnswer); + JS_SESSION_FUNCTION_DEF(WaitForMedia); + JS_SESSION_FUNCTION_DEF(GetEvent); + JS_SESSION_FUNCTION_DEF(SendEvent); + JS_SESSION_FUNCTION_DEF(Hangup); + JS_SESSION_FUNCTION_DEF(Execute); + JS_SESSION_FUNCTION_DEF(Detach); + JS_SESSION_FUNCTION_DEF(Sleep); + JS_SESSION_FUNCTION_DEF(Bridge); + JS_SESSION_GET_PROPERTY_DEF(GetProperty); +}; + +class FSInputCallbackState +{ +public: + FSSession *session_state; + char code_buffer[1024]; + size_t code_buffer_len; + char ret_buffer[1024]; + int ret_buffer_len; + int digit_count; + v8::Persistent function; + v8::Persistent arg; + v8::Persistent ret; + void *extra; + FSSession *jss_a; + FSSession *jss_b; + v8::Persistent session_obj_a; + v8::Persistent session_obj_b; + + FSInputCallbackState(void); + ~FSInputCallbackState(void); +}; + +#endif /* FS_SESSION_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fssocket.hpp b/src/mod/languages/mod_v8/include/fssocket.hpp new file mode 100644 index 0000000000..58f4bb5838 --- /dev/null +++ b/src/mod/languages/mod_v8/include/fssocket.hpp @@ -0,0 +1,83 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fssocket.hpp -- JavaScript Socket class header + * + */ + +#ifndef FS_SOCKET_H +#define FS_SOCKET_H + +#include "mod_v8.h" + +/* Macros for easier V8 callback definitions */ +#define JS_SOCKET_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSSocket) +#define JS_SOCKET_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSSocket) +#define JS_SOCKET_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSSocket) +#define JS_SOCKET_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSSocket) +#define JS_SOCKET_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSSocket) +#define JS_SOCKET_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSSocket) + +class FSSocket : public JSBase +{ +private: + switch_socket_t *_socket; + switch_memory_pool_t *_pool; + char *_read_buffer; + switch_size_t _buffer_size; + int _state; + + void Init(); +public: + FSSocket(JSMain *owner) : JSBase(owner) { Init(); } + FSSocket(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSSocket(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_SOCKET_FUNCTION_DEF(Connect); + JS_SOCKET_FUNCTION_DEF(Close); + JS_SOCKET_FUNCTION_DEF(Send); + JS_SOCKET_FUNCTION_DEF(ReadBytes); + JS_SOCKET_FUNCTION_DEF(Read); + JS_SOCKET_GET_PROPERTY_DEF(GetProperty); +}; + +#endif /* FS_SOCKET_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsteletone.hpp b/src/mod/languages/mod_v8/include/fsteletone.hpp new file mode 100644 index 0000000000..0375b3a75b --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsteletone.hpp @@ -0,0 +1,89 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsteletone.hpp -- JavaScript TeleTone class header + * + */ + +#ifndef FS_TELETONE_H +#define FS_TELETONE_H + +#include "mod_v8.h" +#include + +/* Macros for easier V8 callback definitions */ +#define JS_TELETONE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSTeleTone) +#define JS_TELETONE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSTeleTone) +#define JS_TELETONE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSTeleTone) +#define JS_TELETONE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSTeleTone) +#define JS_TELETONE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSTeleTone) +#define JS_TELETONE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSTeleTone) + +class FSTeleTone : public JSBase +{ +private: + teletone_generation_session_t _ts; + switch_core_session_t *_session; + switch_codec_t _codec; + switch_buffer_t *_audio_buffer; + switch_memory_pool_t *_pool; + switch_timer_t *_timer; + switch_timer_t _timer_base; + v8::Persistent _function; + v8::Persistent _arg; + unsigned int flags; + + void Init(); +public: + FSTeleTone(JSMain *owner) : JSBase(owner) { Init(); } + FSTeleTone(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSTeleTone(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + static int Handler(teletone_generation_session_t *ts, teletone_tone_map_t *map); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_TELETONE_FUNCTION_DEF(Generate); + JS_TELETONE_FUNCTION_DEF(OnDTMF); + JS_TELETONE_FUNCTION_DEF(AddTone); + JS_TELETONE_GET_PROPERTY_DEF(GetNameProperty); +}; + +#endif /* FS_TELETONE_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/fsxml.hpp b/src/mod/languages/mod_v8/include/fsxml.hpp new file mode 100644 index 0000000000..e831c659ec --- /dev/null +++ b/src/mod/languages/mod_v8/include/fsxml.hpp @@ -0,0 +1,96 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * fsxml.hpp -- JavaScript XML class header + * + */ + +#ifndef FS_XML_H +#define FS_XML_H + +#include "mod_v8.h" + +/* Macros for easier V8 callback definitions */ +#define JS_XML_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSXML) +#define JS_XML_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSXML) +#define JS_XML_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSXML) +#define JS_XML_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSXML) +#define JS_XML_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSXML) +#define JS_XML_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSXML) +#define JS_XML_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSXML) + +class FSXML : public JSBase +{ +private: + switch_xml_t _xml; + v8::Persistent _rootJSObject; /* Always keep a reference to the root, so JS doesn't try to clean it up in GC */ + FSXML *_rootObject; + switch_hash_t *_obj_hash; + switch_memory_pool_t *_pool; + + void Init(); + void InitRootObject(); + v8::Handle GetJSObjFromXMLObj(const switch_xml_t xml, const v8::FunctionCallbackInfo& info); + void StoreObjectInHash(switch_xml_t xml, FSXML *obj); + FSXML *FindObjectInHash(switch_xml_t xml); + void DeleteObjectInHash(switch_xml_t xml); + void DestroyHash(); +public: + FSXML(JSMain *owner) : JSBase(owner) { Init(); } + FSXML(const v8::FunctionCallbackInfo& info) : JSBase(info) { Init(); } + virtual ~FSXML(void); + virtual std::string GetJSClassName(); + + static const v8_mod_interface_t *GetModuleInterface(); + + /* Methods available from JavaScript */ + static void *Construct(const v8::FunctionCallbackInfo& info); + JS_XML_FUNCTION_DEF(GetChild); + JS_XML_FUNCTION_DEF(AddChild); + JS_XML_FUNCTION_DEF(Next); + JS_XML_FUNCTION_DEF(GetAttribute); + JS_XML_FUNCTION_DEF(SetAttribute); + JS_FUNCTION_DEF_STATIC(Remove); + JS_XML_FUNCTION_DEF(Copy); + JS_XML_FUNCTION_DEF(Serialize); + JS_XML_GET_PROPERTY_DEF(GetNameProperty); + JS_XML_GET_PROPERTY_DEF(GetDataProperty); + JS_XML_SET_PROPERTY_DEF(SetDataProperty); + JS_XML_GET_PROPERTY_DEF(GetErrorProperty); +}; + +#endif /* FS_XML_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/include/javascript.hpp b/src/mod/languages/mod_v8/include/javascript.hpp new file mode 100644 index 0000000000..a465bf6ea9 --- /dev/null +++ b/src/mod/languages/mod_v8/include/javascript.hpp @@ -0,0 +1,356 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Peter Olsson + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * + * javascript.hpp -- Header file for main JavaScript classes + * + */ + +#ifndef V8_JAVASCRIPT_H +#define V8_JAVASCRIPT_H + +#include +#include + +#include +#include +#include +#include + +/* Enable this define enable V8 debugging protocol, this is not yet working */ +//#define V8_ENABLE_DEBUGGING + +/* + * Enable this define to force a GC after the script has finished execution. + * This is only to help debug memory leaks, and should not be needed for anything else + */ +//#define V8_FORCE_GC_AFTER_EXECUTION + + +/* Macro for easy V8 "get property" callback definition */ +#define JS_GET_PROPERTY_DEF(method_name, class_name) \ + static void method_name(v8::Local property, const v8::PropertyCallbackInfo& info)\ + {\ + JS_CHECK_SCRIPT_STATE();\ + class_name *obj = JSBase::GetInstance(info.Holder());\ + if (obj) {\ + obj->method_name##Impl(property, info);\ + } else {\ + int line;\ + char *file = JSMain::GetStackInfo(info.GetIsolate(), &line);\ + v8::String::Utf8Value str(info.Holder());\ + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "mod_v8", line, NULL, SWITCH_LOG_DEBUG, "No valid internal data available for %s when calling %s\n", *str ? *str : "[unknown]", #class_name "::" #method_name "()");\ + free(file);\ + info.GetReturnValue().Set(false);\ + }\ + }\ + void method_name##Impl(v8::Local property, const v8::PropertyCallbackInfo& info) + +/* Macro for easy V8 "set property" callback definition */ +#define JS_SET_PROPERTY_DEF(method_name, class_name) \ + static void method_name(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info)\ + {\ + JS_CHECK_SCRIPT_STATE();\ + class_name *obj = JSBase::GetInstance(info.Holder());\ + if (obj) {\ + obj->method_name##Impl(property, value, info);\ + } else {\ + int line;\ + char *file = JSMain::GetStackInfo(info.GetIsolate(), &line);\ + v8::String::Utf8Value str(info.Holder());\ + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "mod_v8", line, NULL, SWITCH_LOG_DEBUG, "No valid internal data available for %s when calling %s\n", *str ? *str : "[unknown]", #class_name "::" #method_name "()");\ + free(file);\ + info.GetReturnValue().Set(false);\ + }\ + }\ + void method_name##Impl(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) + +/* Macro for easy V8 "function" callback definition */ +#define JS_FUNCTION_DEF(method_name, class_name) \ + static void method_name(const v8::FunctionCallbackInfo& info)\ + {\ + JS_CHECK_SCRIPT_STATE();\ + class_name *obj = JSBase::GetInstance(info.Holder());\ + if (obj) {\ + obj->method_name##Impl(info);\ + } else {\ + int line;\ + char *file = JSMain::GetStackInfo(info.GetIsolate(), &line);\ + v8::String::Utf8Value str(info.Holder());\ + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "mod_v8", line, NULL, SWITCH_LOG_DEBUG, "No valid internal data available for %s when calling %s\n", *str ? *str : "[unknown]", #class_name "::" #method_name "()");\ + free(file);\ + info.GetReturnValue().Set(false);\ + }\ + }\ + void method_name##Impl(const v8::FunctionCallbackInfo& info) + +/* Macros for V8 callback implementations */ +#define JS_GET_PROPERTY_IMPL(method_name, class_name) void class_name::method_name##Impl(v8::Local property, const v8::PropertyCallbackInfo& info) +#define JS_SET_PROPERTY_IMPL(method_name, class_name) void class_name::method_name##Impl(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) +#define JS_FUNCTION_IMPL(method_name, class_name) void class_name::method_name##Impl(const v8::FunctionCallbackInfo& info) + +/* Macros for V8 callback definitions (class static version) */ +#define JS_GET_PROPERTY_DEF_STATIC(method_name) static void method_name(v8::Local property, const v8::PropertyCallbackInfo& info) +#define JS_SET_PROPERTY_DEF_STATIC(method_name) static void method_name(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) +#define JS_FUNCTION_DEF_STATIC(method_name) static void method_name(const v8::FunctionCallbackInfo& info) + +/* Macros for V8 callback implementations (class static version) */ +#define JS_GET_PROPERTY_IMPL_STATIC(method_name, class_name) void class_name::method_name(v8::Local property, const v8::PropertyCallbackInfo& info) +#define JS_SET_PROPERTY_IMPL_STATIC(method_name, class_name) void class_name::method_name(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) +#define JS_FUNCTION_IMPL_STATIC(method_name, class_name) void class_name::method_name(const v8::FunctionCallbackInfo& info) + +/* Macro for basic script state check (to know if the script is being terminated), should be called before calling any callback actual code */ +#define JS_CHECK_SCRIPT_STATE() \ + if (v8::V8::IsExecutionTerminating(info.GetIsolate())) return;\ + if (JSMain::GetScriptInstanceFromIsolate(info.GetIsolate()) && JSMain::GetScriptInstanceFromIsolate(info.GetIsolate())->GetForcedTermination()) return + +/* strdup function for all platforms */ +#ifdef NDEBUG +#if (_MSC_VER >= 1500) // VC9+ +#define js_strdup(ptr, s) (void)( (!!(ptr = _strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#else +#define js_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#endif +#else +#if (_MSC_VER >= 1500) // VC9+ +#define js_strdup(ptr, s) (void)(assert(((ptr) = _strdup(s))),ptr);__analysis_assume( ptr ) +#else +#define js_strdup(ptr, s) (void)(assert(((ptr) = strdup((s)))),ptr) +#endif +#endif + +/* Makes sure to return a valid char pointer */ +#define js_safe_str(s) (s ? s : "") + +/* JS Constructor callback definition */ +typedef void * void_pointer_t; +typedef void_pointer_t (*ConstructorCallback)(const v8::FunctionCallbackInfo& info); + +/* JS Function definition */ +typedef struct { + const char *name; /* Name of the function */ + v8::FunctionCallback func; /* Function callback */ +} js_function_t; + +/* JS Property definition */ +typedef struct { + const char *name; /* Name of the property */ + v8::AccessorGetterCallback get; /* The property getter */ + v8::AccessorSetterCallback set; /* The property setter */ +} js_property_t; + +/* JS Class definition */ +typedef struct { + const char *name; /* The name of the class */ + ConstructorCallback constructor; /* The constructor definition */ + const js_function_t *functions; /* An array of function definitions */ + const js_property_t *properties; /* An array of property definitions */ +} js_class_definition_t; + +/* Import/export definitions (used by extra loadable modules) */ +#ifdef WIN32 +/* WIN32 */ +#ifdef JSMOD_IMPORT +#define JSMOD_EXPORT __declspec(dllimport) +#else +#define JSMOD_EXPORT __declspec(dllexport) +#endif +#else +/* Not WIN32 */ +#ifdef JSMOD_IMPORT +#define JSMOD_EXPORT +#else +#if (HAVE_VISIBILITY != 1) +#define JSMOD_EXPORT +#else +#define JSMOD_EXPORT __attribute__ ((visibility("default"))) +#endif +#endif +#endif + +/* JSMain class prototype */ +class JSMOD_EXPORT JSMain; + +/* Base class used by all C++ classes implemented in JS */ +class JSMOD_EXPORT JSBase +{ +private: + v8::Persistent *persistentHandle; /* The persistent handle of the JavaScript object for this instance */ + bool autoDestroy; /* flag to tell if this instance should be auto destroyed during JavaScript GC */ + JSMain *js; /* The "owner" of this instance */ + + /* The callback that happens when the V8 GC cleans up object instances */ + static void WeakCallback(const v8::WeakCallbackData& data); + + /* Internal basic constructor when creating a new instance from JS. It will call the actual user code inside */ + static void CreateInstance(const v8::FunctionCallbackInfo& args); + + /* Store a C++ instance to a JS object's private data */ + static void AddInstance(v8::Isolate *isolate, const v8::Handle& handle, const v8::Handle& object, bool autoDestroy); +public: + JSBase(JSMain *owner); + JSBase(const v8::FunctionCallbackInfo& info); + virtual ~JSBase(void); + + /* Returns the JS object related to the C++ instance */ + v8::Handle GetJavaScriptObject(); + + /* Register a C++ class inside V8 (must be called within a entered isolate, and context) */ + static void Register(v8::Isolate *isolate, const js_class_definition_t *desc); + + /* Register an existing C++ class instance inside V8 (must be called within a entered isolate, and context) */ + void RegisterInstance(v8::Isolate *isolate, std::string name, bool autoDestroy); + + /* Get a JSBase instance from JavaScript callback arguments */ + template static T *GetInstance(const v8::FunctionCallbackInfo& info) + { + v8::HandleScope scope(info.GetIsolate()); + return GetInstance(info.Holder()); + } + + /* Get a JSBase instance from a JavaScript object */ + template static T *GetInstance(const v8::Local& self) + { + v8::Local val = self->GetInternalField(0); + + if (!val.IsEmpty() && val->IsExternal()) { + v8::Local wrap = v8::Local::Cast(val); + JSBase *ptr = static_cast(wrap->Value()); + return dynamic_cast(ptr); /* If we're trying to cast to the wrong type, dynamic_cast will return NULL */ + } else { + return NULL; + } + } + + /* Get a JavaScript function from a JavaScript argument (can be either a string or the actual function) */ + static v8::Handle GetFunctionFromArg(v8::Isolate *isolate, const v8::Local& arg); + + /* Default JS setter callback, to be used for read only values */ + static void DefaultSetProperty(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info); + + /* Get the name of the JavaScript class - must be overridden by the actual implementation */ + virtual std::string GetJSClassName() = 0; + + /* Get the JavaScript class instance that owns this instance */ + JSMain *GetOwner(); + + /* Get the JavaScript isolate that's active for the current context */ + v8::Isolate *GetIsolate(); + + /* Get autoDestroy variable */ + bool GetAutoDestroy(); +}; + +/* Definition of the class registration method */ +typedef void (*JSExtenderRegisterMethod)(js_class_definition_t *class_definition); + +/* The struct holding a C++ class instance, to be used in JS */ +typedef struct { + JSBase *obj; /* The class instance to be used in JS */ + char *name; /* The name of the instance within JS */ + bool auto_destroy; /* Flag to know if the instance should be auto destroyed when not needed by JS anymore */ +} registered_instance_t; + +/* Main class for executing a V8 JavaScript */ +class JSMOD_EXPORT JSMain +{ +private: + v8::Isolate* isolate; /* The V8 isolate for this script instance */ + + std::vector *extenderClasses;/* List holding C++ classes to be registered in JS on execution */ + std::vector *extenderFunctions; /* List holding C++ functions to be registered in JS on execution */ + std::vector *extenderInstances; /* List holding C++ class instances to be registered in JS on execution */ + std::set *activeInstances; /* List holding all active instances right now (in a running script) */ + + bool forcedTermination; /* Is set to true if script is triggering a forced termination of the script */ + char *forcedTerminationMessage; /* The message given during forced termination */ + int forcedTerminationLineNumber; /* The JS line number that called the exit function */ + char *forcedTerminationScriptFile; /* The JS script file that called the exit function */ + + /* Internal Log function accessable from JS - used just for testing */ + static void Log(const v8::FunctionCallbackInfo& args); +public: + JSMain(void); + ~JSMain(void); + + void AddJSExtenderFunction(v8::FunctionCallback func, const std::string& name); /* Add a C++ function to be registered when running the script */ + void AddJSExtenderClass(const js_class_definition_t *method); /* Add a C++ class to be registered when running the script */ + void AddJSExtenderInstance(JSBase *instance, const std::string& objectName, bool autoDestroy); /* Add a C++ class instance to be registered when running the script */ + + static JSMain *GetScriptInstanceFromIsolate(v8::Isolate* isolate); /* Get the JavaScript C++ instance from a V8 isolate */ + v8::Isolate *GetIsolate(); /* Get the V8 isolate from the current instance */ + + const std::string ExecuteScript(const std::string& filename, bool *resultIsError); + const std::string ExecuteString(const std::string& scriptData, const std::string& fileName, bool *resultIsError); + + static void Initialize(); /* Initialize the V8 engine */ + static void Dispose(); /* Deinitialize the V8 engine */ + + static void Include(const v8::FunctionCallbackInfo& args); /* Adds functionality to include another JavaScript from the running script */ + static void Version(const v8::FunctionCallbackInfo& args); /* Internal Version function accessable from JS - used to get the current V( version */ + static const std::string GetExceptionInfo(v8::Isolate* isolate, v8::TryCatch* try_catch); /* Get the exception information from a V8 TryCatch instance */ + + const std::vector& GetExtenderClasses() const;/* Returns the list of class definitions */ + const std::vector& GetExtenderFunctions() const; /* Returns the list of function definitions */ + const std::vector& GetExtenderInstances() const; /* Returns the list of class instance definitions */ + + /* Methods to keep track of all created C++ instances within JS */ + void AddActiveInstance(JSBase *obj); + void RemoveActiveInstance(JSBase *obj); + void DisposeActiveInstances(); + + static bool FileExists(const char *file); + static const std::string LoadFileToString(const std::string& filename); + + /* Data related to forced script termination */ + bool GetForcedTermination(void); + void ResetForcedTermination(void); + const char *GetForcedTerminationMessage(void); + const char *GetForcedTerminationScriptFile(void); + int GetForcedTerminationLineNumber(void); + + /* Method to force termination of a script */ + static void ExitScript(v8::Isolate *isolate, const char *msg); + + /* Get the filename and line number of the current JS stack */ + static char *GetStackInfo(v8::Isolate *isolate, int *lineNumber); +}; + +#ifdef V8_ENABLE_DEBUGGING +void V8DispatchDebugMessages(); +#endif + +#endif /* V8_JAVASCRIPT_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/languages/mod_v8/mod_v8.2010.vcxproj b/src/mod/languages/mod_v8/mod_v8.2010.vcxproj new file mode 100644 index 0000000000..101f0ffaad --- /dev/null +++ b/src/mod/languages/mod_v8/mod_v8.2010.vcxproj @@ -0,0 +1,224 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_v8 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064} + mod_v8 + Win32Proj + + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + + Disabled + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + Disabled + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {89385c74-5860-4174-9caf-a39e7c48909c} + + + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} + false + + + {87ee9da4-de1e-4448-8324-183c98dca588} + false + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + \ No newline at end of file diff --git a/src/mod/languages/mod_v8/mod_v8.2010.vcxproj.filters b/src/mod/languages/mod_v8/mod_v8.2010.vcxproj.filters new file mode 100644 index 0000000000..77911bad54 --- /dev/null +++ b/src/mod/languages/mod_v8/mod_v8.2010.vcxproj.filters @@ -0,0 +1,122 @@ + + + + + + BaseClasses + + + BaseClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + + + + BaseClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + + + {57f55a0b-1790-4632-95e6-19acbe9015d3} + + + {dcda9b2f-890a-4820-84e3-4bbcf8f0b62c} + + + {ed9652cf-79bd-4567-9a98-1ed5077d5805} + + + {3efc073f-f052-4e3d-921c-8d6b6a5a7215} + + + \ No newline at end of file diff --git a/src/mod/languages/mod_v8/mod_v8.2012.vcxproj b/src/mod/languages/mod_v8/mod_v8.2012.vcxproj new file mode 100644 index 0000000000..2ff8aaabc6 --- /dev/null +++ b/src/mod/languages/mod_v8/mod_v8.2012.vcxproj @@ -0,0 +1,228 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_v8 + {9B9D2551-D6BD-4F20-8BE5-DE30E154A064} + mod_v8 + Win32Proj + + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + DynamicLibrary + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + NativeMinimumRules.ruleset + false + + + + Disabled + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + Disabled + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + + + + + X64 + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + false + false + + + $(Platform)\$(Configuration)\$(ProjectName).lib + %(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {89385c74-5860-4174-9caf-a39e7c48909c} + + + {AB03E82B-48B1-4374-B32A-A1AF83DDC6C2} + false + + + {87ee9da4-de1e-4448-8324-183c98dca588} + false + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + \ No newline at end of file diff --git a/src/mod/languages/mod_v8/mod_v8.2012.vcxproj.filters b/src/mod/languages/mod_v8/mod_v8.2012.vcxproj.filters new file mode 100644 index 0000000000..77911bad54 --- /dev/null +++ b/src/mod/languages/mod_v8/mod_v8.2012.vcxproj.filters @@ -0,0 +1,122 @@ + + + + + + BaseClasses + + + BaseClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + FSClasses + + + + + + BaseClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + FSClasses\include + + + + + {57f55a0b-1790-4632-95e6-19acbe9015d3} + + + {dcda9b2f-890a-4820-84e3-4bbcf8f0b62c} + + + {ed9652cf-79bd-4567-9a98-1ed5077d5805} + + + {3efc073f-f052-4e3d-921c-8d6b6a5a7215} + + + \ No newline at end of file diff --git a/src/mod/languages/mod_v8/mod_v8.cpp b/src/mod/languages/mod_v8/mod_v8.cpp new file mode 100644 index 0000000000..7d1cdefaf5 --- /dev/null +++ b/src/mod/languages/mod_v8/mod_v8.cpp @@ -0,0 +1,899 @@ +/* + * mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013-2014, Peter Olsson + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is ported from FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Olsson + * Anthony Minessale II + * William King + * + * mod_v8.cpp -- JavaScript FreeSWITCH module + * + */ + +/* + * This module executes JavaScript using Google's V8 JavaScript engine. + * + * It extends the available JavaScript classes with the following FS related classes; + * CoreDB Adds features to access the core DB (SQLite) in FreeSWITCH. (on request only) + * CURL Adds some extra methods for CURL access. (on request only) + * DTMF Object that holds information about a DTMF event. + * Event Object that holds information about a FreeSWITCH event. + * EventHandler Features for handling FS events. + * File Class to reflect the Spidermonkey built-in class "File". Not yet implemented! (on request only) + * FileIO Simple class for basic file IO. + * ODBC Adds features to access any ODBC available database in the system. (on request only) + * PCRE Adds features to do regexp using the PCRE implementeation. + * Request Class for extra features during API call from FS (using 'jsapi' function). This class cannot be constructed from JS code! + * The Request class is only availble when started from 'jsapi' FS command, and only inside the predefined variable 'request'. + * Session Main FS class, includes all functions to handle a session. + * Socket Class for communicating over a TCP/IP socket. (on request only) + * TeleTone Class used to play tones to a FS channel. (on request only) + * XML XML parsing class, using the features from switch_xml. (on request only) + * + * Some of the classes above are available on request only, using the command [use('Class');] before using the class for the first time. + * + * It also adds quite a few global functions, directly available for the user (see fsglobal.cpp for the implementation). + * + * Depedning on how the script was started from FreeSWITCH, some variables might be defined already; + * session If the script is started from the dialplan, the variable 'session' holds the session for the current call. + * request If the script is started using 'jsapi' function, the variable 'request' is an instance of the Request class. + * message If the script is started as a chat application, the actual FreeSWITCH event will be available in the variable 'message'. + * + * All classes are implemented in a pair of hpp/cpp files, named after the class. For instance; class "File" is implemented in fsfile.cpp. + * + */ + +#include "mod_v8.h" +#include + +#ifdef V8_ENABLE_DEBUGGING +#include +#endif + +/* Global JavaScript functions */ +#include "fsglobal.hpp" + +/* Common JavaScript classes */ +#include "fsrequest.hpp" /* Only loaded during 'jsapi' and 'jsjson' call */ +#include "fspcre.hpp" +#include "fsevent.hpp" +#include "fssession.hpp" +#include "fsdtmf.hpp" +#include "fsfileio.hpp" + +/* Optional JavaScript classes (loaded on demand) */ +#include "fscoredb.hpp" +#include "fscurl.hpp" +#include "fsteletone.hpp" +#include "fssocket.hpp" +#include "fsodbc.hpp" +#include "fsxml.hpp" +#include "fsfile.hpp" +#include "fseventhandler.hpp" + +#include + +using namespace std; +using namespace v8; + +SWITCH_BEGIN_EXTERN_C + +/* FreeSWITCH module load definitions */ +SWITCH_MODULE_LOAD_FUNCTION(mod_v8_load); +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_v8_shutdown); +SWITCH_MODULE_DEFINITION_EX(mod_v8, mod_v8_load, mod_v8_shutdown, NULL, SMODF_GLOBAL_SYMBOLS); + +/* API interfaces */ +static switch_api_interface_t *jsrun_interface = NULL; +static switch_api_interface_t *jsapi_interface = NULL; + +/* Module manager for loadable modules */ +module_manager_t module_manager = { 0 }; + +/* Global data for this module */ +typedef struct { + switch_memory_pool_t *pool; + switch_mutex_t *event_mutex; + switch_event_node_t *event_node; + set *event_handlers; +} mod_v8_global_t; + +mod_v8_global_t globals = { 0 }; + +/* Loadable module struct, used for external extension modules */ +typedef struct { + char *filename; + void *lib; + const v8_mod_interface_t *module_interface; + v8_mod_init_t v8_mod_init; +} v8_loadable_module_t; + +#ifdef V8_ENABLE_DEBUGGING +static bool debug_enable_callback = false; +static int debug_listen_port = 9999; +static bool debug_wait_for_connection = true; +static bool debug_manual_break = true; +#endif + +using namespace v8; + +static switch_status_t v8_mod_init_built_in(const v8_mod_interface_t *mod_interface) +{ + switch_assert(mod_interface); + + switch_core_hash_insert(module_manager.load_hash, (char *) mod_interface->name, mod_interface); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully Loaded [%s]\n", mod_interface->name); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t v8_mod_load_file(const char *filename) +{ + v8_loadable_module_t *module = NULL; + switch_dso_lib_t dso = NULL; + switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_loadable_module_function_table_t *function_handle = NULL; + v8_mod_init_t v8_mod_init = NULL; + const v8_mod_interface_t *module_interface = NULL, *mp; + char *derr = NULL; + const char *err = NULL; + + switch_assert(filename != NULL); + + if (!(dso = switch_dso_open(filename, 1, &derr))) { + status = SWITCH_STATUS_FALSE; + } + + if (derr || status != SWITCH_STATUS_SUCCESS) { + err = derr; + goto err; + } + + function_handle = (switch_loadable_module_function_table_t *)switch_dso_data_sym(dso, "v8_mod_init", &derr); + + if (!function_handle || derr) { + status = SWITCH_STATUS_FALSE; + err = derr; + goto err; + } + + v8_mod_init = (v8_mod_init_t) (intptr_t) function_handle; + + if (v8_mod_init == NULL) { + err = "Cannot Load"; + goto err; + } + + if (v8_mod_init(&module_interface) != SWITCH_STATUS_SUCCESS) { + err = "Module load routine returned an error"; + goto err; + } + + if (!(module = (v8_loadable_module_t *) switch_core_permanent_alloc(sizeof(*module)))) { + err = "Could not allocate memory\n"; + } + + err: + + if (err || !module) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Loading module %s\n**%s**\n", filename, switch_str_nil(err)); + switch_safe_free(derr); + return SWITCH_STATUS_GENERR; + } + + module->filename = switch_core_permanent_strdup(filename); + module->v8_mod_init = v8_mod_init; + module->module_interface = module_interface; + + module->lib = dso; + + if ((mp = module->module_interface)) { + switch_core_hash_insert(module_manager.load_hash, (char *) mp->name, (void *) mp); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully Loaded [%s]\n", module->filename); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t v8_load_module(const char *dir, const char *fname) +{ + switch_size_t len = 0; + char *path; + char *file; + +#ifdef WIN32 + const char *ext = ".dll"; +#else + const char *ext = ".so"; +#endif + + if ((file = switch_core_strdup(module_manager.pool, fname)) == 0) { + return SWITCH_STATUS_FALSE; + } + + if (*file == '/') { + path = switch_core_strdup(module_manager.pool, file); + } else { + if (strchr(file, '.')) { + len = strlen(dir); + len += strlen(file); + len += 4; + path = (char *) switch_core_alloc(module_manager.pool, len); + switch_snprintf(path, len, "%s%s%s", dir, SWITCH_PATH_SEPARATOR, file); + } else { + len = strlen(dir); + len += strlen(file); + len += 8; + path = (char *) switch_core_alloc(module_manager.pool, len); + switch_snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext); + } + } + + return v8_mod_load_file(path); +} + +SWITCH_END_EXTERN_C + +static switch_status_t load_modules(void) +{ + const char *cf = "v8.conf"; + switch_xml_t cfg, xml; + unsigned int count = 0; + +#ifdef WIN32 + const char *ext = ".dll"; + const char *EXT = ".DLL"; +#elif defined (MACOSX) || defined (DARWIN) + const char *ext = ".dylib"; + const char *EXT = ".DYLIB"; +#else + const char *ext = ".so"; + const char *EXT = ".SO"; +#endif + + switch_core_new_memory_pool(&module_manager.pool); + + switch_core_hash_init(&module_manager.load_hash, module_manager.pool); + + if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { + switch_xml_t mods, ld; + + if ((mods = switch_xml_child(cfg, "modules"))) { + for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) { + const char *val = switch_xml_attr_soft(ld, "module"); + if (!zstr(val) && strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val); + continue; + } + v8_load_module(SWITCH_GLOBAL_dirs.mod_dir, val); + count++; + } + } + switch_xml_free(xml); + + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Open of %s failed\n", cf); + } + + return SWITCH_STATUS_SUCCESS; +} + +static int env_init(JSMain *js) +{ + /* Init all "global" functions first */ + const js_function_t *fs_proc = FSGlobal::GetFunctionDefinitions(); + for (int i = 0; fs_proc[i].name && fs_proc[i].func; i++) { + js->AddJSExtenderFunction(fs_proc[i].func, fs_proc[i].name); + } + + /* Init all basic classes made available from FreeSWITCH */ + js->AddJSExtenderClass(FSSession::GetClassDefinition()); + js->AddJSExtenderClass(FSFileIO::GetClassDefinition()); + js->AddJSExtenderClass(FSEvent::GetClassDefinition()); + js->AddJSExtenderClass(FSDTMF::GetClassDefinition()); + js->AddJSExtenderClass(FSPCRE::GetClassDefinition()); + /* To add a class that will always be available inside JS, add the definition here */ + + return 1; +} + +static void v8_error(Isolate* isolate, TryCatch* try_catch) +{ + HandleScope handle_scope(isolate); + String::Utf8Value exception(try_catch->Exception()); + const char *exception_string = js_safe_str(*exception); + Handle message = try_catch->Message(); + const char *msg = ""; + string filename = __FILE__; + int line = __LINE__; + string text = ""; + JSMain *js = JSMain::GetScriptInstanceFromIsolate(isolate); + + if (js && js->GetForcedTermination()) { + js->ResetForcedTermination(); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, js->GetForcedTerminationScriptFile(), modname, js->GetForcedTerminationLineNumber(), NULL, SWITCH_LOG_NOTICE, "Script exited with info [%s]\n", js->GetForcedTerminationMessage()); + return; + } + + if (!message.IsEmpty()) { + String::Utf8Value fname(message->GetScriptResourceName()); + + if (*fname) { + filename = *fname; + } + + line = message->GetLineNumber(); + msg = exception_string; + + String::Utf8Value sourceline(message->GetSourceLine()); + if (*sourceline) { + text = *sourceline; + } + } else { + msg = exception_string; + } + + if (!msg) { + msg = ""; + } + + if (text.length() > 0) { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, filename.c_str(), modname, line, NULL, SWITCH_LOG_ERROR, "Exception: %s (near: \"%s\")\n", msg, text.c_str()); + } else { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, filename.c_str(), modname, line, NULL, SWITCH_LOG_ERROR, "Exception: %s\n", msg); + } +} + +static char *v8_get_script_path(const char *script_file) +{ + const char *p; + char *ret = NULL; + const char delims[] = "/\\"; + const char *i; + + if (script_file) { + for (i = delims; *i; i++) { + if ((p = strrchr(script_file, *i))) { + js_strdup(ret, script_file); + *(ret + (p - script_file)) = '\0'; + return ret; + } + } + js_strdup(ret, "."); + return ret; + } else { + return NULL; + } +} + +static int v8_parse_and_execute(switch_core_session_t *session, const char *input_code, switch_stream_handle_t *api_stream, switch_event_t *message) +{ + string res; + JSMain *js; + Isolate *isolate; + char *arg, *argv[512]; + int argc = 0, x = 0, y = 0; + unsigned int flags = 0; + char *path = NULL; + string result_string; + int result = 0; + + if (zstr(input_code)) { + return -1; + } + + js = new JSMain(); + isolate = js->GetIsolate(); + + env_init(js); + + /* Try to read lock the session first */ + if (session) { + if (switch_core_session_read_lock_hangup(session) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Failure.\n"); + session = NULL; + } + } + + /* Execute the actual script */ + //isolate->Enter(); + { + Locker lock(isolate); + Isolate::Scope iscope(isolate); + { + const char *script; + + // Create a stack-allocated handle scope. + HandleScope scope(isolate); + + // Store our object internally + isolate->SetData(0, js); + + // New global template + Handle global = ObjectTemplate::New(); + + if (global.IsEmpty()) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create JS global object template\n"); + } else { + /* Function to print current V8 version */ + global->Set(String::NewFromUtf8(isolate, "version"), FunctionTemplate::New(isolate, JSMain::Version)); + + /* Add all global functions */ + for (size_t i = 0; i < js->GetExtenderFunctions().size(); i++) { + js_function_t *proc = js->GetExtenderFunctions()[i]; + global->Set(String::NewFromUtf8(isolate, proc->name), FunctionTemplate::New(isolate, proc->func)); + } + + // Create a new context. + Local context = Context::New(isolate, NULL, global); + + if (context.IsEmpty()) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create JS context\n"); + } else { + // Enter the created context for compiling and running the script. + Context::Scope context_scope(context); + +#ifdef V8_ENABLE_DEBUGGING + Persistent *debug_context = new Persistent(); + isolate->SetData(1, debug_context); + debug_context->Reset(isolate, context); + + //v8::Locker lck(isolate); + + if (debug_enable_callback) { + Debug::SetDebugMessageDispatchHandler(V8DispatchDebugMessages, true); + } + + if (debug_listen_port > 0) { + char *name = switch_mprintf("mod_v8-%d", (int)switch_thread_self()); + Debug::EnableAgent(name, debug_listen_port, debug_wait_for_connection); + switch_safe_free(name); + } +#endif + + /* Register all plugin classes */ + for (size_t i = 0; i < js->GetExtenderClasses().size(); i++) { + JSBase::Register(isolate, js->GetExtenderClasses()[i]); + } + + /* Register all instances of specific plugin classes */ + for (size_t i = 0; i < js->GetExtenderInstances().size(); i++) { + registered_instance_t *inst = js->GetExtenderInstances()[i]; + inst->obj->RegisterInstance(isolate, inst->name, inst->auto_destroy); + } + + /* Emaculent conception of session object into the script if one is available */ + if (session) { + FSSession *obj = new FSSession(js); + obj->Init(session, flags); + obj->RegisterInstance(isolate, "session", true); + } else { + /* Add a session object as a boolean instead, just to make it safe to check if it exists as expected */ + context->Global()->Set(String::NewFromUtf8(isolate, "session"), Boolean::New(isolate, false)); + } + + if (message) { + FSEvent::New(message, "message", js); + } + + if (api_stream) { + /* The JS class "Request" is only needed when a api_stream object is passed here */ + JSBase::Register(isolate, FSRequest::GetClassDefinition()); + + FSRequest *ptr = new FSRequest(js); + ptr->Init(input_code, api_stream); + ptr->RegisterInstance(isolate, "request", true); + } + + script = input_code; + + if (*script != '~') { + if ((arg = (char *)strchr(script, ' '))) { + *arg++ = '\0'; + argc = switch_separate_string(arg, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + // Add arguments before running script. + Local arguments = Array::New(isolate, argc); + for (y = 0; y < argc; y++) { + arguments->Set(Integer::New(isolate, y), String::NewFromUtf8(isolate, argv[y])); + } + context->Global()->Set(String::NewFromUtf8(isolate, "argv"), arguments); + context->Global()->Set(String::NewFromUtf8(isolate, "argc"), Integer::New(isolate, argc)); + } + + const char *script_data = NULL; + const char *script_file = NULL; + string s; + + if (*script == '~') { + script_data = script + 1; + script_file = "inline"; + } else { + const char *script_name = NULL; + + if (switch_is_file_path(script)) { + script_name = script; + } else if ((path = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR, script))) { + script_name = path; + } + + if (script_name) { + if (JSMain::FileExists(script_name)) { + s = JSMain::LoadFileToString(script_name); + script_data = s.c_str(); + script_file = script_name; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File: %s\n", script_name); + } + } + } + + if (!script_data) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No script to execute!\n"); + } else { + /* Store our base directoy in variable 'scriptPath' */ + char *path = v8_get_script_path(script_file); + if (path) { + context->Global()->Set(String::NewFromUtf8(isolate, "scriptPath"), String::NewFromUtf8(isolate, path)); + free(path); + } + // Create a string containing the JavaScript source code. + Handle source = String::NewFromUtf8(isolate, script_data); + + TryCatch try_catch; + + // Compile the source code. + Handle